Variations in ModBus Standard

  • Thread starter Sebastian Ramirez
  • Start date
S

Thread Starter

Sebastian Ramirez

Hi.

I'm working on the integration of some devices for a automation system.

One of these devices is a RTU with a ethernet link that works as a ModBus slave. The main issue with that RTU is that its responses for 32bit floating point values are coming in word swap format, while it is configured to answer with a standard floating point byte order (ABCD order).

While researching, I asked the IT staff for it, and they said it was possible that the RTU was using the Bristol standard format for 32bt Floating Point numbers.

I've been searching for references of such a standard without success.

Does it really exists? Were can I find information about it? How is it different than the Modbus Standard.
 
The Modbus RTU or TCP Standards does not define the format of the data moved by Modbus beyond

- an input/holding register is 16 bits; a 2 byte word per register.

- Modbus ASCII defines the representation of the hexadecimal characters representing the bytes used in the PDU (?, the actual packet) as ASCII.

The slave represents data values in some format and hopefully explains which format is used in its documentation. Some products take the effort map the same data values to different memory blocks with different formats; say, integer in one block and floating point in another block. I have to admit I haven't seen a slave which maps same values to two different FP formats, but there are thousands of implementations out there.

In the end, the master is stuck reading whatever format is available from the slave. If the format doesn't match what the master can natively decode, the either the master has to do some bit playing or use an intermediate device, a combo master/slave, where the master which can read the slave, do a format conversion and then make the result available in a slave register so your master can read the result.

You can delve into floating point if you want. There's Widipedia:
http://en.wikipedia.org/wiki/IEEE_754-2008

Or there's a 60+ page paper, What Every Computer Scientist Should Know About Floating-Point arithmetic, a mathematical treatment of floating point.

http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html
(take out any space or spaces the forum inserts into the URL)

But in a quick scan of the paper, I didn't see byte order addressed. The erudite IEEE 754 discussion starts on page 13 (pdf).

Most Modbus devices claim to use IEEE 754 floating point. Most use 32 bit. The flow meter vendors and masters that read flow meters sometimes use 64 bit.

If you just want to see the 4 floating point byte orders that are typically made available (Big or Little Endian, straight or swapped) you can check out Honeywell's Modbus document here:

http://hpsweb.honeywell.com/NR/rdonlyres/08BB18BC-23EF-4872-A0DB-DB2E6FB998D1/74345/51522566.pdf
(take out any space or spaces the forum inserts into the URL)

Floating point discussion (including byte order) runs pages 10-14

It isn't clear to me whether the byte ordering designation (4, 3, 2, 1) is Honeywell's designation or IEEE's (I don't have the IEEE paper). Bear that in mind because other vendors use different byte ordering designation (0, 1, 2, 3), so Honeywell's 4,3,2,1 FP order is Acromag's 0,1,2,3 order.

Many masters have a check box somewhere that enables picking one of the two common FP formats:

Floating Point Big Endian or Floating Point Little Endian with byte-swapped. Are you sure yours doesn't?
 
D

Darrin Hansen

ICC makes several of these "intermedate devices" (depending on whether it is an all-RTU/RS-485 network or Modbus/TCP linked to RTU/RS-485). A variety of Enron/Daniel type interpretation options are available on the both the master and slave drivers, as well as the ability to control word order and data endianess. There is also the ability to automatically scale values to convert between (for example) 32-bit floating point values received in word-swap format to standard 16-bit integer values.

XLTR-1000 (for RS-485 to RS-485): http://iccdesigns.com/Merchant2/merchant.mv?Screen=PROD&Store_Code=ICC&Product_Code=xltr1000

ETH-1000 (for RS-485 to/from Ethernet): http://iccdesigns.com/Merchant2/merchant.mv?Screen=PROD&Store_Code=ICC&Product_Code=eth1000

Darrin
 
S

Sebastián Ramírez

Thanks for such a comprehensive and useful answer.

So, there doesn't seems to exist a "Standard" way to handle 32bit Floating Point values in Modbus. Instead, manufacturers use theyr own interpretation of the standard.
 
L

Lynn August Linse

As mentioned, there is NO Modbus standard for 32-bit values. Only 1-bit and 16-bit.

Modicon's first PLC to move 'floats' was based on the 386SX processor (little-endian), thus the Modbus layer just did byte-swapping but NOT word swapping. So you see the float as BA-DC, not the expected BE form of DC-BA.

Some third-party vendors copied Modicon, while other assumed since Modbus is 'big-endian', that 32-bit floats should be true BE as well.

You can find devices which convert (someone above claimed such a device). However, most commercial master/OPC/host products can handle either by user configuration. Some slave devices also allow user configuration - sometimes calling it "Modicon Compatibility Mode".

If you are creating your own master/host software, just add a setting to allow your code to work with either style of float because you will see the 2 different forms 'forever'.
 
Top