LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus read register to a floating point number

Solved!
Go to solution

I am Trying to read values for a prolinx Hart to Modbus controller i have talked to Prolinx and established that my Pressure values are coming from 40031-40032 and my flow values are coming from 40131-40132 each are standard U16 values using LabVIEW code:

modbus post.png

I get a rather nonsensical number.  I have tried reversing arrays and byte and word swapping.  all to no avail.  for register 31-32 LabVIEW reads 61919 and 16811 respectively  which need to combine to get something close to 82 + some change and for registers 131-132 i read 17054 and 61858 respectively which needs to combine to 79 and change.  

 

I Have Tried most of what i can find out there but please ask question about the holes in this question it might pop something out.  

 

Thanks,

Mark 

0 Kudos
Message 1 of 6
(5,289 Views)

What is the datatype of the constant going into the typecast?

 

Make sure it is SGL and not DBL.

0 Kudos
Message 2 of 6
(5,281 Views)

Yes it is a single I have tried it both way meanin both of them are doubles then again as both of them are singles.  either way I get a number in the billions 

0 Kudos
Message 3 of 6
(5,276 Views)
Solution
Accepted by topic author markhrussell

Hi mark,

 

you're doing something wrong:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(5,274 Views)

You're right.  Your constant must be SGL, otherwise you'd have a coercion dot for the wire going into the SGL indicator.

 

Gerd's image shows exactly what I got for your 2nd example.

 

For your first example of 61919 and 16811, I get  -2.21e30, but if I swap the values, I get a more reasonable 21.4931 (though not the 82+) you are expecting.

 

Are you sure about the values coming from the Modbus Read?  Can you put an indicator on the array wire going to the typecast to double check those values?

Message 5 of 6
(5,270 Views)

Ok So.... you're right about me do something wrong but is wasn't really LabView code it turns out that when I went back to look at how my Prolinx profile was set up it turns out that for the flow register I was word and byte swapping in the controller and for pressure I was only byte swapping 

 

Thanks for the hlep guys.

 

 

0 Kudos
Message 6 of 6
(5,266 Views)