LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Modbus Data Type

Solved!
Go to solution

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
(1,513 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 LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,499 Views)

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
(1,495 Views)
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 LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(1,414 Views)

thanks very much for the help

0 Kudos
Message 5 of 5
(1,361 Views)