A Low-Cost Hardware-In-The-Loop Real Time Simulation of Control Systems
A Low-Cost Hardware-In-The-Loop Real Time Simulation of Control Systems
A Low-Cost Hardware-In-The-Loop Real Time Simulation of Control Systems
I. I NTRODUCTION
Our proposal (Fig. 1) was created with the purpose of
exploring some characteristics of control-supervision via PC:
resource sharing between both roles, constraints on sampling Fig. 2. Simulated System.
time, delay on communications, and coding for implementa-
tion; while avoiding hardware related complexities.
This platform is divided in the following modules: Where:
• Supervisor: Module in which the variables related to the ẋ1 x2
dynamics and the controller are displayed. ẋ2 = − M sin(x1 ) − B x2 + Km x3 (2)
J J J
Kω Rm KC
• Controller: Module in which the communications with the ẋ3 − nL m
x 2 − Lm x 3 + Lm u(t)
Dynamic Simulator are done, and control algorithms are
executed. This role, and the Supervisor one, are carried The numerical values of the coefficients are the following:
by a PC. M B Km
• Dynamic Simulator: Module in which the Real Time
= 1.4149030; = 0.587740053; = 0.94903793
J J J
Simulation of the Plant/Process behavior is executed. This
Kω Rm KC
role is fulfilled by an ARM ($55), and a SoC-FPGA = 11.2; = 128.0; = 120.0
($100). nLm Lm Lm
• Communications: The protocol used is TCP/IP over an The implemented controllers using this platform are: a lead
Ethernet layer. With this, multiple simulators can be con- compensator, a PID controller, and a pole placement by
trolled with a PC, without need for additional hardware. state feedback controller, all of them applied to a feedback
The simulated system corresponds to a nonlinear control linearized plant; and, a sliding mode controller (SMC) that
system for the angular position of a rod, mounted on a system exploits the structure of the normal form derived by feedback
of gears and shafts, rotated by the action of a DC motor (Fig. linearization.
2).
II. S IMULATION OF P LANT /P ROCESS DYNAMICS
The equations describing the plant dynamics can be reduced
to the following ones: Real Time Simulation needs a platform with dynamics as
T T close as possible to the simulated model or system. This
x = x1 x2 x3 = θ ω im (1) platform can be analog-based, digital-based or mixed. The
978-1-5090-6363-5/17/$31.00
c 2017 IEEE proposed system on this paper involves only digital platforms.
Fig. 4. Control-Supervision GUIs acting over two simulators (FPGA at left,
Fig. 3. FPGA Design. ARM at right). 1Hz plotting frequency.
The state evolution problem is solved using 4th Order Runge- to the parallel processing on FPGA and the independence
Kutta Method on the dynamics differential equations. between the Dynamic Simulator and communications. Also,
Two platforms were used to implement the Dynamic Simu- changes on the plant only involve changes on the Black Box.
lator: an FPGA was chosen to explore the performance of a The main constraints on the step size involve the following
highly customizable processor, and an ARM to explore the characteristics of the simulation problem:
performance of a programmer-friendly processor. Their step
• Calculation Complexity: Non-parallelizable calculations
sizes for the state evolution problem were 10us and 1ms,
constrain the minimum hardware-related step size. This
respectively.
kind of calculations come from sequential behavior and
A. ARM (Beaglebone Black Rev C) from limits on logic usage (only 40% was used on this
project, so, this is not a common issue).
On this platform, the implementation consists on making • Underflow and Slow Dynamics: Slow dynamics or small
software that fulfills the following functions: step sizes produce a small state displacement, which can
• Setup the TCP/IP Socket and the Initial States. cause underflow and drive off the dynamics from the
• Check if any incoming connections are waiting. If they desired system.
are, send the states and wait for the control action.
• Make the states of the Dynamic Simulator evolve. III. PC BASED C ONTROL AND S UPERVISION
The main constraint on the step size of this Dynamic Simulator A. PC Based Control-Supervision
is the time that the processor takes to verify if the TCP/IP
Socket has any incoming connections. Also, when TCP/IP The controller requirements are related to sampling time:
requests are attended, additional delay is introduced in the having one as small as possible (analog design), and also as
program, and the step size has to be changed during those stable as possible (digital design). The supervisor must show
cycles. the usual waveforms (states, tracking error and control action)
and track the sampling time characteristics.
B. SoC FPGA (DE0-NANO-SoC Module) The Controller-Supervisor program (Fig. 4) is based on
Python, with the GUI framework Qt GraphicView, over a
On this platform, the implementation consists on using the
Linux OS (Fedora 24). This GUI has the following features:
FPGA to create a processor which solves the dynamics of the
plant/process, while the HPS (ARM) of the SoC attends the • A main plot (upper) showing the reference signal and
Ethernet requests (for design simplicity, since that could be angular position; and a secondary one in which tracking
done on the FPGA). The AXI Bridge [1] connects the FPGA error, control action, states, or a loop time histogram can
fabric to the HPS of the SoC. The FPGA part of the design be plotted.
is shown on Figure 3. • Selection of control method, reference signal frequency,
The HPS-FPGA Interface executes instructions coming from plotting frequency, and the secondary plot signal.
the HPS (reset, measures, and control action update). The • A text box in which loop time statistics are printed.
Black Box module takes as input the current states and the 1) Loop Time Statistical Analysis: The analysis involve
control action, and calculates the evolved states after a defined recursive calculations of the mean and variance [2], maxi-
time step. This architecture is designed to simulate third order mum/minimum values, and a histogram of the loop time. Since
systems, but it can be extended to higher order ones by adding the histogram involves only discrete values on the horizontal
registers to store the additional states. axis, while the loop time has a continuous range; a convex
This implementation has the advantage of having a much sum between two neighbors was used to determine the how
smaller and stable time step on the Dynamic Simulator, due the histogram is updated with the new loop time measures.
2) Decimation: Continuous update of the plots slow down
the system, and this speed is not needed due to the limits on
visual perception; so, the graphs are updated with a reduced
frequency with respect to the sampling frequency.
B. Design and Implementation of Controllers
1) Feedback Linearization: It can be shown that the simu-
lated plant is feedback linearizable (for theory, see [3]). The
PID was designed by computerized optimization; while the (a) (b)
compensator and the state feedback were designed by defining
poles explicitly. To avoid derivative kick, the derivative term
of the PID was filtered by a first order LPF.
The normal form of the simulated plant can be obtained by
the transformation:
z1 x1
z2 = x2 (3)
M B Km
z3 − J sin(x1 ) − J x2 + J x3
And its dynamics are expressed by the following equation: (c) (d)
Fig. 5. Histograms vs. plotting frequency: a) 0.1Hz, b) 1Hz, c) 10Hz, d) 1Hz
ż1 z2 Double Simulation.
ż2 = z3 (4)
ż3 −a1 z3 − a2 z2 − β(z) + αu(t)
IV. S YSTEM T ESTS
Where:
Tests on how the sampling period and the controller effi-
B Rm Km Kω + nBRm ciency change with different design parameters are essential
a1 = + ; a2 =
J Lm nJLm to understand the system behavior. The variable parameters on
Km KC M M Rm the test were the plotting frequency, the Dynamic Simulator
α= ; β(z) = cos(z1 )z2 + sin(z1 ) platform, and the execution of control-supervision programs
JLm J JLm
for both Dynamic Simulators. The default values on the test
The transformation between the linear control v(t) and the are:
nonlinear controller u(t) can be expressed by the equation: The default values on the test are:
1 • Sampling period: 5 ms
u(t) = [v(t) + β(z)] (5)
α • Reference signal: 0.1Hz, 2 rad
The transfer function of the PID and Lead Compensator are: • Plotting frequency: 1Hz