Modeling and simulation of dynamic systems
Neglecting the inductance of a small motor is almost always reasonable. With 10 mH and low inertia, the simplified model fails to see that the speed overshoots by 70 % before settling.
01From the physical system to the equations
To design a controller you need a model of the plant: equations that describe how it responds to its inputs. It is obtained by applying the physical laws of each domain, Kirchhoff's laws in circuits, Newton's laws in mechanics, energy and mass balances in thermal and chemical processes, and linearizing around the operating point. The analogies between domains mean that the same type of equation describes very different systems:
| Domain | Effort | Flow | Stores energy | Dissipates |
|---|---|---|---|---|
| Electrical | Voltage | Current | Capacitance, inductance | Resistance |
| Rotational mechanical | Torque | Angular velocity | Inertia, spring | Viscous friction |
| Thermal | Temperature | Heat flow | Thermal capacitance | Thermal resistance |
| Hydraulic | Pressure | Flow rate | Tank, fluid inertance | Restriction |
02A complete example: the DC motor
The permanent-magnet DC motor couples an electrical circuit, with resistance \( R \) and inductance \( L \), and a mechanical load, with inertia \( J \) and friction \( b \). The back EMF is \( K\omega \) and the torque is \( Ki \). With the state variables \( i \) and \( \omega \):
03State space and transfer function
The same model can be written in two ways. In state space, as a system of first-order equations in matrix form, which admits several inputs and outputs, initial conditions and nonlinearities, and is integrated numerically. With the Laplace transform and zero initial conditions, as a transfer function between one input and one output:
A motor with R = 1 Ω, K = 0.05 V·s/rad and b = 10⁻⁵ N·m·s, driven by a 12 V step. The blue curve is the speed of the full model, integrated with fourth-order Runge-Kutta in 4000 steps; the dotted one, that of the first-order model; below, the current.
04Simulation
To simulate is to integrate the state equations numerically. Euler's method advances using the derivative at the start of the step; fourth-order Runge-Kutta averages four derivatives and is much more accurate with the same step. The step has to be considerably smaller than the fastest time constant of the system: if there are very different constants, the system is stiff and a variable-step or implicit integrator is preferable. The usual tools, such as Simulink, Xcos, Modelica or the Python libraries, do this automatically, but the model is written by the engineer.
05In the lab
Measure R with the motor stalled, K with the motor unloaded as a generator, and τm with the speed step response. Build the model and compare the simulation with the measurement.
Simulate the motor in Python with both methods and different steps, and compare with the exact solution.
Model a heated block with its thermal capacitance and resistance and verify the time constant with a measurement.
06Common mistakes
- Using the model away from the point where it was linearized. With large excursions, the nonlinearities change the response.
- Neglecting the inductance without checking. It is only valid if the electrical constant is much smaller than the mechanical one.
- Simulating with a large step. The simulation can oscillate or diverge even if the system is stable.
- Confusing the transfer function with the system. It describes one input and one output with zero initial conditions.
07Self-assessment
What final speed does the lab motor reach with 12 V?
\( K V/(Rb + K^2) = 0.6/0.00251 \approx 239 \) rad/s.
What is τm with J = 10⁻⁵ kg·m²?
\( 10^{-5}/0.00251 \approx 4 \) ms.
How many state variables does a system with two independent capacitors and one inductor need?
Three.
What is the relationship between the poles of the transfer function and the matrix A?
The poles are the eigenvalues of A.
08Further reading
- Katsuhiko Ogata. System Dynamics. 4th ed., Pearson Prentice Hall, 2004 (Spanish edition: “Dinámica de sistemas”, Prentice Hall Hispanoamericana, 1987). The modeling of mechanical, electrical, thermal and hydraulic systems with the same method.
- Norman S. Nise. Control Systems Engineering. 8th ed., Wiley, 2019. State-space and transfer-function modeling with many examples.
- Gene F. Franklin, J. David Powell and Abbas Emami-Naeini. Feedback Control of Dynamic Systems. 8th ed., Pearson, 2019. Models of real systems, from the motor to the airplane, and their simulation.