UNPACK2 block

Short summary

Name

UNPACK2

→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/414781228/UNPACK2-version-1-modificationdate-1534939997110-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 OUT0 and OUT1 . 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 OUT1. 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

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 ExampleUnpack2
VAR
resultA1, resultA2, resultB1, resultB2 : BYTE;
END_VAR
UNPACK2(IN := DWORD#16#04030201, OUT0 => resultA1, OUT1 => resultA2);
UNPACK2(IN := WORD#16#0201, OUT0 => resultB1, OUT1 => resultB2);
 
Assert(resultA1 = 16#01);
Assert(resultA2 = 16#02);
Assert(resultB1 = 16#01);
Assert(resultB2 = 16#02);
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.