Tool

Does your model fit inside the loop?

The budget is not the inference time. It is the protocol read, the scan cycle twice, preprocessing, inference, post-processing, the write back, and whatever the bus is doing for everybody else. This adds them up and tells you what is left.

Part one: the transport

For serial, the frame timing is computed from the baud rate and the register counts, including the 3.5 character silence the protocol requires between frames. For Ethernet, give the measured round trip instead.

Transport
Zero if the loop only reads.
ms
Typically 2 to 50 ms. Measure it rather than assume.
Read transaction
32.9 ms
Write transaction
26.0 ms
Character time
0.57 ms
11 bits per character
Part two: the loop

The controller's scan cycle is counted twice on purpose: once before your read is fresh, and once after your write before it takes effect. Leaving out the second one is the most common way a budget is quietly wrong.

ms
ms
ms
The one term everybody measures.
ms
%
Contention stretches the protocol terms only.
x
Multiplier for the worst case you must survive.
ms
This calculator runs entirely in your browser. Nothing you type is sent anywhere unless you ask for the result by email at the bottom of the page.
Where the deadline goes
TermTimeShare of loopShare of deadline
Read over the protocol32.9 ms35.0%32.9%
Controller scan before the read is fresh10.0 ms10.6%10.0%
Preprocessing2.00 ms2.1%2.0%
Inference12.0 ms12.8%12.0%
Post-processing1.00 ms1.1%1.0%
Write back26.0 ms27.7%26.0%
Next scan before the write takes effect10.0 ms10.6%10.0%
Total94.0 ms100%94.0%
Contention and jitter are applied after this table; the shares above are nominal.
Nominal loop time
94.0 ms
Under contention
119 ms
Bus at 30% utilisation
Worst case
179 ms
With a 1.50x jitter allowance
Inference budget, nominal
18.0 ms
What inference may take with every other term paid
Inference budget, worst case
none
The number to design against
Inference share of the loop
12.8%
Largest term: read over the protocol
Closes nominally at 94.0 ms but misses at worst case (179 ms). Inference fits on a quiet bus and not on a busy one, which is why this fails under load and passes on the bench.
Send me this budget

Your terms go with it, so the reply is about your loop rather than the general case. If the dominant term is one nobody on the program owns, that is usually the finding.

Your inputs are included so the reply can be specific.

Modbus RTU protocol time, by baud rate and register count

One read transaction, in milliseconds, before the device has done anything. This is the floor your loop is built on and it is fixed by the wire, not by your code. Add your device's processing time, which is typically 2 to 50 ms, and then everything above.

Registers read9,600 baud19,200 baud38,400 baud57,600 baud115,200 baud
125.2 ms12.6 ms6.30 ms4.20 ms2.10 ms
534.4 ms17.2 ms8.59 ms5.73 ms2.86 ms
1045.8 ms22.9 ms11.5 ms7.64 ms3.82 ms
2068.8 ms34.4 ms17.2 ms11.5 ms5.73 ms
50138 ms68.8 ms34.4 ms22.9 ms11.5 ms
100252 ms126 ms63.0 ms42.0 ms21.0 ms

Function code 03, one master, no contention. Request 8 bytes, response 5 + 2N bytes, 3.5 character silence before each frame, 11 bits per character. Amber is over 20 ms, red is over 50 ms, because past those a 100 ms loop has already spent a fifth or a half of its budget on the wire.

A worked example

A vision system on a 100 ms loop, reading 10 registers over Modbus RTU at 19200 baud from a controller with a 10 ms scan cycle and 10 ms of device processing. Inference measures 12 ms on the target hardware, which the team reports as comfortably inside budget.

The read is 32.9 ms: 22.9 ms on the wire plus the device's 10 ms. The scan cycle before that read is fresh is 10 ms. Preprocessing is 2 ms, inference 12 ms, post-processing 1 ms. The write back is 26 ms, and the next scan before it takes effect is another 10 ms. That totals 94 ms against a 100 ms deadline. It closes, with 6 ms to spare, and it passes on the bench every time.

Then the line runs other masters on the same link at 30 percent utilisation. The protocol terms are 59 ms of that 94, and they are the ones that queue, so they stretch by about 1.4x and the loop goes to 119 ms. It now misses, intermittently, under load. A 1.5x jitter allowance puts the worst case at 179 ms. The trace shows inference at 12 ms every single time.

The actionable number is the inference budget: 18 ms nominal, and negative at worst case. Inference is 13 percent of the loop and the protocol terms are 63 percent, so no amount of model optimisation reaches this. The cheapest fixes are fewer registers per cycle, a faster baud rate, or taking the other masters off the link, and not one of them is a machine learning decision.

The arithmetic, so you can check it

Modbus RTU frames one character as 11 bits: a start bit, eight data bits, a parity bit and a stop bit. So a character takes 11 / baud seconds, and the protocol requires 3.5 character times of silence before each frame. A read of N holding registers is an 8-byte request and a 5 + 2N byte response.

Contention is modelled as a queueing stretch of 1 / (1 - utilisation), applied to the protocol terms only, since those are the ones that share the link. It is a crude model and it is the right shape: the cost of contention is flat until it is not, and the knee arrives sooner than people expect.

The honest limit

This is a budget, not a measurement. Real controllers do not implement the standard uniformly: register maps differ from documentation, word ordering varies between vendors, and behaviour on a malformed request ranges from a clean exception to a device that needs power-cycling. Treat the device as the specification, put a passive tap on the link, and record what actually happens. The number here tells you whether the design can work; only the tap tells you whether it does.

The reasoning behind every term is in PLC to model: where industrial AI actually breaks, and the same structure applied to a robot in perception to control.

Questions

What goes into a control loop timing budget?

Seven terms, not one: the protocol read, the controller scan cycle before that read is fresh, preprocessing, inference, post-processing, the write back, and the controller's next scan before the write takes effect. Contention from other masters on the link stretches the protocol terms on top of that. Inference is usually the smallest of the seven and the only one anybody measures.

How long does a Modbus RTU transaction take?

A character is 11 bits, so at 19200 baud one character is 0.573 ms. A read of 10 holding registers is an 8-byte request and a 25-byte response, with a 3.5 character silence before each frame, giving 22.9 ms of protocol time before the device has done anything. At 9600 baud the same read is 45.8 ms. Add the device's own processing, typically 2 to 50 ms, on top.

Why is the controller scan cycle counted twice?

Once before your read, because a value is only as fresh as the last scan that wrote it, and once after your write, because the output does not take effect until the next scan. Leaving out the second one is the most common reason a budget that looked fine on paper misses in the field.

Why does my loop meet its deadline on the bench and miss in production?

Almost always contention. The protocol terms queue behind other masters on the same link, so they stretch under load while inference does not. A loop that closes with a quiet bus and misses with a busy one is the signature, and it is invisible in any measurement taken on a test rig with one master.

My inference time is well inside the deadline. Why does the loop still miss?

Because inference is one of seven terms. Teams measure the term they own, find it comfortably inside budget, and never add up the other six. The useful number is the inference budget: the deadline minus everything else, which is what this calculator returns.

Does this apply to EtherNet/IP and other protocols?

The structure does. Switch the transport to Ethernet and supply your measured round trip instead of a baud rate; every other term is unchanged. The serial mode computes frame timing from first principles because that is where the arithmetic is least obvious.