A real-time control system is a control system whose correctness depends not only on the computed command but also on when that command is delivered. In robotics, it reads sensors, runs a control law and writes actuator commands in a fixed, bounded cycle, typically every 1 ms or faster for joint torque loops, so that a late answer counts as a wrong answer.
Among control systems, the real-time property is what turns a correct algorithm such as PID or model predictive control into a physically safe behavior. The defining metric is not average speed but the worst-case response time, together with how much the cycle period varies from one iteration to the next.
How a real-time control loop works
A real-time control loop repeats a sense, compute, actuate cycle at a fixed period. A hardware timer or a fieldbus frame triggers each iteration, the controller samples encoders and force sensors, executes the control law, and publishes new setpoints or torques before the deadline that ends the period.
The loop is usually organized as a cascade of nested loops. The innermost current loop in the motor drive runs at 10 to 40 kHz, the velocity and position loops run at 1 to 8 kHz, and higher layers such as trajectory generation or whole-body control run at 100 Hz to 1 kHz. Each outer loop must be several times slower than the loop inside it, which keeps the layers dynamically decoupled.
The table below lists the typical layers of a robot controller and the timing each one needs.
| Control layer | Typical rate | Usual location |
|---|---|---|
| Motor current loop | 10-40 kHz | Servo drive firmware or FPGA |
| Joint position and velocity loop | 1-8 kHz | Drive or real-time host |
| Impedance or force control | 500 Hz-4 kHz | Real-time host process |
| Whole-body or model predictive control | 100 Hz-1 kHz | Real-time host, multicore |
| Motion planning and perception | 1-30 Hz | General-purpose computer |
Hard, firm and soft real-time requirements
Real-time requirements are classified by the consequence of a missed deadline. The class decides which operating system, hardware and verification effort a design needs, so it should be fixed before any code is written.
| Class | Effect of a missed deadline | Robotics example |
|---|---|---|
| Hard real-time | System failure or safety hazard | Joint torque loop of a collaborative arm |
| Firm real-time | Late result is useless but tolerable if rare | Visual servoing frame from a camera |
| Soft real-time | Quality degrades gracefully | Path replanning or map updates |
Two timing quantities dominate every analysis. Latency is the delay from a sensor event to the corresponding actuator output, and jitter is the variation of the actual cycle start around its nominal time. A loop with low average latency but occasional spikes of several milliseconds is worse for control than a slightly slower loop that is perfectly regular, because the control law assumes a constant sampling period.
Engineers therefore measure the worst-case execution time (WCET) of the control task and verify that WCET plus input and output overhead stays well below the period. A common design margin keeps CPU utilization of the real-time core under 50 to 70 percent so that interrupts and cache effects cannot push the loop past its deadline.
Platforms that provide real-time guarantees
Determinism comes from the whole platform, not from the control code alone. The scheduler, interrupt handling, memory management and communication bus must all have bounded timing, and a single non-deterministic component breaks the guarantee for the entire loop.
The following table compares the platforms most often used to host robot control loops.
| Platform | Typical worst-case jitter | Strengths | Limitations |
|---|---|---|---|
| Microcontroller with RTOS | Below 10 µs | Simple, highly deterministic | Limited compute and memory |
| Linux with PREEMPT_RT | About 20-100 µs | Full Linux ecosystem, multicore | Needs careful tuning and isolation |
| Dual-kernel systems such as Xenomai | About 5-30 µs | Very low latency on PC hardware | Separate API, smaller community |
| PLC runtime | About 10-100 µs | Certified tools, industrial support | Restricted languages and libraries |
| FPGA logic | Nanoseconds | Fully parallel, cycle-exact | Hard to modify and debug |
Communication must be deterministic as well. Fieldbuses such as EtherCAT, CANopen and PROFINET IRT deliver frames on a fixed schedule with distributed clocks, which keeps drives sampling in step. In ROS 2, the real-time path relies on a real-time capable executor, preallocated memory and a suitable DDS configuration, and the ros2_control framework runs hardware interfaces inside a dedicated real-time thread.
How it relates to neighboring control concepts
A real-time control system is an execution property, not a control algorithm. Feedback control, open-loop control, LQR, impedance control and state estimation with a Kalman filter all describe what is computed, while real-time execution describes whether the result arrives in time to be valid.
| Concept | Main question it answers | Link to real-time execution |
|---|---|---|
| Feedback control | How the error drives the command | Needs a constant sampling period |
| Model predictive control | Which input sequence is optimal | Solver must finish within the period |
| State estimation | What the true robot state is | Estimator delay adds to loop latency |
| Motion control | How axes follow a trajectory | Usually the hard real-time core |
| PLC | How industrial logic is executed | A common real-time execution platform |
Delay matters because it erodes phase margin. A pure time delay adds phase lag that grows linearly with frequency, so a loop tuned for 1 ms of latency can oscillate or become unstable when latency rises to 3 ms. Discrete control design assumes a known, constant delay, which is why designers often compensate a full sample of delay explicitly in the model.
Common failure modes and design practices
Most real-time failures come from hidden sources of non-determinism rather than from slow algorithms. The table pairs typical symptoms with their usual cause and an accepted remedy.
| Symptom | Likely cause | Typical fix |
|---|---|---|
| Periodic latency spikes | Dynamic memory allocation in the loop | Preallocate all buffers at startup |
| Random overruns under load | Shared CPU with non-real-time tasks | Isolate cores and pin threads |
| Priority inversion stalls | Mutex shared with a low-priority thread | Lock-free queues or priority inheritance |
| Audible vibration in joints | Jitter in the sampling period | Hardware-timed triggers and bus clocks |
| First cycles miss deadlines | Page faults and cold caches | Lock memory and warm up the loop |
- Never log, print or perform file input and output inside the hard real-time thread; pass data to a non-real-time thread through a lock-free buffer.
- Monitor every overrun with a counter and define a safe reaction, such as holding position or triggering a controlled stop.
- Test under worst-case load, including network traffic and disk activity, because average-case benchmarks hide the spikes that cause failures.
- Separate safety functions such as safe torque off onto certified hardware rather than relying on the main control computer.
Put simply
A real-time control system is a robot brain that must answer on time, every time. Many times per second it checks where the robot is, decides how to correct the movement, and sends new orders to the motors. If an answer comes too late, it is already out of date, because the robot has moved in the meantime.
Think of steering a bicycle. You make small corrections constantly, and you have to make them at the right moment. A correct correction that comes half a second late can still make you fall. Robots work the same way, which is why predictable timing matters more than raw speed.
In practice
An integration team builds a seven-axis collaborative arm for screwdriving on an assembly line. The joint drives are connected over EtherCAT, and an industrial PC running Linux with PREEMPT_RT hosts the impedance controller at 1 kHz. Two CPU cores are isolated for the control thread, and all memory is locked and preallocated at startup.
During early tests, the arm produced a faint buzz whenever the vision computer streamed images over the same network. Latency measurements showed cycle jitter of up to 400 µs caused by interrupt handling on the shared core. After moving network interrupts to a non-isolated core and separating the camera traffic, worst-case jitter fell to about 40 µs, the buzz disappeared, and the arm passed its contact force limits for human collaboration with a comfortable margin.