UNPACK8 block

Short summary

Name

UNPACK8

→POU type

→function

Category

IEC-block, ConvertEnh

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg not defined in IEC-standard

Graphical interface

images/download/thumbnails/414781238/UNPACK8-version-1-modificationdate-1534940035494-api-v2.png

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 OUT0OUT7 . 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 OUT7. 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

→Data type

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

OUT4

BYTE

5th byte output value

OUT5

BYTE

6th byte output value

OUT6

BYTE

7th byte output value

OUT7

BYTE

8th 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.

See:

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 ExampleUnpack8
VAR
resultA1, resultA2, resultA3, resultA4, resultA5, resultA6, resultA7, resultA8, resultB1, resultB2, resultB3, resultB4, resultB5, resultB6, resultB7, resultB8 : BYTE;
END_VAR
UNPACK8(IN := DWORD#16#04030201, OUT0 => resultA1, OUT1 => resultA2, OUT2 => resultA3, OUT3 => resultA4, OUT4 => resultA5, OUT5 => resultA6, OUT6 => resultA7, OUT7 => resultA8);
UNPACK8(IN := WORD#16#0201, OUT0 => resultB1, OUT1 => resultB2, OUT2 => resultB3, OUT3 => resultB4, OUT4 => resultB5, OUT5 => resultB6, OUT6 => resultB7, OUT7 => resultB8);
 
Assert(resultA1 = 16#01);
Assert(resultA2 = 16#02);
Assert(resultA3 = 16#03);
Assert(resultA4 = 16#04);
Assert(resultA5 = 16#00);
Assert(resultA6 = 16#00);
Assert(resultA7 = 16#00);
Assert(resultA8 = 16#00);
Assert(resultB1 = 16#01);
Assert(resultB2 = 16#02);
Assert(resultB3 = 16#00);
Assert(resultB4 = 16#00);
Assert(resultB5 = 16#00);
Assert(resultB6 = 16#00);
Assert(resultB7 = 16#00);
Assert(resultB8 = 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.