Skip to Content

← All functionalities

Bioreactor controlM-DuinoModbus RTUControl

Controlling thermoelectric chillers over Modbus RTU

Holding a bioreactor at a precise temperature means commanding its chiller reliably. This example, from a real bioreactor control deployment, shows Modbus RTU chiller control with an M-Duino PLC over RS485. It writes start/stop, enables cold or heat, and sends a temperature setpoint scaled by ten, all with the small datasheet delays these units need to consolidate each command. Two chillers sit on the same 9600 8N1 bus at addresses 1 and 2.

Four registers run the chiller

Everything is single-register writes (function 0x06): 0x06 is start/stop, 0x08 enables cooling, 0x09 enables heating, and 0x0A holds the temperature setpoint multiplied by ten, so 18.5 C becomes 185. Keeping cold and heat mutually exclusive avoids the unit fighting itself when the process swings around the target.

Respecting the datasheet timing

Thermoelectric chillers need a short pause to latch each command. The helper writes the register, confirms a clean Modbus response, then waits about 500 ms before the next mando. It is tempting to skip this, but back-to-back writes can be silently dropped, leaving the chiller in an unexpected state.

Defensive setpoint refresh

Every ten seconds the loop rewrites the setpoint. If a chiller power-cycles or drops a frame, it converges back to the intended temperature without operator action. This idempotent refresh pattern is cheap on a quiet RS485 bus and turns transient comms glitches into non-events.

A snippet from the implementation

Straight from the example as deployed on the M-Duino — copy it freely:

void setup() {
  Serial.begin(115200);
  master.begin(9600);
  master.setTimeout(300);

  // Example startup: chiller 1 in cooling mode at 18.5 C
  startChiller(CHILLER[0], 1);
  setMode(CHILLER[0], true, false);     // cooling ON, heating OFF
  setSetpoint(CHILLER[0], 185);         // 18.5 C x10
}

The full example is a complete program — wiring header, setup and main loop — ready to adapt to your application.

Frequently asked questions

Why is the setpoint multiplied by ten?

The chiller stores temperature in tenths of a degree as an integer register, so 18.5 C is sent as 185. The PLC scales it on write and back on read.

Can I control both chillers from the same M-Duino?

Yes. Both share the RS485 bus at addresses 1 and 2; you call the same helpers with the other address. In the plant this is orchestrated by the Modbus TCP to RTU gateway module.

Why the 500 ms delay after each write?

It is a datasheet requirement. The chiller needs time to consolidate a command before accepting the next one, so the helper waits before issuing another mando.

Related functionalities