How-to
How to run analog I/O over a Modbus TCP bus coupler
Short answer
Yes: remote analog I/O behind a Modbus TCP bus coupler can close a control loop from the PLC. Prove the electrical path with the network out of the loop, bring up the connection with a real timeout, map and scale the channels against known test points, then close the loop on measured timing — one documented integration refreshes coupler data every 10 ms, but the valve and hydraulics set the real response, and a failed exchange is a fault state, never fresh data.
On this page
- Pass these four gates in order
- First gate: prove the analog path with the network out of the loop
- Second gate: bring up the Modbus TCP connection
- Third gate: map the registers and scale both channels
- Worked example: scaling a voltage torque channel read as 16-bit counts
- Fourth gate: close the loop on measured timing
- Make a lost exchange a fault, never fresh data
- Log the torque data from a machine in the cabinet
- The four gates, decided
- Questions asked
Yes. Remote analog input and output channels behind an Ethernet bus coupler can close a control loop straight from the PLC: the coupler serves its I/O image as Modbus registers and accepts writes to the output channels. Make it hold up by commissioning through four gates: prove the electrical signal path with the network out of the loop, bring up the Modbus TCP connection with a real timeout, map and scale both channels against known test points, then close the loop on measured timing. One rule runs through all of it: a failed or stale exchange is a fault state, never fresh data. The running case is a hydraulic tightening station, with a torque sensor into a four-channel voltage input module (the S20-AI-4-U), a voltage command out to a proportional pressure-reducing valve (the S20-AO-4-U), both behind an S20-ETH-BK coupler.
Pass these four gates in order #
Work the gates in sequence, and do not advance on a green light from the gate above alone:
- Electrical path. With hydraulic motion inhibited, measure the sensor at the input terminals and the command voltage at the output terminals; ranges, references and module selection must match the wiring.
- Connection. Reach the coupler, open the Modbus TCP exchange from the PLC client, and set the client timeout from a measured round trip.
- Map and scale. Fix the register map from the installed module order, then prove both channels at two test points each.
- Loop and fault reaction. Measure request-to-response delay, tune only after that, and make any lost or stale exchange trip a defined fault state.
The coupler builds its process image from the modules it detects, in the order they sit on the rail, so the module order you wire is the map you get. The coupler manual defines the exact process-data mapping and its size limit; size the connection the same way you would size a Generic Ethernet Module connection for WAGO 750 I/O.
First gate: prove the analog path with the network out of the loop #
| Path element | Establish before networking | Pass check |
|---|---|---|
| Torque sensor to input module | Sensor supply, voltage range, signal reference, channel selection | Terminal voltage tracks known torque points |
| Output module to valve | Output range equal to the valve's full-scale command input; reference and load wiring | Terminal voltage follows a bounded test command |
| Modules to coupler | Module order, station power | Coupler diagnostics show every installed module healthy |
- Mount the modules in the planned order and power the station per its installation instructions.
- With hydraulic motion inhibited, measure the sensor at the input terminals and compare against the torque the sensor certificate predicts.
- Command a small bounded voltage from the output channel and measure at the valve terminals with the pump unloaded.
- Advance when both measured signals match the configured ranges and the coupler reports healthy local modules.
One safety note, and it belongs here: a live analog output command moves real hydraulic pressure the instant that channel goes live, so keep motion inhibited and the pump unloaded until the bounded output tests of the third gate pass.
Second gate: bring up the Modbus TCP connection #
The PLC is the client and the coupler is the server. It listens on the standard Modbus TCP port, 502, unless its manual says otherwise, and reachability alone proves nothing about the data behind it.
- Assign the coupler's IP address from the machine's network plan and confirm link and switch status.
- Open the Modbus TCP connection from the PLC client. If you can reach the coupler but the connection fails, look at the service port and anything filtering between the two.
- Measure the round trip: read one register twenty times and keep the worst exchange. On a clean switched network that lands in the low single-digit milliseconds, so set the client's response timeout to about ten times the worst round trip and confirm it stays below the loop period you plan to run.
- Advance when successful exchanges repeat continuously and pulling the Ethernet cable changes the client's health state within one timeout period.
That last check is the one engineers skip, and it is the difference between a timeout that works and a default that never fires.
Third gate: map the registers and scale both channels #
Module order already fixed the map; now read it. The manual tells you which function codes carry the analog image, code 03 or 04 for reads and 06 or 16 for writes, and where each channel sits in it. Analog channels on couplers of this class occupy a 16-bit word each; load-cell class channels occupy two registers as one 32-bit value, which adds word order across the pair to signedness and byte order as the mismatches that produce plausible-looking garbage.
Scale each channel with one line:
engineering value = engineering minimum + (raw - raw minimum) x (engineering maximum - engineering minimum) / (raw maximum - raw minimum)
Take the raw endpoints from the module's documented representation and the engineering endpoints from the sensor certificate; a voltmeter reading does not calibrate a torque channel. Clamp every output write to the configured span before it leaves the PLC, because a write to this register moves a physical device, as can a Modbus write change PLC outputs explains.
Advance when two known input points produce correct engineering values and a bounded output command measures correct at the valve terminals. The same one-line scaling, worked in ladder, is in scaling a 4-20 mA analog input to engineering units in CPM2 ladder.
Worked example: scaling a voltage torque channel read as 16-bit counts #
Inputs. The channel span is 0-10 V, the running case's input module range, and this is the span used throughout the arithmetic below. The raw representation is an unsigned 16-bit word with 0 counts at the span bottom and 32767 counts at full scale, the map this example uses; a module manual may instead document a 12-bit channel, 0-4095 over the same span, which resolves 10 V / 4095 = 2.44 mV per count. Both endpoint sets come from the module documentation, not from the Modbus standard. The test point is 5.000 V injected at the input terminal from a bench supply.
Rule. Counts per volt = raw span / voltage span, so reading in volts = raw counts divided by 32767, multiplied by the span.
Arithmetic.
- Resolution: 10 V / 32767 counts = 0.000305 V per count, about 0.31 mV.
- Inject 5.000 V, exactly half the span: expected raw = 5.000 V / 10 V x 32767 counts = 16383.5 counts, so the coupler returns 16383 or 16384.
- Reading back 16384: 16384 counts / 32767 counts x the span = 5.0002 V. The PLC displays 5.000 V against the meter's 5.000 V.
- The same 5.000 V into a 12-bit channel returns 5.000 V / 10 V x 4095 counts = 2047.5, so 2048 counts. Read that through the 16-bit map instead and you get 2048 / 32767 x the span = 0.625 V, wrong by a factor of about 8.
Result. Two test points across the span reproduce on the PLC to the meter's resolution, and the channel is trustworthy end to end.
Decision. Pass when the PLC value agrees with the meter within 10 mV at two points spanning the range; the 0.31 mV per count floor leaves roughly 30 counts of margin. A constant offset means wrong endpoints, a factor-of-8 error means the wrong bit depth in your map, and readings slamming between zero and full span mean byte order or signedness. The sensor certificate then converts volts to torque with the same one-line formula, and nothing in the Modbus chain changes it.
Fourth gate: close the loop on measured timing #
For this coupler family, the Modbus TCP App is documented with a 10 ms communication cycle, usable as real-time data in the PLC; the CXA_ModbusTCP library route instead inherits the PLC task cycle, and its timing must be measured under load, not assumed. Either way, 10 ms of coupler refresh is not a 10 ms sensor-to-valve response: input conversion, the exchange itself, the PLC task, the output update and the valve's own response all stack in front of the hydraulics.
The timing decision: run the exchange and the loop in the same fast task, at 10-20 ms, so data age never exceeds one cycle; on a clean network the exchange itself adds only a few milliseconds, which leaves the valve and the hydraulic oil as the dominant lag. Commission a bounded open-loop command step first and record response direction, size and settling. Then close the loop with conservative gain, output limits and integral action clamped while the output saturates. Tune to the customer's written tolerance and record the measured request-to-response delay on the same sheet.
Advance when a step command produces a repeatable, stable response and the delay is recorded, not assumed.
Make a lost exchange a fault, never fresh data #
A Modbus TCP server with no watchdog keeps serving the last process image when the client goes away, and nothing pushes an output register low. The PLC owns the reaction:
- Age-stamp every exchange. If the health bit drops or an input's age passes two cycles, trip a communication fault, stop the cycle and command the analog output to its minimum; minimum command drives this pressure-reducing valve to minimum pressure, which releases torque, the right failsafe for this machine.
- Set the loss-of-communication output behavior the coupler's manual documents, as the backstop behind the PLC logic rather than a substitute for it.
- Read the coupler's diagnostic registers over the same link, covering module composition, terminal bus status and cycle times, so the alarm text can separate a lost network link from a faulted module.
A client that fetches once and keeps reusing the buffer hands the loop exactly the stale-data trap described in why a TM200 READ_VAR reads Modbus data only once. Make the read repeat every cycle and let the age stamp prove it.
Advance when pulling the cable at full speed produces a controlled stop and a communication alarm, not a frozen torque reading.
Log the torque data from a machine in the cabinet #
The running case also stores torque history and serves a visualization. Keep that job off the PLC and off an office desktop: a small machine in the cabinet next to the controller, an industrial mini PC built for cabinet duty, runs the logger and the visualization runtime in the same environment the coupler lives in. Keep the logger on the input registers only, so a reporting job can never move the loop output, and let it poll slower than the loop; one reading per second is ample for a tightening record.
The four gates, decided #
Run the station only when all four read pass:
- Electrical: measured signals match the configured ranges with motion inhibited.
- Connection: exchanges repeat, the timeout demonstrably fires, and a pulled cable faults the client inside one timeout period.
- Scaling: two known points agree with the meter within 10 mV on both channels, outputs clamped to span.
- Loop: request-to-response delay recorded, stable step response, and the cable-pull test stops the machine under a communication fault.
If a gate fails, the fix lives in that gate: wiring and ranges in the first, network and port in the second, map and endpoints in the third, and task scheduling or gains only in the fourth.
Questions asked
How many I/O modules can one Modbus TCP bus coupler carry?
Coupler manuals state the module limit and the process-data word limit separately, and both bind. One documented Modbus TCP coupler of this class expands to 32 I/O modules with dual 100 Mbit/s Ethernet ports; your coupler's manual gives its own numbers. For analog work the word limit usually bites first, because each analog channel occupies one or two words of the process image.
Can the PLC read the coupler's own diagnostics over the same link?
Yes. Alongside the process image, couplers keep a register area with the installed module composition, terminal bus status and cycle times. Reading it over the same connection lets the program separate a lost link from a faulted module, and the cycle-time register tells you how fast the coupler actually refreshes its image, so you can verify any refresh figure against your own loop period instead of trusting it.
Does a 4-20 mA input commission any differently?
The four gates are identical; only the endpoints change. A 4-20 mA input maps 4 mA to the low endpoint, so a raw reading at the bottom of the range means a broken loop circuit, not zero signal. Use 4 mA and 20 mA as your two test points and scale between them with the same one-line formula.
What changes when a channel is 32-bit, like a load cell?
Load-cell class channels ride two registers as one 32-bit value, so word order across the pair joins byte order and signedness as the things to match. Read both registers with a single function-code request so the two words come from one snapshot, assemble them in the order the manual shows, and prove the assembled value against a known test weight or a shunt signal before it feeds anything.