Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2012, 07:58:33 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Conversion of values read via ModbusTCP  (Read 1119 times)
tdecant_GMI
Newbie
*
Posts: 2


« 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.
Logged
Greg
HOS†ech
Host Moderator
*****
Posts: 320


Hmmm...


WWW
« 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.
Logged

"You have to believe in free will. You have no choice." -Isaac Bashevis-Singer
franji1
Bit Weenie
Host Moderator
*****
Posts: 1034



WWW
« 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
Logged

tdecant_GMI
Newbie
*
Posts: 2


« Reply #3 on: March 31, 2009, 04:39:08 pm »

Thanks.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM