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

REAL_TO_BYTE

Previous pageReturn to chapter overviewNext page

Block that performs the conversion of a REAL value into a BYTE value.

 

Ladder Representation

 

REAL_TO_BYTE_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

Value

REAL

Value in REAL

VAR_OUTPUT

ENO

BOOL

End of operation

Result

BYTE USINT SINT

Value in BYTE

 

Operation

 

When this block has a TRUE value in EN, it interprets the Value value as REAL and converts it into BYTE, 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

 

REAL_TO_BYTE_flowchart

 

Example in Ladder

 

REAL_TO_BYTE_example01

 

REAL_TO_BYTE_example02

 

REAL_TO_BYTE_example03

 

REAL_TO_BYTE_example04

 

The examples above perform the conversion of variable VALUE, in REAL, into a BYTE value storing the final result in RESULT. The block ends with success and ENO output is activated. Notice that the results are truncated in decimal and only the eight least significant bits are taken into account.

 

Example in ST

 

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

 

 

VAR

  VALUE : REAL := 1.9;

   RESULT : SINT;

END_VAR

 

RESULT := FB_REAL_TO_BYTE(EN:=DI1, Value:=VALUE, ENO=>DO1);