F130_BTS

16-bit data bit set

Turns ON the bit specified by the bit position at n of the 16-bit data specified by d if the trigger EN is in the ON-state. Bits other than the bit specified do not change. The range of n is 0 to 15.

Parameters

Input

d (WORD, INT, UINT)

16-bit area

Output

n (INT)

Specifies bit position to be set

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,F130_BTS!,,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
    F130_BTS( n:= iValue,
         d=> wWord);
END_IF;

IL body

LD

start

(* EN = start; Starting signal for the F130_BTS function. *)

F130_BTS

output_value,

(* n = output_value *)

0

(* d = bit number, here 0 *)

ST

out

(* optional *)

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