Intelligent Control Systems

Chapter 6
Neural Networks for Control

Bachelor Program in Mechatronics Engineering
Intelligent Control Systems   •   Bachelor

Neural Networks for Control

Introduction and Context

A neural network is a parameterized nonlinear function that maps measured inputs to outputs through interconnected computational units. In intelligent control, neural networks are valuable because many mechatronic plants are nonlinear, uncertain, coupled, and difficult to model analytically. Examples include robot manipulators with friction and payload variation, electric drives with saturation, autonomous vehicles with changing dynamics, and thermal systems with delays.

A neural network does not automatically provide a safe controller. Its usefulness depends on the quality of data, the architecture, the training procedure, the operating range, and the way it is integrated with feedback, constraints, and stability analysis. The central engineering principle is therefore:

Use learning to represent uncertainty or nonlinear relationships, while retaining the structure, safety mechanisms, and verification practices of control engineering.

This chapter develops neural-network methods for system modeling, inverse control, function approximation, and nonlinear control. It also addresses generalization, online learning, recurrent networks, computational limitations, and stability.

Learning Objectives

After studying this chapter, the student should be able to:

  1. Explain the structure and operation of feedforward and recurrent neural networks.
  2. Formulate neural-network models of dynamic systems.
  3. Train networks using gradient-based methods and validate their generalization.
  4. Design direct and inverse neural controllers.
  5. Distinguish offline learning, online adaptation, and reinforcement-based learning.
  6. Identify stability, robustness, computational, ethical, and safety issues.
  7. Select an appropriate neural architecture for a mechatronic control problem.

1. Neural Networks as Function Approximators

A single artificial neuron computes a weighted sum followed by an activation function:

z = ∑ᵢ wᵢxᵢ + b, y = φ(z)

Here, xᵢ are input features, wᵢ are weights, b is a bias, z is the pre-activation value, φ is the activation function, and y is the neuron output. Inputs and weights are dimensionless in the mathematical model, although physical inputs must normally be scaled before training.

Common activation functions include the sigmoid, hyperbolic tangent, and rectified linear unit (ReLU):

σ(z) = 1/(1 + e⁻ᶻ), tanh(z) = (eᶻ − e⁻ᶻ)/(eᶻ + e⁻ᶻ), ReLU(z) = max(0,z)

Sigmoid outputs lie in (0,1), tanh outputs lie in (−1,1), and ReLU is unbounded above. Tanh is often useful when signals are normalized symmetrically. ReLU is computationally simple, but may become inactive when its input is persistently negative.

A multilayer perceptron (MLP) with L layers can be represented recursively as:

a⁽⁰⁾ = x,

a⁽ˡ⁾ = φ⁽ˡ⁾(W⁽ˡ⁾a⁽ˡ⁻¹⁾ + b⁽ˡ⁾), l = 1,...,L

where x is the input vector, W⁽ˡ⁾ is the weight matrix, b⁽ˡ⁾ is the bias vector, and a⁽ˡ⁾ is the output of layer l. The final activation is often linear for regression, bounded for constrained outputs, or task-specific for classification.

The universal approximation result states, informally, that a feedforward network with a suitable nonlinear activation and sufficient hidden units can approximate any continuous function on a compact domain to arbitrary accuracy. This is an existence result, not a guarantee that training will find the required parameters, that extrapolation will be safe, or that the approximation will be computationally efficient.

Function Approximation in Control

A static plant relationship may be written as y = f(x), where x may contain position, velocity, current, temperature, or command variables. A network approximates f by f̂(x;θ), where θ denotes all weights and biases. The approximation error is:

ef(x) = f(x) − f̂(x;θ)

The error is generally small only in, or near, the domain represented by training data. Thus, normalization, coverage of operating conditions, and independent testing are essential.

2. Neural Networks for Dynamic System Modeling

A dynamic plant is described by state evolution and output equations:

xₖ₊₁ = f(xₖ,uₖ) , yₖ = g(xₖ,uₖ)

where xₖ is the state at sample k, uₖ is the control input, yₖ is the measured output, and the sampling period is Tₛ seconds. A neural state-space model replaces unknown functions with learned approximations:

x̂ₖ₊₁ = f̂(x̂ₖ,uₖ;θf), ŷₖ = ĝ(x̂ₖ,uₖ;θg)

In many applications the true state is not measured. An autoregressive model with exogenous input (NARX) therefore uses measured histories:

ŷₖ₊₁ = F̂(yₖ,yₖ₋₁,...,yₖ₋ₙ₊₁, uₖ,uₖ₋₁,...,uₖ₋ₘ₊₁;θ)

The integers n and m specify the output and input memory orders. This approach is practical when sensors provide output measurements but not all physical states.

For one-step prediction, a common mean-square loss is:

J(θ) = (1/N)∑ₖ ‖yₖ − ŷₖ(θ)‖²

N is the number of samples and ‖·‖ is the Euclidean norm. For vector outputs, the loss sums squared errors across output channels. If output units differ greatly, a weighted loss should be used, with weights selected to reflect scaling or engineering importance.

One-step accuracy does not necessarily imply good long-horizon simulation. During free-running simulation, the model feeds its own predictions back as future inputs, so small errors can accumulate. Validation should therefore include multi-step prediction, transient behavior, steady-state behavior, and operation near constraints.

Data Preparation

A representative workflow is:

  1. Define safe operating limits and measurable variables.
  2. Excite the plant over the intended operating envelope using safe commands.
  3. Remove or flag corrupted samples, while preserving meaningful transients.
  4. Divide data chronologically into training, validation, and test sets when temporal leakage is possible.
  5. Normalize each variable using training-set statistics only.
  6. Train several candidate models and compare independent test performance.

A common standardization is:

x̃ = (x − μₓ)/σₓ

where μₓ and σₓ are the training mean and standard deviation. The same values must be stored and used during deployment. If σₓ = 0, the variable is constant and should not be standardized by this expression.

3. Training, Regularization, and Generalization

Training adjusts θ to reduce a loss. With gradient descent:

θₜ₊₁ = θₜ − η∇θJ(θₜ)

where η > 0 is the learning rate and ∇θJ is the gradient of the loss with respect to all parameters. Backpropagation efficiently calculates these gradients by applying the chain rule through the network.

A practical objective may include a regularization term:

Jtotal = Jdata + λR(θ)

where R(θ) penalizes undesirable parameter values and λ ≥ 0 controls its strength. L2 regularization commonly uses R(θ) = ‖θ‖², discouraging excessively large weights. Early stopping, dropout, data augmentation, and reduced network size are additional methods for limiting overfitting.

Overfitting occurs when a network fits training noise but performs poorly on unseen data. Underfitting occurs when the model lacks the capacity or training needed to represent the relationship. The validation set supports design decisions; the test set should be used sparingly for final assessment.

Relevant evaluation measures include root mean square error:

RMSE = √[(1/N)∑ₖ(yₖ − ŷₖ)²]

and mean absolute error:

MAE = (1/N)∑ₖ|yₖ − ŷₖ|

These measures have the same units as the output. A controller evaluation must go beyond prediction error and include overshoot, settling time, control effort, constraint violations, disturbance rejection, and failure behavior.

A network generalizes reliably only within a sufficiently represented region. Out-of-distribution detection can use distance from training data, ensembles, uncertainty estimates, or monitored residuals. These methods indicate possible risk; they do not prove safety.

4. Neural Inverse Control

If a plant has an approximate inverse, a network can learn the input required to produce a desired output. For a static relationship y = f(u), an inverse network learns û = f̂⁻¹(yᵈ). For dynamic systems, the desired trajectory and measured history are usually needed:

ûₖ = Ĉ(yᵈₖ₊₁, yₖ, yₖ₋₁,...,uₖ₋₁,...)

A direct inverse controller is simple but has important limitations. The inverse may be nonunique, unstable, discontinuous, or nonexistent. Actuator saturation and plant delays also prevent exact inversion. For a nonminimum-phase plant, attempting to invert unstable zero dynamics can produce unsafe commands.

A safer architecture combines a conventional feedback controller with a learned feedforward term:

uₖ = uFB,ₖ + uNN,ₖ

The feedback component corrects errors and provides known robustness, while the network compensates for repeatable nonlinearities such as gravity, friction, or load-dependent torque. Saturation, rate limiting, and supervisory logic should be applied after combining commands.

Another approach is model predictive control (MPC) using a neural plant model. At each sample, the controller predicts future outputs over a horizon, optimizes a cost subject to constraints, applies only the first input, and repeats. This can manage constraints more explicitly but requires sufficient computation and a trustworthy model.

5. Neural Nonlinear Control and Stability

Consider a nonlinear system:

ẋ = f(x) + g(x)u

A neural controller may approximate an unknown feedback law u = κ(x), or approximate uncertain terms in a model-based controller. For example:

u = umodel − κNN(x) − K e

where e is a tracking error, K is a positive feedback gain or gain matrix, and κ_NN estimates an uncertain nonlinear term. The exact signs and dimensions depend on the plant model.

Stability cannot be inferred merely from low training loss. In continuous-time analysis, a Lyapunov candidate V(x) is positive definite near the desired equilibrium if V(0)=0 and V(x)>0 for x≠0. Stability is supported when its derivative along system trajectories satisfies:

V̇(x) = ∇V(x)ᵀẋ ≤ 0

Strict negativity, V̇(x)<0 for x≠0, gives a stronger asymptotic-stability condition under standard regularity assumptions. If a neural approximation introduces an error d(x), a robust design must bound that error or ensure that feedback dominates it in the relevant region.

For discrete-time systems, the analogous condition uses a difference:

∆V(xₖ) = V(xₖ₊₁) − V(xₖ) ≤ 0

These conditions must be checked on the actual closed-loop system, including actuator limits, sampling, delays, quantization, and disturbances. Region-of-attraction claims are local unless global conditions are established.

Practical safeguards include:

  • bounded network outputs and explicit actuator saturation;
  • a fallback controller for abnormal predictions;
  • rate and acceleration limits;
  • control barrier or constraint-monitoring mechanisms;
  • online residual and sensor-health monitoring;
  • simulation, hardware-in-the-loop, and staged physical tests;
  • conservative operation outside the training domain.

6. Recurrent Networks and Temporal Dependencies

Feedforward networks require history to be supplied explicitly. Recurrent neural networks (RNNs) maintain an internal state:

hₖ = ψ(Wₓxₖ + Wₕhₖ₋₁ + bₕ), ŷₖ = Wyhₖ + by

Here hₖ is the hidden state, Wₓ and Wₕ are input and recurrent weight matrices, and ψ is an activation function. RNNs can represent temporal dependencies, but repeated multiplication through time may cause vanishing or exploding gradients.

Long short-term memory (LSTM) and gated recurrent unit (GRU) architectures introduce gates that regulate information retention and forgetting. They are useful for systems with long delays or unmeasured dynamic states, but their additional parameters increase training and deployment costs. A recurrent controller also creates an internal state whose initialization, reset behavior, and failure handling must be specified.

Training recurrent networks often uses backpropagation through time. Truncated sequences reduce memory and computation but may limit learning of long dependencies. For control, sequence length should reflect the physically relevant memory rather than be selected solely by software convenience.

7. Online Learning and Adaptation

Offline learning trains a network before deployment using stored data. It is comparatively reproducible and easier to validate. Online learning updates parameters during operation, for example:

θₖ₊₁ = θₖ − ηₖ∇θℓₖ(θₖ)

where ℓₖ is the current or recent-sample loss and ηₖ is an adaptation gain. Online adaptation can track changing payloads, wear, temperature, or friction, but it introduces risks: noisy gradients, biased data, actuator excitation, computational overload, and catastrophic forgetting.

Safe online learning should use bounded parameter updates, learning-rate limits, persistent monitoring, a trusted baseline controller, rollback capability, and a clearly defined adaptation envelope. Updating from closed-loop data can also create identification bias because the controller determines which states are visited. Deliberate excitation must never compromise safety.

Reinforcement learning (RL) learns a policy through interaction using rewards rather than direct target labels. A typical discounted return is:

Gₖ = ∑ₜ₌₀^∞ γᵗrₖ₊ₜ₊₁, 0 ≤ γ < 1

where r is reward and γ is the discount factor. In physical control, unrestricted trial-and-error is unacceptable for many systems. Simulation, constraint-aware algorithms, safety filters, and transferring only a verified policy component are therefore important.

8. Computational and Implementation Constraints

A neural controller must execute within the sampling period. If inference takes longer than Tₛ, commands may be delayed or missed. Important resource measures include parameter count, multiply-accumulate operations, memory, worst-case execution time, and energy consumption.

Deployment often requires quantization, pruning, lower-precision arithmetic, or a smaller architecture. These changes can alter outputs and must be validated in closed loop, not only by comparing prediction error. Fixed-point implementation requires attention to overflow, underflow, scaling, and numerical resolution.

Sensor latency and asynchronous sampling can be as damaging as network error. Time stamps, synchronization, filtering delay, and actuator communication must be included in the model or control analysis. Cybersecurity is also relevant: manipulated sensor data, poisoned training data, and unauthorized model updates can cause unsafe commands.

9. Applied Case: Neural Compensation for a Two-Link Robot

Background

This illustrative case concerns a laboratory two-link robot arm. A conventional computed-torque controller tracks joint position, but performance degrades when payload and friction change. The robot has joint position and velocity sensors, torque limits, and a digital controller with a 1 ms sampling period.

Problem

The rigid-body model captures inertia, Coriolis effects, gravity, and nominal friction, but unmodeled friction and payload variation produce steady tracking errors. A neural network is considered as a replacement for, or supplement to, the model-based controller.

Analysis

A direct neural controller would need to learn the entire mapping from desired trajectory and measured state to torque. This requires broad training data and provides limited guarantees. A residual strategy is safer. Let τ_model be the nominal computed torque and let the network estimate a correction:

τ = sat[τmodel(q,q̇,qd,q̇d,q̈d) + τNN(q,q̇,qd,q̇d)]

q and q̇ are measured joint position and velocity, q_d, q̇_d, and q̈_d are desired trajectory quantities, and sat denotes actuator saturation. The network output has two components, one per joint, and is trained from recorded tracking data.

Training trajectories should cover speeds, directions, payloads, and representative configurations. Data are split by complete trajectories, not randomly by individual samples, to avoid placing nearly identical neighboring samples in both training and test sets. Inputs and torque outputs are normalized using training statistics.

Approach and Solution

The design uses a compact MLP with two hidden layers and tanh activations. The nominal controller remains active during training and initial deployment. Network updates are first performed offline. The test procedure includes trajectory tracking, payload changes, sensor noise, torque saturation, communication delay, and emergency fallback.

The network contribution is bounded componentwise, and a supervisory monitor disables it when residuals exceed a threshold or the input leaves the validated operating envelope. A low-pass filter is avoided unless its phase delay is included in testing; otherwise it could reduce apparent noise while degrading stability.

Outcome

In this illustrative scenario, the residual controller reduces repeatable tracking error relative to the nominal controller while preserving fallback operation. It does not eliminate errors under unseen payloads, nor does it establish global stability. The appropriate engineering conclusion is conditional improvement within a tested region, not universal superiority.

Learning Points

The case demonstrates why residual learning is often preferable to replacing a known physical model, why trajectory-level validation matters, and why output bounds, timing analysis, and fallback control are part of the neural-controller design rather than optional additions.

10. Best Practices, Limitations, and Governance

Best practice begins with the control objective and safety requirements, not with selecting the largest network. Use physics-based variables where available, preserve known structure, document data provenance, and test edge cases. Maintain version control for datasets, preprocessing, model parameters, firmware, and calibration constants.

Important limitations include poor extrapolation, sensitivity to distribution shift, lack of transparent physical interpretation, dependence on sensor quality, and possible instability when the learned element interacts with feedback. Prediction uncertainty is not the same as control risk: a small average error can conceal a dangerous rare error near a constraint.

For safety-related mechatronic systems, neural components should be treated as safety-relevant software when their failure can affect hazards. Applicable organizational processes may include risk assessment, traceability, verification and validation, cybersecurity controls, change management, and independent review. The exact regulatory standard depends on the industry and jurisdiction; engineers must consult the relevant machinery, automotive, aerospace, medical, or functional-safety framework rather than assume that a general AI guideline is sufficient.

Contemporary developments include physics-informed networks, neural ordinary differential equations, differentiable simulation, uncertainty-aware ensembles, safe reinforcement learning, neural operators, and hybrid model-learning architectures. These approaches are promising, but complexity can make verification harder. A method is appropriate only when its performance, timing, and failure modes are acceptable for the application.

Chapter Summary

Neural networks provide flexible nonlinear function approximators for mechatronic control. Feedforward networks can model static mappings and dynamic behavior when histories are supplied; recurrent networks represent temporal dependence through internal states. System identification may use neural state-space or NARX models, but one-step prediction accuracy must be distinguished from long-horizon simulation quality.

Training requires suitable data, normalization, gradient-based optimization, regularization, and independent validation. Inverse networks can generate feedforward commands, although nonunique inverses, delays, unstable zeros, and saturation limit their use. Residual neural control combines learned compensation with a trusted feedback or physics-based controller.

Low training loss does not guarantee generalization or closed-loop stability. Lyapunov and discrete-time analyses, bounded outputs, fallback controllers, constraint monitoring, and staged testing are central safeguards. Online learning can adapt to changing plants but requires bounded updates and governance. Recurrent architectures address memory at the cost of additional state and computation. Finally, timing, quantization, cybersecurity, traceability, and industry safety requirements must be included in engineering decisions.

Key Terms

Neural network: A parameterized computational model composed of interconnected nonlinear units.

Neuron: A unit that applies an activation function to a weighted sum and bias.

Activation function: A nonlinear function applied to a neuron’s pre-activation value.

Multilayer perceptron: A feedforward network organized into input, hidden, and output layers.

Universal approximation: The ability of suitable networks to approximate broad classes of continuous functions on compact domains.

System identification: Learning a mathematical model of a plant from measured data.

NARX model: A nonlinear autoregressive model using exogenous input and signal histories.

Loss function: A numerical measure of disagreement between predictions and target data.

Backpropagation: Efficient gradient calculation through a layered computational graph.

Regularization: A method for discouraging overfitting or undesirable parameter values.

Generalization: Performance on data not used during parameter fitting.

Inverse control: Control based on estimating the input needed to produce a desired output.

Residual learning: Learning the difference between a nominal model and actual plant behavior.

Recurrent neural network: A network with an internal state that carries information over time.

LSTM: A gated recurrent architecture designed to retain information over long sequences.

Online learning: Updating model parameters during operation.

Lyapunov function: A scalar function used to analyze stability of an equilibrium.

Distribution shift: A change between training conditions and deployment conditions.

Fallback controller: A trusted controller activated when a learned component is unreliable.

Quantization: Representing numerical parameters or signals with finite precision.

Review Questions

5 Short Answer Questions

  1. What is the purpose of an activation function in a neural neuron?
  2. Distinguish training, validation, and test data.
  3. Why can a one-step-accurate dynamic model perform poorly in long-horizon simulation?
  4. State two limitations of direct neural inverse control.
  5. Why is a fallback controller useful in a neural control architecture?

5 Long Answer Questions

  1. Explain how a neural NARX model can represent a dynamic mechatronic plant, including the role of input and output histories.
  2. Describe gradient descent, backpropagation, regularization, and early stopping in neural-network training.
  3. Compare direct neural control, residual neural control, and neural-model-based MPC.
  4. Explain how Lyapunov reasoning can be used to assess a neural nonlinear controller and why low prediction error is insufficient.
  5. Discuss the engineering consequences of recurrent architectures, online learning, and embedded computational constraints.

3 Analytical / Application Questions

  1. A motor controller performs well for loads represented in its training data but becomes oscillatory for a new load. Propose a diagnostic and safety procedure addressing distribution shift, model uncertainty, and fallback control.
  2. Design a data-collection and validation plan for a neural friction-compensation model in a robot joint. Specify variables, operating coverage, data splits, metrics, and deployment safeguards.
  3. A proposed neural controller requires 1.4 ms for inference, while the control sampling period is 1 ms. Analyze the problem and recommend at least three technically justified remedies, including their possible drawbacks.

Multiple Choice Questions with Answers

Question 1

Which expression represents a standard gradient-descent parameter update?

A. θₜ₊₁ = θₜ + η∇θJ(θₜ)

B. θₜ₊₁ = θₜ − η∇θJ(θₜ)

C. θₜ₊₁ = ηθₜ − ∇θJ(θₜ)

D. θₜ₊₁ = θₜ/η + ∇θJ(θₜ)

Correct Answer: B. θₜ₊₁ = θₜ − η∇θJ(θₜ)

Question 2

What is the main purpose of a validation set?

A. To replace all training data

B. To provide actuator power

C. To support model and training decisions without serving as the final unbiased test

D. To guarantee closed-loop stability

Correct Answer: C. To support model and training decisions without serving as the final unbiased test

Question 3

In a NARX model, the network input commonly contains:

A. Only a constant bias

B. Past outputs and past or present exogenous inputs

C. Only future actuator commands

D. Only network weights

Correct Answer: B. Past outputs and past or present exogenous inputs

Question 4

Why is direct inversion of a nonminimum-phase plant potentially unsafe?

A. It always removes all delays

B. It can attempt to reproduce unstable zero dynamics

C. It guarantees bounded actuator signals

D. It eliminates the need for feedback

Correct Answer: B. It can attempt to reproduce unstable zero dynamics

Question 5

For a continuous-time Lyapunov analysis, which condition is associated with non-increasing V along trajectories?

A. V̇(x) ≤ 0

B. V̇(x) ≥ 1

C. V(x) < 0 for all x

D. V̇(x) = ∞

Correct Answer: A. V̇(x) ≤ 0

Question 6

What is a principal advantage of residual neural control?

A. It removes the need for sensors

B. It combines learned compensation with a nominal controller

C. It guarantees global stability without analysis

D. It requires no training data

Correct Answer: B. It combines learned compensation with a nominal controller

Question 7

Which architecture explicitly maintains an internal temporal state?

A. Static linear regression

B. Recurrent neural network

C. Single normalization layer

D. Pure actuator saturation

Correct Answer: B. Recurrent neural network

Question 8

If inference takes longer than the sampling period, the immediate engineering concern is:

A. Improved phase margin automatically

B. Command delay or missed control deadlines

C. Guaranteed lower energy use

D. Removal of quantization error

Correct Answer: B. Command delay or missed control deadlines

Question 9

For the standardization formula x̃ = (x − μₓ)/σₓ, μₓ and σₓ should normally be calculated from:

A. The deployment sample only

B. The training data

C. The actuator datasheet only

D. Randomly selected future data

Correct Answer: B. The training data

Question 10

Which practice best supports safe online learning?

A. Unlimited parameter updates with no monitoring

B. Disabling the baseline controller permanently

C. Bounded updates, monitoring, and rollback or fallback capability

D. Training exclusively on corrupted sensor data

Correct Answer: C. Bounded updates, monitoring, and rollback or fallback capability

Intelligent Control Systems
Chapter 6 of 14