Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
Transcript of Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
1/7
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
2/7
2 Copyright 2013 by ASME
case, the Real-time Windows Target could enhance the
learning experience as it enables students to observe the
plants immediate response when parameters are changed.
With the aforementioned benefits (i.e. a single
environment for simulation and implementation and real-time
turning) in mind, we naturally chose Simulink instead ofMatlab for the intelligent control course ME 595F which
covers neural networks and fuzzy logic. However, the
microcontroller selection encountered a dilemma as we
intended to choose a platform compatible with the Student
Version of Simulink while providing both benefits.Unfortunately, Real-time Windows Target is not availableon the Student Version, so the choice of microcontrollers is
very limited because very few microcontrollers can
implement real-time tuning in Simulink without Real-time
Windows Target. HILINK (Figure 1) became our final
selection because it uses Simulink as the single environment
for both simulation and implementation and does not requireReal-time Windows Target for real-time tuning. HILINK,
developed by Zeltom, LLC, is a low cost, real-time control
board designed for implementation of hardware-in-the-loopreal-time control systems. It provides a variety of I/Os and
includes Simulink library blocks (see Figure 2) associated
with each input and output. Students can simply drag-and-
drop these blocks to create connections between the Simulink
model and external hardware.
Figure 1: HILINK Hardware
Figure 2: HILINK SIMULINK Library Input and OutputBlocks
We intend to share our experience of using HILINK as a
hardware platform in teaching advanced control coursesthrough this paper. We will present how HILINK is used in
developing and implementing a neural network controller for
the DC motor speed control. The paper is organized as follows:
we first describe the experimental setup for the DC motor speed
control. Then we explain the NARMA-L2 controller design
process using the neural network toolbox, followed by results.
The paper concludes with the summary of experiences in usingHILINK and our recommendations for interested instructors in
control engineering education.
EXPERIMENTAL SETUP DESCRIPTION
As a typical control problem, speed control of a DC motor
was also used in ME595 so students can compare the neural
network control design with the PID control they are familiar
with. The DC motor speed control system consists of a PC
running Simulink, a DC motor with encoder, and HILINK
which transfers the control signal and the sensor measure
between the PC and the DC motor through a serial port, asshown in Figure 3 without PC.
Figure 3: HILINK board (right) and DC motor (left) setup.
HILINK has a broad range of inputs and outputs including
eight analog inputs, two capture inputs, two encoder inputs, one
digital input, two analog outputs, two frequency outputs, two
pulse outputs, and one digital output. , some of which are
multiplexed. For the DC motor speed control application, only
the encoder input and one pulse output for the sensor
measurement and the control signal, respectively (see Figure 3).
The board interfaces via a serial port with a host computer
running Matlab/Simulink. A HILINK library to allow for
accessing HILINK hardware inputs and outputs is included forintegrating with Matlab/Simulink in a real-time Windows
environment (Figure 2). The real-time operation for theHILINK platform operates to a maximum 3.8 kHz sampling
rate.
The DC Motor is a 12V brushed permanent magnet motorwith a 12 bit encoder with 1024 pules per revolution (the angle
resolution of2 / 4096 rad). The computer used in this project
is Dell Precision T3600 running 64bit Windows 7 and has 2G
RAM. The suite of required software includes Simulink 7.9,
Neural Network Toolbox 7.0.3, and HILINK software 1.5.
Serial Connection
Power SupplyH-Bridge
Connection
EncoderConnection
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
3/7
3 Copyright 2013 by ASME
The information exchange between the host computer and
the DC motor is executed by a simple Simulink model shown
in Figure 4. The blocks E0 and H0 represent the encoder input
and the H-bridge PWM output, respectively. The transfer
function, 1/ (0.09 1)s , is a low pass filter to smooth out the
captured encoder signal, and Gain2 is used for unit conversion
so users can choose speed output either in rad/s or rpm. As thepower supply voltage is 12V, Gain3 takes the value of 1/12
to represent the duty cycle of the output PWM signal. The
Out1 and In1 in Figure 4 represent the encoder output velocity
and the controller input of the masked model shown in Figure
5.
Figure 3: DC motor plant HILINK interface sub-blocks.
Figure 5: DC motor plant block diagram.
It can be easily seen from the above description that
programming HILINK can be done within minutes by simple
drag-and-drop operations as the I/Os have been representedby Simulink library blocks.Next, we will present the neural network controller design
and implementation.
CONTROLLER DESIGN AND IMPLEMENTATION
The Neural Network Toolbox is used for controller
design as it provides three popular neural network
architectures for control including model predictive control,
NARMA-L2 control, and model reference control [7].
NARMA-L2 was chosen as the controller requires the least
computation of these three architectures [7].The design of NARMA-L2 controller goes through two
stages: system identification and control design. First, a neuralnetwork model of the plant is developed and trained offline in
batch form. Then the controller is simply a rearrangement ofthe neural network plant model.
A Simulink model for NARMA-L2 control of DC motor
speed control is created as shown in Figure 6. The blue
block represents the NARMA-L2 provided by Neural
Network Toolbox. As described in the previous section, the
masked block, named DC Motor Plant, handles the control
and measurement signal transfer between the computer and the
DC motor. The signal generator provides the reference signal
for the DC motor.
Figure 6: Block diagram of entire control system model.
NARMA-L2 Controller
The Nonlinear Autoregressive-Moving Average (NARMA)model represents general discrete-time nonlinear systems.
NARMA-L2 control linearizes non-linear system dynamics bytransforming the nonlinearities. For this case, the plant model
and the training model are the same form, so the control is
referred to as NARMA-L2 rather than feedback linearization
(Figure 5). The NARMA-L2 uses an approximate model
(companion form) to represent the system:
(k + d)=f[y(k),y(k1),,y(kn + 1), u(k1),, u(km +1)]+
g[y(k),y(k1), ,y(kn + 1), u(k1),, u(km + 1)] u(k)
where y(k) is the system output, u(k) is the system input, andthe format y(k+d)= yr(k+d) indicates the system output followsa reference trajectory. To avoid realization problems, the
NARMA-L2 model typically used is
y(k + d) =f[y(k),y(k1), ,y(kn + 1), u(k), u(k1), , u(kn + 1)]
+g[y(k),,y(kn + 1), u(k),, u(kn + 1)] u(k + 1)
where d 2. As a result, the controller becomes
( + 1 ) =( + ) [(), ,( + 1),(), , ( + 1)]
[(), , ( + 1),(), ,( + 1)]
, which is realizable for d 2.
For this setup, however, the training model used is the DC
Motor plant model discussed in the previous section. The
NARMA-L2 block used in Figure 6 is illustrated in Figure 7
where TDL stands for tapped delay line which represents thedelayed signals in the controller.
System Identification
The NARMA-L2 controller block (Figure 7) is used to trainthe output of the plant to match the reference signal, and the
system identification window is shown in Figure 8.
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
4/7
4 Copyright 2013 by ASME
Figure 7: NARMA-L2 algorithm controller block representation.This shows the workings inside the library block included in theMATLAB neural network toolbox.
Figure 8: NARMA-L2 controller block GUI plant identificationnstage.
Through trial-and-error, the size of 20 neurons was
decided for the hidden layer, and 1,000 training samples were
used for system identification. As the H-bridge works in a
shifted mode which indicates a voltage between 0V and 6V
will result in a clockwise rotation while a voltage between 6V
and 12V will result in a counter clockwise rotation. Forsimplicity, we only consider the counter clockwise rotation.
Therefore, the input signals are limited to 6.2V and 10.8V so
the motor will rotate in a moderate speed to ensure reliable
encoder readings. The behavior of the motor compared to the
reference signal should match the range and therefore theplant should output between 325 and 175 radians per second.
These input and output values should be sent with a minimum
interval of 0.01 seconds and a maximum interval of 1 second.
Training Data for the control block is generated by using the
Generate Training Data operation.
The Generate Training Data Operation sends 10,001 test
inputs between the set minimum and maximum values into the
DC motor plant. The corresponding plant output velocity values
are then compared with the plant input values. The operationthen adjusts the weights using the user specified learning
algorithm (see Bias and Weight Setting section). In this
simulation, a comparison of the 10,0001 input and output data
samples collected over a period of 1000 seconds reveals a
proportionality between their rates of change (Figure 9). Thistranslates into corresponding input based velocity changes in
the DC Motor rotations. Using this collected data that can be
exported for saving and imported for later use.
Figure 9: Plant training data results collected over 1000 seconds ata 0.1s sampling rate for a total of 10,000 data samples.
The learning algorithm used in the training of the Narma-L2
controller was the Levenberg-Marquardt Algorithm (LMA) [7].The training results for our plant are portrayed below in Figures
10-16. As can bee seen in Figure 10, the neural network model
never matches the plant output perfectly modeling neverreaches a zero error state. Yet because the performance of the
controller is based on the total sum of the point squared errors
this number will tend to be higher for training data with a large
amount of samples. Increasing the number of neurons in the
network produced small improvements in its performance but
at the cost of a significant increase in training duration. Inaddition, regardless of the number of neurons utilized in the
training, and because we utilized validation data in the training,the maximum number of epochs was never reached without
encountering a validation check stop condition. That is, a point
at which the mean squared error of only the points used for
validation increased for 6 consecutive iterations. Figures 11-13
compare the plant input, plant output, neural network output,
and the total system error based only on training, validation,
and testing data respectively.
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
5/7
5 Copyright 2013 by ASME
Figure 10: LMA neural network training tool results.
Figure 11: Model performance based on training data.
Figure 42: Model performance based on validation data.
The overall performance of the system identificationprogress is based on four different criteria: MSE, Gradient, m,
and validation. Once those conditions are met, the system
reverts to those weight and bias values providing the lowest
validation MSE.
The other three parameters are plotted as part of the final
series of outputs for the users beneft as shown in F igure 15.
The gradient value represents the derivative of the networkerror based on the change of the current weights and biases.
The mu parameter represents an internal paramanter of theLMA calculation and serves to determine how the method will
approximate the Hessian matrix in each particular time step[7].Finally, the validation plot shows all failed validation checks
through the duration of training.In reference to the training parameters, the regression plots
(Figure16) indicate the resulting data points deviation from the
best fit, providing a measure of their linearity.
Figure 53: Model performance based on testing data.
0 100 200 3000
100
200
300
400Input
0 100 200 300
0
200
400
600
Plant Output
0 100 200 300-200
0
200
400
600Error
time (s)
0 100 200 300
0
200
400
600
NN Output
time (s)
0 50 100 1500
100
200
300
400Input
0 50 100 150
0
100
200
300
400
500
Plant Output
0 50 100 150-150
-100
-50
0
50
100Error
time (s)
0 50 100 150
0
100
200
300
400
500
NN Output
time (s)
0 50 100 1500
100
200
300
400Input
0 50 100 150
0
100
200
300
400
500
Plant Output
0 50 100 150-150
-100
-50
0
50
100
Error
time (s)
0 50 100 150
0
100
200
300
400
500
NN Output
time (s)
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
6/7
6 Copyright 2013 by ASME
Figure 65: Other training states and parameter of finalcontroller training.
Figure 76: Regression of all three data point types separatelyand combined.
The simulation of the entire control system as shown in
Figure 15 consists of a single feedback loop, the components
of which can be arranged to follow a typical input- controller-
plant diagram. Out plant and controller are the HILINK and
NARMA-L2 subsystems as dicussed in previous sections and
the input is a simple signal generator allowing for different
wave configurations.
Control Design
As NARMA-L2 is simply a rearragement of the neural
network model, the control design is completed by runningthe Simulink model shown in Figure 6.
The reference signal sent into the NARMA-L2 control
block originates the signal generator. The signal generator
consists of a square wave with a simulation time T, a 50 rad/s
amplitude and a 5 Hz frequency. To vertically translate the
square wave to be entirely in the positive y-axis sector, a
constant value of 250 rad/s is added with a sample time T. This
also ensures the signal does not reach speed values that are too
low for the encoder to measure accurately. After shifting, thesquare wave is sent through a signal specification block (Figure
17) where the minimum parameter allowed is 0 and the
maximum value is 350 rad/s, with automatically inherited data
and a sample time T.
Figure 8: Reference signal input block diagram.
RESULTS AND ANALYSIS
The overall results of the simulation refer only to thetracking error of the reference signal. Through this response it
is possible to assess the final performance of the systemincluding the average settling time, steady state error, and the
systems robustness over time. Figure18 shows the response of
the system for the first 10 s of simulation time. From this plot it
is possible to observe the output changes little over time, this
remains true even after extensive run times (10 min).
Figure 9: Error Between Reference Signal (Blue) and Encoder
Output Velocity (Green)
Taking this previous observation into account, it is
acceptable to say the average performance parameters can bedetermined from a single step response. From further analysisof the data plotted in Figure 18, we can determine the steady
state error to be 6.5 rad/s (2.1%) and the average settling time is0.35 s. As the neural network model cannot match the plant
output perfectly, the steady state error cannot be eliminated.
The delay in the response is partly due to HILINKs
-
8/12/2019 Teaching Neural Network Control System Design Using a Low-cost Rapid Control Prototyping Platform
7/7
7 Copyright 2013 by ASME
performance degrades in Normal Mode. If Real-time
Windows Target is used, HILINK can be used in External
Mode to support higher real-time performance, and the delay
cannot be reduced.
All points of interest for this model can be determined
from its response to a square wave as shown in Figure 19 butin order to assess the controllers flexibility other input wave
forms were tested as well. Figures 20-21 show the systems
overall response to a saw tooth wave and a sine wave. The
controller exhibits an average peak to peak error of 1.9 rad/s
relative to the saw tooth (Figure 20) and 2.1 rad/s relative tothe sine wave (Figure 21). This performance is comparable to
that of the case shown in Figure 19 and shows the error
remains consistent regardless of the input signals shape as
long as the frequency of the input does not exceed the
physical response time of the DC motor.
Figure 10: Single Square Wave: Error Between Reference Signal(Blue) and Encoder Output Velocity (Green)
Figure 11: Saw Wave: Error Between Reference Signal (Blue)and Encoder Output Velocity (Green)
CONCLUSION
This paper presents how the rapid control prototyping
platform HILINK facilitates neural network design. With
HILINK, students can quickly design and implement a
NARMA-L2 controller for DC motor speed control by simpledrag-and-drop operations. Therefore, they can focus on thecontrol parameter selection without developing low-level
code to program the microcontroller. The control performance
can be improved if Real-time Windows Target is used so
HILINK can be used in External Mode.
Figure 12: Sine Wave: Error Between Reference Signal (Blue) andEncoder Output Velocity (Green)
ACKNOWLEDGMENTSThe authors acknowledge the financial support of IEEE
Control Systems Society Outreach Fund and technical supportfrom Zeltom LLC.
REFERENCES
[1] P. S. Shiakolas, S. R. Van Schenck, D. Piyabongkarn and I.
Frangeskou. Magnetic levitation hardware-in-the-loop andMATLAB-based experiments for reinforcement of neural
network control concepts.Education, IEEE Transactions On
47(1),pp. 33-41. 2004.
[2] Woon-Seng Gan, Yong-Kim Chong, W. Gong and Wei-Tong Tan. Rapid prototyping system for teaching real-time
digital signal processing.Education, IEEE Transactions On
43(1),pp. 19-24. 2000.
[3] P. S. Shiakolas and D. Piyabongkarn. Development of areal-time digital control system with a hardware-in-the-loop
magnetic levitation device for reinforcement of controls
education.Education, IEEE Transactions On 46(1),pp. 79-87.
2003.
[4] James B. Dabney and Thomas L. Harman, "Mastering
SIMULINK," Prentice Hall, 2004.
[6] L. Zeltom, "HILINK Real-Time Hardware-In-The-LoopControl Platform For MATLAB/SIMULINK User
Manual," vol. 2013, pp. 35, May 1, 2011, 2011.
[7] H. B. Demuth, M. Beale and M. T. Hagan. "Levenberg-
marquardt (trainlm)," inNeural Network Toolbox 6 User's
Guide Mathworks 2012, .