FP_COMBINE

Combine data

This FP instruction combines the two values at inputs s1 and s2 whereby the bit values at input s3_Mask determine the source of each bit. A bit value FALSE means the bit at input s1 is used, a bit value TRUE means the bit at input s2 is used. The result is stored in d.

Parameters

Input

s1, s2 (WORD, DWORD)

Values to be combined

s3_Mask (WORD, DWORD)

Input mask determining the source of each bit

Output

d (WORD, DWORD)

Combined result

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.
sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

  • if the area specified using the index modifier exceeds the limit.
Related topics:

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
		bStart: BOOL:=FALSE;
			(*activates the function*)
		dwInput_value1: DWORD:=2#00000000000000001001110011001111;
		dwInput_value2: DWORD:=2#00000000000000001001010110101010;
		dwSelection: DWORD:=2#00000000000000001110100111110100;
		dwOutput_value: DWORD:=0;
			(*the result after a 0->1 leading edge
from start:
2#00000000000000001001110011001110*)
	END_VAR

LD body

When the variable bStart is set to TRUE, the function is carried out. The mask bits at dwSelection determine which bits are returned at the dwOutput_value. For mask bits which are TRUE (1), the corresponding bits of dwInput_value1 are returned. For mask bits which are FALSE (0), the corresponding bits of dwInput_value2 are returned.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_F,FP_COMBINE!,,12,0,20,6,,?DEN?D@'s1'?Ds2?Ds3_Mask?AENO?Cd);
B(B_CONTACT,,bStart,4,1,6,3,);
B(B_VARIN,,dwInput_value1,10,2,12,4,);
B(B_VARIN,,dwInput_value2,10,3,12,5,);
B(B_VARIN,,dwSelection,10,4,12,6,);
B(B_VAROUT,,dwOutput_value,20,2,22,4,);
L(1,2,4,2);
L(6,2,12,2);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bStart then
    FP_COMBINE(s1 := dwInput_value1, s2 := dwInput_value2, s3_Mask := dwSelection, d => dwOutput_value);
END_IF;

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