You've already figured it out, it seems that you just don't realize it. The conversion DWORD_TO_REAL
is taking the integer (hex) value stored in 4bytesData
and converting it to IEEE754 REAL format.
This is not what you want to do. 4479FFFF
is already in IEEE754 REAL format - you're taking that value, interpreting the REAL as a DWORD, and then converting the DWORD value to a REAL. The short answer is that you don't need the conversion - 4bytesData
is already in the correct format.
edit
follow up on comments :
here FunctionBlock2 delclares rIn(REAL), rOut(REAL) and sets rOut:=rIn;
. This gets around the forced typecasting of ST. Nothing is changing about the data stored in D2000
here - it's the same binary data. The top function block is storing it into memory and the bottom one is reading it from memory. The only difference is that the top rung is interpreting it as a DWORD (for display purposes) and the bottom rung is interpreting it as REAL.
edit
I've been reading the Beckhoff manual. It seems you may have other options. Try perhaps declaring a DWORD and REAL at the same memory location. If not, perhaps pointers would let you do it (not sure if type restrictions also apply to pointers with Beckhoff?)