Reference Manual
PMAC 2 Software Reference
PMAC Mathematical Features 365
Remarks
ATAN implements the standard inverse tangent, or arc-tangent function of the
mathematical expression contained inside the following parentheses. This standard
arc-tangent function returns values only in the +/-90-degree range; if a full +/-180-
degree range is desired, the ATAN2 function should be used instead.
This function returns values in degrees if I15 is set to the default value of 0; it returns
values in radians if I15 is set to 1.
Example
P50=ATAN(P48/P49) ; Computes angle whose tan is P48/P49
C(ATAN(Q70/10)) ; Move C axis to specified angle
ATAN2
Function
Two-argument trigonometric arc-tangent
Syntax
ATAN2({expression})
Domain
All real numbers in both arguments
Domain units
none
Range
-Pi to +Pi radians (-180 to +180 degrees)
Range units
Radians/degrees
Remarks
ATAN2 implements the expanded (two-argument) inverse tangent, or arc-tangent
function of the mathematical expression contained inside the following parentheses,
and the value of variable Q0 for the coordinate system used. (If this function is used
inside a PLC program, make sure the desired coordinate system has been selected with
the ADDRESS command.)
This expanded arc-tangent function returns values in the full +/-180-degree range; if
only the +/-90-degree range is desired, the standard ATAN function should be used
instead. The ATAN2 function makes use of the signs of both arguments, as well as the
ratio of their magnitudes, to extend the range to a full 360 degrees. The value in the
parentheses following ATAN2 is the “sine” argument; the value in Q0 is the “cosine”
argument.
This function returns values in degrees if I15 is set to the default value of 0; it returns
values in radians if I15 is set to 1.
If both arguments for the ATAN2 function are equal to exactly 0.0, an internal
division-by-zero error will result, and an arbitrary value will be returned. No error will
be reported, and the program will not stop. It is the programmer’s responsibility to
check for these possible domain errors.
Example
Q30=-0.707 ; “Cosine” argument
Q31=-0.707 ; “Sine” argument
Q32=ATAN(Q31/Q30) ; Single-argument arctangent
Q32 ; Query resulting value
45 ; Returns value in +/-90 range
Q0=Q30 ; Prepare “cosine” for ATAN2
Q33=ATAN2(Q31) ; Two-argument arctangent
Q33 ; Query resulting value
-135 ; Note different result
Q0=M163-M161 ; X target – X present position
Q1=M263-M261 ; Y target – Y present position
IF (ABS(Q0)>0.001 OR ABS(Q1)>0.001) ; Div by 0 check
Q2=ATAN2(Q1) ; Calculate directed angle
ENDIF