Tiza Group

Home / Guides / Testing, commissioning and faults

Modbus Relay That Locks Up When Writing a Value

A relay stops answering or rejects commands on Modbus writes: causes, exception codes, repeated writes and safe tests. We configure it remotely.

By Shadai García, CEO and protection engineer at Tiza Group.

Short answer

First determine what got stuck: only communication, writing that register or the whole device. A capture of request and response separates a rejection with an exception from silence. The usual causes are an unsupported register or value, a missing access level, multi-register data written in parts, cyclic writing and retries that repeat the command.

Symptom

A system writes a value to the relay over Modbus (a command, a setpoint, the time, a setting) and something stops: the device does not answer for seconds or until restarted, returns an error, ignores later commands or ends up in a restricted access state. Reads worked before the write, and that contrast is the first clue.

Write functions, data types and exceptions are described in Modbus register map and data types. Here the only subject is what to do when writing causes the problem.

Probable causes, from most to least likely

CauseHow to recognize itWhat confirms or rules it out
Register read-only, nonexistent or off by oneException 02 always at the same addressManufacturer’s map versus the address in the frame (zero-based)
Value out of range or wrong formatException 03, or the stored value differs from the one sentScale, sign, word order and limits in the manual
Missing unlock or access levelRejected although address and value are correctThe manual requires a password, a prior sequence or remote mode
Relay applies the change and goes awayShort silence after writing settings, then it returns by itselfEvent log with settings change or restart at the same time
Client retriesThe command appears twice or more; the device answers busyCapture with the same request repeated after the timeout
Cyclic writing to non-volatile memoryThe problem grows over months; memory alarmThe master writes the same register on every scan
Two clients writing at onceValues change on their ownSession log; removing one client makes it stop
Firmware or communication module defectOne specific request silences the module, always the same wayReproduces on a bench unit; manufacturer’s release notes

How to diagnose it

  1. Establish what got stuck. Look at the relay front: if it is healthy and protecting, the problem is communication. If it shows an internal alarm, restart or failure, treat it as a protection fault and tell operations.
  2. Capture the frame. Save the write request and the response. On a successful write with functions 05 or 06 the response echoes the request; with 16 it returns the starting address and the number of registers.
  3. Read the result. Exception 01: function not supported. 02: illegal address. 03: illegal data value in the request. 04: device failure while executing. 05: accepted, it will take a while. 06: busy. Silence: damaged frame, absent device or hung module.
  4. Check the quantity. Function 16 allows at most 123 registers per request according to the specification; a relay may allow fewer and its manual says so. In function 05 the only valid values are FF00 and 0000.
  5. Compare with a write the manufacturer documents. If a simple setpoint works and yours does not, the problem is that register or its sequence.
  6. Look at the frequency. Count how many times per hour the master writes each address.
  7. Reproduce it out of service. Any test that changes states or settings must be done on a bench or with the relay isolated and authorized.

Reading what happens afterward

The frame capture tells only half. Complete the picture with three reads, in this order. First, the relay event log: if a settings change, a device start or a failed access attempt appears at the time of the write, you know what the device did with the command. Second, a read of the same register a few seconds later: if it keeps the old value, the write was not applied even though the response was normal. Some devices require a separate command to confirm or save a change, and the manual states it. Third, a read of any other register: if it answers, the module is alive and only writing is blocked; if no client gets an answer, the problem is the port or the whole module.

Also note how long recovery takes and what caused it: on its own, on closing the connection, or only after removing power. A device that needs a restart after a well-formed request is a matter for the manufacturer.

Illustrative example

Made-up figures. A controller writes a setpoint every second to a register the relay keeps in non-volatile memory. That is 86,400 writes a day. If the memory were rated for one hundred thousand cycles, it would wear out in a little over a day; the real figure depends on the device and must come from the manual. The fix is to write only when the value changes and confirm by reading.

In another case the master waits 200 ms and the relay takes 800 ms to apply the change. The master assumes the command was lost and sends it three more times: the action may execute again or the device may answer busy. The fix is a longer timeout for writes and checking the state before retrying.

Field checklist

  • Relay healthy on the front panel, no internal alarm.
  • Request and response capture saved.
  • Frame address checked against the map (off by one).
  • Write function supported for that register.
  • Value within range, with correct scale and word order.
  • Access or prior sequence requirements met.
  • Master timeout and retry count reviewed.
  • Write frequency per register.
  • Only one client allowed to write.
  • Firmware version noted and compared with release notes.

What to do

  • Address, format or range: correct the map in the master and test again out of service.
  • Access: follow the documented sequence and do not leave the password written in logic or shared files.
  • Retries: write, wait as long as the device needs, read to confirm and only then decide.
  • Cyclic writing: change to write-on-change.
  • Several clients: leave one with control rights and the rest read-only.
  • Firmware: report the frame that reproduces the failure to the manufacturer and do not apply updates without a test plan.

What not to do

  • Do not repeat the write “to see if it goes through now” on an in-service relay.
  • Do not use a broadcast write (address zero on a serial bus) to test: it reaches everyone and nobody answers.
  • Do not restart the relay without coordinating: it does not protect while booting.
  • Do not write to undocumented registers or sweep writes to discover the map.
  • Do not expose Modbus to outside networks; the protocol does not authenticate the writer.

When to call us

If the relay rejects commands with no explanation, restarts on receiving them or several systems compete to write to it, we review map, sequence and master logic using your captures. We configure it remotely: send us the case.

References

  • Modbus Organization, MODBUS Application Protocol Specification V1.1b3: functions 05, 06 and 16 and exception codes.
  • Modbus Organization, MODBUS over Serial Line, Specification and Implementation Guide.
  • Relay manufacturer’s communication manual and register map.

Frequently asked questions

Can a Modbus write stop a relay from protecting?

It depends on the device. Some relays restart or are momentarily out of service when applying a settings change. Before writing to an in-service relay, confirm in its manual what each register does and coordinate with operations.

What does exception 06 in the response mean?

Code 06 says the device is busy processing a long command and the client should repeat the request later. Insisting immediately and without pause makes it worse.

Is it better to write with function 06 or 16?

Function 06 writes one register and 16 writes several in one request. A 32-bit value is best written whole with 16 if the device supports it, so it never reads one new half and one old half. The manufacturer's map always prevails.

WhatsApp