Overview

Modbus register addressing can be confusing because of a Modbus specification and a common convention. This article tries to explain these and provide some examples.

Zero vs. One Based Numbering

The Modbus specification says “Registers are addressed starting at zero. Therefore input registers numbered 1-16 are addressed as 0-15.” Unfortunately, that means a register documented with an address of 1221 (Frequency) must be requested by sending an address of 1220 (04C4 hex) to the WattNode. Most application software will automatically handle this subtraction, but if you are writing your own code or watching raw packet bytes, you need to be aware of this offset by one.

Function Code Prefix

It is a common convention (but not mentioned in the specifications) to describe a register address with a leading digit to indicate the Modbus function code required to access the register. This results in a format like the following:

XNNNN

Where “X” is one of the following Modbus function codes:

  • 1 – Read coils (not used in the WattNode)
  • 2 – Read discrete inputs (not used in the WattNode)
  • 3 – Read holding registers (the WattNode treats holding and input registers are interchangeable)
  • 4 – Read input registers

And where “NNNN” is the register number and may range from 1 to 9999 (these will become 0 to 9998 when converted to Modbus register addresses).

Early versions of the WattNode Modbus manual followed this convention, but this resulted in significant confusion, so we changed our manual to eliminate the leading Modbus function code, since all of the WattNode registers may be read with either function code 03 or 04.

For example, if you see a Modbus register number 41221 (Frequency), this is really register number 1221 and should be accessed using the Modbus function 04 “Read Input Registers”.

In general, never enter a five digit number starting with “4” as a register number or register address. The WattNode register numbers range from 1001 to 1723.

Raw Packet

When converted to a Modbus packet and sent to the WattNode, the command to request the integer frequency register (1221) will look like:

01 04 04 C4 00 01 71 07

These hex bytes have the following meanings:

  • 01 – WattNode address (set with DIP switches)
  • 04 – Read input registers
  • 04 C4 – Register address: 1220, which corresponds to a register number of 1221 or 41221 with the leading “4”
  • 00 01 – Count of input registers to read: 1
  • 71 07 – CRC – cyclic redundancy check – used to check for communication noise

You should see a response like:

01 04 02 02 58 B9 AA

These hex bytes have the following meanings:

  • 01 – WattNode address
  • 04 – Read input registers
  • 02 – Byte count
  • 02 58 – Frequency: 0258 hex = 600 decimal = 60.0 Hz
  • B9 AA – CRC – cyclic redundancy check – used to check for communication noise