Arithmetic instructions
78
Part II IEC Instructions
Data type I/O Function
REAL y Cartesian y coordinate
REAL x Cartesian x coordinate
Data types
Example
In this example the function has been programmed in ladder diagram (LD) and structured text (ST).
The same POU header is used for all programming languages.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
LD
ST
When programming with structured text, enter the following:
(* Angle value of point in quadrant 2 *)
rPhi1Rad:=ATAN2_YX(y := 10.0, x := -10.0); (* Result: 2.3561947 *)
rPhi1Degree := rPhi1Rad * DEGR_OF_RAD; (* Result: 135.00002 *)
(* Angle value of point in quadrant 4 *)
rPhi2Rad:=ATAN2_YX(y := -5.0, x := 5.0); (* Result: -0.78539819 *)
rPhi2Degree := rPhi2Rad * DEGR_OF_RAD; (* Result: -45.0 *)