Robotics & Control Systems

Chapter 7
Digital, Embedded and Real-Time Control

Bachelors Program in Mechnical Engineering
Robotics & Control Systems   •   Bachelor

Digital, Embedded and Real-Time Control

Introduction and Context

Robotic systems increasingly depend on digital computation. A sensor measures a physical variable, an embedded processor calculates a control action, and an actuator changes the mechanical system. Unlike a continuous analogue controller, a digital controller operates at discrete instants and is affected by sampling, computation time, quantization, communication delay, processor limitations, and scheduling.

A successful robotic controller must therefore satisfy two requirements simultaneously: it must be dynamically appropriate and computationally executable. A mathematically stable controller can fail in practice if its sampling period is too long, its numerical representation is inadequate, or its control task misses deadlines.

This chapter develops the foundations of sampled-data control, discrete-time modelling, z-domain analysis, digital controller design, embedded implementation, programmable logic controllers (PLCs), industrial communication, and real-time scheduling.

Learning Objectives

By the end of this chapter, a student should be able to:

  1. Explain sampling, reconstruction, aliasing, quantization, and computational latency.
  2. Convert continuous-time models into discrete-time representations.
  3. Use the z-transform to analyse discrete-time systems.
  4. Design and implement digital proportional–integral–derivative controllers.
  5. Select suitable embedded processors, PLCs, sensors, and communication methods.
  6. Analyse real-time task timing, priorities, jitter, and deadline feasibility.
  7. Recognize how digital implementation changes stability, performance, safety, and maintainability.

1. The Digital Control Loop

A typical digital feedback loop contains the following elements:

  1. A reference command, such as a desired joint angle.
  2. A sensor and signal-conditioning circuit.
  3. An analogue-to-digital converter (ADC).
  4. A processor executing the control algorithm.
  5. A digital-to-analogue converter (DAC), pulse-width-modulation output, or network message.
  6. A power amplifier and actuator.
  7. The mechanical plant.

The processor does not observe the plant continuously. If the sampling period is T_s seconds, measurements are acquired at times t = kT_s, where k is an integer. The sampled signal is represented as x[k] rather than x(t).

Digital feedback control architecture Reference r[k] Digital controller Actuator Mechanical plant Sensor ADC / sampling feedback y(t)sampled y[k]
Digital feedback control architecture
Figure: Digital feedback control architecture

Figure: A digital feedback loop containing sampling, computation, actuation, and feedback measurement.

The loop may be synchronous, with all operations triggered by a periodic timer, or event-driven, with execution initiated by interrupts or messages. Synchronous execution is usually easier to analyse because the sampling interval is predictable.

2. Sampling and Reconstruction

2.1 Sampling theorem

A continuous signal with highest significant frequency f_max can be reconstructed from ideal uniform samples if the sampling frequency satisfies

fs > 2fmax

where f_s = 1/T_s is the sampling frequency in hertz. The frequency 2f_max is called the Nyquist rate. The strict inequality is important because a component exactly at the Nyquist frequency is difficult to reconstruct reliably in practical systems.

The theorem assumes band-limited signals and ideal sampling and reconstruction. Real sensors and actuators are not ideal, so an analogue anti-aliasing low-pass filter is normally placed before the ADC. If a signal above f_s/2 is sampled, it can appear as a false lower-frequency signal. This phenomenon is aliasing and cannot generally be removed after sampling.

2.2 Choice of sampling period

Sampling faster is not always better. A smaller T_s improves temporal resolution but increases processor load, communication traffic, and sensitivity to measurement noise. A common engineering starting point is to choose the sampling frequency several times greater than the closed-loop bandwidth, then verify the resulting discrete design through simulation and testing. The exact factor depends on plant dynamics, delay, noise, actuator bandwidth, and the required phase margin.

2.3 Quantization

An n-bit ADC with input range V_min to V_max has an ideal voltage resolution approximately equal to

q = (Vmax - Vmin) / 2n

where q is in volts per count. The quantization error e_q is commonly modelled as bounded by

−q/2 ≤ eq ≤ q/2

under the assumption of rounding and a non-overloaded converter. Quantization is nonlinear and can produce limit cycles in low-speed control systems. Increasing resolution, scaling signals appropriately, and adding suitable filtering can reduce its effects, but filtering introduces delay.

3. Discrete-Time Models and Discretization

A continuous-time plant is described by differential equations or a transfer function G(s). A digital controller requires a discrete model G(z), where z is the complex shift variable. Discretization should preserve the behaviour relevant to the chosen sampling period and operating range.

3.1 Zero-order hold

Most digital actuators hold the computed command constant until the next update. This is modelled by a zero-order hold (ZOH). For a state-space model

ẋ(t) = Ax(t) + Bu(t)
y(t) = Cx(t) + Du(t)

the exact ZOH equivalent is

x[k+1] = Ad x[k] + Bd u[k]
Ad = e^(ATs)
Bd = ∫0Ts e^(Aτ)B dτ
y[k] = Cx[k] + Du[k]

Here A, B, C, and D are continuous-time state-space matrices; A_d and B_d are discrete matrices; and τ is an integration variable. The equations assume a constant input over each interval [kT_s,(k+1)T_s).

For a first-order plant

G(s) = K / (τs + 1)

where K is the static gain and τ is the time constant in seconds, the exact sampled model is

x[k+1] = a x[k] + b u[k]
a = e^(−Ts/τ), b = K(1 − e^(−Ts/τ))

This form is useful because it directly predicts the next sample.

3.2 Common approximate methods

The forward Euler approximation replaces the derivative with

ẋ(t) ≈ [x[k+1] − x[k]] / Ts

The backward Euler and Tustin methods use future or averaged values. Tustin’s substitution is

s ≈ (2/Ts)(z − 1)/(z + 1)

It maps the stable left half of the s-plane into the interior of the unit circle and is often preferred for controller discretization. Approximate methods are convenient, but their accuracy depends on T_s and system dynamics.

Worked Example 1: Exact first-order discretization

Consider G(s) = 2/(0.5s + 1), sampled at T_s = 0.1 s. The discrete coefficients are

a = e^(−0.1/0.5) = e^(−0.2) ≈ 0.8187
b = 2(1 − 0.8187) ≈ 0.3625

Thus x[k+1] = 0.8187x[k] + 0.3625u[k]. Since |a| < 1, the sampled open-loop first-order mode is stable. If u[k] = 1 and x[0] = 0, then x[1] = 0.3625 and x[2] ≈ 0.8187(0.3625)+0.3625 = 0.6593.

4. The z-Transform and Stability

For a sequence x[k], the z-transform is

X(z) = ∑_(k=0)^∞ x[k]z^(−k)

under conditions for which the series converges. The delay property is particularly important:

x[k−1] ↔ z^(−1)X(z)

A discrete transfer function is defined as H(z) = Y(z)/U(z), with zero initial conditions. The poles of H(z) determine natural modes. A linear time-invariant discrete system is asymptotically stable when every pole lies strictly inside the unit circle:

|zi| < 1

A pole on the unit circle generally produces sustained oscillation and is not asymptotically stable; poles outside it produce growing responses.

A difference equation can be converted directly. For example,

y[k] = 0.8y[k−1] + 0.1u[k]

has transfer function

H(z) = 0.1/(1 − 0.8z^(−1))

and one pole at z = 0.8.

The mapping z = e^(sT_s) relates continuous and discrete poles. If s = σ + jω, then the discrete pole magnitude is e^(σT_s), so a continuous stable pole with σ < 0 maps inside the unit circle.

5. Digital PID Control

A continuous PID controller is

u(t) = Kp e(t) + Ki ∫e(t)dt + Kd de(t)/dt

where e(t) = r(t) − y(t), K_p is proportional gain, K_i is integral gain, and K_d is derivative gain. Units depend on the input and output variables.

A practical discrete implementation uses

u[k] = Kp e[k] + I[k] + Kd(e[k] − e[k−1])/Ts
I[k] = I[k−1] + KiTs e[k]

The derivative term amplifies high-frequency measurement noise. Therefore, practical controllers often filter the derivative, for example by using a first-order filtered derivative rather than an ideal difference.

Integral windup and anti-windup

If the actuator is limited to u_min ≤ u[k] ≤ u_max, the integral state may continue increasing while the actuator is saturated. When the error reverses, the stored integral causes excessive overshoot. This is integral windup. Common remedies include conditional integration, integral clamping, and back-calculation.

For back-calculation, one representative implementation is

I[k] = I[k−1] + Ts[Ki e[k] + Kaw(usat[k] − u[k])]

where u[k] is the unsaturated command, u_sat[k] is the limited command, and K_aw is an anti-windup gain. The sign and exact form must be consistent with the controller convention.

Digital PID design must account for the effective delay from measurement acquisition, computation, output update, and actuator response. Even a fraction of a sampling period can reduce phase margin.

6. Embedded Control Hardware

An embedded controller typically combines a processor, memory, timers, ADCs, digital input/output, communication interfaces, and power-management circuits.

PlatformTypical strengthTypical limitation
MicrocontrollerLow cost, timers, ADCs, deterministic I/OLimited memory and computational capacity
Digital signal processorFast numerical operationsMore specialized development
Single-board computerOperating-system support and high-level softwareLess deterministic without real-time configuration
FPGAParallel and highly deterministic processingGreater design complexity
PLCIndustrial robustness, diagnostics, and maintenance toolsOften higher cost and lower numerical flexibility

Selection should consider control-loop frequency, number of axes, sensor interfaces, safety requirements, environmental conditions, cybersecurity, lifecycle support, and available engineering skills. Floating-point arithmetic simplifies scaling but may require more resources. Fixed-point arithmetic can be efficient, but overflow, rounding, and scaling must be explicitly analysed.

A robust implementation separates fast control tasks from slow supervisory tasks. For example, a motor-current loop may execute at 10 kHz, a position loop at 1 kHz, and diagnostics at 10–100 Hz. These rates are illustrative, not universal specifications.

7. PLCs and Industrial Control

A PLC repeatedly performs an input scan, program execution, and output update. This scan-cycle model is predictable and well suited to sequencing, interlocking, material handling, and machine automation. Ladder logic, function-block diagrams, structured text, and sequential function charts are common programming languages under IEC 61131-3 practices.

PLCs differ from general-purpose computers through industrial I/O, fault diagnostics, rugged construction, maintainability, and predictable operation. Motion-control PLCs may include interpolation, synchronized axes, and high-speed networks. Safety PLCs use certified hardware and software mechanisms for functions such as emergency stops and protective guarding.

The scan time must be short enough for the controlled process. A slow PLC scan can cause delayed reactions or missed pulses. High-speed counters, hardware interrupts, and distributed I/O may be necessary when ordinary cyclic scanning is insufficient.

8. Communication Networks and Latency

Robotic systems use communication for sensors, drives, PLCs, supervisory systems, and safety devices. Examples include CAN and CANopen, EtherCAT, PROFINET, Ethernet/IP, Modbus, and time-sensitive Ethernet technologies. The choice depends on bandwidth, determinism, topology, distance, synchronization, diagnostics, and safety requirements.

Communication introduces several delays:

  • sensor conversion and filtering delay;
  • packet formation and transmission delay;
  • queuing and switching delay;
  • processor scheduling delay;
  • actuator update delay.

If the total delay is approximately L seconds, a simple continuous approximation is e^(−sL). A pure delay contributes phase lag that increases with frequency. In discrete simulation, a delay of d samples is represented by z^(−d), where d is an integer. If the delay is not an exact multiple of T_s, it must be approximated or represented using a more detailed timing model.

Time synchronization is important in coordinated robotics. Distributed clocks, timestamped measurements, and deterministic update windows allow several drives to act on a common time base. Safety communication must additionally meet relevant risk-reduction and functional-safety requirements; ordinary data communication must not automatically be treated as safety-rated.

9. Real-Time Scheduling

A real-time system is defined by whether it meets timing requirements, not merely by how quickly it computes. A hard real-time task has a deadline whose violation may cause unacceptable or dangerous behaviour. A soft real-time task tolerates occasional lateness with degraded performance.

For task i, define execution time C_i, period T_i, and deadline D_i. Under ideal fixed-priority assumptions, a basic utilization measure is

U = ∑ Ci/Ti

This is a workload indicator, not a complete schedulability proof. Blocking, interrupts, context switching, communication, cache effects, and release jitter must also be considered.

For a fixed-priority task i, response-time analysis is commonly expressed as

Ri = Ci + Bi + ∑_(j∈hp(i)) ⌈Ri/Tj⌉Cj

where R_i is the worst-case response time, B_i is blocking time, hp(i) is the set of higher-priority tasks, and the equation is solved iteratively. The task is schedulable if R_i ≤ D_i. This formula assumes a defined priority order and known worst-case execution times.

Rate-monotonic scheduling assigns higher priority to tasks with shorter periods. Earliest-deadline-first scheduling dynamically assigns priority to the nearest deadline. Practical systems also require priority-inversion control, often through priority inheritance or priority ceilings.

Timing quality

Jitter is variation in task release or completion time. It changes the effective sampling interval and can produce output variation or phase disturbance. A control task should therefore use a hardware timer or a real-time operating-system mechanism rather than an uncontrolled software delay.

10. Worked Example 2: Timing Feasibility

Suppose three periodic tasks have the following parameters:

TaskC_iT_iC_i/T_i
Current control0.04 ms0.20 ms0.20
Position control0.10 ms1.00 ms0.10
Diagnostics0.50 ms10.0 ms0.05

The total utilization is

U = 0.20 + 0.10 + 0.05 = 0.35

Thus the processor executes estimated task work for 35% of available CPU time, leaving 65% for operating-system overhead, communication, bursts, and timing margin. This calculation does not prove deadline satisfaction, but it indicates that the nominal workload is feasible if execution-time estimates are reliable and priorities are properly assigned.

11. Illustrative Case: Networked Robot Palletizer

Background

A six-axis palletizing robot transfers boxes from a conveyor to pallets. The system includes servo drives, a PLC, a vision sensor, safety gates, and a supervisory computer.

Problem

Occasional placement errors occur even though the offline trajectory is correct. Investigation shows that the conveyor speed varies, the vision measurement is transmitted over a shared network, and the robot controller processes data at a fixed period.

Analysis

The measurement delay consists of camera exposure, image processing, network transmission, PLC scheduling, and robot-controller update. If the conveyor moves at velocity v and the total delay is L, the uncorrected positional displacement is approximately

∆x = vL

For v = 0.40 m/s and L = 0.075 s, ∆x = 0.030 m, or 30 mm. This is large relative to the required placement tolerance.

Approach and solution

The engineering team uses timestamped vision measurements, a synchronized network, a conveyor encoder, and prediction of the object position at the expected actuation time. The prediction is validated against measured conveyor motion. The vision task is assigned a bounded execution time, while the servo task retains the highest control priority. Network traffic is separated into real-time and non-real-time classes. Safety functions remain implemented through certified safety hardware rather than relying on the ordinary vision channel.

Outcome

Placement accuracy improves because the controller compensates for measured transport delay rather than treating the vision coordinate as current. The system also becomes easier to diagnose because timestamps distinguish sensor delay from scheduling delay.

Learning points

  1. A correct trajectory is insufficient when information is delayed.
  2. Timing should be measured, not assumed.
  3. Prediction is useful only when the motion model and timestamps are trustworthy.
  4. Safety and performance communication should be architecturally separated.

12. Verification, Safety, and Cybersecurity

Digital control should be verified at several levels:

  • unit tests for numerical functions;
  • processor-in-the-loop tests;
  • software-in-the-loop simulation;
  • hardware-in-the-loop testing;
  • fault injection for sensor loss, saturation, and communication failure;
  • timing measurement under worst-case load;
  • physical tests with guarded energy and emergency-stop capability.

Engineering documentation should state sampling rates, scaling, units, saturation limits, task priorities, deadlines, communication assumptions, and failure responses. A controller should enter a defined safe state when sensor validity, watchdog, communication, or actuator conditions are violated.

Cybersecurity is a control concern because unauthorized commands or altered measurements can destabilize a machine. Access control, authenticated updates, network segmentation, secure configuration, logging, and vulnerability management should be integrated into the lifecycle. Safety, cybersecurity, and functional performance are related but distinct: a secure system is not automatically safe, and a safety-rated device is not automatically cybersecure.

Relevant standards depend on the application and jurisdiction. Examples include IEC 61131-3 for PLC programming, IEC 61508 for functional safety, ISO 10218 for industrial robots, ISO 13849 for safety-related control systems, and IEC 62443 for industrial cybersecurity. Engineers must consult the current applicable editions and regulatory requirements rather than treating a standard name as a complete design method.

13. Contemporary Developments and Best Practices

Modern controllers increasingly use multicore processors, real-time Linux, FPGA acceleration, time-sensitive networking, digital twins, and model-based development. Machine learning may assist vision, anomaly detection, or adaptive modelling, but safety-critical control should not depend on an unverified model. Learned components require validation over representative operating conditions and explicit handling of uncertainty.

Best practices include:

  1. Choose T_s from plant bandwidth, delay, noise, and computation—not convenience alone.
  2. Apply analogue anti-aliasing and validate sensor ranges.
  3. Use consistent units and explicit numerical scaling.
  4. Include actuator saturation and anti-windup in simulations.
  5. Measure worst-case execution time and communication latency.
  6. Reserve timing margin for faults and future software growth.
  7. Separate safety functions from ordinary control logic.
  8. Log timestamps, modes, faults, and commands for diagnosis.
  9. Test quantization, packet loss, jitter, resets, and sensor failure.
  10. Document assumptions so that the design remains maintainable.

Challenges and Limitations

Digital control models are approximations. A ZOH model may omit actuator dynamics, computational delay, friction, backlash, and changing loads. Sampling can hide fast events, while quantization and noise can interact in nonlinear ways. Networked systems may exhibit variable delay and packet loss. Processor timing can change after software updates or when diagnostic functions are added. Finally, formal stability of a nominal model does not guarantee safe behaviour under saturation, faults, or unmodelled dynamics.

Chapter Summary

Digital control converts continuous physical behaviour into sampled measurements and computed actuator commands. Sampling must be fast enough to represent relevant dynamics, and anti-aliasing is required before conversion. Quantization produces bounded numerical error but may create nonlinear effects. Exact zero-order-hold discretization provides a useful discrete plant model, while the z-transform represents delays and stability through poles inside the unit circle. Digital PID controllers require careful treatment of derivative noise, actuator saturation, and integral windup. Embedded processors and PLCs differ in computational flexibility, determinism, diagnostics, and industrial suitability. Communication networks introduce latency, jitter, synchronization requirements, and cybersecurity concerns. Real-time scheduling must consider execution time, periods, priorities, blocking, and deadlines. Reliable robotic control therefore combines control theory with embedded engineering, timing analysis, verification, safety, and lifecycle management.

Key Terms

Sampling: Measuring a continuous signal at discrete time instants.

Sampling period: Time between consecutive samples, denoted T_s.

Aliasing: False low-frequency interpretation caused by undersampling.

Nyquist rate: Twice the highest frequency that must be represented.

Quantization: Mapping a continuous numerical value to finite digital levels.

ADC: Analogue-to-digital converter.

DAC: Digital-to-analogue converter.

Zero-order hold: Model that keeps an actuator command constant between updates.

Discretization: Conversion of a continuous-time model into a discrete-time model.

z-transform: Transform used to analyse discrete-time sequences and systems.

Unit circle: The locus |z| = 1 in the complex z-plane.

Jitter: Variation in task release, sampling, or completion time.

Latency: Delay between an event, its computation, and the resulting action.

PLC: Programmable logic controller used for industrial automation.

Real-time system: System whose correctness includes meeting timing requirements.

Deadline: Latest acceptable completion time for a task.

Integral windup: Excessive accumulation of integral action during actuator saturation.

Priority inversion: Situation in which a high-priority task is delayed by a lower-priority task.

Anti-aliasing filter: Analogue filter that limits input bandwidth before sampling.

Functional safety: Reduction of unacceptable risk through safety-related functions.

Review Questions

Short Answer Questions

  1. Why is an anti-aliasing filter placed before an ADC?
  2. State the discrete-time stability condition in terms of pole locations.
  3. What is the purpose of a zero-order hold model?
  4. Define integral windup and name one method of preventing it.
  5. Distinguish hard real-time from soft real-time operation.

Long Answer Questions

  1. Explain the complete signal path in a digital robotic feedback loop and identify major sources of delay.
  2. Derive the exact discrete model of a first-order plant using the zero-order-hold assumption.
  3. Compare microcontrollers, PLCs, single-board computers, and FPGAs for robotic control applications.
  4. Explain how quantization, sampling, and derivative action affect a digital PID controller.
  5. Discuss the role of communication synchronization, functional safety, and cybersecurity in networked robotics.

Analytical / Application Questions

  1. A first-order plant has K = 3, τ = 0.6 s, and T_s = 0.12 s. Calculate the exact discrete coefficients a and b and write the resulting state equation.
  2. Three tasks have (C_i,T_i) values of (0.05 ms, 0.25 ms), (0.20 ms, 1 ms), and (0.8 ms, 10 ms). Calculate total utilization and discuss why utilization alone is not a schedulability proof.
  3. A conveyor moves at 0.5 m/s and a vision-based command experiences 60 ms total delay. Calculate the approximate uncompensated displacement and propose two engineering methods to reduce placement error.

Multiple Choice Questions with Answers

Question 1

A sampled system has a highest relevant signal frequency of 200 Hz. Which sampling frequency satisfies the ideal Nyquist condition?

A. 100 Hz

B. 250 Hz

C. 400 Hz

D. 800 Hz

Correct Answer: D. 800 Hz

Question 2

For an ideal n-bit ADC with input range V_min to V_max, which expression gives the approximate voltage resolution?

A. (V_max + V_min)n

B. (V_max − V_min)/2^n

C. 2^n/(V_max − V_min)

D. (V_max − V_min)2^n

Correct Answer: B. (V_max − V_min)/2^n

Question 3

A discrete-time linear system is asymptotically stable when all its poles are:

A. Outside the unit circle

B. On the positive real axis

C. Strictly inside the unit circle

D. Exactly at z = 1

Correct Answer: C. Strictly inside the unit circle

Question 4

What does a zero-order hold assume about the actuator command between two updates?

A. It is zero

B. It changes sinusoidally

C. It remains constant

D. It is differentiated

Correct Answer: C. It remains constant

Question 5

Which PID problem occurs when the integral state continues accumulating during actuator saturation?

A. Aliasing

B. Integral windup

C. Priority inversion

D. Clock drift

Correct Answer: B. Integral windup

Question 6

For G(s) = 2/(0.5s + 1) with T_s = 0.1 s, the exact coefficient a = e^(−T_s/τ) is approximately:

A. 0.1353

B. 0.5000

C. 0.8187

D. 1.2214

Correct Answer: C. 0.8187

Question 7

Which quantity is directly represented by z^(−d) in a discrete model?

A. A gain of d

B. A delay of d samples

C. A derivative of order d

D. A quantization level

Correct Answer: B. A delay of d samples

Question 8

A task has execution time C_i = 0.2 ms and period T_i = 1 ms. Its utilization contribution is:

A. 0.02

B. 0.2

C. 1.2

D. 5

Correct Answer: B. 0.2

Question 9

Which scheduling characteristic is most important for a hard real-time control task?

A. Meeting its deadline predictably

B. Using the largest possible memory

C. Maximizing screen resolution

D. Avoiding all communication

Correct Answer: A. Meeting its deadline predictably

Question 10

A conveyor travels at 0.4 m/s and a control signal is delayed by 0.075 s. The approximate displacement during the delay is:

A. 0.003 m

B. 0.030 m

C. 0.300 m

D. 5.33 m

Correct Answer: B. 0.030 m

Robotics & Control Systems
Chapter 7 of 15