Two-Argument Arctangent (ATAN2)

The ATAN2 instruction takes the two-argument arc tangent of the Source values and stores the result in the Destination (in radians). The ATAN2 operator/function computes the arc tangent of the Source and returns the FLOAT result. The resulting value in the Destination is greater than or equal to -p and less than or equal to p (where p = 3.141593).
Available Languages
Ladder Diagram
ATAN2 instruction
IMPORTANT:
Unexpected operation may occur if:
  • Output tag operands are overwritten.
  • Members of a structure operand are overwritten.
  • Except when specified, structure operands are shared by multiple instructions.
Operand
Data Type
Format
Description
Source Y
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
immediate
tag
Source Y of ATAN2 Input
Source X
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
immediate
tag
Source X of ATAN2 Input
Dest
REAL
LREAL
tag
Tag to store result of the instruction.
Operator Aspects
The ATAN2 operator can be used in various RLL expressions. ATAN2 returns a FLOAT result containing the result of two argument arc tangent of the Source Y and Source X. Depending on the context, this value can then be type converted if appropriate.
Affects Math Status Flags
Conditional, see Math status flags.
Major/Minor Faults
None specific to this instruction. See Index through arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
N/A
Rung-condition-in is false
Set Rung-condition-out to Rung-condition-in.
Rung-condition-in is true
Set Rung-condition-out to Rung-condition-in.
Dest = ATAN2(Source Y, Source X)
Postscan
N/A
Example
Ladder Diagram
ATAN2 instruction example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.