0% found this document useful (0 votes)
58 views1 page

Swap Bytes Real

Step7 Bytes are re-ordered to construct a REAL HMI

Uploaded by

rigo_sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views1 page

Swap Bytes Real

Step7 Bytes are re-ordered to construct a REAL HMI

Uploaded by

rigo_sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

FUNCTION_BLOCK "swap_bytes_REAL"

TITLE = Bytes are re-ordered to construct a REAL


{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
VAR_INPUT
Byte_1 { S7_HMI_Accessible := 'False'; S7_HMI_Visible
// byte to form real value 1 of 4
Byte_2 { S7_HMI_Accessible := 'False'; S7_HMI_Visible
// byte to form real value 2 of 4
Byte_3 { S7_HMI_Accessible := 'False'; S7_HMI_Visible
// byte to form real value 3 of 4
Byte_4 { S7_HMI_Accessible := 'False'; S7_HMI_Visible
// byte to form real value 1 of 4
END_VAR

:= 'False'} : Byte;
:= 'False'} : Byte;
:= 'False'} : Byte;
:= 'False'} : Byte;

VAR_OUTPUT
OUT { S7_HMI_Accessible := 'False'; S7_HMI_Visible := 'False'} : Real;
/ Resulting value constructed from bytes
END_VAR
VAR

Value { S7_HMI_Accessible := 'False'; S7_HMI_Visible := 'False'} : Real;


// Reconstructed value
Raw { S7_HMI_Accessible := 'False'; S7_HMI_Visible := 'False'} AT Value :
DWord; // Raw value constructed from BYTES
END_VAR
BEGIN
#Raw.%B0 := #Byte_4;
#Raw.%B1 := #Byte_3;
#Raw.%B2 := #Byte_2;
#Raw.%B3 := #Byte_1;
#OUT := #Value;
END_FUNCTION_BLOCK

You might also like