IMDHMIControls LibraryShop main store

Explainer

Modbus register bit addressing in a SCADA item reference

SCADA and data logging Published 5 min read

Short answer

A bit inside a holding register such as 40041 is not a Modbus protocol address: the standard moves the register as one 16-bit word. Use the driver's documented bit-reference syntax only when it states the format and the numbering; otherwise read the full register and derive each Boolean with an AND mask.

On this page
  1. What the Modbus protocol actually moves
  2. Why a bit reference is a driver feature, not a protocol rule
  3. Two numbering conventions, and which one to assume first
  4. Worked example: read the whole register and derive the bits
  5. Writing one bit without clobbering the other fifteen
  6. Verify the mapping before you trust the tags
  7. The decision for each case
  8. Questions asked

A tag points at Modbus holding register 40041 and other tags must show the individual field bits packed inside that word. The answer: the Modbus protocol has no address for a single bit of a holding register, because its read and write functions move the register as one 16-bit value. A per-bit reference exists only as a feature of the SCADA driver, and every driver defines its own separator and its own bit numbering. So the decision is this: use the driver's documented bit-reference form only when its documentation states the format and the numbering, and otherwise read the full register as an unsigned integer and derive each Boolean in the SCADA application with an AND mask. That method works on any driver and needs no guessing.

What the Modbus protocol actually moves #

The Modbus application protocol defines four data objects, and only two of them are bits. Function 01 reads coils and function 02 reads discrete inputs, one bit each; function 05 and function 15 write individual coils. Holding registers and input registers are 16-bit objects: function 03 reads holding registers, function 04 reads input registers, and function 06 or function 16 writes whole registers. The 4xxxxx address range names holding registers with read and write access, and 3xxxxx names input registers, which are read-only. There is no function code that addresses a chosen bit position inside a holding register, so every single-bit view of one is computed somewhere: either inside the SCADA driver or in code you write.

Whether the driver hands you that word as signed or unsigned changes which masks you use, so confirm the interpretation before you build expressions. Converting an unsigned 16-bit Modbus word to a signed integer walks through that decision.

Why a bit reference is a driver feature, not a protocol rule #

Because the protocol cannot express a bit of a word, SCADA drivers add their own convenience syntax so a Boolean tag can sit on one bit position. Each driver defines the format in its addressing documentation: some append the bit index after a separator, some expose a separate Boolean data type, and some support nothing at all. The forms are not interchangeable. Entering a reference you saw in another package, whether a space between the register and the bit, a period or a slash, without this driver's documentation is a guess. At best the driver rejects the item; at worst it parses the string into a different register or a malformed request, and the tag sits still while the link looks healthy. Open the addressing page for the exact driver and version in your project before you create any bit tag.

Two numbering conventions, and which one to assume first #

Even a documented bit reference leaves one question open: where the count begins. Zero-based numbering calls the least significant bit bit 0, worth 2 to the power 0, which is decimal 1. One-based numbering calls that same physical bit bit 1. Both conventions appear in real drivers, and picking the wrong one shifts every tag by a factor of two in the mask. Assume zero-based, least-significant-bit-first unless the documentation says otherwise, because it matches the AND-mask arithmetic directly, then confirm the choice with the test described further down.

Worked example: read the whole register and derive the bits #

Suppose 40041 reads 274 as an unsigned decimal value. In binary that is 0000 0001 0001 0010, and the set positions are those worth 256, 16 and 2, which are zero-based bits 8, 4 and 1, since 256 + 16 + 2 = 274. Derive each Boolean with a mask:

  • Bit 1 is TRUE when the word AND 2 is not zero: 274 AND 2 = 2, so TRUE.
  • Bit 4 is TRUE when the word AND 16 is not zero: 274 AND 16 = 16, so TRUE.
  • Bit 8 is TRUE when the word AND 256 is not zero: 274 AND 256 = 256, so TRUE.
  • Bit 0 is TRUE when the word AND 1 is not zero: 274 AND 1 = 0, so FALSE.

Every derived tag refreshes when the register read refreshes, so one polled item feeds all sixteen Booleans and the mask arithmetic costs the SCADA processor almost nothing.

Writing one bit without clobbering the other fifteen #

The read side is safe to compute, but the write side is where a bit reference can hurt you. A register write with function 06 or function 16 replaces all sixteen bits, so a SCADA command that sets one bit is really a read-modify-write of the whole word. If the PLC program or a second client writes that same register, the two writers race and one erases the other's bits. When you control the PLC program, either map those field bits to coils, which the protocol writes individually with function 05 or 15, or dedicate one word to SCADA-written bits and keep the PLC from writing it. The safe way to structure Modbus writes to PLC output registers from SCADA is a design step to settle before any live command goes out.

Verify the mapping before you trust the tags #

A connected link that reports no item errors proves nothing about which bit a tag selected. Force or operate one known field signal at a time, watch which Boolean tag changes, and compare that tag's state with the word value shown on a test screen. Do this for every bit tag you built, including the ones derived from masks, because a wrong constant in one mask fails exactly like a wrong driver syntax. When a mapping is confirmed, write it down: the register, the convention and the mask decimal for each bit. The broader verification approach for a SCADA installation is covered in What a SCADA system does and how to verify it works.

The decision for each case #

Case Decision
The driver documents the bit-reference syntax and the numbering Use the documented form, verify the mapping once on the bench, and keep the register and convention in the project notes
The documentation is silent or the syntax is unconfirmed Read the full register as an unsigned word and derive each Boolean with an AND mask in the application
SCADA must write individual field bits often Map those bits to coils or dedicate one word to SCADA writes; never bit-pack a register the PLC also writes

The word-and-mask route is the default because it depends on nothing the driver documentation can contradict. The driver's own bit syntax is an optimization you adopt after its documentation and one bench test agree with each other.

Questions asked

How do I test whether a driver counts register bits from 0 or from 1?

Put a test value with only the lowest bit set, decimal 1, into a spare register, or force that one field signal. If your tag built for bit 0 and a candidate tag built for bit 1 both target the same physical lowest bit, only one of the two mappings will match the observed value. Decimal 1 tests the lowest position and decimal 2 tests the next one.

Why do two SCADA packages label the same holding register differently?

Entry conventions differ between drivers: some count registers from 0 and some from 1, and some expand the leading 4 into six digits. The same physical register can therefore be entered as 40040 in one package and 40041 in another. Check the addressing page for each driver instead of copying the string between projects.

Can I read the word once and use one tag for all sixteen bits?

Yes. Expose the register as one integer tag and derive the Booleans in expressions or scripts. Every derived bit then refreshes together at the register poll rate, and the link carries one item instead of sixteen, which also keeps the mask arithmetic in one place where you can audit it.

Keep reading

  • Troubleshooting

    Fixing junk Modbus TCP REAL writes from Citect SCADA

    The junk is the two 16-bit halves of your 32-bit REAL, assembled in the wrong order. Give each REAL two consecutive holding registers and set the [MODNET]FloatMode parameter - values 0 to 3, default 0, byte order 1 0 3 2 - until the PLC reads back the entered value. The address is usually right; ModScan already matched the PLC arrangement.

    SCADA and data logging

  • Troubleshooting

    Why Ignition Modbus TCP tags read a Click PLC wrong

    Ignition rejects the Click DF addresses because the 4- holding-register prefix is parsed as part of the register number; strip it and the tags create. Set the device to zero-based addressing under Show advanced properties when the values land one register off. DF floats occupy two registers each, so the map steps by 2; change word order only if floats stay wrong.

    SCADA and data logging

  • Troubleshooting

    Why a Modicon M221 bit stays fixed in Kepware over Modbus TCP

    A Modbus TCP tag at 00001 that never changes usually reads the wrong Modbus object, not a broken link. The M221 does not expose its %I inputs to a read request, so match the controller's documented coil mapping, then correct Kepware's zero-based addressing option before blaming the network.

    SCADA and data logging