BIT_SET block
Short summary
Name |
BIT_SET |
→POU type |
|
Category |
|
Conform to →IEC-standard |
not defined in IEC-standard |
Graphical interface |
|
Available since |
|
Functionality
The block returns a value with a bit that is additionally set at a certain position.
At input IN, enter a value (the value at input IN is unchanged when the setting takes place). At input N, enter the bit number (0-based) that should be set.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN |
BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT) |
input value |
N |
USINT |
the bit number (0-based) to set |
|
Return value: |
– |
BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT) |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Example for usage within ST-editor
PROGRAM Test
VAR
result1 : WORD;
result2 : LWORD;
END_VAR
result1 := BIT_SET(IN := WORD#
16
#
8003
, N :=
2
); (* The variable
'result1'
evaluates to
'WORD#16#8007'
. *)
result2 := BIT_SET(IN := LWORD#
16
#
0000000000000003
, N :=
63
); (* The variable
'result2'
evaluates to
'LWORD#16#8000000000000003'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.