FP_SET_BIT

Bit set

This FP instruction turns ON the bit specified by the bit position at n_Pos of the data specified by d if the trigger EN is in the ON-state. Bits other than the bit specified do not change.

Parameters

Input

n_Pos (INT)

Bit position to be set (permissible range: 0–15)

Input/output

d (WORD)

16-bit data area

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.

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
		bSet: BOOL:=FALSE;
			(*activates the function*)
		iValue: INT:=0;
			(*bit position*)
		wWord: WORD:=2#101010;
			(*result after a 0->1 leading
edge from start: 2#101011*)
	END_VAR

POU body

When the variable bSet is set to TRUE, the function is carried out. The bit on position 0 is set to 1.

LD body

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_CONTACT,,bSet,3,1,5,3,);
B(B_VARIN,,iValue,8,2,10,4,);
B(B_VAROUT,,wWord,16,2,18,4,);
B(B_F,FP_SET_BIT!,,10,0,16,4,,?DEN?Dn?AENO?Cd);
L(5,2,10,2);
L(1,2,3,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bSet then
    FP_SET_BIT( n:= iValue,
         d=> wWord);
END_IF;

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