D
ELTA
T
AU
T
URBO
PMAC
U
SER
’
S
M
ANUAL
F
EB
-2003
O
PEN
S
ERVO
A
LGORITHMS
2
Access to Turbo PMAC Variables
Open Servo algorithms can utilize all of Turbo PMAC’s I, P, Q, and M-variables, reading and
writing to them as appropriate. As in other user programs, it uses floating-point arithmetic to
process these variable values, even those that are stored as fixed-point values (see Floating-Point
vs. Fixed-Point Mathematics, below). Q-variables are always accessed from Open Servo
algorithms according to the Coordinate System 1 addressing scheme, no matter which coordinate
system the motor executing the Open Servo algorithm is assigned to.
Compiler-Assigned Pointer Variables
For direct and efficient access to Turbo PMAC registers, Open Servo algorithms support two
types of pointer variables for which the register assignment is made at compilation time, not at
program execution time.
L-variables are pointers to short (24-bit) registers, treated as integer (fixed-point) values. These
work in the same way as L-variables do in compiled PLC programs. They can access either X or
Y short registers, either as entire 24-bit registers (treated as signed integers only), or as portions
of the registers 1, 4, 8, 12, 16, or 20 bits wide (treated as signed or unsigned integers, except for
1-bit variables, which are unsigned only).
F-variables are pointers to long (48-bit) registers. If the F-variable definition is an “L” format
(e.g. F1->L:$10F0), the register is accessed as a 48-bit floating-point register. If the F-variable
definition is a “D” format variable (e.g. F2->D:$88), the register is accessed as a 48-bit signed
integer, but conversion to or from Turbo PMAC’s 48-bit floating-point format is automatically
performed, so it can be used in floating-point mathematics.
(Do not confuse L-variables, which are short-word compiler pointers, with “L-format” F-
variables and M-variables, which are long-word variables.)
Note that Turbo PMAC itself cannot recognize L-variables or F-variables; these variables have
meaning only to the compiler on the host computer.
By contrast, when using Turbo PMAC’s M-variable pointers, the register assignment is made
when the line is executed, each time it is executed. This assignment requires about 600
nanoseconds additional computation time (on a 100 MHz CPU) each time the variable is
accessed. However, this does permit the M-variable definition to be changed during execution,
enabling techniques such as indirect addressing.
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, you can
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 Open Servo
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 and accessing this definition at run time permits indirect
addressing techniques through real-time modification of this M-variable definition using another
pointer variable.