25 TYPE CONVERSION FUNCTIONS
25.67 Writing the Specified Bit of the Word Label
1889
25
When using SET_BIT_OF_INT(_E) in ST, create a program which assigns the return value to a variable.
The return value of SET_BIT_OF_INT(_E) also works as input/output. Do not directly assign it to the input argument of
another instruction, function, or function block.
There is no operation error.
By using the bit specification of labels, a concise program having the same operation as SET_BIT_OF_INT
can be created.
The following example changes the value in bit 5 (b5) of g_int1 to the value of g_bool1 the same as when
SET_BIT_OF_INT is used.
Ladder
ST
g_int1.5 := g_bool1;
FBD/LD
//The return value of SET_BIT_OF_INT is assigned to a variable and used.
g_int1 := SET_BIT_OF_INT(TRUE, 0);
g_bool1 := GET_BIT_OF_INT(g_int1, 0);
//In the following program, the value of the first argument of GET_BIT_OF_INT is undefined.
g_bool1 := GET_BIT_OF_INT( SET_BIT_OF_INT(TRUE, 0), 0);