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.
Solved! Go to Solution.
you can use U32/I32 to store those values. Scaling to/from float by 2**X, with X as the number of fractional bits...
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.
now providing an example:
No need for FXP, only simple scaling using simple math…