Host Engineering Forum
General Category => General Discussion => Topic started by: tdecant_GMI on March 30, 2009, 10:56:59 AM
-
I am reading in VMemory values with VB. In the PLC the values I want to view reside as Real. What is the conversion? I am able to convert the Byte array to a readable Decimal value but I don't know how to translate the 4 Bytes (the 2 VMemory locations) to a Real.
Thanks.
-
If I'm understanding you properly, then the format of the real number in V-memory is IEEE 32-bit format. If, for example, you are using a DL205, then in the d2user manual on page 5-90 is a graphical description of this format.
-
If you have 2 V memory locations from the PLC, then the 32 bit IEEE floating point number SHOULD work as follows:
V2000 and V2001 in 2 16 bit locations in VB as type WORD (I'm not a VB buy, but you should know how you are storing your 16 bit word in VB). Likewise the result would be in a 32 bit float - not sure what that is in VB (VB6? VB.Net?)
WORD MyV2000
WORD MyV2001
float MyVB32BitFloat
HIWORD of MyVB32BitFloat is set to MyV2001
LOWORD of MyVB32BitFloat is set to MyV2000
-
Thanks.