Hardware Implementation of The Neural Network
Hardware Implementation of The Neural Network
net/publication/275515282
CITATION READS
1 724
1 author:
Dr Ammar A Aldair
University of Basrah
27 PUBLICATIONS 192 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Design and Implementation of NeuroFuzzy Controller Using FPGA for Sun Tracking System View project
design and implementation a fuzzy controller for biped robot View project
All content following this page was uploaded by Dr Ammar A Aldair on 26 October 2016.
control system for coupled tank level. A Very High speed The twin-connected tanks system is a nonlinear
integrated circuit Hardware Description Language (VHDL) dynamical system and the governing dynamical equations
codes have been used to describe the operation of the can be written as
NNPC. The Xilinx Integrated Software Environment
a 1
(Xilinx ISE 10.1) has been used as environment to type h1 = − 12 2 g ( h1 − h2 ) sgn ( h1 − h2 ) + q (1)
the VHDL codes. The Xilinx Spartan XC3S500E FPGA A A
board has been suggested to use in this work. The Spartan a12 a
3E starter Kit board highlights the unique features of the = h2 2 g ( h1 − h2 ) sgn ( h1 − h2 ) − 2 2 g h2 (2)
Spartan_3E FPGA family and provides a convenient A A
development board for embedded processing applications. where h1 is the level in the first tank;
The Hirose 100-pin FX2 Edge connector (J3) can be used h2 is the level in the second tank;
as input and output port to receive the digital input error
data from the A/D converter (error signal is the difference q1 is the flow rate from the first tank to the second tank;
between the output of the controlled system and desired q2 is the flow rate from the second tank to a reservoir;
output) and send the digital control signal to the D/A q is the inlet flow rate;
converter. The analogue control signal is used to force the
g is the gravitational constant;
output of the controlled system to follow the desired
A is the cross-section area of first tank and second tank;
output.
a2 is the cross-section area of the outlet orifice;
For the simulation results, ModelSim XE III 6.4b
a12 is the cross-area of the coupled orifice.
simulation program will be used with the FPGA-based
design. In order to compare the responses of FPGA design
with the Simulink design, an M-file will be used to plot 2.2. System Constraints
the data collected from the ModelSim program and the The pump can only pump the water into the first thank,
other data collected from the Simulink design to make therefore, the inlet flow rate q is always positive. The
sure the FPGA boards work like the neural network constraint on the inlet flow rate is given by
predictive controller for coupled tank system. Simulation
q≥0 (3)
results show that the FPGA board can be used as neural
predictive controller for controlling the liquid level of the In the steady state, for constant water level set points ,
coupled tank system. the respective derivatives must be zero separately i.e.,
h= 0
h= (4)
1 2
2. Dynamic Model of the Two Tank System
At the steady state, Equation. 1 and Equation 2 cab be
The coupled tank system is shown in Figure 1. It rewritten as
consists of two identical hold-up tanks coupled by an a 1
orifice. The input is supplied by a variable speed pump 0=
− 12 2 g ( h1 − h2 ) sgn ( h1 − h2 ) + Q (5)
A A
which supplies liquid to the first tank. The orifice allows
the liquid to flow into the second tank and hence out to a a12 a1
reservoir. The control task is to adjust the inlet flow rate =0 2 g ( h1 − h2 ) sgn ( h1 − h2 ) − 2 g h2 (6)
A A
q(t) by pumping the liquid into the first tank so as to force
the level of the liquid in the second tank, h2k close to a where Q is the steady state inflow rate. From Equation 5
desired set point level, H. It is assumed that the back and Equation 6, to satisfy the constrain in Equation 3, the
pressure created by the water-head of the second tank does following constrain should be satisfy as
not affect the flow rate of the pump significantly. The h1 ≥ h2 (7)
controller has been designed based on the neural
predictive control.
3. Neural Network Predictive Control
To design the neural network predictive control, two
steps should be carried out:
• Determine the neural network plant model for the
given nonlinear system (system identification).
• The neural network plant model is used by the
controller to predict future performance.
The following subsection described the steps design of
the NNPC.
development of a mathematical model of the system to be where f(.) represents an unknown nonlinear system, d
controlled. Previous studies in system identification have represented the time delay of the system, ny and nu are the
demonstrated that neural networks are successful in orders of the system. For an unknown model plant, many
modelling many non-linear systems [13]. Before neural forms of NN model can be applied. In this work, the
networks are investigated for identification, linear multilayer perceptron neural network is used to model the
techniques such as auto regressive with exogenous input nonlinear system as shown in Figure 2. The neural
(ARX) and auto regressive moving average with network design to identify the plant is expressed as
exogenous input (ARMAX) will be applied to nonlinear
y ( t + 1)
system.
The model of any nonlinear system in the form of
NARMA is given as
y ( t − 1) , y ( t − 2 ) , …, y t − n y
= f
( ) , (9)
u ( t − d − 1) , …, u ( t − d − n )
y ( t + 1) u
q
= f
(
y ( t − 1) , y ( t − 2 ) , …., y t − n y ) , (8)= F
∑
m
v j g ∑ wlj ul + b1 j + b2
u ( t − d − 1) , …, u ( t − d − n ) j 0= l 1
u
=
Where y ( t ) is the output of the neural network system, ul predictions y ( t ) , which in some sense are “close” to the
th
represents the l input of the neural network; v j , w, b1 true outputs y(t)
Because the training of neural network is often operated
and b2 are the weights and biases of the NN (the
off-line, any training algorithms in batch version can be
adjustable parameters of the NN); F(.) and g(.) are
developed to minimize the following criterion
nonlinear functions ; q and m are the number of the nodes
in the hidden and input layer, respectively. 1 N
∑ y ( t ) − yˆ ( t|θ ) y ( t ) − yˆ ( t|θ ) (11)
T
The adjustable parameters of the NN are determined VN =
2N i =1
from a set of examples through the process called training.
The examples, or the training data as they are usually where θ is the trainable parameters vector.
called, are a set of inputs, u(t), and corresponding desired The weights are then found as θ = arg min VN . By some
outputs, y(t).
Specify the training set by kind of iterative minimization scheme:
direction and step size are selected. The MATLAB Neural The command u may be subject to amplitude
toolbox provides a lot of training algorithms such as: constraints
Backpropagation algorithm, Variable Learning Rate
umin ≤ u (k + i ) ≤ umax (15)
algorithm, Resilient Backpropagation algorithm,
Conjugate Gradient algorithm, Quasi-Newton Algorithm, The cost function is often used with the weight factor
Levenberg-Marquardt algorithm, and Reduced Memory ρ = 0 . A very important parameter in the predictive
Levenberg-Marquardt algorithm.
control strategy is the control horizon Nu , which
3.2. Predictive Controller specifies the instant time, since when the output of the
controller should be kept at a constant value.
The objective of the predictive control strategy using The output sequence of the optimal controller is
neural predictors is twofold: (i) to estimate the future obtained over the prediction horizon by minimizing the
output of the plant and (ii) to minimize a cost function cost function J P with respect to the vector U. This can be
based on the error between the predicted output of the
achieved by setting
processes and the reference trajectory. The cost function,
which may be different from case to case, is minimized in ∂J P
= 0 U= u (k − d ),..., u ( k − d + Nu − 1) (16)
T
order to obtain the optimum control input that is applied to ∂U
the non-linear plant. In most of the predictive control
algorithms a quadratic form is utilized for the cost The analytical approach to the optimization problem
function: needs for the differentiation of the cost function and,
finally, leads to a nonlinear algebraic equation;
y ( k + 1) − r ( k + i )2 unfortunately this equation cannot be solved by any
N2
J p = ∑ Nu
analytic procedure. This is why a computational method is
2 (13)
i = N1 + p ∑ ( u ( k + i − 1) − u ( k + i − 2 ) )
preferred for the minimization of the cost function, also
i =1 complying with the typical requirements of the real-time
implementations (guaranteed convergence, at least to a
with following requirements: sub-optimal solution, within a given time interval). Figure
3 depicts the structure of the NNPC. The controller
∆u ( k + i − 1)= 0,1 ≤ Nu <i ≤ N 2 (14)
consists of the neural network plant model and the
where Nu is the control horizon; N1 is the minimum optimization block. The optimization block determines the
prediction horizon; N2 is the prediction horizon; i is the values of u' that minimize J P , and then the optimal u is
order of the predictor; r is the reference trajectory; ρ is inputted to the plant (nonlinear system).
weight factor; and ∆ is the differentiation operator.
4. Hardware Implementation of the during the life-cycle of a device, through patches and
updates. However, they are much more inefficient in terms
Neural Predictive Control of speed and area. Reconfigurable computing is intended
to fill the gap between hardware and software, achieving
During the last years, consumer digital devices have potentially much higher performance than software, while
been built using either application specific hardware maintaining a higher level of flexibility than hardware.
modules (ASICs) or general purpose software Reconfigurable devices, including Field-Programmable
programmed microprocessors, or a combination of them. Gate Arrays (FPGAs), contain an array of computational
Hardware implementations offer high speed and efficiency elements whose functionality is determined through
but they are tailored for a specific set of computations. If multiple programmable configuration bits. These elements,
an alternative implementation is needed, a new and usually called logic blocks, are connected using a set of
expensive design process has to be performed. On the routing resources that are also programmable.
contrary, software implementations can be modified freely
44 American Journal of Electrical and Electronic Engineering
Neural networks can be implemented using analogy or designed and simulated using MATLAB software tool.
digital systems. The digital implementation is more This Software-Based Controller (SBC) will be used to
popular as it has the advantage of higher accuracy, better make a comparison with the proposed design. This
repeatability, lower noise sensitivity, better testability, comparison is important because it tells us to which extent
higher flexibility, and compatibility with other types of our FPGA-Based Controller (FBC) is close to similar
pre-processors. Two implementation methods can be used controller designed as a computer program.
to implement the NNPC: (i) FPGA implementation; and
(ii) DSP implementation. FPGA is a suitable hardware for
neural network implementation as it preserves the parallel 5. Simulation and Results
architecture of the neurons in a layer and offers flexibility
in reconfiguration. In this work, the Simulink Toolbox is used to simulate
The VHDL coding developed is tested using Xilinx the NNPC and coupled tank system. Figure 4 depicts the
10.1 software tool to design the NNPC. This software is MATLAB Simulink model of coupled tank system. While,
synthesised the VHDL codes and generated a Figure 5 shows the connection between NNPC and
configuration file that used to program the FPGA board. coupled tank system.
The ModelSim 6.4b software tool is used to simulate the
output response of the FPGA boards. The same NNPC is
As it is mentioned before, to design the neural network multivariate function expressed as the sum of squares of
predictive control, two steps should be carried out: nonlinear real-valued functions. It has become a standard
• Determine the neural network plant model for the technique for nonlinear least-squares problems [15],
given nonlinear system (system identification). widely adopted in a broad spectrum of disciplines.
• The neural network plant model is used by the To design the NN identifier, we assume that it has four
controller to predict future performance. inputs (y(t-1),y(t-2),u(t-1)) and u(t-2) and one output y ( t ) .
To carry out the first step, the neural network is used to
The size on hidden layer is assumed seven.
design the identification system for the coupled tank
In this work, the Levenberg-Marquardt algorithm is
system. The training data should be generated by applying
used as training algorithm to adjust the trainable
a random step inputs to the coupled tank Simulink model.
parameters of the NN. After 166 optimization iteration
Figure 6 shows the input/output data set that is used to
design the neural network identifier. steps, the objective function VN has been minimized to
The Levenberg-Marquardt Algorithm (LMT) is an very small value as shown in Figure 7.
iterative technique that locates the minimum of a
American Journal of Electrical and Electronic Engineering 45
6. Conclusion
The neural network based predictive control is
proposed in this paper for controlling the liquid level of
the nonlinear coupled tank system. Using the neural
predictive controller, the liquid level of the second tank is
tracked the desired set points by applying the liquid flow
rate as a control signal. The Levenberg-Marquardt training
algorithm is used to design the neural network identifier
which is used to design the predictive control. To
investigate the effectiveness of the neural network based
predictive controller, the output response of the coupled
tank with the NNPC is compared with the response of the
controlled system with PID controller. Simulation results
show that when the proposed controller is applied, all
transient response specification such as: maximum
overshoot, settling time delay time, rise time and peak
time have been minimized. It means the NNPC can be
used effectively to implement the control system for the
coupled tank system practically. The obtained adjustable
parameters of the NN can be used to implement the
controller using an FPGA board. The results show that the
Figure 9. the flowchart of describe the Neural network using VHDL control signals obtained from FPGA boards are identical
American Journal of Electrical and Electronic Engineering 47
to the control signals which are obtained from design [7] Evans, J.T., et al., Implementation and Performance Evaluation of
simulation. Therefore, it can be arrived that the FPGA an On-line Neural Network Control Scheme. International
Conference on Control, 1994.
boards can be used to control the coupled tank system. [8] Ng, K.C., et al., Genetic Algorithms Applied to Fuzzy Sliding
Mode Controller Design. Frst International Conference on Genetic
Algorithms in Engineering Systems: Innovations and Applications,
References 1995.
[9] Clarke, D., C. Mohtadi, and P. Tuffs, Generalized Predictive
[1] Seng, T.L., M. Khalid, and R. Yusof, Tuning of a Neurofuzzy Control-Part I: the Basic Algorithm. Automatica, 1987. 23(2): p.
Controller by Genetic Algorithms with an Application to A 137-148.
Coupled Tank Liquid Level Control System. International Journal [10] Sedighizadeh, M., M. Rezaei, and V. Najmi, A Predictive control
of Engineering Applications on Artificial Intelligence, 1998. 11: p. based on Neural Network for Proton Exchange Membrane Fuel
517-529. Cell. World Academy of Science, Engineering and Technology,
[2] Mahyuddin, M.N., M.R. Arshad, and Z. Mohamed. Simulation of 2011. 74: p. 461-465.
Direct Model Reference Adaptive Control on a Coupled-Tank [11] Lawrynczuk, M., A Family of Model Predictive Control
System Using Nonlinear Plant Model in International Conference Algorithms with Artificial Neural Networks. International Journal
on Control, Instrumentation and Mechatronics Engineering. 2007. of Applied Mathematics and Computer Science, 2007. 17(2): p.
Johor, Malaysia. 217-232.
[3] Hassan, K.H., Self Learning of ANFIS Inverse Control using [12] Chen, X. and Y. Li, Neural Network Predictive Control for Mobile
Iterative Learning Technique. International Journal of Computer Robot Using PSO with Controllable Random Exploration Velocity.
Applications, 2011. 21(8): p. 24-29. International Journal of Intelligent Control and Systems, 2007.
[4] Khan, M.K. and S.K. Spurgeon, Robust MIMO Water Level 12(3): p. 217-229.
Control in Interconnected Twin-tanks Using Second Order Sliding [13] Li, X., Z. Chen, and Z. Yuan, Simple Recurrent Neural Network-
Mode Control. Control Engineering Practice 2006. 14: p. 375-386. Based Adaptive Predictive Control for Nonlinear Systems. Asian
[5] Rojas, I., et al. Analysis and Electronic Implementation of a Fuzzy Journal of Control, 2002. 4(2): p. 231-239.
System for the Control of a Liquid Tank. in Proceedings of the [14] Chidrawar, S. and B. Pater, Generalized Predictive Control and
Sixth IEEE International Conference on Fuzzy Systems 1997. Neural Generalized Predictive Control Leonardo Journal of
Barcelona. Sciences, 2008. 13: p. 133-152.
[6] Saini, J.S. and Y.P. Singh, Use of Causal Knowledge in a Real- [15] Wilamowski, B.M., et al., An Algorithm for Fast Convergence in
time Fuzzy Logic Controller. IEEE Trans. Ind, Application, 1999. Training Neural Networks, in International Joint Conference on
35: p. 554-560. Neural Networks. 2001: Washington, DC p. 1778-1782.