Trouble with floats

So in the tag viewer I’m unable to get floats to show up correctly, they are all 0, if I use modpoll the value comes through correctly. The diagnostics shows that the value is good with a scientific notation value. It’s my first time with floats so I’m sure I’m just not using the tags properly.



Check that the tag offset is correct (try moving up or down one register) and also play with two of the settings on the device connection:

  1. Reverse Word Order
  2. One-Based Addressing

Also worth looking at: is this “scientific notation value” really close to 0 and modpoll is showing you a rounded number?

the scientific notation value is 2.4243e-41, modpoll shows 300, moving up and down a register gives an error, in that block there’s only 1 float register, if I get each register at a time the first is 0 and the second is like 17,302. The opc item path is using the HRF prefix.

how do I reverse the byte order?

Reverse byte order is counter to the Modbus spec, so we don’t directly support it, but you could try to do so from a script:

def int32BE_to_float32LE(i): 
	from java.lang import Float, Integer
	return Float.intBitsToFloat(Integer.reverseBytes(i))

The word order reversal is an advanced option on the driver settings.

Reversing byte order requires @PGriffith’s scripting workaround.


I figured it out, think it’s because the modbus protocol is big endian, I had my software store the data as such. Thanks everybody.

Had the same problem fo you @codersmurf. Just solve it playing with play with Reverse Word Order and One-Based Addressing, also being aware of the Modbus spec.

Many thanks to all!

Where would you install this script.

On the Value Changed Event?

how should the tag be setup? as an int or float?


Try reading this before messing with that:

There are some special register types like HRBCD and such that will grab the data with conversions.