F303_BASIN

BCD type arcsine operation

The function calculates the arcsine 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

Output

d (WORD)

Result stored in 3 words

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
		start: BOOL:=FALSE;
			(*activates the function*)
		input_value: ARRAY [0..2] OF WORD:=[2(0),16#5000];
			(*corresponds to 0.5*)
		output_value: WORD:=0;
			(*result after a 0->1 leading
edge from start: 16#60
corresponds to 60°*)
	END_VAR

LD body

The first element of the ARRAY’s input_value is given the value 1 (- sign). The second element has 0 as its whole number value, and in the third element 16#4500 is written as the value after the decimal point. When the variable start is set to TRUE, the function is carried out. The result for the output_value = 16#333 (333°).

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,,1,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#4500,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,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,F303_BASIN,,9,0,18,4,,?DEN?D@'s'?AENO?Cd);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

input_value[0]:=1;
input_value[1]:=0;
input_value[2]:=16#4500;
IF start THEN         
    F303_BASIN(input_value, output_value);
END_IF;

IL body

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