StateTick Docs Home →
StateTick
Timing and limits
Determinism

What the clock actually guarantees.

Anyone deciding whether to put a controller on a production machine asks the same question, in one form or another: will it be there when the sensor changes, every time?

This page answers that with mechanism and measurement rather than adjectives — how each machine is scheduled, what StateTick records about its own timing, what it does when a scan runs long, and where the edges of the system are.

01

A clock per machine

Timing is a property of each machine, not of the program as a whole.

Every machine you describe in StateTick runs on its own execution thread with its own period, set where the machine is defined. A safety interlock can sit at a few milliseconds while a recipe sequencer above it runs an order of magnitude slower, on the same controller.

The practical consequence is isolation. Adding a slow machine to a project does not lengthen the scan of a fast one, because they were never sharing a scan. The usual pressure — where every addition to the program taxes the tightest loop in it — does not arise, because there is no single program.

It also means the number you choose is a decision you can defend. A machine that reads a flow meter does not need to be visited every two milliseconds, and one watching a light curtain should not be visited every fifty.

02

Deadlines, not delays

The difference between a loop that drifts and one that does not.

The obvious way to hold a period is to do the work, measure how long it took, and sleep for the remainder. It is also the way that drifts: every scan carries a little measurement overhead and a little wake-up inaccuracy, and because each sleep is calculated from now, those errors compound. An hour later the loop is running visibly late and nothing reported it.

StateTick advances a fixed deadline instead. Each cycle adds exactly one period to the target timestamp and sleeps until that absolute moment, so a scan that runs slightly long is absorbed by the next sleep rather than pushed into the next cycle. Error does not accumulate.

TARGET GRID — WHERE EACH CYCLE SHOULD START Sleep for the remainder error compounds scan scan scan scan scan drift keeps growing Advance a fixed deadline error is absorbed scan long scan scan scan scan one cycle runs long… …the next still starts on the grid IF A SCAN FALLS MORE THAN A FULL PERIOD BEHIND the deadline is reset to now, so the machine resumes at its normal rate instead of firing a burst of catch-up cycles.
The mechanism matters more than the nominal period. A loop that drifts is one whose timing you cannot reason about a week later.

The second half of that figure is the part worth dwelling on. If a scan falls behind by more than one whole period — the operating system scheduled something else, a disk stalled, a burst of work arrived at once — StateTick does not try to make up the lost cycles. It resets the deadline to the present and carries on at the normal rate.

That is a deliberate choice. Firing several cycles back to back to “catch up” would mean a machine briefly running its logic far faster than it was designed to, which is worse than the lateness it is correcting.

03

Measured, not asserted

Timing claims are only worth what the instrument behind them is worth.

Every machine records its own timing while it runs, in microseconds, on the controller. Not sampled in a lab once — continuously, on the machine you deployed, available live and in the logs.

Per cycle

  • Scan time — and its minimum, maximum and average.
  • Jitter against the target period — with min, max and average.
  • Target period and actual cycle time, side by side.
  • Garbage-collection pauses, isolated from the rest.

Within the cycle

  • Timer tick, edge commit, inbox drain.
  • Guard evaluation — the usual suspect.
  • Entry, exit and step actions, separately.
  • So a slow scan points at a phase, not a shrug.

That last column is the difference between knowing a scan is slow and knowing why. When a machine starts running long, the profile says whether the cost is in evaluating conditions, in the actions a state performs, or in a collection pause — and those have completely different fixes.

Because the numbers are recorded rather than estimated, they also travel. A timing question from a commissioned machine is answered with that machine’s own figures rather than with a benchmark from somewhere else.

What this is, plainly: StateTick is a real-time control application running on a general-purpose operating system. Its timing is bounded by the platform underneath it — the hardware, the kernel, and whatever else is running on the box. It is not a hypervisor and does not claim a hard real-time guarantee independent of those things. What it does provide is a scheduler that does not accumulate error, and continuous measurement so the timing you actually get is a number you can look at rather than an assumption.

04

When something goes wrong

The behaviour under failure is part of the specification, not an afterthought.

If a machine throws an unhandled error, StateTick stops every machine in the project, not just the one that failed. That is the deliberate choice: half a line running with the other half stopped is a more dangerous state than a full stop, because the remaining machines carry on acting on a plant that is no longer whole.

Three things happen at that moment. The fault is recorded with the machine name, message and stack trace. It is written into the FSM trace log alongside the state history, so the sequence leading up to it is there rather than lost. And a crash file is written to disk, so the evidence survives a restart.

The stop is treated as transient rather than as an operator decision. StateTick installs as a service — a systemd unit on Linux — and comes up with the machine, so a restarted controller resumes normally rather than waiting for someone to notice it is down. A stop somebody deliberately commanded is remembered; a fault stop is not.

Shutdown is handled, not abrupt. The runtime listens for the termination signal a service manager sends, so an ordinary stop or restart unwinds cleanly instead of being cut off mid-cycle.

05

Working with your safety and motion hardware

How StateTick integrates with the rest of the cabinet.

Safety

StateTick integrates directly with external safety modules and safety relays. It sees the guard circuit, knows the moment the safety chain drops, and sequences the machine around it — bringing the process to a controlled state, holding, and resuming cleanly when the chain is restored.

This is the architecture most machines are already built around, and StateTick slots straight into it. Your safety hardware does what it is there to do; StateTick runs the machine and responds to it.

Motion

StateTick speaks the protocols your drives and motion controllers use, and coordinates them: when each axis is commanded, what has to be true first, how moves interlock with the rest of the machine, and what happens if one does not arrive. The drives execute the profiles; StateTick choreographs them against everything else on the line.

Because the coordination is a state plan rather than buried code, the motion sequence is something the whole project team can read and review.

Fieldbus and I/O

EtherCAT is used primarily for digital and analog I/O, and has been validated against standard bus couplers and I/O modules. Modbus TCP and RTU, OPC UA as both server and client, serial and raw TCP cover the rest, with the mapping held separately from the logic so the same machine can be pointed at different hardware without touching its sequence.

Working on a specific machine?

Every machine is specific, and a general capability list is a poor substitute for talking about yours. Send us your project specification — the axes, the safety architecture, the buses and the cycle you need — and we will go through it with you.

06

Running production today

Everything above is shaped by lines that are already making product.

StateTick runs production machines at three sites today, in packaging and palletising — lines where product moves through several stations, the timing between them matters, and a stoppage is counted in cases that did not get made.

Those machines are why this page reads the way it does. The deadline scheduler, the per-phase timing instrumentation and the decision to stop a whole line on a fault are not design-office preferences; each one is there because a running line demanded it. That is a shorter feedback loop between a machine and the software that drives it than most platforms will ever have again.

Numbers you can check beat adjectives you have to trust.

The argument of this page is not that StateTick is fast. It is that its timing is built to be inspected: a period per machine so the question is well-posed, a scheduler that does not let error accumulate, per-phase measurement so a slow scan has an address, and a defined behaviour when a cycle overruns or a machine faults.

And it is built to work with the rest of the cabinet: safety modules, relays, drives and motion controllers all integrate directly, with StateTick coordinating them against everything else on the line. Bring us the machine you are building and we will go through the specification with you.

Also worth reading

A Plant of Machines — why each machine keeps its own clock, and what that changes about how a plant is described.

Finding a Stuck Machine — the diagnostic side: live state, waveform signal capture and the FSM trace log.