question on Modbus Holding register and input register data type

G

Thread Starter

Giri

Hi,
I am working on Modbus RTU and ASCII master device implementation. My understanding is that in Modbus protocol Holding register and input register uses 2 bytes for each register is this Modbus standard that every Holding register and input register should use only 2 bytes.

is there any possibility of devices using different sizes (1, 3, 4 etc… bytes) for the Holding register and input register.

another question is Modbus data in Holding register and input register read response will be always in big endian format only...
 
This answer involves Modbus RTU only

source: Modbus-IDA December 28, 2006 http://www.Modbus-IDA.org 1/51
MODBUS APPLICATION PROTOCOL SPECIFICATION V1.1b

page 15:
6.3 03 (0x03) Read Holding Registers
The register data in the response message are packed as two bytes per register, with the binary contents right justified within each byte. For each register, the first byte contains the high order bits and the second contains the low order bits.

page 16:
6.4 04 (0x04) Read Input Registers
The register data in the response message are packed as two bytes per register, with the binary contents right justified within each byte. For each register, the first byte contains the high order bits and the second contains the low order bits.
-----------------

2) 4.2 Data Encoding
• MODBUS uses a ‘big-Endian’ representation for addresses and data items. This means
that when a numerical quantity larger than a single byte is transmitted, the most
significant byte is sent first. So for example
Register size value
16 - bits 0x1234 the first byte sent is 0x12 then 0x34

Until I searched for it, I was unaware that the Spec addressed format (data encoding). To my recollection, the original big vs little endian situation was due to some difference in Motorola vs Intel peripheral IC's, but I could be mistaken. Neither is showstopper nowadays.

Having something other than 2 bytes per register is a show stopper.

The spec says two bytes per register.

Use as many bytes per register as you want, but don't call it Modbus.

Issac
 
M

Michael Griffin

If you use a register size of other than 2 bytes, it isn't Modbus. Any standard Modbus slave your master tries to talk with won't understand the protocol. However, there are a few non-standard implementations such as Enron Modbus, that have 4 byte registers in addition to 2 byte registers.

As for byte order, the spec is clear on what this should be. The problem arose because Intel designed their microprocessors backwards from nearly everyone else. It's not what is stored in the system's RAM that matters. It how it goes out on the wire that would affect anything else. Modbus uses what is also commonly called "network" order, because nearly all network protocols work this way.
 
F

Fred Loveless

A single register is defined as 2 bytes, signed or unsigned data. IEEE Floats an signed or unsigned 32 bit data will be 4 consecutive bytes or 2 register locations. For those devices that support Double precision floats (64 bit data) ther will be 8 bytes or 4 registers.

That is for true Modbus RTU or Enron Modbus RTU devices.

There are a large number of devices that say they are Modbus because the protocol they use started out as Modbus. These are really Modbus-like. Typically the designers of these devices have chosen to alter the normal Modbus protocol to fit it to the unique requirements of their devices.

Fred Loveless
Senior Application Engineer
Kepware Technologies
http://www.kepware.com
 
There is a modified Modbus specification designed by Enron Corporation that uses 32-bit registers for floating point numbers and 32-bit integers as well as 16-bit registers for 16-bit integers.

Since this specification also supports reading historical values and events that standard modicon modbus does not, it is still in use.

See www.simplymodbus.ca/Enron.htm for more information on Enron Modbus.
 
Top