0% found this document useful (0 votes)
48 views

Hardware Implementation of The Neural Network

Uploaded by

Agus Melaske
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Hardware Implementation of The Neural Network

Uploaded by

Agus Melaske
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/275515282

Hardware Implementation of the Neural Network Predictive Controller for


Coupled Tank System

Article · January 2014


DOI: 10.12691/ajeee-2-2-2

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.

The user has requested enhancement of the downloaded file.


American Journal of Electrical and Electronic Engineering, 2014, Vol. 2, No. 1, 40-47
Available online at http://pubs.sciepub.com/ajeee/2/2/2
© Science and Education Publishing
DOI:10.12691/ajeee-2-2-2

Hardware Implementation of the Neural Network


Predictive Controller for Coupled Tank System
Ammar A. Aldair*

Electrical Engineering Department, University of Basrah, Basrah, Iraq


*Corresponding author: [email protected]
Received April 24, 2014; Revised June 17, 2013; Accepted January 25, 2014
Abstract In this paper, a neural network based predictive controller is designed for controlling the liquid level of
the coupled tank system. The controlled process is a nonlinear system; therefore, a nonlinear prediction method can
be a better match in a predictive control strategy. The neural network predictive controller that is discussed in this
paper uses a neural network model of a nonlinear plant to predict future plant performance. The simulation results
are compared with PID control. The results show that the effectiveness of using the neural predictive controller for
the coupled tank system. The Simulink Toolbox in MATLAB has been used to simulate the controlled system with
the proposed controller. The VHDL has been used to describe the implementation of neural controller. Xilinx ISE
Project Navigator Version 10.1 is used to obtain the compilation and timing test results as well as the synthesized
design. The hardware implementation of the neural network predictive controller using FPGA board is proposed. To
make sure that the FPGA board works like the simulated neural predictive controller, MATLAB programme is used
to compare between the set of the data that are obtained from the ModelSim program and the set of the data that are
obtained from the MATLAB Simulink model. Simulation results show that the FPGA board can be used as neural
predictive controller for controlling the liquid level of the coupled tank system.
Keywords: neural network predictive controller, coupled tank system, FPGA
Cite This Article: Ammar A. Aldair, “Hardware Implementation of the Neural Network Predictive Controller
for Coupled Tank System.” American Journal of Electrical and Electronic Engineering, vol. 2, no. 1 (2014): 40-
47. doi: 10.12691/ajeee-2-2-2.

[9]. The most popular MPC algorithms that found a wide


acceptance in industry are: Dynamic Matrix Control
1. Introduction (DMC), Model Algorithmic Control (MAC), Predictive
Functional Control (PFC), Extended Prediction Self
The coupled-tank liquid level control system is Adaptive Control (EPSAC), Extended Horizon Adaptive
regarded as the relevant plant to emulate the process Control (EHAC) and Generalized Predictive Control
control in petrol and chemical industries. The processing (GPC). GPC has been originally developed with linear
plants in these industries largely involve in controlling the plant predictor model, which leads to a formulation that
liquid level and the flow rate from one tank to another in can be solved analytically. But in many industrial
the presence of nonlinearity and disturbance. processes which usually have nonlinear dynamical
Many authors investigated the problem of controlling behaviours and such complicated systems may be not
liquid flow of single or multiple tanks. The neurofuzzy easily to control by the linear GPC method. In recent years,
controller based on the radial basis function neural incorporation of neural networks as intelligent control
network is tuned automatically using genetic algorithm to techniques and adaptive control system has been claimed
design a control system for the coupled tank [1]. In to be a new method for the control of systems with
reference [2], the direct model reference adaptive control significant nonlinearities. Those neural network based
is designed for coupled tank system. While, an iterative adaptive control system is called neural network predictive
learning control is used to tune an adaptive neurofuzzy control (NNPC). It is widely used as a controller for many
inference system inverse controller for tank system [3]. nonlinear systems [10,11,12,13,14]. In this work, a neural
Khan and Spurgeon presented a second order sliding mode network predictive controller is designed for controlling
control algorithm for a class of MIMO nonlinear system. the liquid level of the coupled tank system.
This algorithm has been applied for robust control of The special-purpose VLSI chips is used to implement
liquid level in interconnected twin-tanks [4]. Intelligent the NNPC in real time applications with enhanced
control including fuzzy control [5,6], neural network processing speed, but due to different neural models and
control [7], and genetic algorithms [8] have also been limited use, it has been prohibitively expensive and time
applied to the coupled tanks system. consuming to develop such chips. In this paper, the
Model predictive control (MPC) is used successfully in network predictive control is mapped into hardware using
some practical application since it was developed in 1980s field programmable gate array FPGA board to design a
American Journal of Electrical and Electronic Engineering 41

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 h1 = − 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 = h2 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.

3.1. Nonlinear System Modeling Using Neural


Networks
Figure 1. Two Tanks System System identification is the process of developing a
mathematical model of a dynamic system based on the
2.1. System Modelling input and output data from the actual process. An
important stage in control system design is the
42 American Journal of Electrical and Electronic Engineering

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 
=  

Figure 2. Nonlinear system identification

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:

ZN= {u ( t ) , y(t ) |t= 1, …, N } (10) θ ( i +=


1)
θ ( i ) + µ (i ) S (i ) (12)

Where θ ( ) specified the current iterate; S (i ) is the search


i
where N is the number of the samples in training set.
The objective of training is then to determine a direction; and µ (i ) the step size.
mapping from the set of training data to the set of possible
A large number of training algorithms exist, each of
weights. Therefore, the neural network will produce
which is characterized by the way in which search
American Journal of Electrical and Electronic Engineering 43

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.

Figure 3. Structure of neural network predictive control

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

Figure 4. MATLAB Simulink model of coupled tank system

Figure 5. MATLAB Simulink model of NNPC with coupled tank system

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

Figure 6. Input/output data training set

Figure 7. Objective Function during optimization steps


Figure 8. the output response of the coupled tank system with different
The optimization problem was addressed in accordance control system
with the computational scenario built in Subsection 3.1.
With respect to the notations introduced in Subsection 3.1, After the design of neural network predictive controller
the following concrete values were chosen for the tuning has been completed, the FPGA board can be used to
parameters of the predictive control algorithm: N1=1, implement the proposed control system. First, VHDL
N2=10, Nu=5, and ρ =0.05. The NNPC is generated the codes, which describe the operation of NNP controller, are
suitable control signal to force the liquid level of the written (the flowchart of VHDL program is shown in
second tank to track the reference input signal. In this Figure 9). This program is downloaded into the FPGA
work, the random step input is used as the reference input chip (XILINX Spartan XC3S700AN) by using USB cable.
signal. In order to investigate the effectiveness of the Then, the Hirose 100-pin FX2 Edge connector (one port of
neural network based predictive controller, the output the FPGA board) can be used to connect the FPGA board
response of the controlled system with NNPC is compared with the tank system. The error between the reference
with output response of the controlled system with PID input and the system output can be applied as input to the
controller as shown in Figure 8. The Internal model A/D converter. The digital output of the A/D converter
control theory is used to design the PID controller. Figure has been applied as input data to the FPGA boards. The
8 shows that the overshoot and settle time of the output FPGA board generates digital inputs to the NNP controller
response are minimized. (error and error rate). The NNP controller generates a
46 American Journal of Electrical and Electronic Engineering

suitable digital control signal based on the program that is


stored in the FPGA chip. The digital control signal is sent
to the D/A convertor to generate an analogy control signal
which is applied as input to the pump of tank system.
Figure 10 shows the control signal obtained from
ModelSim program, while, Figure 11 shows the output
signal of the NNP controller obtained from MATLAB
simulation. By comparing Figure 10 and Figure 11, it can
be seen that, the two output signals are identical.

Figure 10. Control signal obtained from FPGA Board

Figure 11. Control signal obtained from MALAB Simulation

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.

View publication stats

You might also like