F304_BACOS

BCD type arccosine operation

The function calculates the arccosine 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 of 0° to 360° (16#0 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 -1.0000 to 1.0000. 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

  • if s is not between -1.0000 and 1.0000

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if s is not a BCD value

  • if s is not between -1.0000 and 1.0000

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

When the variable start is set to TRUE, the function is carried out.

The input_value = 0 (+ sign) in the ARRAY’s first element. 0 represents the whole in the second element, and the value after the decimal point is 8660. The function thus calculates the output_value = 16#30 (30°).
BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_VARIN,,output,7,1,9,3,);
B(B_VARIN,,input_value,7,2,9,4,);
B(B_VAROUT,,output_value,18,2,20,4,);
B(B_F,F304_BACOS,,9,0,18,4,,?DEN?D@'s'?AENO?Cd);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start THEN         
    F304_BACOS(input_value, output_value);
END_IF;

IL body

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