Description
The "Parse the bit sequence into individual bits" instruction parses a tag of the BYTE, WORD, DWORD or LWORD data type into individual bits and saves them in an ARRAY of BOOL, an anonymous STRUCT or a PLC data type exclusively with Boolean elements.
|
Note Multi-dimensional ARRAY of BOOL With the "Parse the bit sequence into individual bits" instruction, the use of a multidimensional ARRAY of BOOL is not permitted. |
|
Note Length of the ARRAY, STRUCT or PLC data type The ARRAY, the anonymous STRUCT or the PLC data type must have exactly the number of elements that is specified by the bit sequence. This means for the data type BYTE, for example, the ARRAY, STRUCT or the PLC data type must have exactly 8 elements (WORD = 16, DWORD = 32 and LWORD = 64). |
|
Note Availability of the instruction The instruction can be used with a CPU of the S7-1200 series as of firmware version >4.2, and for a CPU of the S7-1500 series as of firmware version 2.1. |
This way you can, for example, parse a status word, and read and change the status of the individual bits using the index. Using GATHER, you can merge the bits once again into a bit sequence.
The enable output ENO returns signal state "0" if one of the following conditions applies:
-
Enable input EN has signal state "0".
-
The ARRAY, STRUCT or PLC data type does not provide enough BOOL elements.
Parameter
The following table shows the parameters of the instruction:
|
Parameter |
Declaration |
Data type |
Memory area |
Description |
|
|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
||||
|
EN |
Input |
BOOL |
BOOL |
I, Q, M, D, L or constant |
Enable input |
|
ENO |
Output |
BOOL |
BOOL |
I, Q, M, D, L |
Enable output |
|
IN |
Input |
BYTE, WORD, DWORD |
BYTE, WORD, DWORD, LWORD |
I, Q, M, D, L |
Bit sequence that is parsed. The values must not be located in the I/O area or in the DB of a technology object. |
|
OUT |
Output |
ARRAY[*] of BOOL, STRUCT or PLC data type *: 8, 16, 32 or 64 elements |
ARRAY[*] of BOOL, STRUCT or PLC data type *: 8, 16, 32 or 64 elements |
I, Q, M, D, L |
ARRAY, STRUCT or PLC data type in which the individual bits are stored |
You can find additional information on valid data types under "See also".
Example with an ARRAY
Create the following tags in the block interface:
|
Tag |
Section |
Data type |
|---|---|---|
|
Enable |
Input |
BOOL |
|
SourceWord |
WORD |
|
|
EnableOut |
Output |
BOOL |
|
DestinationArray |
ARRAY[0..15] of BOOL |
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameter |
Operand |
Data type |
|---|---|---|
|
IN |
SourceWORD |
WORD (16 bits) |
|
OUT |
DestinationArray |
The operand "DestinationArray" is of the data type ARRAY[0..15] of BOOL. It consists of 16 elements and is therefore just as large as the WORD that is to be parsed. |
If the operand #Enable returns the signal state "1" at the enable input EN, the instruction is executed. The operand #SourceWord of the data type WORD is parsed into its individual bits (16) and assigned to the individual elements of the #DestinationArray operand. If an error occurs during the execution of the instruction, the operand #EnableOut returns the signal state "0" at the enable output ENO.
Example with a PLC data type (UDT)
Create the following PLC data type "myBits":
Create the following tags in the block interface:
|
Tag |
Section |
Data type |
|---|---|---|
|
Enable |
Input |
BOOL |
|
SourceWord |
WORD |
|
|
EnableOut |
Output |
BOOL |
|
DestinationUDT |
"myBits" |
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameter |
Operand |
Data type |
|---|---|---|
|
IN |
SourceWord |
WORD (16 bits) |
|
OUT |
DestinationUDT |
The "DestinationUDT" operand has the PLC data type (UDT). It consists of 16 elements and is therefore just as large as the WORD that is to be parsed. |
If the operand #Enable returns the signal state "1" at the enable input EN, the instruction is executed. The #SourceWord operand of the data type WORD is parsed into its individual bits (16) and assigned to the individual elements of the #DestinationArray operand. If an error occurs during the execution of the instruction, the operand #EnableOut returns the signal state "0" at the enable output ENO.