LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Modbus Data Type

Solved!
Go to solution
Highlighted

I am trying to add bound variables to my modbus server from a device that has a data format I have never before.  First the data is either 16 bit  (single register) or a 32 bit (two register) each type can also be signed or unsigned.  The data represents an integer part and a fractional part which is defined as a number of bits for each part.  The manufacture supplies a "scaling factor" represented by  8.24, where the first 8 bits is the integer and the remaining 24 bits is the fractional part.  Because my explanation may not be clear I have attached screen captures from the manual.  Also I have attached how to get the real value using labview code.

 

However I would like to add this to my Modbus server (Labview DSC Module) and was wondering if there was a modbus function to deal with this type of data, Like a F400001 for floats or  300001.1 for individual bits.

 

I was hoping that there might be something directly from the modbus server I could just read the registrar and display a value directly from the modbus server.

0 Kudos
Message 1 of 5
(350 Views)

Hi Terry,

 

you can use U32/I32 to store those values. Scaling to/from float by 2**X, with X as the number of fractional bits...

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 5
(336 Views)
Highlighted

I think what you'll have to do is read that as a 32 bit integer.  Than do some math on it manipulating the bits to break them down into integer and fractional, then doing the math and combining the parts.  Perhaps you can create a fixed point data type and try type casting the 32 bit integer into the FXP type.  But that is speculation on my part.  I haven't needed to mess with FXP types.

0 Kudos
Message 3 of 5
(332 Views)
Highlighted
Solution
Accepted by Terry_S

Hi Terry,

 

now providing an example:

No need for FXP, only simple scaling using simple math…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 4 of 5
(251 Views)
Highlighted

thanks very much for the help

0 Kudos
Message 5 of 5
(198 Views)