User's Manual
Turbo PMAC User Manual
172 Motor Compensation Tables and Constants
Register Arrays: Register arrays work with the compiler’s short L-variables and long F-variables.
These arrays must be declared to the compiler before the start of the actual Open Servo algorithm. In use,
the number of the array index is placed inside square brackets, and specifies the address offset from the
declared beginning of the array. The expression that determines this number is a fixed-point expression,
so it can only use the compiler’s L-variables and constants that fit within the range of a 24-bit signed
integer.
L and F-variable register arrays must be declared to the compiler before the start of the actual Open Servo
algorithm. Examples of these definitions are:
L100->X:$010000[32]
F200->D:$030040[64]
F300->L:$030080[128]
The declared array size must be a power of 2 in the range 2 to 8192. L-variable register arrays always use
full 24-bit X or Y registers, treating the values as signed integers.
Operators
As with any Turbo PMAC user program, Open Servo can utilize the following mathematical and logical
operators:
• + (addition)
• - (subtraction
• x (multiplication)
• / (division)
• % (modulo, remainder)
• & (bit-by-bit AND)
• | (bit-by-bit OR)
• ^ (bit-by-bit XOR)
All of these operators can be used in either floating-point or integer statements. Integer division rounds
the result to the nearest integer; in the case where the fraction is exactly 0.5, it will round to the next more
positive integer (e.g. -7.5 to -7, and 7.5 to 8).
Comparators
As with any Turbo PMAC user program, Open Servo can utilize the following comparators in conditional
statements:
• = (equal to)
• > (greater than)
• < (less than)
• ~ (approximately equal to [within 0.5])
• != (not equal to)
• !> (not greater than, less than or equal to)
• !< (not less than, greater than or equal to)
• !~ (not approximately equal to [not within 0.5])
The ~ and !~ comparators can only be used in floating-point statements. Note that the <>, >=, and <=
comparators, which can be used in some programming languages, cannot be used in the Open Servo or
other Turbo PMAC programs.
Functions
As with any Turbo PMAC user program, Open Servo can utilize the following mathematical functions.
Note that these functions can only be used in floating-point statements within the Open Servo:
• SIN (trigonometric sine)
• COS (trigonometric cosine)
• TAN (trigonometric tangent)