Navigation:  Equipments (Devices) > SCA06 > Ladder > Conversion > BYTE >

WORD_TO_BYTES

Convert Word to Bytes

Previous pageReturn to chapter overviewNext page

Block that performs the conversion of a 16 bits (WORD) value in two 8 bits (2 BYTES) value.

 

Ladder Representation

 

WORD_TO_BYTES_block

 

Block Structure

 

Variable Type

Name

Data type

Description

VAR_INPUT

EN

BOOL

Block enabling

Value

WORD UINT INT

Value in WORD

VAR_OUTPUT

ENO

BOOL

End of operation

Result1

BYTE USINT SINT

Value in BYTE (LSB)

Result2

BYTE USINT SINT

Value in BYTE (MSB)

 

Operation

 

When this block has a TRUE value in EN, it interprets the Value value as WORD and converts it in two BYTE variables, storing in Result.

 

When EN has FALSE value, Result remains unchanged.

 

The ENO value forwards to the next Ladder block the EN value after the operation is completed.

 

 

Block Flowchart

 

WORD_TO_BYTES_flowchart

 

Example in Ladder

 

WORD_TO_BYTES_example01

 

WORD_TO_BYTES_example02

 

The examples above perform the conversion of variable VALUE "VAL_IN", in WORD, in two BYTE values storing the final result in RESULT1 and RESULT2. The block ends with success and ENO output is activated.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

   VAL_IN : INT := 256;

   RES_1 : SINT;

   RES_2 : SINT;

END_VAR

 

DO1 := FB_WORD_TO_BYTES(

   EN:=DI1,

   Value:=VAL_IN,

   Result1=>RES_1,

   Result2=>RES_2);