Description
The "Parse elements of an ARRAY of bit sequence into individual bits" instruction parses one or more elements of an ARRAY of BYTE, WORD, DWORD or LWORD into individual bits and saves them in an ARRAY of BOOL, an anonymous STRUCT or a PLC data type exclusively with Boolean elements. At the COUNT_IN parameter you specify how many elements of the source ARRAY are going to be parsed. The source ARRAY at the IN parameter may have more elements than specified at the COUNT_IN parameter. The ARRAY of BOOL, the anonymous STRUCT or the PLC data type must have sufficient elements to save the bits of the parsed bit sequences. However, the destination memory area may also be larger.
|
Note Multi-dimensional ARRAY of BOOL If the ARRAY is a multi-dimensional ARRAY of BOOL, the padding bits of the dimensions contained are counted as well even if they were not explicitly declared and are not accessible. Example 1: An ARRAY[1..10,0..4,1..2] of BOOL is handled like an ARRAY[1..10,0..4,1..8] of BOOL or like an ARRAY[0..399] of BOOL. Example 2: At the IN parameter, an ARRAY[0..5] of WORD (sourceArrayWord[2]) is interconnected. The COUNT_IN parameter has the value "3". At the OUT parameter, an ARRAY[0..1,0..5,0..7] of BOOL (destinationArrayBool[0,0,0]) is interconnected. Both the array at the IN parameter and at the OUT parameter has a size of 96 bits. The ARRAY of WORD is parsed into 48 individual bits. |
|
Note If the ARRAY low limit of the target ARRAY is not "0", note the following: For performance reasons the index must always start at a BYTE, WORD, DWORD or LWORD limit. This means the index must be calculated starting at the low limit of the ARRAY. The following formula is used as basis for this calculation: Valid indices = ARRAY low limit + n(number of bit sequences) × number of bits of the desired bit sequence For an ARRAY[-2..45] of BOOL and the bit sequence WORD the calculation looks as follows:
You can find an example described below. |
|
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 status words, 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 source ARRAY has fewer elements than specified at the COUNT_IN parameter.
-
The index of the destination ARRAY does not start at a BYTE, WORD, DWORD or LWORD limit. In this case, no result is written to the ARRAY of BOOL.
-
The ARRAY[*] of BOOL, STRUCT or PLC data type does not provide the required number of elements.
-
S7-1500-CPU: In this case as many bit sequences as possible are parsed and written to the ARRAY of BOOL, the anonymous STRUCT or the PLC data type. The remaining bit sequences are no longer taken into account.
-
S7-1200-CPU: There is no copying procedure.
-
|
Note S7-1200-CPU: Enable output ENO = 0 When the enable output ENO has signal state "0", no data are written to the output parameter OUT. |
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 |
Element of an ARRAY[*] of - BYTE - WORD - DWORD |
Element of an ARRAY[*] of - BYTE - WORD - DWORD - LWORD |
I, Q, M, D, L |
ARRAY of <bit sequence> that is parsed. The values must not be located in the I/O area or in the DB of a technology object. |
|
COUNT_IN |
Input |
USINT, UINT, UDINT |
USINT, UINT, UDINT, ULINT |
I, Q, M, D, L |
Counter for the number of elements of the source ARRAY that are going to be parsed. The value must not be in the I/O area or in the database of a technology object. |
|
OUT |
Output |
Element of an ARRAY[*] of - BOOL - STRUCT - PLC data type |
Element of an ARRAY[*] of - BOOL - STRUCT - PLC data type |
I, Q, M, D, L |
ARRAY, STRUCT or PLC data type in which the individual bits are stored |
You can select the required bit sequence from the "???" drop-down list of the instruction box.
You can find additional information on valid data types under "See also".
Example of a destination ARRAY with the low limit "0"
Create the following tags in the block interface:
|
Tag |
Section |
Data type |
|---|---|---|
|
Enable |
Input |
BOOL |
|
SourceArrayWord |
ARRAY[0..5] of WORD |
|
|
CounterInput |
UDINT |
|
|
EnableOut |
Output |
BOOL |
|
DestinationArrayBool |
ARRAY[0..95] 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 |
SourceArrayWord[2] |
ARRAY[0..5] of WORD (96 bits can be parsed.) |
|
COUNT_IN |
CounterInput = 3 |
UDINT3 (3 WORDs or 48 bits are to be parsed. This means at least 48 bits must be available in the destination ARRAY.) |
|
OUT |
DestinationArrayBool[0] |
The operand "DestinationArrayBool" is of the data type ARRAY[0..95] of BOOL. This means it provides 96 BOOL elements. |
If the operand #Enable returns the signal state "1" at the enable input EN, the instruction is executed. The 3rd, 4th and 5th WORD of the #SourceArrayWord operand is parsed into its individual bits (48) and as of the 1st element assigned to the individual elements of the #DestinationArrayBool 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 of a destination ARRAY with the low limit "-2"
Create the following tags in the block interface:
|
Tag |
Section |
Data type |
|---|---|---|
|
Enable |
Input |
BOOL |
|
SourceArrayWord |
ARRAY[0..5] of WORD |
|
|
CounterInput |
UDINT |
|
|
EnableOut |
Output |
BOOL |
|
DestinationArrayBool |
ARRAY[-2..93] 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 |
SourceArrayWord[2] |
ARRAY[0..5] of WORD (96 bits can be parsed.) |
|
COUNT_IN |
CounterInput = 3 |
UDINT3 (3 WORDs or 48 bits are to be parsed. This means at least 48 bits must be available in the destination ARRAY.) |
|
OUT |
DestinationArrayBool[14] |
The operand "DestinationArrayBool" is of the data type ARRAY[-2..93] of BOOL. This means it provides 96 BOOL elements. |
If the operand #Enable returns the signal state "1" at the enable input EN, the instruction is executed. The 3rd, 4th and 5th WORD of the #SourceArrayWord operand is parsed into its individual bits (48) and as of the 16th Element assigned to the individual elements of the #DestinationArrayBool operand. If an error occurs during the execution of the instruction, the operand #EnableOut returns the signal state "0" at the enable output ENO. The remaining 32 bits are not written.