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

DWORD_TO_BYTES

Convert Double Word to Bytes

Previous pageReturn to chapter overviewNext page

Block that performs the conversion of a 32 bits (DWORD) value into four 8 bits (4 BYTES) value.

 

Ladder Representation

 

DWORD_TO_BYTES_block

 

Block Structure

 

Variable Type

Name

Data type

Description

VAR_INPUT

EN

BOOL

Block enabling

Value

DWORD UDINT DINT

Value in DWORD

VAR_OUTPUT

ENO

BOOL

End of operation

Result1

BYTE USINT SINT

Value in BYTE (LSB)

Result2

BYTE USINT SINT

Value in BYTE

Result3

BYTE USINT SINT

Value in BYTE

Result4

BYTE USINT SINT

Value in BYTE (MSB)

 

Operation

 

When this block has a TRUE value in EN, it interprets the Value value as DWORD and converts it into four BYTE values (from Result1 to Result4, where Result 1 is LSB), 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

 

DWORD_TO_BYTES_flowchart

 

Example in Ladder

 

DWORD_TO_BYTES_example01

 

DWORD_TO_BYTES_example02

 

The examples above perform the conversion of variable VALUE, in DWORD, into four BYTE value storing the final result in RESULT1, RESULT2, RESULT3 and RESULT4. 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

  VALUE : DINT := 65536;

   RESULT1 : SINT;

   RESULT2 : SINT;

   RESULT3 : SINT;

   RESULT4 : SINT;

END_VAR

 

DO1 := FB_DWORD_TO_BYTES(

   EN:=DI1,

   Value:=VALUE,

   Result1=>RESULT1,

   Result2=>RESULT2,

  Result3=>RESULT3,

  Result4=>RESULT4);