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 floating point result. The resulting value in the
Destination is greater than or equal to -pi and less than or equal to pi (where pi =
3.141593).
Available Languages
Ladder Diagram

Function Block Diagram
Function Block Diagram supports only the FBD function:
FBD Function

Structured Text
This instruction is not available in structured text.
TIP:
Use ATAN2 as an operator in an expression to compute the same result. Refer
to Structured Text Syntax for more information on the syntax of
expressions and assignments within structured text.
Operands
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.
There are data conversion rules for mixing numeric data types within an instruction. See
Data Conversions.
Ladder Diagram
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. |
Function Block Diagram
FBD Function
Operand | Data Type | Description |
Source Y | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | Source Y of ATAN2 Input |
Source X | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | Source X of ATAN2 Input |
Output Operand (Right Pin) | Data Type | Description |
Dest | REAL LREAL | Result of the function. |
See FBD Functions.
Operator Aspects
The ATAN2 operator can be used in various RLL expressions. Similarly, the ATAN2 function is
invoked in Structured Text statements. ATAN2 returns a floating point 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 |
Function Block Diagram
FBD Function
Condition/State | Action Taken |
Prescan | N/A |
Normal Scan | Dest = ATAN2(Source Y, Source X) |
Instruction first run | N/A |
Instruction first scan | N/A |
Postscan | N/A |
Examples
Ladder Diagram

Function Block Diagram
FBD Function

Structured Text
REAL_dest := ATAN2(REAL_srcY, REAL_srcX);
Provide Feedback