How-to
Driving a WAGO 750-653 Modbus RTU module from CODESYS
Short answer
On a CODESYS Control Win V3 soft PLC, WagoAppPlcModbus cannot reach a 750-653 behind a 750-354 EtherCAT coupler, because those blocks need WAGO controller firmware. Drive the module's raw process image yourself: set the serial parameters, move each fragment with the control/status byte toggle handshake, and frame the Modbus RTU request and response in your task. Each fragment costs at least two task cycles, so a full transaction takes ten cycles or more.
On this page
WagoAppPlcModbus cannot drive a 750-653 serial module from CODESYS Control Win V3: its blocks reach a serial module through WAGO controller firmware and a local module bus, and a Windows soft PLC has neither. The working route on your hardware — a soft PLC plus a 750-354 EtherCAT coupler — is to drop the WAGO application libraries, map the 750-653's raw process image, and write a small driver that splits each Modbus RTU request into the module's payload width, toggles the control byte for every fragment, and reassembles the response inside the task. The module is a transparent byte pipe, so framing and CRC are yours. Below: why the library stops, how to map and configure the module, the handshake code, and the timing arithmetic that sets your polling rate.
Why the WAGO library stops at the first hop #
WagoAppPlcModbus and the WagoSysFieldbus layer under it are written for WAGO controllers: the function block resolves a serial module by its position on the controller's own module bus and lets the controller firmware move the bytes. On a soft PLC the block either reports the module missing or never raises a transmit request, so nothing reaches the EtherCAT master and an RS-485 line probe stays silent.
| Hop | Carries | Failure signature | Where to look |
|---|---|---|---|
| Task to WagoAppPlcModbus block | Modbus PDU as block inputs | Block busy or in error, no bus traffic | Block status output, output image |
| EtherCAT master to 750-354 | Cyclic PDO frame | Slave not in OP, working-counter fault | Master diagnostics, slave state |
| 750-354 via K-bus to 750-653 | Process-image bytes | Byte count or offset wrong | I/O mapping tab versus module order |
| 750-653 to RS-485 | Serial characters | No edges on the pair | Scope across the line |
Decision: remove both libraries from the project and drive the process image directly. If this machine could instead run on a WAGO controller, WagoAppPlcModbus is the supported home for this module and the driver work disappears — on the soft PLC that route does not exist.
Map the 750-653 through the EtherCAT coupler #
Install the WAGO ESI device description for the 750-354 and its modules in the CODESYS device repository, then scan the bus instead of typing the node by hand. A scan reads the actual module list and kills hand-typed offset errors. The 653 appears as a complex module: a few user-data bytes in each direction, plus one control byte you write and one status byte you read.
The payload width is a configured property on this module family, not a constant — the sibling 750-652 serial module documents an adjustable process image of 12, 24 or 48 bytes. Read the 653's width from its hardware manual, then confirm it against the bytes shown in the I/O mapping tab. If the tab shows fewer bytes than the manual, the module is in a different operating mode than you assumed. Digital modules and complex modules are grouped differently in the 750 process image, so adding or removing any card upstream of the 653 shifts everything after it; rescan after every hardware change. The same byte widths decide the connection when this I/O sits behind a different master, which is the subject of sizing a Generic Ethernet Module connection for WAGO 750 I/O.
Check: with the slave in OP, write a non-zero pattern to the output data bytes while the control byte stays at zero. Nothing should leave on the wire, and the status byte must read stable and non-zero. A status byte pinned at 0 with no request in flight points at the K-bus or the mapping, not at your logic — and trust the slave state over any single flag, the lesson of why a CODESYS EtherCAT master xError stays false on a cable pull.
Capture the working RS-485 setup first #
The USB adapter that reads the sensors today is your reference. Record its baud rate, data bits, parity, stop bits, slave addresses, function codes and register numbers, and leave it connected until the new path answers. Note the polarity convention the adapter uses: A/B labels differ between vendors, and a swapped pair is a dead line with no error bit anywhere. Carry the signal common, because two-wire RS-485 still needs a reference when sensors on separate supplies sit at the far end of a greenhouse.
Fit 120 Ω termination at the two physical ends of one linear segment only, never at intermediate drops; star wiring and long stubs that survive at 9600 baud fail as soon as you raise the rate. One safety note: the module terminals are powered from the I/O system, so isolate the segment and any separately fed sensors before you touch the pair.
Check: with the adapter still connected, poll each sensor once and log the response bytes. After you move the pair to the 750-653, the line should idle quiet — continuous activity means a driver is stuck on.
Set the serial parameters in the module #
The 653 has no DIP switches: its serial parameters live in module registers and persist across power cycles. Set them with WAGO-I/O-CHECK over the coupler's service interface for commissioning, or through register writes sequenced by the control byte when settings must change at runtime. Match the sensors exactly. A parity mismatch is the classic silent killer: perfect edges on the scope, characters received, a framing or parity error flagged in the status byte, and nothing usable delivered. Read the configuration back after writing it.
Write the fragment handshake #
The module moves only a few user-data bytes per process-image update, so a request longer than the payload width is split into fragments, each confirmed by a toggle handshake between the control byte you write and the status byte you read. Take the bit positions for the length field, transmit request, transmit acknowledge, receive request and receive acknowledge from the control/status byte table in the 750-653 hardware manual — do not guess them. The variable names below are mine; the masks come from that table.
- Build the request in a byte buffer and append the CRC-16.
- Split the buffer into fragments of the mapped payload width.
- Present a fragment: copy its bytes to the module's output data, write the length field, toggle the transmit-request bit.
- On a later cycle the status byte's transmit-acknowledge bit equals your toggle; only then present the next fragment. That is two task cycles per fragment, minimum.
- Receive fragments as they appear in the input data with the receive-request bit set; toggle the receive-acknowledge bit to release each one and append its bytes to the response buffer.
- Stop at the expected response length, verify the CRC-16, then move the register values, big-endian, into application variables.
VAR
abyTx : ARRAY[0..15] OF BYTE; (* request incl. CRC, illustrative *)
usiWidth : USINT := 4; (* payload width, from the mapping tab *)
usiFrag : USINT := 0; (* fragment index *)
usiFragLen : USINT := 4; (* bytes in this fragment *)
xTxToggle : BOOL := FALSE;
uiAckCount : UINT := 0;
END_VAR
(* abyOutData, byControl, byStatus: mapped module bytes, names illustrative.
byMASK_LEN, byMASK_TX_REQ, byMASK_TX_ACK: BYTE constants from the
control/status byte table in the 750-653 manual. *)
// present fragment usiFrag
FOR usiI : USINT := 0 TO usiWidth - 1 DO
abyOutData[usiI] := abyTx[usiFrag * usiWidth + usiI];
END_FOR
byControl := usiFragLen; // length field encoded per the manual
IF xTxToggle THEN
byControl := byControl OR byMASK_TX_REQ;
END_IF
xTxToggle := NOT xTxToggle;
// test, run with the RS-485 pair disconnected
IF ((byStatus AND byMASK_TX_ACK) <> 0) = xTxToggle THEN
uiAckCount := uiAckCount + 1;
END_IF
// uiAckCount must rise by exactly 1 per fragment while the pair stays idle
Run the driver in a dedicated cyclic task, with the EtherCAT bus task at least that fast so every task cycle sees fresh process data.
Frame the response by length, not by silence #
The module transports bytes and has no notion of Modbus. Fragments are paced by the bus cycle, so by the time your task sees them the original character spacing is destroyed and gap detection cannot work. Frame instead by expected length: a read of N registers with function 03 or 04 returns 5 + 2N bytes — address, function code, byte count, 2N data bytes, CRC. Verify the CRC-16 before using any of it; on failure, discard the buffer and retry in the next polling slot, counting retries so a dead sensor becomes visible instead of silent.
Worked example and polling rate #
One temperature read at 9600 baud, 8N1, two registers:
- Request: address 1 byte + function 1 byte + start address 2 bytes + quantity 2 bytes + CRC 2 bytes = 8 bytes.
- Response: address 1 byte + function 1 byte + byte count 1 byte + data 4 bytes + CRC 2 bytes = 9 bytes.
- Wire time at 10 bits per character: 80 bits ÷ 9600 bit/s = 8.3 ms out, 90 bits ÷ 9600 bit/s = 9.4 ms back, plus two 3.5-character silent intervals of about 7.3 ms — roughly 25 ms on the pair.
- Handshake: with a 4-byte payload width the request is ceil(8 ÷ 4) = 2 fragments and the response is ceil(9 ÷ 4) = 3 fragments; 5 fragments × 2 cycles = 10 task cycles = 100 ms at a 10 ms task.
The handshake, not the wire, sets the rate: 100 ms against 25 ms. Decisions: run a dedicated task at 5 to 10 ms, expect one transaction per 125 ms — eight per second — and count on four sensors round-robin completing a scan in about half a second, ample for greenhouse temperature and wind. The task-cycle arithmetic rather than the baud rate is also why Modbus RTU drive polling on one serial port comes out slow. When one sensor's response bytes match the adapter's logged bytes and the CRC passes, retire the adapter.
Questions asked
Will WagoAppPlcModbus work if I just copy the library files into the project?
No. The blocks compile against a WAGO controller's firmware and resolve modules by their position on that controller's local bus. On CODESYS Control Win V3 the calls have nothing to answer, so the block stays busy or errors without producing bus traffic. No amount of reinstalling changes that; the driver has to talk to the process image instead.
Can the CODESYS Modbus library replace the driver?
Not by itself. Those library parts expect a serial interface on the runtime, and the 750-653 is an I/O module behind an EtherCAT coupler, not a COM port. Use the CODESYS Modbus library where you want ready-made PDU building and CRC handling, then feed those bytes to your own fragment pump. The wire side stays yours either way.
How many sensors can I poll per second through the 750-653?
With a 10 ms task and a 4-byte payload width, one read of two registers costs at least ten task cycles, about 100 ms, plus roughly 25 ms of wire time at 9600 baud. That is about eight transactions per second. Four sensors polled round-robin complete a scan in roughly half a second, which is ample for greenhouse temperature and wind readings.
Does the module handle the Modbus CRC for me?
No. The module transports bytes and knows nothing about Modbus. Append the CRC-16 to every request before fragmenting, and verify it on every reassembled response before trusting register values. A response that fails the check is discarded and retried in the next polling slot, with a bounded retry count that flags the sensor offline instead of failing silently.