News:

  • April 30, 2026, 02:48:25 PM

Login with username, password and session length

Author Topic: Conversion of values read via ModbusTCP  (Read 12195 times)

tdecant_GMI

  • Newbie
  • *
  • Posts: 2
Conversion of values read via ModbusTCP
« 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.

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Conversion of values read via ModbusTCP
« Reply #1 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.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Conversion of values read via ModbusTCP
« Reply #2 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

tdecant_GMI

  • Newbie
  • *
  • Posts: 2
Re: Conversion of values read via ModbusTCP
« Reply #3 on: March 31, 2009, 04:39:08 PM »
Thanks.