Author Topic: Modbus registers and coils, how they work (is not a question).  (Read 1650 times)

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
For all of us who are not versed in Modbus, I received a bulletin from RTA Automation with this very practical description on how it's based, so I wanted to share it. Hope is useful for someone.

Quote
Registers and Coils

Coils are single bits. They can be ON (1), or they can be OFF (0). Some coils represent inputs, meaning they contain the status of some physical discrete input. Coils can also represent outputs, meaning that they hold the state of some physical discrete output signal.

Registers are 16-bit unsigned register data. They can have a value from 0 to 65535 (0 to FFFF hexadecimal). There is no representation for negative values, no representation for any values greater than 65535, and no representation for real data such as 200.125.

Applications can impose these representations on registers. For example, an application can treat two registers, the first containing 200 and the second containing 125, as 200.125. Any application can organize and treat register data in any way it may want, but there is no way for any other Modbus device to automatically know what that representation is. A Modbus application that reads registers from a Modbus slave device must have some prior knowledge of how particular registers are treated to process them correctly.

Registers are grouped into input registers and holding registers. Like input coils, input registers report the state of some external input as a value between 0 and 65535. The original intent of an input register was to reflect the value of some analog input. It is a digital representation of an analog signal like a voltage or a current. Most Modbus devices today are not I/O devices and input registers simply function identically to holding registers.

Holding registers were originally designed as temporary program storage for devices like Modbus controllers. Today, holding registers function as data storage for devices. Both Modbus registers and coils are addressed with the first register or coil as Address 0 and the last as Address 65535. That means that there can be up to 65535 (FFFF Hex) input registers, 65535 output registers, 65535 input coils and 65536 status coils, but most devices use far fewer. The typical address space notation used in Modbus follows:

0x is Status Coil Address Space from 00000 to 065535
1x is Input Coil Address Space from 10000 to 165535
3x is Input Register Address Space from 30000 to 365535
4x is Holding Register Address Space from 40000 to 465535

When you see a notation that some value is at Modbus register 40010, you know that the value is stored in a holding register at offset 11, the 11th value, in the holding register area of the device. When a Modbus device is designed, the designer makes a decision of not only how many registers or coils are needed, but also which address space to use (input coil, status coil, input register, holding register) and where in that address space to locate those values. That example points to one of the deficiencies of this data representation. There are no standards.

There is no way to communicate to the user of the device any metadata. If the value of register 40100 is a temperature, there is no standard way to communicate the meaning of register 40100 and how to interpret the data. The user has no information to know if a value of 1001 means 100.1 degrees or 10.01 degrees or 1001 degrees. There is no standard regarding device profiles. Another temperature controller may store its temperature at 40200 and use a completely different data interpretation. The Modbus data representation is simple and almost standards-free. That is both a blessing and a curse to those of us who still use Modbus daily.

« Last Edit: May 10, 2021, 02:34:41 PM by Noe »