Copyright 20001-2002 by OSAI
All rights reserved
Edition: July 2001
IMPORTANT USER INFORMATION
This document has been prepared in order to be used by OSAI. It describes the latest release of the
product.
OSAI reserves the right to modify and improve the product described by this document at any time
and without prior notice.
Actual application of this product is up to the user. In no event will OSAI be responsible or liable for
indirect or consequential damages that may result from installation or use of the equipment described
in this text.
ABC
ABC
Update
10 Series CNC PLUS Library - User Manual
SUMMARY OF CHANGES
General
This publication has been issued with the software release 6.1.
This issue completely replaces the previous ones (MOV.08)
PAGETYPE OF UPDATE
INDEXupdated
CHAPTERS 5, 6, 9, 10, 11updated: the various functions with maximum process number to 20
CHAPTER 7
page 16corrected: diagrams to which the $ANAIN function refers
CHAPTER 10
page 3inserted: parameter 9 RCM in function $GBPROVAR
CHAPTER 11
page 7inserted: Pilot Panel management in the multi-process environment
CHAPTER 12
pages 29, 32
pages 36, 38
page 41
page 63
page 65
pages 66, 67
APPENDIX Dmodified: field 7 in the axes table
APPENDIX Ginserted: missing error messages
inserted: parameters 24 and 25 for reading Jerk information in function
$AX_GET7
inserted: parameters 21 to 25 in function $AX-PUT1.
inserted: note concerning the parameter “STANDSTILL_GAIN”
inserted: examples and details for the parameters for using function
$AXD_RDD
inserted: new results in the description of function $AXD_WRD
added: new considerations in the description of functions $AXD_RDS
and $AXD_WRS.
10 Series CNC PLUS Library - User Manual (09)
asda
Preface
10 Series CNC PLUS Library - User Manual
PREFACE
This manual contains the description of all block functions (FB) needed for the logic application
projects of the 10 Series CNC.
It contains the corresponding instruction list (IL) code for each FB and a description of the input and
output variables.
This manual deals specifically with functions and function blocks. For further information on PLUS, its
language and its applications in the 10 Series CNC environment consult the following manuals:
10 Series CNC PLUS APPLICATION MANUALCode 45006677Z
10 Series CNC PLUS LANGUAGE & PLUSEDITCode 45006672 P
You can find an FB or a function more easily if you look up the Function Reference List below in this
preface.
In this list the functions are ordered alphabetically and for each of them there is a short description
plus the page number.
In this manual the various function blocks have been subdivided into groups depending on the type of
operation they fulfil or the environment to which they belong. So if you do not know the exact name of
an FB, but know the environment to which it refers, you can easily find the FB in the manual by
consulting the index.
COMMON FEATURES OF FUNCTION BLOCKS:
All function blocks can be used in the Ladder Diagram / Function Block Diagram (LD/FBD) editors
and in the MACRO Instruction List (MACRO-IL) editor. The function blocks discussed in Chapters 1
and 3 are base function blocks i.e. built from standard elements of the instruction list (IL). All the
other function blocks are extensions which internally use a function call. These functions can also be
used in the IL editor. For each FB there is an example for the calls and the necessary parameters in
IL.
NOTE:
When using function calls in IL, there is no control to ensure that the number and type of parameters
are correct.
When using the MACRO-IL editor, the function block parameters are always checked.
10 Series CNC PLUS Library - User Manual (09) 1
Preface
10 Series CNC PLUS Library - User Manual
enable input
Many of the function blocks shown in this manual have an “enable” input which enables/disables the
execution of the block.
• Enable is a Boolean variable which can be inverted if necessary.
• You can link all types of Boolean variables available in PLUS including the Boolean constants KB1
and KB0.
• The enable signal linked to the FB P1 (pulse) or the use of FBs for controlling the program flow
allows you to write faster and attain a more efficient machine code. In general it is better to try to
limit the number of always enabled FB (enable always = 1) by disabling them when their function
is not required, in order to increase the performance of the machine logic.
stat_wrd output (function status output word)
The function status output is available on all system function blocks. After the relevant function has
been completed, this word contain a value indicating that all went well or that there was some kind of
problem. When everything was ok, the status word will be zero. In case of problems the value of the
status word is different from zero. Please refer to the specific function block for the meaning of the
values returned in the status word.
Often you're not interested in knowing the status of the functions because your program has been
tested and always works well. You can then hook up only one single short variable, e.g. MW 999, to
the status output of many functions.
ax_id input (physical axis identifier)
The axis identifier is used for many system functions. It is a number identifying the internal resources
for one axis on an axes module. Each axes module supports 8 axes, 6 resources are reserved for
physical axes (which read encoders and/or write to D/A converters) and 2 for virtual axes. A machine
axis (e.g. "X") may be related to any of the available physical axis resources on any of the axes
modules.
There can be up to 4 axes modules in the 10 Series CNC chassis, allowing for up to 32 axes
(theoretically). The axis identifier now, is a number in the range of 1 through 32. It must be assigned
during the axes configuration in AMP and will also serve to define the page number of the axes table
on which this axis will be managed.
Even when you move the physical connections (encoder, D/A) of an axis to another axes module, its
ax_id will remain unchanged and the axis data will remain available on the same page of the axes
table.
The function A_TO_ID converts an ASCII axis address to its physical axis identifier number.
tc_id input (transducer/converter physical identifier)
The identifiers of the tansducer inputs are numbers in the range of 100Hex up to 1nnHex. On the first
servo module you will find (top to bottom) the transducers 100Hex through 105Hex, on the second
106Hex through 10BHex, on the third module 10CHex through 111, and so on.
The D/A converters have a similar numbering system. On the first module you will find the converters
200Hex through 205Hex, on the second module 206Hex through 20BHex, and so on.
210 Series CNC PLUS Library - User Manual (09)
Preface
10 Series CNC PLUS Library - User Manual
symbolic names
Symbolic names to be associated to the user subroutine (DSRB) and to the label (LBL) must be
different from those predefined in PLUS (FB names, predefined routines, etc.) and should never begin
with a $.
Furthermore, symbolic names should always begin with a letter and not with a number.
TYPES OF SYSTEM FUNCTION CALLS
There can be 3 different types of system function calls (system function blocks):
WAIT
A WAIT function call suspends the execution of the task that called it. This task will resume its
activity after the function has been completely executed.
The suspension of a task implies the suspension of all routines that make up this task. The WAIT
function is normally executed by an environment other than the I/O processor module (the system).
For this reason a WAIT function is a synchronous call: when the logic scan exits from a WAIT
function block, this block has been completely executed.
NOWAIT
A NOWAIT function call does not suspend the execution of the logic task that called it. Immediately
after the call has been issued, the logic task resumes execution. The function call will be executed
by an environment other than the I/O processor module (system).
For this reason a NOWAIT function is an asynchronous call: when the logic scan exits from a
NOWAIT function block, the function is still being executed by another environment.
The execution of many NOWAIT function calls from a logic task may cause a system overloading
since the simultaneous execution of many functions is required.
When 15 NOWAIT functions are in parallel execution, the function that has generated the last call is
in any case executed and it returns to the word status a warning code (1000 hexadecimal).
If you continue to call NOWAIT functions after the warning message, that is when 25 functions are in
parallel execution, an unrecoverable emergency is generated ("too many requests").
INTERNAL
An INTERNAL function is similar to a WAIT function call but its execution is much faster because it's
done by the same environment that calls the function (PLUS). An INTERNAL function call is in all
aspects like a subroutine available to the PLUS environment. For this reason an INTERNAL function
is a synchronous call: when the logic scan exits from an INTERNAL function block, this block has
been completely executed.
$AX_GET1: Get axis (spindle) servo parameters .................................................12-15
$AX_GET2: Get axis (spindle) servo parameters .................................................12-17
$AX_GET3: Get axis (spindle) servo parameters .................................................12-20
$AX_GET4: Get axis (spindle) servo parameters .................................................12-22
$AX_GET5: Get axis (spindle) servo parameters .................................................12-24
$AX_GET6: Get axis (spindle) servo parameters .................................................12-26
$AX_GET7: Get axis (spindle) servo parameters .................................................12-28
$AX_GET8: Get axis (spindle) servo parameters .................................................12-33
$AX_PUT1: Set axis servo parameter................................................................12-35
Notes concerning the “STANDSTILL-GAIN” parameter.........................................12-41
$AX_PUT2: Set axis servo parameter................................................................12-42
$AX_PUT3: Set axis servo parameter................................................................12-44
$AX_GETS: Get axis status .............................................................................12-46
$TC_CONF: It configures the transducer ERDC for read operations ......................12-48
$TC_READ1: It reads the physical position of the transducer...............................12-50
$TC_WRIT: Set D/A Converter output ................................................................12-52
$FAX_WCON:Configures the driver for real time data communication
from PLUS to AXES.........................................................................................12-55
$FAX_RCON: Configures the driver for real time data communication
from AXES to PLUS .........................................................................................12-57
$FAX_PUT: Real time updating of an axis' zero shift value ...................................12-59
$FAX_GET: Reads in real time axis parameters .................................................12-61
$AXD_RDD: It reads a numerical parameter from a digital drive
associated to a D.S.I. axis...............................................................................12-63
$AXD_WRD: It writes a numerical parameter to a digital drive
associated to a D.S.I. axis...............................................................................12-65
$AXD_RDS: It reads a string parameter from a digital drive
associated to a D.S.I. axis...............................................................................12-66
$AXD_WRS: It writes a string parameter to a digital drive associated
to a D.S.I. axis 12-67
$AXD_PUT: Sets Control Word bits of a digital drive associated with
a D.S.I. axis12-68
vi10 Series CNC PLUS Library - User Manual (09)
SPECIAL FUNCTIONS
$ACTRES: Request an active reset to be executed ............................................13-2
$LOCKTAB: Set table interlock status (inhibit third party access) ........................13-3
$UNLKTAB: Cancel table interlock status (enable third party access)..................13-5
$FAST_WR: Writes data in the DP dedicated area .............................................13-6
$FAST_RD: Reads data from a dedicated DP area.............................................13-8
$DE_ETH: enables or disables communication via Ethernet ................................13-10
The basic language function blocks are the direct equivalents of the corresponding instruction list
elements. Every time you use one of these function blocks, its internal (IL) code will be inserted in
your program. In this sense the basic language function block behave like macros. The function
blocks discussed in this chapter do not call any functions. Each one of the sections in this chapter
covers a group of function blocks which all work on the identical data format.
Those function blocks which internally use a system function call are covered in the other chapters of
this manual. They are called language extensions because they expand the capabilities of the
language beyond the capabilities of the single instructions.
For each of the basic language function blocks you will find a table which contains the attributes of
the inputs and outputs of a function block. The columns in this table are:
NAME :Name of the connection
INVERSION :Indicates whether the input or output can be logically inverted. This attribute
is only available for Boolean connections.
DUPLICATION :If this attribute shows yes, you are allowed to make one or more copies of
this connection. Each one of the copied connections will have the same
attributes as the original and the connected variable will be processed just
like the original variable.
FORMAT :The format of an operand to be connected to an input or an output can be
one of:
Booleanonly bits allowed
short16 bit integer operand
double64 bit floating point operand
charstring or string constant
allno check, all formats possible
specialfor special operands NAM and LAB only
As you enter an operand for a function block, it will be checked if it
matches the required format.
GROUP :The different types of operands are divided into groups. For certain function
block connections some groups will be excluded (e.g. it is not allowed to
connect an input to a Boolean function block output). The letters in this
column indicate which type of operand may be used:
10 Series CNC PLUS Library - User Manual (08)1-1
Chapter 1
WARNING
Basic Language Function Blocks
MM variables (depending on the format you must select M Boolean
MW -> short MD -> double).
Gglobal retentive G variables (depending on the format you must
select G -> Boolean, GW -> short or GD -> double).
SSystem flags or S variables. (again, select the S or SW
depending on the format of the connection; S -> Boolean or SW > short)
TTimer variables. T or TW depending on the format (T -> Boolean,
TW -> short).
CCounter variables. C or CW depending on the format (C ->
Boolean, CW short).
KConstants. KB -> Boolean, KW or KH -> short, KD -> double.
Xlocal variables. Select X -> Boolean, XW -> short or XD -> double,
depending on the format of the connection.
Ysubroutine parameters. select Y -> Boolean, YW -> short or YD -
> double in accordance with the format of the connection.
Double constants (KD) are defined with the following format:
KD ± x.yyyyE ± zzz
The decimal part yyyy must always be written in full (4 figures).
1-210 Series CNC PLUS Library - User Manual (08)
Chapter 1
IMPORTANT
Basic Language Function Blocks
LINE ELEMENT
The line element can be used to "connect" a variable or a constant (left side) with one or more other
variables (right side). The variables (constants) on both sides must have the same type (i.e. short).
The line element is only available to connect Boolean, short and double variables and constants.
Examples:
short constant c onnected to short variable s
KH00FF
Boolean constant connect ed to boolean variables
KB1O 24,03
Short constant connected to a timer preset word
KW100TW 020
MW 200
MW 201
G 010,00
.
Of course you cannot connect inputs and/or constants to the right side of a line element. For an
explanation of how to insert a line element please refer to the Plusedit manual.
When you design a logic program using Function Blocks please consider some
rules related to “broken” Line Elements. We will explain this using an example:
GD 00
I 00,00
SE TD
I1
En
O1
GD 01
The use of a 'broken' line element in this example forces the PLUS development package to assign
an automatic variable (MD 151) for this line. This variable will always be assigned to the destination
variable GD 1, independent of the status of I 00,00. The translation of the block shows clearly why:
rec. word instr. operand symbol comment
00001 ; Assignment with broken line
00005 L I 00,00
00006 AND(
00007 LDGD 00
00008 = MD 151
00009 )
00002 00010 L MD 151
00015 = GD 01
10 Series CNC PLUS Library - User Manual (08)1-3
Chapter 1
Basic Language Function Blocks
As you can see, the assignment of MD 115 to GD 01 is not conditioned by the input I 00,00 of the
Function Block SETD.
To avoid this probably undesired behaviour you should connect the destination variable GD 01 using a
straight line:
G D 00
I 0 0,0 0
S E T D
I1
E n
G D 0 1
Using this straight connection, the translation in IL does not require an automatic variable:
rec. word instr. operand symbol comment
00000 ; Assignment with straight line
00000 LI 00,00
00001 AND(
00002 LD GD 00
00003 =GD 01
00004 )
Please keep in mind these considerations when using FB programming:
• The use of 'broken' line elements as explained above can cause 'abnormal' behaviour of your logic
program. Problems due to an unwanted assignment as in above example
• Broken' line elements use automatic variables and generate extra code which requires more
memory and more execution time.
• Avoid to use 'broken' line elements to keep your logic as fast as possible.
1-410 Series CNC PLUS Library - User Manual (08)
Basic Language Function Blocks
BOOLEAN FUNCTION BLOCKS
$=NBOOLEAN INVERTER
=N
I1O1
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
O1YESYESBooleanO M G S X Y
$ANDBOOLEAN AND GATETRUTH TABLE
AND
I1
I20
AND
O1
I20I1
00
1
0
Chapter 1
O1
0
0
1
0
11
Connection attributes:
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
I2YESYESBooleanI O M G S X Y T C K
O1YESNOBooleanO M G S X Y
The output O1 will be true when Boolean input I1 and I20 are true.
$ORBOOLEAN OR GATETRUTH TABLE
OR
I1
I20
O1
OR
I20I1
000
1
0
11
0
1
O1
0
1
1
1
1
10 Series CNC PLUS Library - User Manual (08)1-5
Chapter 1
Basic Language Function Blocks
Connection attributes:
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
I2YESYESBooleanI O M G S X Y T C K
O1YESNOBooleanO M G S X Y
The output O1 will be true when either Boolean input I1 or I20 or both are true.
$XORBOOLEAN XOR GATETRUTH TABLE
XORXO R
I1I2O1
000
1
0
11
I2I1
O1
0
1
1
1
0
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
I2NONOBooleanI O M G S X Y T C K
O1NONOBooleanO M G S X Y
The output O1 will be true when either Boolean input I1 or Boolean input I2 is true.
$R/SRS FLIP FLOP WITH RESET PRIORITYTRUTH TABLE
RSQ
R/S
R
S
Q
R/S
00
1
0
11
NC = No Change
N C
0
0
1
Connection attributes:
nameinversionduplicationformatgroup
1
0
RYESNOBooleanI O M G S X Y T C
SYESNOBooleanI O M G S X Y T C
QNONOBooleanO M G S X Y
1-610 Series CNC PLUS Library - User Manual (08)
Basic Language Function Blocks
$S/RRS FLIP FLOP WITH SET PRIORITYTRUTH TABLE
Chapter 1
S/R
SQ
R
Connection attributes:
nameinversionduplicationformatgroup
RYESNOBooleanI O M G S X Y T C
SYESNOBooleanI O M G S X Y T C
QNONOBooleanO M G S X Y
S/R
00
1
11
NC = No Change
RSQ
001
1
NC
0
1
10 Series CNC PLUS Library - User Manual (08)1-7
Chapter 1
Basic Language Function Blocks
FUNCTION BLOCKS FOR WORD OPERATIONS
$ORWBITWISE LOGICAL OR 16 BIT WORDS
O R W
I1
I20
O 1
E X A M P L E :
I1 0 0 1 1 0 1 0 1 1 0 1 0 0 1 1 1 ( 1 3 7 3 5 )
I20 0 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 (17 9 6 1 )
O 1 0 1 1 1 0 1 1 1 1 0 1 0 1 1 1 1 ( 3 0 6 3 9 )
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I20NOYESshortM G S X Y T C K
O1NONOshortM G S X Y T C
I1NONOshortM G S X Y T C K
I20NOYESshortM G S X Y T C K
O1NONOshortM G S X Y T C
$XORWBITWISE XOR OPERATION ON 16 BIT WORDS
X O RW
I1
I2
O 1
E X A M P L E :
I1 0 0 1 1 010 1 101 0 01 1 1 (13 7 3 5 )
I2 0 1 0 0 011 0 001 0 10 0 1 (17 9 6 1 )
O 1 0 1 1 1 001 1 100 0 11 1 0 (2 9 5 8 2 )
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
1-810 Series CNC PLUS Library - User Manual (08)
$XCHSWAP LOW AND HIGH BYTE IN A 16 BIT WORD
Chapter 1
Basic Language Function Blocks
XCH
I1O1
E X A M P L E :
I1 : 0 0 1 1 010 1 10 1 0 01 1 1 (13 7 3 5 )
O 1 : A F T E R "x c h " 1 0 1 0 0111 001 1 01 0 1 ( -2 2 7 3 1 )
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
$NOTINVERT A 16 BIT WORD (1'S COMPLEMENT)
NOT
I1O1
E X A M P L E :
I1 : 0 0 1 1 010 1 10 1 0 01 1 1 (1 3 7 3 5 )
O 1 : A F T E R "N O T " 110 0 101 0 01 0 1 10 0 0 (-13 7 3 6 )
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
O1NOYESshortM G S X Y T C
$NEGNEGATE WORD (2'S COMPLEMENT)
N EG
I1O1
E X A M P L E :
I1: 001 1 01 0 1 10 1 0 0 1 1 1 (1 3 7 3 5 )
O 1 : A FT E R "N E G " 1 1 0 0 10 1 0 0 1 0 1 1 0 0 1 (-1 3 7 3 5 )
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
O1NOYESshortM G S X Y T C
$<<LOGICALLY SHIFT 16 BIT WORD SC PLACES LEFT
E X A M P L E :
< <
I1
S C
O 1
T h e u p p e r 4 bits fro m t h e a c cu m u la tor a re se t to z e ro .
I1:
O 1 : a f ter 4 b it rig h t shift0 0 0 0 0 0 1 1 0 1 0 1 1 0 1 0 ( 2 3 1 5 2 )
the sh i f t cou n t sc m u st h a ve a v a lu e in th e ra n g e of 0 - 1 6 .
0 0 1 1 0 1 0 1 101 0 011 1 ( 1 3 7 3 5 )
10 Series CNC PLUS Library - User Manual (08)1-9
Chapter 1
Basic Language Function Blocks
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
scNONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
$>>LOGICALLY SHIFT 16 BIT WORD SC PLACES RIGHT
E X A M P L E :
> >
I1
S C
O 1
T h e u p p e r 4 bits fro m t h e a c cu m u la tor a re se t to z e ro .
I1:
O 1 : a f ter 4 b it rig h t shift0 0 0 0 0 0 1 1 0 1 0 1 1 0 1 0 ( 0 0 8 5 8 )
the sh i f t cou n t sc m u st h a ve a v a lu e in th e ra n g e of 0 - 1 6 .
0 0 1 1 0 1 0 1 101 0 011 1 ( 1 3 7 3 5 )
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
scNONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
$RESRESET A 16 BIT WORD TO 0
RE S
O1
En
Connection attributes:
nameinversionduplicationformatgroup
EnYESNObooleanI O M G S X Y T C K
O1NOYESShortM G S X Y T C
$SETSET A 16 BIT WORD TO A VALUE
SET
I1
En
O1
NOTE:
The output branch must be a straight line (see page 1-3)
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
EnYESNOBooleanI O M G S X Y T C K
O1NOYESshortM S X Y G T C
1-1010 Series CNC PLUS Library - User Manual (08)
$INCWINCREMENT WORD
Chapter 1
Basic Language Function Blocks
INCW
I1
O 1
E X A M P L E :
I1:
001 1 0101 101 0 011 1
O 1 : 0 0 1 1 0 1 0 1 10 1 0 1 0000
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
$DECWDECREMENT WORD
D E C W
I1O 1
E X A M P L E :
I1: 001 1 01 0 1 10 1 0 0 1 1 1 (1 3 7 3 5 )
O 1 : 0 0 1 1 0 1 0 1 1 0 1 0 01 1 0 (1 3 7 3 4 )
nameinversionduplicationformatgroup
I1NONOShortM G S X Y T C K
(13735)
(13736)
O1NONOShortM G S X Y T C
$ADDWADD TWO OR MORE 16 BIT WORDS
A D D W
I1
I20
0 1
E X A M P L E :
I1: 001 1 01 0 1 10 1 0 0 1 1 1 (1 3 7 3 5 )
I20: 0 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 (1 7 9 6 1 )
O 1 : 0 1 1 1 1 0 1 1 1 1 0 1 00 0 0 (3 1 6 9 6 )
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I20NOYESshortM G S X Y T C K
O1NONOshortM S X Y G T C
10 Series CNC PLUS Library - User Manual (08)1-11
Chapter 1
Basic Language Function Blocks
$SUBWSUBTRACT TWO OR MORE 16 BIT WORDS
S U B W
I1
I20
O 1
E X A M P L E :
I1: 0 0 1 1 0 1 0 1 1 0 1 0 01 1 1 (1 3 7 3 5 )
I20: 01 0 0 0 1 1 0 0 0 1 0 1 0 0 1 (1 7 9 6 1 )
O 1 : 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 (-4 2 2 6 )
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I20NOYESshortM G S X Y T C K
O1NONOshortM G S X Y T C
$MULWM ULTIPLY TWO SHORTS, SHORT RESULT
M U L W
MU1
O 1
MU2
E X A M P L E :
I1 0 0 0 0 01 0 1 10 1 0 0 1 1 1 ( 0 1 4 4 7 )
I2 0 0 0 0 00 0 0 00 0 0 1 0 0 1 ( 0 0 0 0 9 )
O 1 0 0 1 1 001 0 110 1 11 1 1 (1 3 0 2 3 )
Connection attributes:
nameinversionduplicationformatgroup
MU1NONOshortM G S X Y T K
MU2NONOshortM G S X Y T K
O1NONOshortM G S X Y
$DIVWDIVIDE TWO SHORTS, SHORT RESULT
D IVW
I1
O 1
I2
E X A M P L E :
I1 0 0 1 1 01 0 1 10 1 0 0 1 1 1 (1 3 7 3 5 )
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOshortM G S X Y T C
$BIN_BCDCONVERT AN INTEGER FROM BINARY TO BCD
B IN_B C D
B INB C D
E X A M P L E :
B IN(3 5 7 9 b i
B C D0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1(1 3 6 8 9 b
0 0 0 0 1 1 0 1 1 1 1 1 10 1 1
3579(3 5 7 9 B
Connection attributes
nameinversionduplicationformatgroup
n a ry)
C D )
in a ry)
BINNONOShortM G S X Y T C K
BCDNONOShortM G S X Y T C
$BCD_BINCONVERT AN INTEGER FROM BCD TO BINARY
BCD_BIN
BCDBIN
E X A M P L E :
B C D0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1( 1 3735)8
B IN(13736 binary)
0 0 0 0 1 1 0 1 111 1 101 1
Connection attributes
nameinversionduplicationformatgroup
BCDNONOShortM G S X Y T C K
BINNONOShortM G S X Y T C
C D )3579( 3 5 7 9 B
10 Series CNC PLUS Library - User Manual (08)1-13
Chapter 1
Basic Language Function Blocks
FUNCTION BLOCKS FOR STRING OPERATIONS
$STRADDCONCATENATION OF STRINGS
STRADD
Sti
Sto
+0
St0
En
Connection attributes:
nameinversionduplicationformatgroup
StiNONOcharA #"
+0YESYESBooleanI O M G S X Y T C K
St0NOYEScharA #"
StoNONOcharA
EnYESNOBooleanI O M G S X Y T C K
With this function block you can concatenate strings. The strings to be concatenated may be string
constants (#") or strings from the ASCII-array in memory. The resulting string Sto is always stored in
the ASCII-Array. The Boolean inputs +n can be used to select the strings to be concatenated with
string Sti.
Example:
#"This is a
I 01,00
#" useful
I 01,01
#" simple
I 01,02
#" example
I 01,03
STRADD
Sti
+0
St0
+1
St1
+2
St2
En
Sto
A 00200,033
When we assume that En is true, then the resulting output string in the above example depends on
+0, +1 and +2:
+0+1+2Resulting string
000"This is a"
100"This is a useful"
010"This is a simple"
110"This is a useful simple"
001"This is an example"
101"This is a useful example"
011"This is a simple example"
111"This is a useful simple example "
1-1410 Series CNC PLUS Library - User Manual (08)
FUNCTION BLOCKS FOR FLOATING POINT OPERATIONS
$RESDRESET A FLOATING POINT VARIABLE (TO 0)
RESD
En
Connection attributes:
nameinversionduplicationformatgroup
EnYESNOBooleanI O M G S X Y T C K
01NONOdoubleM G X Y
$SETDSET A FLOATING POINT VARIABLE TO A VALUE
O1
Chapter 1
Basic Language Function Blocks
SETD
I1
E n
O 1
NOTE:
The output branch must be a staight line (see page 1-3)
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
EnYESNOBooleanI O M G S X Y T C K
O1NOYESdoubleM G X Y
$NEGD INVERT SIGN OF FLOATING POINT NUMBER
NEG D
I1
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
01NOYESdoubleM G X Y
10 Series CNC PLUS Library - User Manual (08)1-15
Chapter 1
Basic Language Function Blocks
$ADDADD TWO OR MORE FLOATING POINT NUMBERS
The "ADD" function block adds the value of the I20 operand to the floating point operand I1 and stores
the result in O1.
ADD
I1
I20
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
I20NOYESdoubleM G X Y K
O1NONOdoubleM G X Y
$SUBSUBTRACT FLOATING POINT NUMBERS
The "SUB" function block subtracts the value of the constant or variable floating point operand I20
from the floating point operand I1 and stores the result in 01
SUB
I1
I20
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
I20NOYESdoubleM G X Y K
O1NONOdoubleM G X Y
1-1610 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
$MULFLOATING POINT MULTIPLICATION
The "MUL" function block multiplies the contents of the floating point operand I1 with the value of the
constant or variable floating point operand I20 and stores the result in O1.
MUL
I1
I20
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
I20NOYESdoubleM G X Y K
O1NONOdoubleM G X Y
$DIVDIVIDE FLOATING POINT NUMBERS, FLOATING POINT RESULT
The "DIV" function block divides the contents of the floating point operand I1 with the value of the
constant or variable floating point operand I20 and stores the floating point result in
DIV
I1
I20
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOdoubleM G X Y K
I20NOYESdoubleM G X Y K
O1NONOdoubleM G X Y
10 Series CNC PLUS Library - User Manual (08)1-17
Chapter 1
Basic Language Function Blocks
PROGRAM FLOW CONTROL FUNCTION BLOCKS
Subroutines
The subroutine allows to define a number of instructions that can be easily resumed from any point of
the logic program.
Subroutines must be defined by the user outside the logic tasks and from pre-defined tasks; they can
be called from another PLUS program or routine and they can be nested. The maximum nesting level
allowed is 5, that is the calling program plus 4 subroutine levels can be activated simultaneously. A
subroutine cannot be called simultaneously by two different tasks. The last subroutine level (level 4)
can not call other functions.
The subroutine starts in correspondence of the DSBR block and ends with the ESBR block. Use CAL
block to call the subroutine.
The subroutine is characterized by the name (NAM parameter) and by one or more parameters (PA0
parameter can be duplicated).
The number of parameters appearing in the DSBR subroutine definition (formal parameters) must be
the same as the one appearing in the CAL call (actual parameters).
The correspondence between formal and actual parameters is positional.
Input parameters utilized in the DSBR block must not be Y parameters, therefore, in the subroutine
you must utilize the above parameters and not the ones utilized in the CAL block.
Inside a routine you will find available local X variables that cannot be used outside the routine itself.
Furthermore, their value is lost each time you exit the subroutine: as a consequence, at the next call
the previous value is not available any longer.
It is important to keep in mind that Y parameters refer directly to the parameters used in the CAL
block so when you modify Y parameters in the subroutine's body you actually modify the parameters
used in the CAL function.
The subroutines are not "re-entrant", i.e. they cannot be called simultaneously by several tasks.
This means that a subroutine will usually be used by one task only.
If it is intended to call the same subroutine from numerous tasks, access must be synchronized so
that the calls are made in sequence.
An exception to the above rule is represented by the subroutines written in IL language which only
use the YW and XW variables (input parameters and local variables).
1-1810 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
Example:
Definition of a subroutine called ADD that adds the two input parameters and returns the result to the
variable GD0.
DTSK
NAM
Nam
(NAM = $BACK1)
. . . . . . . .
. . . . . . . .
NAM
GD 00
GD 01
KB 1
NAM
YD 00
YD 01
YD 00
CAL
Nam
Pa0
Pa1
En
. . . . . . . .
. . . . . . . .
ETSK
DSB
R
Nam
Pa0
Pa1
ADD
I1
(NAM = ADD)
(NAM = ADD)
O1
YD 00
YD 01
I20
ESBR
To be noted is that when the result of the ADD function is assigned to the YD0 variable, the user will
find at the end of the ADD subroutine execution the result of the addition in variable GD0.
10 Series CNC PLUS Library - User Manual (08)1-19
Chapter 1
Basic Language Function Blocks
$DSBRDEFINE USER SUBROUTINE
DSBR
Nam
Pa 0
Connection attributes:
nameinversionduplicationformatgroup
NamNONOspecialroutine name
Pa0NOYESallY
NOTE:
The names for the user defined subroutines must not interfere with any pre-defined PLUS routine
names. Therefore the routine's name should never begin with a "$"-sign.
Furthermore, the system considers lowercase and uppercase letters differently (i.e. the subroutine
called MySub is different from the subroutine called MYSUB).
$ESBRDEFINE END OF USER SUBROUTINE
ESBR
$CALCALL USER DEFINED SUBROUTINE AND PASS PARAMETERS
CAL
Nam
Pa 0
En
Connection attributes:
nameinversionduplicationformatgroup
NamNONOspecialroutine name
Pa 0NOYESallMGSX
EnYESNOBooleanIOMGSXYTCK
1-2010 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
PLUS PRE-DEFINED ROUTINES (TASKS)
There is a large number of pre-defined routines which make up the interface between the system and
the logic. Most of these routines are optional. If you want to use the interfacing capacities offered by
these routines, they must be defined using the following instructions and the names given in the
PLUS Application Manual. The design of the interface routine is up to the user; the Application
Manual gives some proposals for their structure.
$DTSKDEFINE PLUS ROUTINE
DTSK
Nam
Connection attributes:
nameinversionduplicationformatgroup
NamNONOspecialroutine name
NOTE:
The names for the routines which can be declared with this function block are pre-defined. They can
be standard logic routines like $FORE or $BACKn or can be part program interface or executive
command filter routines. All pre-defined names begin with a "$" sign and you can find them listed in
appendix A.
$ETSKDEFINE END OF PLUS ROUTINE
ETSK
This function block must always be used to terminate a PLUS pre-defined routine. For every DTSK
block used in your logic program you must have a matching ETSK block.
10 Series CNC PLUS Library - User Manual (08)1-21
Chapter 1
Basic Language Function Blocks
JUMPS
$LBLDEFINE JUMP LABEL
LBL
Lbl
Connection attributes:
nameinversionduplicationformatgroup
LblNONOspecialLabel name
$GOTOCONDITIONAL JUMP TO LABEL
GO TO
Lbl
En
Connection attributes:
nameinversionduplicationformatgroup
LblNONOspecialLabel name
EnYESNOBooleanIOMGSXYTCK
1-2210 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
TASK SYNCHRONIZATION BLOCKS
$WAITWAIT ON SEMAPHORE
WA IT
I1
En
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G X K
EnYESNObooleanI O M G S X Y T C K
This function block suspends the execution of a PLUS routine (a routine defined with DTSK) until
another routine activates the SEND function block (or the SEND instruction) on the same semaphore
number. The semaphore number at the input I1 can be a constant in the range of 0-31 or a short
variable in the same range.
A routine which is suspended using WAIT will not be executed all until a SEND is received. After
having received the SEND command, the routine's execution will be resumed with the block following
the WAIT function block.
$SENDSEND A SEMAPHORE
SEND
I1
En
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G X K
EnYESNObooleanI O M G S X Y T C K
This function block terminates the suspension of a PLUS routine waiting for the same semaphore.
The semaphore number at the input I1 can be a constant in the range of 0-31 or a short variable in the
same range.
When SEND is used on a non-used semaphore (no task is suspended in WAIT on this semaphore),
the SEND function block /instruction will be ignored.
10 Series CNC PLUS Library - User Manual (08)1-23
Chapter 1
sem
val
Basic Language Function Blocks
$: IFWAITSEMAPHORE STATE INQUIRY
IFWAIT
Link Attributes:
name inversion duplication format group
Sem NO NO short M G K X
Val NO NO Boolean O M G X
This function is used for enquiring if the tasks are suspended by a semaphore. It is typically a
complement to the functions $SEND and $WAIT for solving special synchronisation problems.
For example, when processing M functions, the background execution of a logic branch can be
conditioned by the fact that the preparation phase for the related task has been finished i.e. has been
effectively suspended.
The input value for this FB is the ID of the semaphore (sem) and can be between 0 and 32. The output
value indicates the status of the semaphore.
1-2410 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
$DLYWAIT FOR TIME-OUT
DLY
I1
En
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G X K
EnYESNOBooleanI O M G S X Y T C K
This function block suspends the execution of a PLUS routine (a routine defined with DTSK) for a
period of time. After the time elapses, the routine execution will be continued. The time must be
entered at input I1 and is expressed in .01 s. You can use a short constant or a short variable to
enter the time in the range of 1-65535.
NOTES:
• It is not possible to restart a task with a SEND instruction before it went into a wait. The SEND
will be ignored.
• You are not allowed to use the SEND instruction or the SEND function block from the foreground
routine and the fast input routine. It can only be used in the background routines.
• The background must release all routines in wait when a RESET or HOLD status is reported by
the system (see PLUS Application Manual)
10 Series CNC PLUS Library - User Manual (08)1-25
Chapter 1
Basic Language Function Blocks
CONDITIONAL EXECUTION OF BLOCKS
$IFCONDITIONAL EXECUTION OF A PART OF THE PROGRAM
IF
Cnd
Connection attributes:
nameinversionduplicationformatgroup
CndYESNOBooleanI O M G S X Y T C K
If the condition at the input Cnd is true, the code following this function block up to the next IF,
ENDIF or ELSE block will be executed. If the condition is false the program execution will be
continued with the next ENDIF or ELSE function block.
$ELSEALTERNATIVE EXECUTION OF A PART OF THE PROGRAM
ELSE
This function block can only be used in conjunction with an IF function block. The code following the
ELSE block up to the next ENDIF block will only be executed if the part between IF and ELSE was
not executed.
$ENDIFEND OF ALTERNATIVE EXECUTION PART OF THE PROGRAM
ENDIF
This function block must be used to define the end of a conditional group or groups of instructions.
These groups may begin with either IF or ELSE.
1-2610 Series CNC PLUS Library - User Manual (08)
Chapter 1
code to be executed when condition false
code to be executed when condition true
Condition
Basic Language Function Blocks
Application Note:
The function blocks IF, ELSE and ENDIF have been designed to allow program flow control also when
programming in FBD/LD. Using these blocks, there are basically 2 types of constructions you can
apply:
1. IF - ENDIF construction
If the input condition of the IF function block is true, the code between IF and ENDIF will be
executed. If the input condition of the function block IF is FALSE the code between IF and ENDIF
will not be executed.
IF
C o n d itio n
C n d
c o d e to b e e xe c u te d w h e n c o n d itio n t ru e
E N D IF
2. IF - ELSE -ENDIF construction
If the input condition of the block IF is TRUE, the code between the blocks IF and ELSE will be
executed. The code between ELSE and ENDIF will NOT be executed.
If the input condition of the IF function block is FALSE, the part of the code between IF and ELSE
will NOT be executed. The code included by ELSE and ENDIF will be executed.
IF
C n d
E L S E
E N D IF
The function blocks IF, ELSE and ENDIF may be nested. The number of nesting levels is not limited.
On the next page there is an example of how to use IF, ELSE and ENDIF in a 'nested' FBD
construction:
10 Series CNC PLUS Library - User Manual (08)1-27
Chapter 1
Basic Language Function Blocks
PRO JECT: BAC K4S M_No: 1 sym
REQUWARN
VARIABLE1
MESSAGE1
ENABLE
MESSAGE2
ENABLE
IF
Cnd
IF
Cnd
WARNING
Ind
En
ELSE
IF
CndVARIABLE 2
WARNING
Ind
En
St
St
ELSE
TX: 9 TY: 0
STATUS
STATUS
IF
CndVARIABLE 3
MESSAGE3
ENABLE
ENDIF
WARNING
Ind
En
ENDIF
ENDIF
ENDIF
STATUS
If variable REQUWARN is false, no code will be executed.
If variable REQUWARN is true one of the messages MESSAGE1, MESSAGE2 or MESSAGE3 will be
displayed based on the condition of VARIABLE1,VARIABLE2 and VARIABLE3 respectively. If
VARIABLE1 is true, MESSAGE1 will be displayed; else if VARIABLE2 is true, MESSAGE2 will be
displayed; else if VARIABLE3 is true, MESSAGE3 will be displayed. If none of the variables is true,
no message will be displayed.
1-2810 Series CNC PLUS Library - User Manual (08)
Basic Language Function Blocks
WORD COMPARISON FUNCTION BLOCKS
$LTWLESS THAN COMPARISON FOR WORDS (I1 < I2)
LTW
I1
I2
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
$LEWLESS OR EQUAL COMPARISON FOR WORDS (I1 <= I2)
O1
Chapter 1
LEW
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
$EQWEQUAL COMPARISON OF TWO WORDS (I1 = I2)
EQW
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
10 Series CNC PLUS Library - User Manual (08)1-29
Chapter 1
Basic Language Function Blocks
$NEWNOT EQUAL COMPARISON FOR WORDS (I1 <> I2)
NEW
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
$GEW GREATER EQUAL WORD COMPARISON (I1 >= I2)
GEW
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
$GTWGREATER THAN COMPARISON FOR WORDS (I1 > I2)
GTW
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONOshortM G S X Y T C K
I2NONOshortM G S X Y T C K
O1NONOBooleanO M G S X Y
1-3010 Series CNC PLUS Library - User Manual (08)
FLOATING POINT COMPARISON FUNCTION BLOCKS
$LTDOUBLE LESS THAN COMPARISON (I1 < I2)
LT
I1
I2
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONODoubleM G X Y K
O1NONOBooleanO M G S X Y
$LEDOUBLE LESS OR EQUAL COMPARISON (I1 <= I2)
O1
Chapter 1
Basic Language Function Blocks
LE
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONODoubleM G X Y K
O1NONOBooleanO M G S X Y
$EQDOUBLE EQUAL COMPARISON (I1 = I2)
EQ
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONODoubleM G X Y K
O1NONOBooleanO M G S X Y
10 Series CNC PLUS Library - User Manual (08)1-31
Chapter 1
Basic Language Function Blocks
$NEDOUBLE NOT EQUAL COMPARISON (I1 <> I2)
NE
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONODoubleM G X Y K
O1NONOBooleanO M G S X Y
$GTDOUBLE GREATER THAN COMPARISON (I1 > I2)
GT
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONOdoubleM G X Y K
O1NONOBooleanO M G S X Y
$GEDOUBLE GREATER EQUAL COMPARISON (I1 >= I2)
GE
I1
I2
O1
Connection attributes:
nameinversionduplicationformatgroup
I1NONODoubleM G X Y K
I2NONOdoubleM G X Y K
O1NONOBooleanO M G S X Y
1-3210 Series CNC PLUS Library - User Manual (08)
Chapter 1
Basic Language Function Blocks
COMPOSED FUNCTION BLOCKS
Unlike the function blocks discussed up to now, the " composed function blocks" are not the
implementation of a single instruction in a function block. They are little programs which consist of
several instructions and can also serve as examples of how to construct your own function blocks.
$P1IMPULSE ON RISING EDGE OF INP I1
O1P1
I1
Connection attributes:
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
O1NONOBooleanO M G S X Y
The output of this function block goes to a TRUE state on the rising edge of the input signal I1 and
remains TRUE until this block is scanned again by the I/O processor.
I1
O1
t
Timing diagram for P1
$P2DIVIDE BY 2 ELEMENT
O1P2
I1
Connection attributes:
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
O1NONOBooleanO M G S X Y
10 Series CNC PLUS Library - User Manual (08)1-33
Chapter 1
Basic Language Function Blocks
The output O1 of this function block changes state on each rising edge of the input signal I1.
I1
O1
t
Timing diagram for P2
$P3IMPULSES ON RISING AND FALLING EDGES OF INPUT SIGNAL I1
nameinversionduplicationformatgroup
I1YESNOBooleanI O M G S X Y T C K
O1NONOBooleanO M G S X Y
O2NONOBooleanO M G S X Y
This function block supplies two impulses O1 and O2. The output O1 goes TRUE on the rising edge
of the input signal I1; The output O2 goes TRUE on the falling edge of the input signal I1. When set,
the outputs will remain true until the function block is scanned again by the I/O processor.
I1
O1
O2
t
Timing diagram for P3
END OF CHAPTER
1-3410 Series CNC PLUS Library - User Manual (08)
Chapter
2
LANGUAGE EXTENSIONS
The function blocks we have covered up to now, were direct implementations of the equivalent PLUS
instructions.
The extensions offer additional functionality and power which can not be obtained with the standard
instructions. An extension is a routine which is supplied with the system and not by the language. It
can be used either in instruction list programming or in function block programming.
This chapter contains the following sections:
NUMBER AND FORMAT CONVERSIONS
INDIRECT LOAD AND STORE
STRING/CHARACTER HANDLING
ARITHMETICS WITH FORMAT CONVERSION
SPECIAL CONVERSIONS
10 Series CNC PLUS Library - User Manual (04)2-1
Chapter 2
Language Extensions
NUMBER AND FORMAT CONVERSIONS
$ATOI: Convert an ASCII string to an integer number (16 bit)
This function converts a character string to an integer (16 bit) binary number. The input string is a
sequence of characters which can be interpreted as a numerical value of the integer type. The
function stops reading characters from the input string at the first character which cannot be
recognized as a part of the number. This character may be the NULL-character (\0) terminating the
string.
The string to be converted may contain in the given order whitespace characters, (space and/or tab),
a sign (+/-) and up to 5 numerical digits.
$ITOA: Convert an integer number to an ASCII string
LD/FBD:
Chapter 2
Language Extensions
Type: Internal
value
enableEn
ITOA
int
ASC
string
IL:
CAL$ITOA
value
string
INPUT VARIABLE:integer value to convert(short)
OUTPUT VARIABLE:ASCII string(char)
Description:
The $ITOA function converts the significant digits of the given value value to a NULL-terminated
character string and stores the result in the indicated A variable string. The output string length is 7
bytes (sign, 5 digit number and the terminating NULL).
If the string length indicated in the output string is less than required for the resulting string, the most
significant digits of the string will be 'cut' off.
10 Series CNC PLUS Library - User Manual (04)2-3
Chapter 2
Language Extensions
$ATOF: Convert an ASCII string to a floating point number
LD/FBD:
ATOF
ASCstring
enableEn
IL:
CAL$ATOF
string
dest_var
dest_varFLT
Type: Internal
INPUT VARIABLE:ASCII string(char)
OUTPUT VARIABLE:floating point destination variable(double)
Description:
This function converts a character string string to a double precision floating point value. The input
string is a sequence of characters which can be interpreted as a numerical value of the type 'double'.
The function stops reading characters from the input string at the first character which cannot be
recognized as a part of the number. This character may be the NULL character (\0) terminating the
string.
The string may contain in the given order whitespace characters (space/tab), a sign character (+/),
numerical digits, a decimal point or decimal comma and further numerical digits. Up to 15 numerical
digits can be converted (maximum 8 integer digits plus 7 decimal digits).
Example:
legal strings " -1234.5678" or "+1234567" or "-33,45" etc.
2-410 Series CNC PLUS Library - User Manual (04)
$FTOA: Convert a floating point number to an ASCII string
LD/FBD:
FTOA
value
dig_integer
dig_fraction
enableEn
IL:
Flt
int
Fra
ASC string
Chapter 2
Language Extensions
Type: Internal
CAL$FTOA
value
dig_integer
dig_fraction
string
INPUT VARIABLES:double value to be converted(double)
number of digits before decimal point(short)
number of digits after decimal point(short)
OUTPUT VARIABLE:string result(char)
Description:
The $FTOA function converts the floating point number to a NULL-terminated character string and
stores the result in the string indicated in the function call. The parameter value is the floating point
number to be converted, the dig_integer parameter indicates how many digits must be converted in
front of the decimal point. If the value parameter has less significant digits than indicated in
dig_integer, the leading zeros will be filled up with spaces. If the number in the value parameter
exceeds the value which can be represented with dig_integer places, the leading digits will be cut
off.
The dig_fraction parameter indicates the number of digits after the decimal point. If the number of
decimal digits in the value parameter exceeds the number indicated in dig-fractioncount, the low
order digits are rounded. If the resulting string after the decimal point is shorter than dig_fraction
digits, the string is padded with zeros.
The values of dig_integer and dig_fraction are limited to 7 each.
10 Series CNC PLUS Library - User Manual (04)2-5
Chapter 2
Language Extensions
Examples:
value *dig_integerdig_fractionstring
-123456.65432177- 123456.6543210
12345.1237712345.1230000
123456.1234565523456.12346
-1.1561- 1.2
-1.1522- 1.15
* These numbers show the internal resolution, they cannot be entered in this way using PLUSEDIT.
2-610 Series CNC PLUS Library - User Manual (04)
$FTOI: Convert a floating point format to an integer format
LD/FBD:
F T O I
flt
e n a b leE n
IL:
F L T
integerIN T
Chapter 2
Language Extensions
Type: Internal
CAL$FTOI
flt
integer
INPUT VARIABLE:floating point input variable(double)
OUTPUT VARIABLE:integer output variable(short)
Description:
This function converts a floating point number (double) to a signed 16 bit integer (short). Any fraction
of the source floating point number will be truncated. In case the value of the floating point number is
between 32768 and 65535, this function will return the corresponding negative short numbers. If the
value of the floating point number exceeds the value of 65535, the short result will consist of the lower
16 bit of the integer representing the floating point number. The result may be either positive or
negative and is really unpredictable.
10 Series CNC PLUS Library - User Manual (04)2-7
Chapter 2
Language Extensions
$ITOF: Convert a short variable to a double variable
LD/FBD:
ITOF
Intinteger
enableEn
IL:
CAL$ITOF
integer
flt
Fltflt
Type: Internal
INPUT VARIABLE:integer input variable(short)
OUTPUT VARIABLE:floating point output variable(double)
Description:
This function provides the conversion of a short integer variable to a floating point variable.
This function copies a single character string from the ASCII array to the lower byte of a single short
variable. Normally the string must be one character long (A..,1). Since only the first character of the
indicated string is copied, using a longer string causes no error. The upper byte of the destination
variable will always contain 0.
See also:
Functions:$WTOCcopy a short variable into the ASCII array
Instructions/function blocks:XCHexchange upper and lower byte of the word accumulator
This function copies the lower byte of a single short variable to a character in the ASCII array. The
upper byte of the source variable has no influence on the result of the function.
See also:
Functions:$CTOWcopy an ASCII character into a short variable
Instructions/function blocks:XCHexchange upper and lower byte of the word accumulator
2-1010 Series CNC PLUS Library - User Manual (04)
INDIRECT LOAD AND STORE
$ILDGW: Indexed load of word from GW word variables area
LD/FBD:
ILDGW
ind_gwIndOutdest
IL:
Chapter 2
Language Extensions
Type: Internal
CAL$ILDGW
ind_gw
dest
INPUT VARIABLE:index of the GW variable to load (0..255)(short)
OUTPUT VARIABLE:value of indexed GW variable(short)
Description:
This function can be used to load the output word dest using active indexing in the global word
variable area in the dual port memory of the I/O processor module (GW variables). The indexing can
be done with other variables of the word type (MW, GW, SW, XW, TW and CW) or with equivalent
constants (KHxxxx or KWxxx). The index contained in this variable or constant must be in the range
of 0 through 255 to be a legal index. If the index exceeds 255, nothing will happen (the output variable
dest will not be changed.)
10 Series CNC PLUS Library - User Manual (04)2-11
Chapter 2
Language Extensions
$ILDMW: Indexed load of a word from the MW variables memory area
Type: Internal
LD/FBD:
ILDMW
ind_MW
IndOutdest
IL:
CAL$ILDMW
ind_MW
dest
INPUT VARIABLE:index of the MW variable to load(0..999)(short)
OUTPUT VARIABLE:value of indexed MW variable(short)
Description:
This function can be used to load the output word dest using active indexing in the MW memory area.
The indexing can be done with a variable of the word type (MW, GW, SW, XW, TW and CW) or with
an equivalent constant (KHxxxx or KWxxx). The index contained in this variable or constant must be
in the range of 0 through 4999 to be a legal index. If the index exceeds 4999, nothing will happen (the
output variable dest will not be changed.)
2-1210 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
$ILDSW: Indexed load of the word from the SW word variables memory area
Type: Internal
LD/FBD:
ILDSW
ind_SW
IndOutdest
IL:
CAL$ILDSW
ind_SW
dest
INPUT VARIABLE:index of the SW variable to load (0..99)(short)
OUTPUT VARIABLE:value of indexed SW variable(short)
Description:
This function can be used to load the output word dest using active indexing in the SW memory area
(system variables). The indexing can be done with a variable of the word type (MW, GW, SW, XW,
TW and CW) or with an equivalent constant (KHxxxx or KWxxx). The index contained in this variable
or constant must be in the range of 0 through 99 decimal or 0 - 63 hex to be a legal index. If the index
exceeds 99, nothing will happen (the output variable dest will not change.)
10 Series CNC PLUS Library - User Manual (04)2-13
Chapter 2
Language Extensions
$ILDMD: Indexed load of a double from the MD variables memory area
Type: Internal
LD/FBD:
ILDMD
ind_MD
IndO utdest
IL:
CAL$ILDMD
ind_MD
dest
INPUT VARIABLE:index of the MD variable to load (0..999)(short)
OUTPUT VARIABLE:value of indexed MD variable (double)
Description:
This function can be used to load the output word dest using active indexing in the MD memory area.
The indexing can be done with a variable of the word type (MW, GW, SW, TW and CW) or with an
equivalent constant (KHxxxx or KWxxx). The index contained in this variable or constant must be in
the range of 0 through 999 to be a legal index. If the index exceeds 999, nothing will happen (the
output variable dest will not be changed.)
2-1410 Series CNC PLUS Library - User Manual (04)
$ILDGD: Indexed load of double from GD variables area
LD/FBD:
ILDGD
Chapter 2
Language Extensions
Type: Internal
ind_GD
IndO utdest
IL:
CAL$ILDGD
ind_GD
dest
INPUT VARIABLE:index of the GD variable to load (0..63)(short)
OUTPUT VARIABLE:value of indexed GD variable(double)
Description:
This function can be used to load the output double dest using active indexing in the global double
variable area in the dual port memory of the I/O processor module (GD variables). The indexing can be
done with other variables of the word type (MW, GW, SW, TW and CW) or with equivalent constants
(KHxxxx or KWxxx). The index contained in this variable or constant must be in the range of 0
through 63 to be a legal index. If the index exceeds 63, nothing will happen (the output variable dest
will not be changed.)
10 Series CNC PLUS Library - User Manual (04)2-15
Chapter 2
Language Extensions
$ISTGW: Indexed storage of the input word to the GW variables memory
area
Type: Internal
LD/FBD:
ISTGW
ind_GW
value
IL:
Ind
Val
CAL$ISTGW
ind_GW
value
INPUT VARIABLES:index of the destination GW variable(short)
value to be stored(short)
OUTPUT VARIABLE:none
Description:
This function can be used to store the contents of the input word value to a GW variable in the dual
port memory using active indexing. The indexing can be done with a variable of the word type (MW,
GW, SW, XW, CW and TW) or an equivalent constant (KHxxxx or KWxxx). The contents of the
indexing variable or constant ind_GW must be in the range of 0 through 255. If the index exceeds the
value of 255, nothing will happen. In this case also no error condition will be issued.
2-1610 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
$ISTMW: Indexed storage of the input word to the MW variables memory
area
Type: Internal
LD/FBD:
ISTMW
ind_MW
IL:
Ind
Valvalue
CAL$ISTMW
value
ind_MW
INPUT VARIABLES:index of the destination MW variable(short)
value to be stored(short)
OUTPUT VARIABLE:none
Description:
This function can be used to store the contents of the input word value to an MW variable using
active indexing. The indexing can be done with a variable of the word type (MW, GW, SW, XW, CW
and TW) or an equivalent constant (KHxxxx or KWxxx). The contents of the indexing variable or
constant ind_MW must be in the range of 0 through 4999. If the index exceeds the value of 4999,
nothing will happen. In this case also no error condition will be issued.
10 Series CNC PLUS Library - User Manual (04)2-17
Chapter 2
Language Extensions
$ISTMD: Indexed storage of the input double to the MD variables memory
area
Type: Internal
LD/FBD:
ISTMD
ind_MD
IL:
Ind
Valvalue
CAL$ISTMD
ind_MD
value
INPUT VARIABLES:index of the destination MD variable(short)
value to be stored(double)
OUTPUT VARIABLE:none
Description:
This function can be used to store the contents of the input double value to an MD variable using
active indexing. The indexing can be done with a variable of the word type (MW, GW, SW, XW, CW
and TW) or an equivalent constant (KHxxxx or KWxxx). The contents of the indexing variable or
constant ind_MD must be in the range of 0 through 999. If the index exceeds the value of 999,
nothing will happen. In this case also no error condition will be issued.
2-1810 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
$ISTGD:Indexed storage of the input double to the GD variables memory
area
Type: Internal
LD/FBD:
ISTGDD
ind_ GD
IL:
Ind
Valvalue
CAL$ISTGD
ind_GD
value
INPUT VARIABLES:index of the destination GD variable(short)
value to be stored(double)
OUTPUT VARIABLE:none
Description:
This function can be used to store the contents of the input double value to an GD variable using
active indexing. The indexing can be done with a variable of the word type (MW, GW, SW, XW, CW
and TW) or an equivalent constant (KHxxxx or KWxxx). The contents of the indexing variable or
constant ind_GD must be in the range of 0 through 63. If the index exceeds the value of 63, nothing
will happen. In this case also no error condition will be issued.
10 Series CNC PLUS Library - User Manual (04)2-19
Chapter 2
Language Extensions
$WR_ASCII:Write ASCII task output parameters (indexed loading of ACCUS
from ASCII buffer)
Type: Internal
LD/FBD:
WR_ASCII
start
length
enable
IL:
Ind
Num
En
CAL$WR_ASCII
start
length
INPUT VARIABLES:starting index in the ASCII buffer(short)
length of string to copy to the string accu(short)
OUTPUT VARIABLE:none
Description:
This function can be used to load the string accumulator using active indexing in the ASCII array. The
indexing can be done with 2 variables of the type short (MW, XW, SW, GW). The first variable is the
index of the first character of the ASCII array to be copied. The value of this index must be in the
range between 0 and the maximum limit established by the ASCIEDIT utility; if the maximum limit
established is exceeded, the function has no effect.
The second variable indicates, how many characters must be copied. The string accumulator will
always be filled up from the bottom upwards.
For some tasks the string accumulator (ACCUS) serves as an output parameter.
NOTE:
The NULL ('\0') end of string character will be treated as a normal character. For this reason NULL
characters will be copied to the string accumulator together with other characters.
See also:
Functions:$RD_ASCIIRead ASCII input parameters of a task
$INDEXACopy a range of ASCII variables
2-2010 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
$RD_ASCII: Read ASCII input parameters of a task (indexed store of ACCUS
in ASCII buffer)
Type : Internal
LD / FB D :
s t a rt
l e n g t h
e n a b l e
R D _A S C II
In d
N u m
E n
IL:
CAL$RD_ASCII
start
length
INPUT VARIABLES:starting index in the ASCII array(short)
length of string to copy from the string accu(short)
OUTPUT VARIABLE:none
Description:
This function can be used to store the contents of string accumulator to the ASCII array using active
indexing. The indexing can be done with 2 variables of the type short (MW, XW, SW, GW). The first
variable indicates the index of the first destination character in the ASCII array. The value of this index
must be in the range between 0 and the maximum limit established by the ASCIEDIT utility; if the
maximum limit established is exceeded, the function has no effect.
The second variable indicates, how many characters must be copied (0-128). The copying always
starts with the first character of the string accu.
NOTE:
The NULL ('\0') end of string character will be treated as a normal character. For this reason, NULL
characters will be copied from the string accumulator just like normal characters.
second string(char)
case sensitivity selection(short)
OUTPUT VARIABLE:comparison result(short)
Description:
This function compares two strings.
If the strings are identical, the result (RESULT) is 1, otherwise the output result will be 0.
If you set the case sensitivity input (CASE) to a positiv value, the comparison will differentiate
between upper and lower case characters.
The length of the string specified in the input parameter (i.e. A0,15) is never taken into consideration.
The character sequence beginning from the specified address (in the case 0) and ending with the first
null character found (end of string), is considered as a string.
2-2210 Series CNC PLUS Library - User Manual (04)
$STR_LEN: Calculate string length
LD/FBD:
source_ind
enableEn
IL:
Chapter 2
Language Extensions
Type: Internal
STR_LEN
Sind
Numnumber
CAL$STR_LEN
source_ind
number
INPUT VARIABLE:source_ind string (0..3999)(short)
OUTPUT VARIABLE:number of characters(short)
Description:
This function can be used on strings stored in the ASCII-array of the I/O processor module which are
addressable with an index.
It writes to the output number the number of characters in the string that begins starting from the
index specified in source_ind. The count begins with the character in the ASCII-array pointed at by
source_ind and ends when the NULL character is encountered. The returned output number does
not include the NULL character.
source_ind must assume a value between 0 and the maximun limit set by the ASCIEDIT utility.
If the NULL character will not be encountered until the fixed limit set by the ASCIEDIT utility, the
function doesn’t work
10 Series CNC PLUS Library - User Manual (04)2-23
Chapter 2
Language Extensions
$INDEXA: Copy a range of ASCII variables
LD/FBD:
INDEXA
source_index
number
dest_index
IL:
Sind
Num
Dind
Enenable
Type: Internal
CAL$INDEXA
source_index
number
dest_index
INPUT VARIABLES:index in ASCII buffer (start) (0..4999)(short)
number of characters to read (1..127)(short)
index of destination variable (0..4999)(short)
OUTPUT VARIABLE:none
Description:
This function copies a block of characters within the ASCII buffer. The parameters source_index and
number indicate the start position in the buffer and the number of characters to copy. The block will
be copied to the destination index dest_index in the ASCII buffer. This function can be used to read
the ASCII buffer and to display messages of fixed lengths.
The copy is not interrupted when the function encounters a NULL character in the ASCII buffer.
NOTE:
If source_index + number exceeds 3999 or dest_index + number exceeds the fixed limit set by the
ASCIEDIT function, this system function call will not copy at all.
Related function calls:
Functions:$WSCREENmessage visualisation in PLUS video screen
$WARNINGmessage visualisation in all screens
2-2410 Series CNC PLUS Library - User Manual (04)
$INDEX: Copy a range of M variables
LD/FBD:
source_ind
number
dest_ind
IL:
Chapter 2
Language Extensions
Type: Internal
INDEX
Sind
Num
Dind
Enenable
CAL$INDEX
source_ind
number
dest_ind
INPUT VARIABLES:index of first source M variable (0..4999)(short)
number of m variables to copy (1..4999)(short)
index of destination M variable (0..4999)(short)
OUTPUT VARIABLE:none
Description:
This function copies a block of M variables within the M variables memory area. Source and
destination index (source_ind and dest_ind) can be defined with constants of the word type (KHxxxx
and KWxxx) or with word type variables (MW, GW, SW, TW, CW and XW).
NOTE:
If source_index + number exceeds 999 or dest_index + number exceeds 4999, this system
function call will not copy at all.
10 Series CNC PLUS Library - User Manual (04)2-25
Chapter 2
Language Extensions
$STR_I: Copy ASCII characters from the ASCII buffer to the M variables
Type: Internal
LD/FBD:
STR_I
ind_source
number
ind_dest
IL:
CAL$STR_I
ind_source
number
ind_dest
Ain
Num
Min
Enenable
INPUT VARIABLES:first character to copy(short)
number of characters to copy(short)
index of first destination M variable(short)
OUTPUT VARIABLE:none
Description:
This function copies a number of characters from the ASCII array starting at index ind_source to the
M variables starting from the given word index ind_dest. The most significant bytes of the M
destination variables will be set to zero.
The variables ind_source and ind_dest can be M, G or S variables or can be constants of the word
type containing the index of source or destination.
NOTE:
The function will copy nothing in case all input parameters do not follow the following conditions:
• number must be between 1 and 5000
• M_index + number must be minor or equal to 5000
• M_index + number must not exceed the limit established through the ASCIEDIT utility
Example:
L KH0100constanthex constant 0x0100 -> decimal 256
= MW 100ind_source
CAL$STR_Icopy string from A array to M variables
MW 100ind_sourceindex of source variable in A array
KW 5numbernumber of characters to copy
KW 500ind_destindex of destination in MW variables
2-2610 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
Above example copies 5 characters from the A array (A 00256,005) into variables from MW 500
through MW 504.
10 Series CNC PLUS Library - User Manual (04)2-27
Chapter 2
Language Extensions
$I_STR: Copies a number of words to the ASCII array
LD/FBD:
I_STR
M_index
numberNum
A_index
IL:
Min
Ain
Enenable
Type: Internal
CAL$I_STR
M_index
number
A_index
INPUT VARIABLES:index of first M variable to copy(short)
number of M variables to copy(short)
destination index in the ASCII array(short)
OUTPUT VARIABLE:none
Description:
The function copies a number of integers from the local M memory variables to the ASCII array. Only
the lower byte (least significant byte) will be copied. The most significant byte of the M variables is
discarded.
You can use constants of the word type (KHxxxx or KWxxx) or word type variables (MW, GW, SW,
TW, CW and XW) to indicate the index of source and destination.
NOTE:
The function will copy nothing in case all input parameters do not follow the following conditions:
• number must be between 1 and 5000
• M_index + number must be minor or equal to 5000
• M_index + number must not exceed the limit established through the ASCIEDIT utility
2-2810 Series CNC PLUS Library - User Manual (04)
ARITHMETICAL FUNCTIONS
$MULF: Multiply two short operands with double result
LD/FBD:
MULF
mul1
mul2
enableEn
MU1
MU2
resultQf
Chapter 2
Language Extensions
Type: Internal
IL:
CAL$MULF
mul1
mul2
result
INPUT VARIABLES:first operand of the multiplication(short)
multiplier(short)
OUTPUT VARIABLE:multiplication result(double)
Description:
Multiplication of two shorts. Use this function instead of function block MULW/instruction/MUL when
a double precision format result is required. If a short result is required, use MUL instruction or MULW
function block.
See also:
Functions:$DIVFdivision with quotient
Function block:MULmultiplication of 2 double operands, double result
MULWmultiplication of 2 short operands, short result
Instructions:MULmultiplication of accumulator times operand, result in the
accumulato. Function for double and short formats
10 Series CNC PLUS Library - User Manual (04)2-29
Chapter 2
Language Extensions
$DIVF: Division of two short operands with a double result
LD/FBD:
Type: internal
DIVF
div1
div2
enableEn
D1
D2
resultQf
IL:
CAL$DIVF
div1
div2
result
INPUT VARIABLES:dividend(short)
divisor(short)
OUTPUT VARIABLE:quotient(double)
Description:
Division of two shorts. Quotient in double precision format.
2-3010 Series CNC PLUS Library - User Manual (04)
Example:
Chapter 2
Language Extensions
PROJECT: PROJECT1
MW 100
MW101
I 24,00
KW 5
KW 5
KW 10 0
KW 7
KW1 2
KW 1
KW 7
DIVF
D2D1QF
En
WRI_SCR
Ind
Scr
Row
Col
Att
ModKW0
En
St
SM_NO: 1 ABS
FTOA
Flt
Int
Fra
En
MW 101
ASC
Display the quotient of two shorts in the PLUS #7 screen, utilizing a 5.5 format.
See also:
Function blocks:DIVDivision of 2 double operands, double result
DIVWDivision of 2 short operands, short result
MODDivision remainder of 2 short operands
TX: 2 TY: 20
A 0 0100,012
10 Series CNC PLUS Library - User Manual (04)2-31
Chapter 2
Language Extensions
SPECIAL CONVERSIONS
$A_TO_ID: Requests conversion from process axis name to axis identifier.
Type: Internal
LD/FBD:
ax_name
m
enableEn
A_TO_ID
Proproc_nu
Nam
Aidax_id
IL:
CAL$A_TO_ID
proc_num
ax_name
ax_id
INPUT VARIABLES:process number(short)
axis name (ASCII name)(short)
OUTPUT VARIABLE:axis identifier(short)
Description:
This function converts the ASCII axis' name belonging to a specified process into the physical axis
identifier needed for most of the function calls.
The axis name and identifier are associated through "AMP" characterization program.
If the process number is out of range (0÷20) and/or the axis name does not exist, the "ax_id"
parameter must be zero.
2-3210 Series CNC PLUS Library - User Manual (04)
Chapter 2
Language Extensions
$ID_TO_A: Conversion from physical axis identifier to ASCII axis name and
This function converts the axis identifier format to the ASCII axis representation and a process
number. The axis name and the physical identifier are associated through the "AMP" characterization
program.
If the axis identifier is out of range (1÷32), the function is not executed and the output parameters
"proc_num" and "ax_name" remain unvaried.
END OF CHAPTER
10 Series CNC PLUS Library - User Manual (04)2-33
Chapter
3
COUNTERS AND TIMERS
SET COUNTER................................................................................................... CTS
In PLUS, 256 counters are available. A counter has:
four Boolean inputs
SET
RESET
COUNT UP (increases)
COUNT DOWN (decreases)
one Boolean output
The output is set to TRUE when the count value is greater than zero and less than the counter preset
value.
A counter has 2 internal "registers":
• an accumulator which contains the actual count
• a preset register which contains a preset value.
The accumulator of a counter is a read-only word, while preset register is a write-only word for the
logic. The maximum count value is limited to a 13 bit number (0-8191) and will always be positive.
NOTE:
Counters are retentive, that is their accumulator will not loose count after a power cycle.
Preset of a counter:
The preset operation can be done by utilizing standard assign blocks such as:
. . . . . _______________ . . . . .
or
SET 01
I1
En
The preset value must not be higher than 8191: if the counter is supplied with higher numbers these
will be "cut out" that is the three most significant bits will be taken to zero (bit 15,14,13).
3-210 Series CNC PLUS Library - User Manual (03)
Chapter 3
Counters and Timers
$CTDCOUNT DOWN
CTD
I-
Cn
Q
The I- input is the count down input. Every time this input goes one, (a rising edge of the signal) the
counter accumulator value will be decremented.
As long as the counter accumulator value is not equal to zero and less than the counter preset value,
the output bit Q will be true. Counting down from zero will cause the accumulator to roll over to 8191.
The counter number C nnn must be connected to the Cn input.
$CTUCOUNT UP
CTU
I+
Cn
Q
The I+ input is the count up input. Every time this input goes true, (a rising edge of the signal) the
counter accumulator value will be incremented.
When the counter accumulator value is equal to 8191, a further transitions on the I+ input will cause
the accumulator to roll over to 0. The counter number C nnn must be connected to the Cn input.
You can use the same counter number Cnnn for both CTU and CTD function blocks.
$CTRCOUNTER RESET
CTR
R
Cn
If the R input is at zero, the FB CTR zeroes the accumulator of the counter and the Q bit.
The Cn input must be linked to a counter (Cn).
$CTSSET COUNTER ACCUMULATOR = PRESET VALUE
CTS
S
Cn
If the S input is at zero, the fb CTS transfers the counter preset value to the counter accumulator and
clears the Q bit.
10 Series CNC PLUS Library - User Manual (03)3-3
Chapter 3
Counters and Timers
Connection attributes:
nameinversionduplicationformatgroup
I-/I+YESNOBooleanI O M G S X YT C
R/SYESNOBooleanI O M G S X Y T C
CnNONOBooleanC (Cnnn)
QYESNOBooleanO M G S X Y
NOTES:
• The Q bit is only evaluated when one of the above counter instructions is executed. When you use
instructions or function blocks on the accumulator/preset register values, the counter output Q will
never change state.
• You can use all word related function blocks on both the counter registers. Both counter
accumulator and counter preset register are addressed with CW nnn (where nnn is a number in
the range of 000 thru 255). Automatically, all output instructions will work on the preset register,
all input will be read from the counter accumulator.
Example:
3-410 Series CNC PLUS Library - User Manual (03)
Chapter 3
Counters and Timers
TIMERS
In PLUS, you can use up to 128 "slow" timers and up to 128 "fast" timers. A slow timer has a 0.1
second time base and a fast timer has a 0.01 second time base. The fast timers occupy the timer
numbers T 0-127, the slow timers range from T128 thru T255. These timer functions are elementary
functions from which all kinds of timers can be derived by connecting their inputs and outputs in a
different way. The variables used for the accumulated time (actual value), preset time and the control
bits are stored in the dual port memory of the I/O processor module. This part of the dual port
memory is cleared at power turn on time, so if a timer accumulated value must be saved, it must be
written to retentive memory (G-variables) before switching off.
TIMER nnn
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
ACCUM
PRESET
TI TRCONTROL
TIMER REGISTERS
The first register, the accumulator, is used to store the actual time value. Its initial value is loaded
from the preset word at each reset of the timer. The timer will decrement the time accumulator in predefined time intervals (0.01 or 0.1 s), as long as the timer input is true and the actual time value is not
zero.
The actual time value is a read only variable, it cannot be written. It must be read using the LW or the
L instruction on the corresponding TW variable (TW000 - TW255).
The timer preset register contains the preset value of the timer. It can only be written to the dual port
memory with the word assignment instructions "=", "S" and "R". The preset value cannot be read.
Normally, the timer preset value is defined only once.
The control word contains the time-out bit T nnn (used by the logic) and some controls bits for internal
use by the timer. You cannot access the control word in PLUS You can only use the timer
instructions to change the status of these bits.
To switch the timer on, you must set the TI nnn bit. Even when the instructions containing the timer
are not actively executed, the timer is active and continues decrementing its actual value.
The input RESET timer is triggered on the positive edge of the connected signal.
10 Series CNC PLUS Library - User Manual (03)3-5
Chapter 3
Counters and Timers
The 13th bit in the timer control register is used to indicate the state of the timer. The timer sets this
bit true when the timer input bit TI is set and the value in the accumulator has not yet reached zero (TI
AND (ACCU > 0).
The range of a timer is 16 bit, giving a resolution of 65535 time increments, which can be translated in
maximum times of 6553.5 seconds (1 hour, 49 minutes) for slow timers and 655,35 seconds (11
minutes) for fast timers.
If the value of the time accumulator must be used, you should keep in mind that the I/O processor
treats integer number larger than 32767 as negative numbers.
We advise to limit the timer range to values less than or equal to 32767 time increments.
Let's see, how the timer can be used in the IL programming language:
rec.wordinstr.CCOPNosymbolcomment
00000 ; the timer preset value was 5 minutes
00000LI00,00INPUT0load the condition
00001LWKW3000load the constant (5minutes)
00002STW255
00001 ; timer start-up
00003LI00,01INPUT1load the condition
00004TIT255
00002 ; verify timer status
00005LT255
00006=O00,0OUTPUT0timer is counting
00003 ; stop the timer
; the preset register in the accumulator
00007LI00,2
00008RT255INPUT2reset input
00004 ; force the preset value to 0
00009LI00,03INPUT3clear preset
00010RTW255
00005 ; compare the accumulator
00011LTW255
00012LEKW600less than one minute to finish?
00013SO00,1OUTPUT1time <= 60 seconds
As you can see, some instructions do have a special meaning when used in conjunction with a timer.
• The bit reset R executed on Tnnn means that you will restore the value from the preset register
into the accumulator.
• The word reset instruction R on the timer word variable TW nnn means that the preset value will be
reset (set to zero ).
• The TI instruction can only be used together with a T nnn operand.
3-610 Series CNC PLUS Library - User Manual (03)
Counters and Timers
TIMERS AND FB PROGRAMMING
The PLUS FB library contains 2 dedicated function blocks for timers:
$TIMTIMER ENABLED
Chapter 3
TIM
TI
Tn
Q
The TI input is the binary accu. The timer starts when this input is true. The timer stops when it is
false. T nnn specifies the number of the timer.
Q is the timer active bit (TW>0 AND TI=TRUE). Time counting can be suspended more than once
before reaching end of timing.
$TMRTIMER RESET/PRESET
TMR
R
Tn
When the R-bit is high, the timer output bit Q will be set to 0 and the time preset value is loaded into
the time accumulator. Input R can be inverted if needed. Tn specifies the number of the timer.
Connection attributes:
nameinversionduplicationformatgroup
TIYESNOBooleanI O M G S X YT C
RYESNOBooleanI O M G S X Y T C
TnNONOBooleanT (Tnnn)
QYESNOBooleanO M G S X Y
This is an example, of how a time off delay can be programmed, using the standard timer function
blocks.
10 Series CNC PLUS Library - User Manual (03)3-7
Chapter 3
Counters and Timers
This is the corresponding timing diagram
I 14,00
Q
O12,0
<>
t
3-810 Series CNC PLUS Library - User Manual (03)
Counters and Timers
This is the corresponding timing diagram
Chapter 3
I14,00
Q
O12,0
<>t
10 Series CNC PLUS Library - User Manual (03)3-9
Chapter 3
Counters and Timers
This is the corresponding timing diagram
I 14,00
Q
I 14,01
O 12, 0
<><<>>t1t2t3
t1 + t2 + t3 = TW255
<t1
3-1010 Series CNC PLUS Library - User Manual (03)
Counters and Timers
$T_START: Enables/disables PLUS timer
LD/FBD :
T_START
Chapter 3
Type: internal
timer_num
preset
control
Tind
Pre
Ctr
St
stat_wrd
IL:
CAL$T_START
timer_num
preset
control
stat_wrd
INPUT VARIABLES :timer index (0...255)(short)
preset value(short)
control word(short)
OUTPUT VARIABLES:status word(short)
Description:
The $T_START function controls PLUS timers. It facilitates timer operation by providing an alternative
to the functions described in previous pages. The "preset"parameter specifies the base time units to
be "loaded" in the timer. The bits of the "control" parameter must be read as follows:
bitmeaning
0go/stop
1-15reserved
On the rising edge (from 0 to 1) of bit 0 of the "control" parameter the timer starts counting by
decrementing the preset value. The current value is available on the TWn variable (where n is the timer
number).
FB $T_READ permits to monitor the timer status. It indicates whether the timer is counting, has
stopped counting or has been disabled.
On the falling edge (from 1 to 0) of bit 0 of the "control" parameter the timer is stopped and reset.
The $T_START function provides the following values of the STAT_WRD parameter:
ValueMeaning
0OK
10 Series CNC PLUS Library - User Manual (03)3-11
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.