Delta Tau GEO BRICK LV Manuel D’Utilisation

Page de 440
 
Turbo PMAC User Manual 
378
 
Writing and Executing PLC Programs
 
It is possible to use L-variables for fast integer arithmetic while retaining the run-time flexibility of M-
variable definitions.  (This does add the run-time definition-access computational penalty described 
above.)  Instead of directly defining L-variables to registers for the compiler, reference a range of L-
variables to Turbo PMAC M-variable definitions with the LMOVERLAY {start},{end} compiler 
directive.  This directive must precede the actual compiled PLC program.  For example, LMOVERLAY 
10,20
 instructs the compiler that the definitions of L10 through L20 are to be assigned at run time using 
the definitions of M10 through M20 respectively at the time each statement is executed, not at 
compilation time. 
Using the M-variable definition for an L-variable and accessing this definition at run time permits indirect 
addressing techniques through real-time modification of this M-variable definition using another pointer 
variable. 
Floating-Point vs. Fixed-Point Mathematics 
Each statement in a compiled PLC that utilizes any mathematics can be executed either floating-point or 
integer (fixed-point) mathematics.  In a floating-point statement, all variables used are processed through 
an intermediate working format that is 48-bit floating-point, regardless of the storage format of the 
variable.  Floating-point statements can utilize any of Turbo PMAC’s I, P, Q, or M-variables, and the 
compiler’s long F-variable pointers.  They cannot use the compiler’s short fixed-point L-variable pointers.  
All constants used in these statements are stored as 48-bit floating-point values. 
In an integer statement, all variables used are processed through an intermediate working format that is 
24-bit signed integer, regardless of the storage format of the variable.  Integer statements can only utilize 
the compiler’s short fixed-point L-variable pointers.  They cannot use the compiler’s long F-variable 
pointers, or Turbo PMAC’s I, P, Q, or M-variables.  All constants used in these statements are stored as 
24-bit signed integers.  All constants used and intermediate values computed must fit in the range of these 
integers: -8,388,608 to +8,388,607.  No mathematical functions (e.g. SIN, COS) may be used in an 
integer statement. 
Note that if a constant appears on a line before any variable (e.g. IF (0=P1) …), the line is assumed to 
be floating-point.  This means that the statement IF (0=L1) is illegal because it mixes floating-point 
and fixed-point data types. 
Short-word integer operations will execute more than 10 times faster than the same operations done as 
long floating-point operations, but they do not have nearly the dynamic range of floating-point operations. 
If direct conversion between integer and floating-point data types is required, compiled PLCs provide the 
ITOF (integer-to-float) and FTOI (float-to-integer) functions.  The ITOF function (with an integer 
expression as its argument) can be used in a floating-point statement, such as: 
P20=ITOF(L10+L11)*3.14159/P628 
The FTOI function (with a floating-point expression as its argument) can be used in a fixed-point 
statement, such as: 
L10=L9+FTOI(P5*100)-5 
The FTOI function will round the value of the floating-point expression to the nearest integer. 
It is not permissible to nest FTOI and ITOF functions within an expression. 
Note: 
The use of FTOI and ITOF requires the “PRO” series of PMAC Executive 
program (PEWIN32PRO) and Turbo PMAC firmware revision 1.938 or newer.