User's Manual

Turbo PMAC User Manual
Motor Compensation Tables and Constants 173
ASIN (trigonometric arc sine
ACOS (trigonometric arc cosine)
ATAN (trigonometric arc tangent)
ATAN2 (special 2-argument, 4-quadrant arc tangent)*
ABS (absolute value)
INT (greatest integer within)
EXP (exponentiation)
LN (natural logarithm)
SQRT (square root)
The trigonometric functions use degrees if Turbo PMAC variable I15 is set to the default value of 0; they
use radians if I15 is set to 1. The present value of I15 is evaluated each time a trigonometric function is
executed.
Note:
The ATAN2 function uses Q0 as its second argument – the cosine argument. The
first argument – the sine argument – is inside the parentheses immediately
following ATAN2. The Q0 used in Open Servo is always Coordinate System 1’s
Q0, no matter which coordinate system the executing motor has been assigned to.
Special Saturation-Check Function
The Open Servo has a special function to check a signed quantity against an unsigned limit magnitude
and saturate the quantity at the magnitude of the limit. The function FLIMIT({value},{limit})
compares the signed quantity {value} against the positive value {limit} and the negative value
{limit}. If {value} is greater than {limit}, the function returns the value of {limit}; if
{value} is less than –{limit}, the function returns the value of -{limit}. Otherwise, the function
simply returns the value of {value}. Both quantities – {value} and {limit} – must be floating-
point expressions (the expressions can be simply variables or constants).
For example, the statement:
P2=FLIMIT(P1,20000)
is equivalent to:
IF (P1>20000)
P2=20000
ELSE
IF (P1<-20000)
P2=-20000
ELSE
P2=P1
ENDIF
ENDIF
The FLIMIT function reduces the size of both the source code and the resulting compiled code.
Special Access to Motor Values and Registers
The Open Servo algorithms have several special statements to support useful features for servo loop
execution.
MTRNUM Function: The MTRNUM function returns the number of the motor (1 – 32) for which the
algorithm is presently executing. The number is returned as a fixed-point (integer) value. For example,
the statement L10=MTRNUM*100 would set fixed-point variable L10 to 200 when the Open Servo
algorithm is executing for Motor 2, or to 1800 when executing for Motor 18. Similarly, the statement
P10=ITOF(MTRNUM*100+30) would set floating-point variable P10 to 230 when the Open Servo
algorithm is executing for Motor 2, or to 1830 when executing for Motor 18.