Host Engineering Forum

General Category => General Discussion => Topic started by: tdecant_GMI on March 30, 2009, 10:56:59 AM

Title: Conversion of values read via ModbusTCP
Post 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.
Title: Re: Conversion of values read via ModbusTCP
Post by: Greg on March 31, 2009, 12:30:12 PM
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.
Title: Re: Conversion of values read via ModbusTCP
Post by: franji1 on March 31, 2009, 12:49:30 PM
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
Title: Re: Conversion of values read via ModbusTCP
Post by: tdecant_GMI on March 31, 2009, 04:39:08 PM
Thanks.