BCD type arctangent operation
The function calculates the arctangent of a BCD value that is entered at input s as an ARRAY with three elements. The result is returned as BCD angular data in the range 0° to 90° (16#0 to 16#90) or 270° to 360° (16#270 to 16#360) at output d.
Input
Area where angle data is stored in 3 words
Output
Result
BCD values for input s lie in the area from -9999.9999 to 9999.9999. They are entered as follows:
preceding sign (0 when input is +, 1 when input is -)
whole number before the decimal point (0 or 1)
numbers after the decimal point with 4 significant figures as a BCD value (16#0000 to 16#9999).
if s is not a BCD value
if s is not a BCD value
if the result is 0.
if the result is overflowed.
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
output: BOOL:=FALSE;
(*activates the function*)
input_value: ARRAY [0..2] OF WORD:=[3(0)];
(*number between -9999.9999 and 9999.9999
input_value[0] = +/- sign
input_value[1] = pre-decimal point values
input_value[2] = post-decimal point values*)
output_value: WORD:=0;
(*BCD value between
16#0 and 16#360 (0° and 360°)
result: here 16#20*)
END_VAR
The first element of the ARRAY’s input_value is given the value 0 (+ sign). 0 is the whole number value in the second element, and the third element has a value of 3639 after the decimal point. When the variable start is set to TRUE, the function is carried out. The result for the output_value = 16#20 (20°).
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_VARIN,,0,8,0,10,2,);
B(B_VAROUT,,input_value[0],10,0,12,2,);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_VARIN,,0,8,0,10,2,);
B(B_VAROUT,,input_value[1],10,0,12,2,);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_VARIN,,16#3639,8,0,10,2,);
B(B_VAROUT,,input_value[2],10,0,12,2,);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,output,8,1,10,3,);
B(B_VARIN,,input_value,8,2,10,4,);
B(B_VAROUT,,output_value,19,2,21,4,);
B(B_F,F305_BATAN,,10,0,19,4,,?DEN?D@'s'?AENO?Cd);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
input_value[0]:=0;
input_value[1]:=0;
input_value[2]:=16#3639;
IF start THEN
F305_BATAN(input_value, output_value);
END_IF;