IMDHMIControls LibraryShop main store

How-to

How to send Modbus FC06 from a Modicon M172 in Machine Expert HVAC 1.7

Industrial networks Published 8 min read By IMDHMI controls team

Short answer

Add the thermostat as a Generic Modbus device from the Catalog and define the setpoint write as an explicit function 06 command, because the ModbusCustomEditor template only accepts single-register writes. Capture the request on RS485 to confirm the function field carries 06, not 16, then read the register back before release.

On this page
  1. Why the setpoint write leaves as FC10
  2. Replacing the write with a Generic Modbus command
  3. Building the FC06 request for slave 17 and register 40002
  4. Reading the captured frame
  5. Register and encoding checks before the write
  6. Verifying the rebuild after the 1.4 to 1.7 migration
  7. Questions asked

A thermostat that accepts only single-register writes rejects the M172's setpoint transaction because it arrives as function 16 — 10 hex on the wire — instead of function 06, the write single register command. In EcoStruxure Machine Expert - HVAC 1.7 the fix is to add the thermostat as a Generic Modbus device from the Catalog and define the setpoint write itself as a command with function 06, because that catalog object lets you specify each Modbus command sent to the slave. Applications built in version 1.4 no longer compile in 1.7 anyway, since their write functions are gone, so the transaction has to be rebuilt around the Generic Modbus command regardless. Confirm the result on the wire: capture the request, check the function byte for 06, then read the register back.

Why the setpoint write leaves as FC10 #

Function 16 writes one or more 16-bit read/write objects in a single transaction and is one of the Modbus function codes documented for the M171 and M172 controllers. The write path this project inherited — a fixed multi-register transaction — emits exactly that, and a device whose command template implements only the single-register write for that register answers with a Modbus exception instead of applying the setpoint. The template in this case was produced with ModbusCustomEditor, and it accepts function 06 for the setpoint register.

The version matters as much as the function code. The write functions a 1.4 application called are no longer available in 1.7, so opening such a project ends in compilation errors. There is no old function call to retune: the transaction is rebuilt on the Generic Modbus catalog device, which is also the one place the function code can be chosen per command.

Replacing the write with a Generic Modbus command #

Work through these steps in order and stop at the first one that fails.

  1. Add the thermostat to the serial network as a Modbus slave. The software's operating guide documents right-clicking the RS485 item and using Add command, with dragging a Modbus slave from the Catalog window onto the RS485 item as the alternative; pick the Generic Modbus device.
  2. Enter the thermostat's slave address and the serial parameters the installed link already runs — baud rate, parity, stop bits — not a default.
  3. Add a command for the setpoint write and set its function to 06. Do not group the setpoint with adjacent registers: grouping is what turns the transaction into function 16.
  4. Enter the register as the zero-based protocol address, not the reference number printed in the map; the next section works the conversion.
  5. Map one application variable to the command's value and apply the register map's scaling and signedness to it before it reaches the command.
  6. Trigger the command on a change of the setpoint or as a one-shot, and gate the next request on the command's completion or error status.
  7. Build the application and confirm no reference to the removed 1.4 write functions survives in the compiler output.
  8. Capture one request on the RS485 link and check the function byte for 06 before trusting anything else.
  9. Read the register back and compare values before the write is released to operation.

Building the FC06 request for slave 17 and register 40002 #

This example builds the request byte by byte so the capture in the next section has something exact to compare against. The slave address and register come from the standard documented FC06 example message — slave 17, holding register #40002 — not from the thermostat's own map; substitute the register and address your map gives.

The inputs: slave address 17; register reference #40002; an example setpoint of 21.50 °C carried as 2150 counts with two implied decimal places, a scaling convention the register map must confirm rather than assume; function 06; and the CRC-16, appended low byte first.

The rule in words: an FC06 request is eight bytes — slave address, function, register address as two bytes, value as two bytes, CRC as two bytes — and holding-register reference numbers convert to protocol addresses by subtracting 40001.

The arithmetic: 40002 - 40001 = 1, so the register address field carries 0001 hex. Slave 17 decimal is 11 hex. The value divides as 2150 / 256 = 8 remainder 102, and 102 is 66 hex, so the value field carries 08 66. The length checks out: 1 + 1 + 2 + 2 + 2 = 8 bytes. Running the CRC-16 over those six data bytes gives 705D, sent low byte first.

Byte(s) On the wire Meaning
1 11 slave address 17
2 06 function 06, write single register
3–4 00 01 register address, reference #40002 minus 40001
5–6 08 66 value 2150 counts, 21.50 °C at two implied decimals
7–8 5D 70 CRC-16, low byte first

The result is the eight-byte request 11 06 00 01 08 66 5D 70, whose second byte identifies the transaction as a single-register write. The decision follows from that byte alone: a captured 06 is the write the template accepts; a 10 means the multiple-register transaction is still on the wire and the thermostat will refuse it — fix the command definition before chasing addresses or scaling. A request longer than eight bytes means the value field carries more than one register, which is function 16 by construction.

Reading the captured frame #

An application variable changing value proves only that the program ran; it proves nothing about which frame left the port. Put a Modbus RTU monitor on the RS485 link, or use the communication diagnostics the software provides, trigger one write, and compare the captured bytes against the reference frame above.

Captured request What it means Next step
11 06 ... answered by a normal echo function 06 accepted at transport level read the register back and compare values
11 10 ... function 16 still on the wire; the Generic Modbus command is not in the executing path rebuild the transaction with the steps above
11 06 sent, 11 86 ... returned transport works but the thermostat refuses the write itself check the register's write permission and the thermostat's operating mode
no response at all the frame is not reaching a listening slave check wiring, termination and the slave address before touching logic

A valid response to a single-register write echoes the slave address, function, register address and value that were sent. The echo establishes that the frame was accepted; it does not establish that the thermostat's active setpoint now uses the value, which is what the readback step is for.

Register and encoding checks before the write #

A correct function code cannot rescue a wrong register. Work these checks in commissioning order and stop at the first mismatch:

  • Read the model off the thermostat's label. The project described here targets a TC903 in the SpaceLogic TC900 family, and the register map must be the one for the label on the device, because a display setpoint, an internal control setpoint and a network setpoint can be separate objects even when they show similar values.
  • Confirm the register is a writable holding register in that map, and enter the zero-based protocol address: documentation prints a 40000-series reference while the frame carries the protocol address, and being one off is the same off-by-one that makes a Modbus TCP coil write land one address off the map.
  • Take scaling, signedness and the permitted range from the map and range-check the value in the PLC before the command sends it; a correctly encoded but out-of-range value can still be refused at the device.
  • Match the link: the M172's RS485 port settings and the slave address must match what the thermostat expects. A request that draws no answer is usually aimed at nobody — the failure behind frames that go to slave address 0 instead of your device.

If the capture already shows function 06 with a matching echo, stop checking the link; the remaining fault lives in register identity, scaling or mode, and piling application logic on top of a wrong register only buries it.

Verifying the rebuild after the 1.4 to 1.7 migration #

Record what the old write did before deleting it: source value, trigger condition, target register, scaling, completion handling and retry behavior. Recreate those requirements around the Generic Modbus command instead of hunting for a replacement for the removed function calls — the compilation error in 1.7 is the interface change, not a thermostat fault. Keep the requested setpoint separate from the confirmed setpoint and update the confirmed one only after a successful response and readback.

One safety note: a setpoint write drives plant equipment, so range-check the value before transmission and keep the authority to put the thermostat into its local mode at the panel, so a failed Modbus link never leaves the loop chasing a setpoint nobody on the floor can correct.

A clean compilation proves only that the new interface is valid. The acceptance tests for this migration are the captured frame with 06 in the function field and a readback that matches the value sent. If the same RS485 link also carries polled reads, a write triggered every scan competes with them for the wire, and the trigger discipline described in speeding up Modbus RTU writes behind polled reads is the pattern to copy.

Questions asked

What does the thermostat send back when it rejects the write?

A Modbus slave that refuses a request answers with an exception response instead of a normal echo. For a rejected single-register write the function field returns as 86 hex, which is function 06 with the most significant bit set, followed by an exception code: 01 for an illegal function, 02 for an illegal data address and 03 for an illegal data value. The code 86 01 means the device still does not accept that function in its present mode; 02 or 03 points at the register address, the value or the permitted range.

How do I prove the setpoint actually took effect?

A valid response proves the thermostat accepted the frame, not that the new setpoint is in force. Read the same register back with function 03, read holding registers, from the protocol address the write used, and compare the returned counts with the value you sent once both sides use the map's scaling. When the readback matches and the thermostat's active setpoint follows it, file the capture and the readback together as the acceptance evidence for the migration.

Does the application have to calculate the CRC?

No. The Modbus RTU driver computes the CRC-16 over the address, function, register address and value bytes and appends it low byte first, so the Generic Modbus editor only asks for the slave address, the function, the register and the value. The CRC still matters when you read a capture: if the last two bytes of a sniffed frame do not match the CRC-16 of the bytes before them, noise or a framing problem is corrupting the exchange and the slave will discard the request silently.

Can the Generic Modbus command execute on every scan?

Technically yes, but it should not. Every write occupies the RS485 link for the request and its response, so a command executed every scan competes with polled reads and slows every slave on the network. Trigger it on a change of the setpoint or as a one-shot, and use the command's done or error status as the condition that allows the next request.

Keep reading

  • Troubleshooting

    Why S7-1200 V4.1 MB_SERVER rejects single-register writes with 8383

    With firmware V4.1, MB_SERVER accepts a client write only when the request covers the whole MB_HOLD_REG block, so a one-register write returns Modbus exception 02 and STATUS 16#8383 while reads keep working. Declare MB_HOLD_REG as an Array of Word instead of a STRUCT, set MB_DATA_LEN to the register count, and single-register writes pass; firmware V4.2 or later also corrects the behavior.

    Industrial networks

  • Explainer

    Can a Modbus write change PLC outputs?

    Yes, but not by outrunning the scan. On a Modicon CPU the communication interface reaches data memory only between scans, so a write is applied whole and the next scan either consumes it or overwrites it. The real exposure is that Modbus TCP authenticates nothing: any host that can reach the CPU can write an unprotected holding register your logic unpacks into outputs, so pack status into read-only words, keep commands in a separate writable range, and enforce write protection with an IP access control list.

    Industrial networks

  • Selection guide

    Choosing a Modbus RTU bridge for an iQ-R DCS migration

    Keep the DCS-facing Modbus RTU slave register contract frozen and bridge it with hardware that exists today: a retained Q-series PLC holding its QJ71MB91 link, or an external gateway that is CC-Link IE Field slave to the iQ-R side and Modbus RTU slave to the DCS. Do not schedule cutovers around an iQ-R native Modbus RTU slave module with no committed release date, and leave the OPC UA module for the SCADA layer that replaces the DCS.

    Industrial networks