UNPACK4 block
Short summary
Name |
UNPACK4 |
→POU type |
|
Category |
|
Conform to →IEC-standard |
not defined in IEC-standard |
Graphical interface |
|
Available since |
version 1.50.0 (for logi.CAD 3) |
Functionality
The block transfers the value that is connected to the input IN bytewise to the outputs OUT0 – OUT3 . In case of target systems saving data in little →endian format, the lowest significant byte of the input is transferred to the output OUT0, the highest significant byte to OUT3. A reversed behavior is true for target systems saving data in big endian format.
Special cases (see under "Example for usage within ST-editor" ) :
If the size of the input value (number of bytes representing the data type) is > than the number of the outputs, only the lower significant input bytes are transferred.
If there are more output bytes than the input value contains, the higher significant output bytes remain not-initialized. In case of target systems saving data in little endian format, these are the outputs positioned in the lower part of the block.
In-/Outputs
|
Identifier |
Description |
|
Inputs: |
IN |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, DATE_AND_TIME, DATE or TIME_OF_DAY |
input value |
Outputs: |
OUT0 |
BYTE |
1st byte output value |
OUT1 |
BYTE |
2nd byte output value |
|
OUT2 |
BYTE |
3rd byte output value |
|
OUT3 |
BYTE |
4th byte output value |
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
The following example is valid for target systems saving data in little endian format . The calculated values are evaluated by using the Assert block .
FUNCTION_BLOCK ExampleUnpack4
VAR
resultA1, resultA2, resultA3, resultA4, resultB1, resultB2, resultB3, resultB4 : BYTE;
END_VAR
UNPACK4(IN := DWORD#
16
#
04030201
, OUT0 => resultA1, OUT1 => resultA2, OUT2 => resultA3, OUT3 => resultA4);
UNPACK4(IN := WORD#
16
#
0201
, OUT0 => resultB1, OUT1 => resultB2, OUT2 => resultB3, OUT3 => resultB4);
Assert(resultA1 =
16
#
01
);
Assert(resultA2 =
16
#
02
);
Assert(resultA3 =
16
#
03
);
Assert(resultA4 =
16
#
04
);
Assert(resultB1 =
16
#
01
);
Assert(resultB2 =
16
#
02
);
Assert(resultB3 =
16
#
00
);
Assert(resultB4 =
16
#
00
);
END_FUNCTION_BLOCK
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.