Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
120 views

A Microcontroller Implementation of Constrained Model Predictive Control

1) The document discusses implementing a constrained model predictive control (MPC) algorithm on a microcontroller. 2) It proposes an efficient firmware for constrained MPC implementation on an STM32 microcontroller using an interior point method. 3) Performance studies showed good execution speed and low computational burden, encouraging development of predictive control algorithms for industrial standard processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

A Microcontroller Implementation of Constrained Model Predictive Control

1) The document discusses implementing a constrained model predictive control (MPC) algorithm on a microcontroller. 2) It proposes an efficient firmware for constrained MPC implementation on an STM32 microcontroller using an interior point method. 3) Performance studies showed good execution speed and low computational burden, encouraging development of predictive control algorithms for industrial standard processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

World Academy of Science, Engineering and Technology

International Journal of Electrical and Information Engineering


Vol:5, No:8, 2011

A Microcontroller Implementation of Constrained


Model Predictive Control
Amira Kheriji Abbes, Faouzi Bouani, Mekki Ksouri

MPC has been applied in high bandwidth applications


Abstract—Model Predictive Control (MPC) is an established con- such as the slow dynamical systems encountered in chemical
trol technique in a wide range of process industries. The reason for
process control as well as servomechanisms[12]. In addition,
this success is its ability to handle multivariable systems and systems
having input, output or state constraints. Neverthless comparing to process units as fluid catalic cracking and crude atmospheric
PID controller, the implementation of the MPC in miniaturized distillation have been controlled by MPC controllers for more
devices like Field Programmable Gate Arrays (FPGA) and microcon- than two decades [13]. However, in control systems with fast
trollers has historically been very small scale due to its complexity in sampling times the MPC has not been introduced yet. The
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

implementation and its computation time requirement. At the same


reason for this is that its implementation is explained by its
time, such embedded technologies have become an enabler for future
manufacturing enterprisers as well as a transformer of organizations time demanding and its mathematical complexity requirement.
and markets. In this work, we take advantage of these recent advances In the same time, this control strategy is very desirable for ap-
in this area in the deployment of one of the most studied and applied plications with fast dynamical systems. There are few recently
control technique in the industrial engineering. In this paper, we works which investigated the MPC in fast devices such as
propose an efficient firmware for the implementation of constrained
FPGA and Programmable Logic Controller (PLC) [14], [15],
MPC in the performed STM32 microcontroller using interior point
method. Indeed, performances study shows good execution speed [16], [17] and only few works [18] developed the implemen-
and low computational burden. These results encourage to develop tation of MPC using a microcontroller but without constraints.
predictive control algorithms to be programmed in industrial standard The FPGA and the PLC devices have the advantage of a
processes. The PID anti windup controller was also implemented in simple implementation of control methods since either their
the STM32 in order to make a performance comparison with the
program tools present a straightforward communication with
MPC. The main features of the proposed constrained MPC framework
are illustrated through two examples. Matlab/Simulink software or the matrix operation blocks are
already implemented. Although the FPGA are characterized by
Keywords—Embedded software, microcontroller, constrained
Model Predictive Control, interior point method, PID antiwindup, a high speed since the maximum frequency can reach even 300
Keil tool, C/C++ language. MHz, its drawback is the high power consumption. However,
since until recently the priority requirement for embedded
I. I NTRODUCTION systems application is the low power consumption, in this
wing to its ability in controlling Muti Input Multi work, we propose an efficient implementation of the proposed
O Output systems and in handling constraints arising in
industrial applications, the Model Predictive Control (MPC)
constrained MPC firmware using a performed microcontroller
characterized by a very low cost and an extensive range of
has become a mature control strategy in the last few years. All peripherals and featuring three low-power mode.
these advantages make this method attractive to the academic A microcontroller is described as a computer on a chip
community and to be emerging in the process industries. because it contains all the features of a full computer including
Fundamentally, at each step of MPC, an optimal control central processor, volatile and non-volatile memories, input
sequence is computed such that plant outputs follow a given and output ports with special features such as serial com-
reference trajectories by minimizing the difference between munication, analog-to-digital conversion and, more recently,
set-points and predicted outputs. This optimal control sequence signal processing. The presence of microcontroller in semi
is found by solving a quadratic program problem. Then, only conductor products is becoming undoubtedly noticeable. This
the optimal current input is applied to the plant and this device is used for a variety of industrial applications such as
procedure is repeated at the next sampling instance [1]. for medicine and bioengineering, aerospace, automotive sys-
In order to predict the future behavior of the process output, tems and transportation, microwave ovens, washing machines,
we may have a model. In this work, the state space model is integrated secure network systems, etc. Moreover, the advance-
considered to compute the control signal. The advantage of this ment of microcontrollers and what they offer combined with
type of model is that the multivariable systems can easily be their speed, made them more suitable for a large variety of
dealt with. Moreover, extensive amount of literature consider control applications.
this representation to solve robust model predictive control [2], In this paper, we propose an efficient constrained Model
[3], [4], [5], [6], [7], [8], [9], [10], [11]. Predictive Controller firmware for a performed STMicro-
electronics microcontroller (STM32). The inverse matrix is
A. K.Abbes, F. Bouani, M. Ksouri are in members of the Labora- implemented using the Gauss-Jordan method presented in [19].
tory of Analysis and Control Systems, National School of Engineering
of Tunis Belvedere BP 37, 1002 Tunis e-mails: amira.kheriji@enit.rnu.tn, Moreover, the optimization problem is solved using the interior
faouzi.bouani@enit.rnu.tn, mekki.ksouri@enit.rnu.tn. point method explained in [20]. The control application could

International Scholarly and Scientific Research & Innovation 5(8) 2011 878 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

benefit from the power features and the flexibility of the Here Hp is the prediction horizon, Hc is the control horizon,
STM32F103xB devices. The STM32 keil starter kit based on a λ11 is the weighting factor, y(k + j|k) is described in equation
JTAG interface and the STM32 board was used to implement 3, w(k +j) denotes the set-point at time k +j, umin and umax
the proposed constrained MPC firmware. Since the conversion are respectively the low and the high levels of the control
from m files (Matlab) to C file decreases the performance of action and Δumin and Δumax are are respectively the low
the execution time, in this work, we choose to develop all and the high levels of the control increments.
the proposed framework with Keil development tools designed It is easier to use the matrix form. Therefore, the output
for ARM processor-based microcontroller devices working sequence on Hp prediction horizon can be written as follows:
with C/C++ language. In order to test the effectiveness of
our proposed constrained MPC software, the PID antiwindup Y = LΔU + M x(k) (6)
was also implemented in the STM32 and compared with the
in which:
proposed constrained MPC software.
The rest of this paper is organized as follows: in section
II, a theoretical background which consists of a review of Y = [
y (k + 1|k), y(k + 2|k), . . . , y(k + Hp |k)]T ,
the MPC method as well as the interior point method are ΔU = [Δu(k), Δu(k + 1), . . . , Δu(k + Hc − 1)]T ,
presented. Section III states the hardware and the software
It is assumed that there is no control action after time k +
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

development tools used in this application. In section IV, a


detailed description of the proposed firmware development is Hc − 1, i.e. Δu(k + i) = 0 for i > Hc − 1. Since the MPC is
presented in which the different source files and functions a receding horizon approach, only the first computed control
are illustrated. In section V, the effectiveness of the proposed increment Δu(k) is implemented.
code is outlined through two examples in which a performance The L matrix with the (Hp , Hc ) dimension and M which
study of this proposed MPC software and a comparison with is an (Hp , n) dimensional matrix are given by:
the PID anti windup controller are done. The last section is ⎡ ⎤
dedicated to conclude this paper. HG 0... 0
⎢ 0 ⎥
⎢ HF G HG

II. T HEORETICAL BACKGROUND : REVIEW OF THE L= ⎢ .. .. .. ⎥,
⎣ . . . ⎦
CONSTRAINED MPC AND THE INTERIOR POINT METHOD
HF Hp −1 G HF Hp −2 G ... HF Hp −Hc G
A. Review of the constrained MPC ⎛ ⎞
HF
We consider the following discrete state space model: ⎜ HF 2 ⎟
⎜ ⎟
x(k + 1) = F x(k) + GΔu(k) (1a) M =⎜ .. ⎟.
⎝ . ⎠
y(k) = Hx(k) (1b) HF Hp
in which x(k) ∈ Rn is the state of the system, Δu(k) is The objective function can be expressed as:
the control increment, y(k) is the measured output and the
operator Δ = 1−z −1 denotes the integral action which ensures J1 = (Y − W )T (Y − W ) + λ11 ΔU T ΔU (7)
static error elimination.
Consequently, we can obtain using equation 1 the following in which:
state at time k + j :

j−1 W = [w(k + 1), . . . , w(k + Hp )]T
x(k + j|k) = F j x(k) + F j−1−i GΔu(k + i) (2)
i=0 In this way, the constrained MPC problem is formulated as
Furthermore, by using equations 1 and 2, the j-step ahead a compact Quadratique Program (QP) problem:
output predictor value is written as follows:
1

j−1 min( ΔU T QΔU + cT ΔU ) (8)
y(k + j|k) = HF x(k) +
j
HF j−1−i
GΔu(k + i) (3) 2
i=0 s.t:
The constrained MPC problem to be minimized is a
quadratic one given by: JΔU ≤ g (9)


Hp

Hc where :
2 2
J1 = (
y (k+j|k)−w(k+j)) +λ11 Δu(k+j−1) (4)
j=1 j=1 Q = 2(LT L + Λ) ,
subject to linear inequality constraints on the system inputs: Λ1 = λ11 Ic ,
c = (L M x − L W ).
T T

umin ≤ u(k + i − 1) ≤ umax , i = 1, · · · , Hc (5a) Hc ×Hc


Ic ∈ R is the identity matrix, Q ∈ RHc ×Hc , J ∈
Δumin ≤ Δu(k + i − 1) ≤ Δumax , i = 1, · · · , Hc (5b) R mc ×Hc
and g ∈ RHc ×1 are computed using equations 5 and

International Scholarly and Scientific Research & Innovation 5(8) 2011 879 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

where mc is the number of constraints (in our case mc = Algorithm 1: the unfeasible Interior Point method
4Hc since only the constraints on the control and the control Step 1 Given (v 0 , λ0 , t0 ) with (λ0 , t0 ) > 0.
increment are considered).
Step 2 At the k-th iteration step, solve the increments
(Δv k, Δλk , Δtk ) as follows:
   k 
Q JT Δv k r1
=
J −(Λk )T k ) Δλk r2k
and
Δtk = −tk + (Λk )−1 (σ k μk e − T k Δλk ),
B. The interior point method
where:
r1k = −Qv k − J T λk − c,
)−1 e,⎤
r2k⎡= −Jv k + g − σ k⎤μk (Λk⎡
The connections between optimization and control theory
λ1
k
1
have been explored by many researchers and optimization ⎢ . ⎥ ⎢ . ⎥
algorithms have been applied with success to optimal control Λ =⎣
k .. ⎦, e = ⎣ .. ⎦ .
[21]. λkmc ⎤ 1
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067


tk1
In this paper, we apply the unfeasible interior point method ⎢ .. ⎥
in the proposed constrained MPC software microcontroller Tk = ⎣ . ⎦,
implementation. The special case of the optimality conditions tkmc
that must be satisfied by solutions of linear program problems for some σk ∈ (0, 1) which is often confined to
of equations 8 and 9 are knwown as the Karush Kuhn Tucker the range [10−3 , 0.8].
(KKT) conditions [20]:
Remark: The increments (Δv k , Δλk ) can also
be solved using these equations:

Qv + J T λ = −c Δλk = (Γ − JQ−1 J T )−1 (r2k − JQ−1 r1k ),


−Jv + g = t (10) Δz k = Q−1 r1k − Q−1 J T Δλk ,
λ ≥ 0 , t ≥ 0 , t λ = 0. T
Step 3 Compute the new variables:

(v k+1 , λk+1 , tk+1 ) = (v k , λk , tk )


+ αk (Δv k , Δλk , Δtk )
where v = ΔU .
Moreover, the unfeasibilities and the duality gap μ defined for some αk ∈ (0, 1], this step length
by: is computed as follows :

first, find the maximum value of αk such that:


(v k , λk , tk ) + αmax (Δv k , Δλk , Δtk ) > 0,
(tk )T λk then, we set: αk = min(1, 0.995αmax)
μk = (11)
mc
Step 4 If the iteration converges stop the process and
the optimal value v k+1 is obtained; otherwise
go back to step 2 with the new values obtained
are gradually reduced to zero as k −→ ∞, where k is the of (v k+1 , λk+1 , tk+1 ) and continue the iteration
number of iteration sequence. process.
The mixed Linear Complementary is defined such that:

       III. STM32 STARTER KIT AND K EIL DEVELOPMENT TOOL


Q JT v c 0
+ = (12) In this section, an overview of the hardware and the software
−J 0 λ g t
development tools is presented.

A. STM32F103RB microcontroller
The steps of the unfeasible interior point method for solution First of all, we have to clarify why the choice of a micro-
of equations 8 and 9 are listed in algorithm 1. controller? Most of the proposed works of the implementation

International Scholarly and Scientific Research & Innovation 5(8) 2011 880 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

of the predictive control method use only the FPGA or the •MCBSTM32 Evaluation Board which includes:
PLC. – STM32F103 with 72 MHz maximum Cortex-M3
May be this is due to the complexity of use of the microcon- processor based MCU with 128KB Flash, 20KB
troller and the huge amount of time needed to implement such RAM, and 49 GPIO.
method above all when incorporating constraints. However, by – USART, CAN, USB Interfaces and SD/MMC card
proposing an optimized algorithm with a reducing size of code slot.
and by choosing a low cost microcontroller with a low power – 16x2 LCD panel, 8 LED’s, 3 push buttons, and
consumption, one can takes advantages of such miniaturized scratchpad area.
device. • A JTAG interface supporting Cortex-M3 Serial Wire
Moreover, the choice to adopt STM32 is based on trade Debugger (SWD) and Serial Wire Viewer (SWV) modes.
offs between price (since the STM32 discovery costs few
In order to load the program into the STM32 device, the
dollars), performance and low power consumption. Indeed,
ULINK-ME is used. Moreover, test data and test results can
the STM32F103RB performance line family incorporates the
be transferred between STM32 and the PC through the RS232
high-performance ARM Cortex-M3 32-bit RISC core operat-
serial link via the USART communication protocol.
ing at a maximum of 72 MHz frequency, high-speed embedded
memories (Flash memory of 128 Kbytes size and SRAM of
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

20 Kbytes size), and an extensive range of enhanced I/Os and C. Keil development tools
peripherals connected to two APB buses [22]. Furthermore, Keil is a software developement tools. It makes C/C++
it has 12-bit ADCs, three general purpose 16-bit timers plus compilers, debuggers, integrated environments, middleware,
one PWM timer, as well as standard and advanced com- real-time kernels, simulation models, and evaluation boards
munication interfaces: two I2Cs and SPIs, three Universal for ARM, Cortex-M processor families. The used version is
synchronous asynchronous receiver transmitter USARTs, an the μVision 4. The μVision 4 screen provides a menu bar for
USB and a CAN peripherals. In addition, the STM32F103RB command entry, a tool bar where can select command buttons,
has configurable and flexible power management features. The and windows for source files, dialog boxes, and information
power consumption or hardware can be managed to match displays. This version has two operating modes:
the system’s requirements. Power management is provided • Build Mode: Allows to translate all the application files
via clock control to the CPU and individual peripherals. and to generate executable programs.
This device supports the following three global power control • Debug Mode: Provides a debugger for testing the appli-
modes. cation.
The STM32F10xxx devices feature three low-power modes: This tool has the ability to communicate information to the
sleep mode (CPU clock off, all peripherals including Cortex- serial port of the PC monitor.
M3 core peripherals like NVIC, SysTick, etc. are kept run-
ning), stop mode (all clocks are stopped) and the standby IV. F IRMWARE DEVELOPMENT
mode (1.8V domain powered-off). In addition, the power
consumption in run mode can be reduced by one of the In the proposed algorithm, the constrained Model Predictive
following means: slowing down the system clocks, gating the Control is implemented (see Fig. 2).
clocks to the APB and AHB peripherals when they are unused.
This is obviously an attractive property to industry as saving
power and CPU high frequency can be a very costly affair
indeed.

B. STM32 starter kit


The STM32 starter kit presented in Fig. 1 was used to
implement the MPC program. It is composed of:

Fig. 2. Structure of MPC algorithm in Keil μVision4 development tool

A. Software description of the MPC controller


This subsection describes the MPC controller software and
gives details about the related functions. It is important to
Fig. 1. STM32 starter kit notice that automatically generating matlab algorithms into
C/C++ environment is time demanding. Therefore in this work

International Scholarly and Scientific Research & Innovation 5(8) 2011 881 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

TABLE III
we choose to implement all the predictive control algorithm M ATRIX P RODUCT FUNCTION DESCRIPTION
in C/C++ code. In spite of its complexity, this method will be
Function name Matrix Product
more optimized. Function prototype void Matrix Product(float *P1 , float *P2 ,
In order to use the MPC controller software, some steps float *P3 , int n1 , int p1 , int m1 )
should be followed: Behavior description Compute the product of two matrices
Input P1 : the first left matrix,
1) define the number of states, the number of iterations, the P2 : the second right matrix,
prediction horizon, the control horizon and the weighting P3 : the product matrix,
n1 : the number of lines of P1 ,
factor λ1 , p1 : the number of lines of P2 ,
2) define the state matrix, the input matrix and the output m1 : the number of columns of P2 .
matrix of the model, Output None
3) fix the initial values of the control signal and the state,
TABLE IV
4) solve the minimization problem of equations 8 and 9 M ATRIX S UM FUNCTION DESCRIPTION
and find the optimal control action using the unfeasible
Function name Matrix Sum
interior point method, Function prototype void Matrix Sum(float *S1 , float *S2 , float
5) Test the convergence of the interior point algorithm, if it *S3 , int nl , int nc )
converges inject the control action in the plant in order to Behavior description Compute the sum of two matrices
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

Input S1 : the first matrix,


find the state and the output actions, otherwise go to step S2 : the second matrix,
4 with the new computed variables (v k+1 , λk+1 , tk+1 ). S3 : the sum matrix ,
Below, we present the different functions developed in this nl : the number of lines of S1 ,
nc : the number of columns of S1 .
firmware, their description, their inputs and their outputs which Output None
allow finally to compute the optimal control action.
• MPC Main: it presents the main program of the MPC
controller. A call of routines of the matrix operations is 4) The Matrix Trans: it is described in Table V and return
made when needed to compute the optimal control action the transpose of a matrix.
using the interior point method. In order to be executed,
TABLE V
this main program needs the declaration of the model, M ATRIX T RANS FUNCTION DESCRIPTION
the prediction horizon, the control horizon, the weighting
Function name Matrix Trans
factor and the number of iterations. It requires also the Function prototype void Matrix Transp(float* M, float* Mt ,
initialization of the control signal and the initialization int n , int m)
of the interior point variables such as λ0 , t0 and v 0 . Behavior description Compute the transpose of a matrix
Input M : the matrix, Mt : the transpose matrix,
Moreover, the system clock frequency is configured using n: the number of lines of M ,
RCC Configuration function described in Table I: m: the number of columns of M .
Output None
TABLE I
RCC C ONFIGURATION FUNCTION DESCRIPTION
5) The Prod Vect Sca : it is described in Table VI and it
Function name RCC Configuration allows the multiplication of a vector with a scalar.
Function prototype void RCC Configuration(void)
Behavior description Configures the different system clocks TABLE VI
Input None P ROD V ECT S CA FUNCTION DESCRIPTION
Output None
Function name Prod Prod Vect Sca
Function prototype void Prod Vect Sca(float *V, float *S, float
• Matrix Operations: it contains all the matrix manipula- *VS, int n11 , int m11 )
tion functions described below: Behavior description Compute the product of a vector with a
scalar
1) Zero Matrix: it is described in Table II and allows to Input V : the vector,
initialize all the matrices at zeros. S: the scalar,
V S: the result ,
TABLE II n11 : the number of lines of V ,
Z ERO M ATRIX FUNCTION DESCRIPTION m11 : the number of columns of V .
Output None
Function name Zero Matrix
Function prototype void Zero matrix(float *T, int nz , int mz )
Behavior description Matrix initialization 6) Matrix Inverse : This routine returns the resulting in-
Input T: the output matrix, verted matrix using augmented matrix with the Gauss
nz : the number of lines of T,
mz : the number of columns of T. Jordan algorithm. Its parameters are described in table
Output None VII.

2) Matrix Product: it is described in Table III and allows V. S IMULATION EXAMPLES


the multiplication of two matrices. The main features of the proposed constrained MPC con-
3) The Matrix Sum: it is described in Table IV and make troller software are illustrated through two examples. All these
the sum of two matrices. examples were tested in run mode and executed from the

International Scholarly and Scientific Research & Innovation 5(8) 2011 882 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

TABLE VII
M ATRIX I NVERSE FUNCTION DESCRIPTION A. A First order plant
Function name Matrix Inverse The first example is a simple first order system which has
Function prototype void Matrix Inverse(float *M, float *Inver, the following discrete time model:
int nlines)
Behavior description Compute the inverse of a matrix 0.09516z −1
M : the input matrix,
y(k) = u(k)
Input 1 − 0.9048z −1
Inver: the inverted matrix,
nlines: the number of lines of M . The closed loop simulation results are obtained with the
Output None following constrained MPC and anti windup PID parameters:
Hp = 5, Hc = 1, λ1 = 6, Kp = 5.7, Ki = 0.1 and
Kd = 0.25, starting from: u(0) = u(1) = 0.1 and x0 = [0 0]T .
flash memory. In order to allow the implementation of such The PID gains are computed using the Takahashi method. In
a computationally expensive controller on chip, we propose addition, the following constraints are considered : 0.07 ≤
reducing the frequency of the STM32 CPU to 24MHz while u(k) ≤ 3.2 for the MPC and the PID and −2 ≤ Δu(k) ≤ 2
maintaining good performance. This value is the maximum for the MPC.
frequency of STM32 discovery which is characterized by a The Fig. 3 presents the closed loop simulation results of the
very low price and additional peripherals comparing with the first order system.
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

proposed STM32 Keil board (for example: it contains a DAC:


3
Digital to Analog Converter). All the simulations examples MPC output
were performed on a Core 2 Duo CPU 2.2 GHz/3.00 Go RAM. PID output
2
set−point
Moreover, besides the constrained MPC firmware, the anti
1
windup PID controller was implemented in the STM32 on
the Keil tool, using the Takahashi method anti saturation of 0
0 50 100 150 200
the integral term [23], [24]. Therefore, the control signal is Iterations

computed as follows: (a)

u(k) = Kp ε(k) + ui (k) + ud (k) 4


MPC control PID control u u
max min
3
where:
⎧ 2

⎨umax − (Kp ε(k) + ud (k)) if u0 (k) > umax 1
ui (k) = umin − (Kp ε(k) + ud (k)) if u0 (k) ≤ umin

⎩ 0
ui (k − 1) + Kp TTsi ε(k − 1) otherwise 0 50 100
Iterations
150 200

(b)
in which:
1 Kp N
ud (k) = ud (k − 1) − , Fig. 3. Closed-loop simulation results for the first order plant
1 + Kd Ts 1 + Kd N
Ts
u0 (k) = Kp ε(k) + ui (k) + Kp ε(k − 1) + ud (k),
Ti B. A second order plant
ε(k) = w(k) − y(k), In this second example, we consider a classical angular
Ts Td positioning system. The system is consisted of a rotating
Ti = , Kd = ,
Ki Ts antenna at the origin of the plane, driven by an electric motor.
The control problem is to use the input voltage to the motor
and N ≥ 5 and Ts is the sampling time.
to rotate the antenna so that it is always points in the direction
In this work, we found that solving the QP problem as in
of a moving object in the plane [3].
8 and 9 as it is commented in [14] sometimes gave incorrect
The motion of the antenna can be described by the following
results. In fact, in order to overcome this limitation, we re-
discrete-time equation obtained from their continuous time
scaled the QP problem as follows: counterparts by discretization, using a sampling time of 0.1s
and Euler’s first order approximation for the derivative and
1  based on the observer canonical form:
min( ΔU T QΔU cT ΔU )
+ (13)
2
   
s.t: θ(k + 1) 1 0.1
x(k + 1) = = x(k)

JΔU ≤
g (14) θ̇(k + 1) 0 0.9
 
0
where : Q = αQ,  c = αc , J = βJ and g = βg, in which + u(k)
0.0787
α and β are scalar constants. It is observed that the scaling  
y(k) = 1 0 x(k)
of Q, c, J and g matrices to a range of ±1 do not change
the solution of the original QP problem, however it allows The closed loop simulation results are obtained with the
obtaining accurate solutions. following constrained MPC and anti windup PID parameters:

International Scholarly and Scientific Research & Innovation 5(8) 2011 883 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

Hp = 6, Hc = 1, λ1 = 0.1, Kp = 7.58, Ki = 0.1 and 1.5


output1 output2 set−point
Kd = 0.12 starting from: u(0) = u(1) = 0.1 and x0 = [0 0]T . 1
In Fig. 4, the closed loop simulations of the angular posi-
0.5
tioning process using the constrained MPC and the PID anti
windup methods is presented where the following constraints 0
0 50 100 150
are considered: 0 ≤ u(k) ≤ 30 for both methods and Iterations

−2 ≤ Δu(k) ≤ 2 for the MPC method. (a)


However, Fig. 5 shows the closed loop simulations of the
15
angular positioning process using the constrained MPC and
the PID anti windup methods where only constraints on the 10
control deviation signal are considered as follows: −0.7 ≤ control1 control2

Δu(k) ≤ 0.7 for the first simulation (output1, control1 and 5

Δu1) and −0.35 ≤ Δu(k) ≤ 0.35 for the second simulation 0


0 50 100 150
(output2, control2 and Δu2). Iterations

(b)
3
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

1
2
0.5
1
set−point output PID output MPC
0
0 Δumax2 Δumax1 Δu1 Δu2
0 50 100 150 200
Iterations
−0.5
0 50 100 150
(a) Iterations

(c)
30

20 Fig. 5. Closed-loop simulation results for angular positioning process:


constraints on control deviation
10
control MPC control PID u
max
0
0 50 100 150 200
Iterations of predicting the behavior of the output with respect to the set-
(b) point changes. In addition Fig. 5, shows that when we reduce
the control deviation constraints, the response of the MPC is
Fig. 4. Closed-loop simulation results for angular positioning process: more sluggish.
constraints on control Tables IX and X list the time performance of the proposed
constrained MPC software. In the first table the control horizon
is fixed at 1. However, for the second one the prediction
VI. I NTERPRETATIONS AND RESULTS horizon is equal to 4.
Figs. 3, 4 and 5 show that the proposed software constrained TABLE IX
MPC contoller and the anti windup PID based on STM32 P ERFORMANCE STUDY FOR H C =1
successfully control both processes with a good set-point
tracking. The prediction horizon (Hp) 2 4 6 8
The average execution time per 0.766 0.776 0.785 0.795
sample (ms)
TABLE VIII
P ERFORMANCE C OMPARISON BETWEEN PID AND MPC CONTROLLER

PID anti MPC TABLE X


windup controller P ERFORMANCE STUDY FOR H P =4
1st 2nd 1st 2nd
example example example example
The control horizon (Hc) 1 2 3 4
The average execution 3.5 13.214 316.554 785
The average execution time per 0.766 3.626 10.586 234.468
time per sample (μs)
sample (ms)
The flash memory 5.956 7.34 8.858 8.884
code size (KBytes)
Based on these tables, it can be seen that when the predic-
Although based on table VIII, the execution time of the tion horizon grows higher, the computation time of the on-line
on-line algorithm of the anti windup PID is less than that of MPC algorithm increases slightly. However, this increase is
the MPC, the last method has more parameters such as λ1 , Hc considerably clear when the control horizon rises. This can be
and Hp which allow controlling the performances of the closed explained by the computation each iteration of some matrices
loop response. Indeed, from the simulation results of Figs. 3 in which their dimensions depend on the control horizon such
and 4, we notice that the constrained MPC has the advantage as: J, Λ and T .

International Scholarly and Scientific Research & Innovation 5(8) 2011 884 scholar.waset.org/1307-6892/4067
World Academy of Science, Engineering and Technology
International Journal of Electrical and Information Engineering
Vol:5, No:8, 2011

VII. C ONCLUSION [14] K. Ling, S. Yue, and J. Maciejowski, “A fpga implementation of model
predictive control,” in Proceedings of American Control Conference,
Two frameworks for embedding constrained model predic- 2006.
[15] K. Ling, B. Wu, and J. Maciejowski, “Embedded model predictive
tive control and PID anti windup controller on a performed control (mpc) using a fpga,” in Proceedings of the 17th World Congress:
STM32 microcontroller have been provided. The STM32 Keil The International Federation of Automatic Control, Seoul, Korea, 2008.
starter kit was used to implement both firmwares. Two exam- [16] U. R. Y. Jayaraman, “Fpga implementation of predictive control strategy
for power factor correction,” in Proceedings of World Academy of
ples were used to test the proposed software performances. Science, Engineering and Technology, 2008.
Hence, an efficient implementation of this code yields a low [17] G. Palomo, K. Hilton, and J. Rossiter, “Predictive control implementa-
computational burden with a high speed. Indeed based on the tion in a plc using the iec 1131.3 programming standard,” in Proceedings
of American Control Conference, 2009.
simulation results, we noticed that the proposed softwares con- [18] A. K. Abbes, F. Bouani, and M. Ksouri, “A microcontroller implementa-
trol successfully the processes with a good set-point tracking. tion of model predictive control,” in Proceedings of International Con-
A comparison between both softwares has also been done. ference on Computer, Electrical, and Systems Sciences, and Engineering,
WASET, 2011.
Although the low computational burden of the PID anti windup [19] P. Lascaux and R. Thodor, Analyse numerique matricielle appliquee
software comparing to this of the constrained MPC, the last l’art de l’ingenieur, tome 1. Dunod, 2004.
one gives better control performances such as output prediction [20] C. V. Rao, S. J. Wright, and J. B. Rawlings, “Application of interior-point
methods to model predictive control,” Journal of Optimization Theory
and less control signal oscillation. This comparison results and Applications, vol. 99, no. 3, pp. 723–757, 1998.
International Science Index, Electrical and Information Engineering Vol:5, No:8, 2011 waset.org/Publication/4067

should allow the use of MPC to be pioneered in an increasingly [21] S. Wright, “Applying new optimization algorithms to model predictive
wide range of process industries where the computational load control,” in Fifth International Conference on Chemical Process Control,
1997.
has been considered too great and encourage to implement [22] STMicroelectronics, “Datasheet stm32f103x8, stm32f103xb,” 2009.
such control method in microcontrollers. There are still much [Online]. Available: http://www.st.com/internet/mcu/family/141.jsp
detailed analysis and tests to be done, which should handle [23] A. Voda and S. Gentil, Regulateur PID analogique et numeriques.
Technique de l’ingenieur, 1999.
multivariable systems and a power consumption study in all [24] S. Sung, J. Lee, and I. Lee, Process Identification and PID Control.
possible low power modes has to be investigated. John Wiley and Sons (Asia), 2009.

R EFERENCES
[1] E. Camacho and C. Bordons, Model Predictive Control. London:
Springer, 2004.
[2] P. Campo and M. Morari, “Robust model predictive control,” in Pro-
ceedings of American Control Conference, 1987, pp. 1021–1026.
[3] M. Kothare, V. Balakrishnan, and M. Morari, “Robust constrained model
predictive control using linear matrix inequalities,” Automatica, vol. 32,
no. 10, pp. 1361–1379, 1996.
[4] Z. Wan and M. Kothare, “Robust output feedback model predictive
control using linear matrix inequalities,” Journal of Process Control,
vol. 12, pp. 763–774, 2001.
[5] Y. Wang and J. Rawlings, “A new robust model predictive control
method 1: theory and computation,” Journal of Process Control, vol. 14,
pp. 231–247, 2002.
[6] A. Casavola, D. Famularo, and G. Franze, “Robust constrained predictive
control of uncertain norm-bounded linear systems,” Automatica, vol. 40,
pp. 1865–1876, 2004.
[7] G. Pannochia, “Robust model predictive control with guaranteed set
point tracking,” Journal of Process Control, vol. 14, pp. 927–937, 2004.
[8] T. Alamo, D. Ramirez, and E. Camacho, “Efficient implementation of
constrained min-max model predictive control with bounded uncertain-
ties: a vertex rejection approach,” Journal of Process Control, vol. 15,
pp. 149–158, 2005.
[9] A. Kheriji, F. Bouani, and M. Ksouri, “Efficient implementation of
constraind robust model predictive control using a state space model,”
in Proceedings of International Conference on Informatics in Control,
Automation and Robotics (ICINCO), 2010.
[10] A. Kheriji, F. Bouani, and M.Ksouri, “Ggp approach to solve non convex
min-max robust model predictive controller for a class constrained mimo
systems,” in Proceedings of the International Workshop on Symbolic
and Numerical Methods, Modeling and applications to circuit design,
(SM2ACD) CEDA competition, 2010.
[11] A. Kheriji, F. Bouani, and M. Ksour, “A ggp approach to solve non
convex min-max predictive controller for a class of constrained mimo
systems described by state-space models,” International Journal of
Control Automations and Systems (IJCAS), vol. 9, no. 3, 2011, will
appear in June.
[12] S. Karacan, H. Hapoglu, and M. Alpbaz, “Generalized predictive control
to a packed distillation column for regulatory problems,” in European
Symposium on Computer Aided Process Engineering, 1998.
[13] G. D. Nicolao, L. Magni, and R. Scattolini, “Robust predictive control of
systems with uncertain impulse response,” Automatica, vol. 32, no. 10,
pp. 1475–1479, 1996.

International Scholarly and Scientific Research & Innovation 5(8) 2011 885 scholar.waset.org/1307-6892/4067

You might also like