F305_BATAN

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.

Parameters

Input

s ARRAY [0..2] of (WORD)

Area where angle data is stored in 3 words

Output

d (WORD)

Result

Remarks

BCD values for input s lie in the area from -9999.9999 to 9999.9999. They are entered as follows:

ARRAY[0]

preceding sign (0 when input is +, 1 when input is -)

ARRAY[1]

whole number before the decimal point (0 or 1)

ARRAY[2]

numbers after the decimal point with 4 significant figures as a BCD value (16#0000 to 16#9999).

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)

if s is not a BCD value

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

if s is not a BCD value

sys_bIsEqual (turns to TRUE and remains TRUE)

if the result is 0.

sys_bIsCarry (turns to TRUE for one scan)

if the result is overflowed.

Example

POU header

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

LD body

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

ST 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;

IL body

Modified on: 2019-01-24Feedback on this pagePanasonic hotline