Sei sulla pagina 1di 31

Integrated Multiple Predictive Algorithm Control Tool.

Tool for the Second Edition of the book MPC


By E.F.Camacho and C.Bordons

SUMMARY

Page

1. Introduction
2. Installation
3. Users interface
4. System Source files for Impact
5. System
6. The System File Window
7. Controller
7.1. GPC: Generalized Predictive Control
7.2. SPG: GPC with Smith Predictor
7.3. DMC: Dynamic Matrix Control
7.4. PFC: Predictive Functional Control
7.5. SSMPC: State Space MPC
8. Experiment
9. Indications to perform an experiment
10. Acceding variables through Matlab workspace
11. Possible errors

2
2
3
4
7
8
9
10
11
12
14
14
17
23
25
26

APPENDIX I
Files from the book: the way of preloading an experiment
12.1. Example source Code
12.2. Glossary of code for preloading

28
28
29

IMPACT: Integrated Multiple Predictive Algorithm Control Tool.


1. INTRODUCTION
The objective of this program is to show several linear predictive controllers inside an
only user interface that allows simulating systems in such an easy and fast way. It gives
the opportunity to change the parameters of a simulation to analyze the differences
produced.
The controllers implemented under the interface are:

GPC (Generalized Predictive Control)


SPGPC (GPC with Smith Predictor)
DMC (Dynamic Matrix Control)
PFC (Predictive Functional Control)
SSMPC (State Space Model Predictive Control)

The algorithms for all these controllers have been programmed for a generic
multivariable case to work with SISO and MIMO systems.
The interface will let to select the system to simulate, the controller to be used, and the
design parameters of this control. Regarding to the parameters relative to the
experiment, it will be possible to set its duration, reference to reach, constraints and
additional fields, such as noise and disturbances.
The result of the simulation will be a graphic, time versus outputs, and it will be
possible to add other ones to get more information about the experiment.
2. INSTALLATION
1. Unzip the file IMPACT.ZIP into a directory, this will result in the files needed
for this program (p files), and some subdirectories with the examples (m files).
2. It is necessary to add the path of this directory into the Matlab path in order to
run IMPACT correctly.

3. USERS INTERFACE
Typing impact in the MATLAB Command Window brings up the IMPACT interface
with the next figure:

The interface is divided in three different parts:


SYSTEM: This part loads the system file to be simulated, changes its properties
(matrices) and saves a system created by the user in a file.
CONTROLLER: It sets the kind of MPC controller to be used, and allows
changing the specific tuning parameters, such as horizons or weighting matrices.
EXPERIMENT: It establishes the main features of the simulation: time,
reference parameters, constraints, noises, disturbances and graphics to be
showed.
Apply and Cancel are the buttons that start the simulation or close the interface
respectively. Apply makes all the calculations of the experiment verifying the correct
filling of the fields in the interface, and advising through warning or error windows
about possible errors.

4. SYSTEM SOURCE FILES FOR IMPACT


A system source file in IMPACT will contain the different matrices that model the
behaviour of a system.
The following forms of modelling a system are accepted by IMPACT.
1. Carima Model.
( z 1 ) y (t ) z d ( z 1 ) u (t 1)

1
C ( z 1 ) e(t )

A and B model the system, and the delay factor (z-d) have been integrated in B.
For example a model with d=3 given by:
(1 az 1 ) y (t ) z 3 (b0 b1 z 1 ) u (t 1) e(t )

will be described in the system file in the next way:


A=[1 a]; B=[0 0 0 b0 b1];
This model is used by controllers GPC, SPGPC and DMC, for this case with a previous
transformation from CARIMA into a Step Response model.
2. Step Response Model

y (t ) g i u (t i )
i 1

Used by DMC, it is implemented by the matrix g in the file. The length of this
matrix sets the upper value of the prediction horizon in the DMC controller. The
variable gninputs contains the inputs of the system, necessary if IMPACT works with
the step response model.
3. Space State Model
X (t ) M X (t 1) N u (t 1)
y (t ) Q X (t )

M, N and Q describe the system. In the file their names are the variables Mm,
Nm and Qm. They are used by PFC and SSMPC controllers.
These models are used by the simulator of the process, but it is possible that the
controller uses a different model of the system, i.e. an Error Modelling, that can be
enabled in the interface. In this case the file system will contain other matrices named
by Ap and Bp for the CARIMA, gp for the Step response, and Mp, Np and Qp for the
State Space Model.
A general information about the system in the file is contained in the cell array sinfo.

The system file also contains two variables that set the reference for the system:

1. Constant Reference: vrefc, that contains a constant reference for the outputs. It is a
column vector with the Set-Points in the case of using a constant reference in the
experiment. Notice that its size will be the number of outputs of the system.
2. Variable Reference: vrefv, built by the creator of the system file to describe changes
in the Set-Point. It is a matrix whose vectors are the Set-Points for each output. The
length of these vectors will be adapted to the simulation time of the experiment.
An example of the structure of a m-file accepted by IMPACT is the next one (SISO
system):
% e1s1d0.m
% Model Matrices
A=[1 -0.8];
B=[0.2];
% Error Model Matrices:.
Ap=[1 -0.875];
Bp=[0.154];
%Step response model and error modelling
g =[0;0.2;0.36;0.488;0.5904;0.67232;0.737856;0.7902;0.83222;...
0.865782272;0.8926258176;0.91410065408;0.9312805;0.945];
gp=g;
gninputs=1; %Needed if the system only works with g
%State-Space Model
Mm=0.8; Nm=0.5; Qm=0.4;
%State Space Error Modelling
Mp=0.9; Np=0.5; Qp=0.35;
%Information of the system
sinfo={'FIRST ORDER SYSTEM WITHOUT DELAY'};
%Constant SP
vrefc=[0.5];
%Built Variable SP built on vrefv
intt=50;totalt=100; %Local variables to built vrefv
vrefv=[0.5*ones(1,intt) , 0.25*ones(1,(totalt-intt)+1)];

There are several options for the system files that are described in Appendix I. These
ones are designed specifically to load an experiment directly with the system file. They
have been used with the example and exercise files that accompany this software,
corresponding to the chapters of the book MPC.
In spite of this, these options can be used by the user to create his system and
experiment files.

5. SYSTEM

The system part initially present two fields:


A list menu that includes the m-files of the directory
A button that allows changing the directory which the system files are included
in.
Pressing this button the next window appears:
Current directory

It moves to the
directory above
List of
subdirectories

In the field Directory it is possible to write directly the root of the system file
location. To search it, press the button to go to the directory above of choose in the list
menu some of the subdirectories to continue. When the root directory is ready, press the
button Apply.
Then the main window loads the names of all the m-files in the root in the field FILE.
You can display it and choose some of the system files.
CAUTION 1: When a file is selected, the program executes the m-file, so this one has
to store the parameters required by the interface. However if you choose another kind of
system, the results could be unpredictable, causing errors. In this case close the
IMPACT interface and load it again, selecting an appropriate system.
CAUTION 2: Type the name of the unit in the edit field if you want to change from C:\
the unit that stores the system files.
Selecting one of the system file the system is completed with the next fields:

General Information
about the system

Button that
opens the
system
window

In the case of selecting a system file with the possibility of loading an experiment from
the file, such as files with examples and exercises of the book, a new button appears.
Pressing LOAD EXPERIMENT all the parameters of the experiment and the control are
loaded (see Appendix I for more information).

This step is quite enough to continue the selection of the controller and the experiment.
If you want to see more details of the system, change it of save a new system into a file,
press the System Info button to open the System File Window.
6. THE SYSTEM FILE WINDOW
All the fields indicated in the previous point could be showed by pressing the System
Info in the main menu.

The fields Inputs, Outputs and Delays are automatically calculated by IMPACT through
the given model.
Then, it is possible to change the system by some of its model descriptions, writing
directly over the edit fields. In this case the fields inputs, outputs and delays, can be
automatically reloaded, changing the matrices of the system.
Press Cancel if you do not want to load the changes. The changes will be enabled
pressing Save Changes and Close.
If we want to save the changed system pressing on Save in a File, a new window
appears, asking for the name and the root of the file.

Change the directory or the file name to the wished one. A general information about the
system (commentaries, description, 5 lines maximum) could be added too. Pressing
SAVE button the changes are completed and the file is saved.
7. CONTROLLER
This part enables the type of controller to be used, and the possibility of considering a
modelling error for the system load above.
The modelling error button enables it for Prediction Model , Ap,Bp, or Mp,Np and Qp
instead of the model represented by A,B or Mm, Nm and Qm. This mode will be
possible only if the system file contains an error modelling, in other case a warning
window will be displayed.

ON

7.1. GENERALIZED PREDICTIVE CONTROL (GPC)


This control uses the CARIMA model, where B contains the delay factor:
( z 1 ) y (t ) ( z 1 ) u (t 1)

1
C ( z 1 ) e(t )

where the unmeasurable disturbance is given by a white noise coloured by C(z-1).


The objective function is a quadratic cost function of he form::
N2

J( N1, N2, N u) =

y (t j | t ) w(t j )

Nu

j N1

u (t j 1 | t )

2
Q

j 1

Where y (t j / t ) is the optimal prediction in t+j of the system output computed in t, w


is the reference trajectory. N1 and N2 are the initial and the final value of the prediction
horizon and Nu is the control horizon. R and Q are positive matrices that represent the
weightings for the trajectory and the control respectively.
Considering the effect of the delay d in the system, the horizons N1 and N2 have been
chosen in the following way:
N1=d+1
N2=d+N
N will be the prediction horizon parameter of the GPC.
Four parameters are necessary for tuning the controller:
N, PREDICTING HORIZON
Nu, CONTROL HORIZON
Q1, CONTROL WEIGHT. Column vector that contains the weighting of each
control input. Its size is [q1;;qn], being n: number of inputs.
R1, REFERENCE WEIGHT. Column vector that contains the weighting of each
output with size number of outputs.
Q1 and R1 appear initially as column vectors with 1s. The program internally uses a
diagonal matrices Q and R, whose diagonals are the elements of Q1 and R1.

Applying for each controller, the tuning parameters appear on the right side of the
controller to show the active parameters and their values.

7.2. GPC WITH SMITH PREDICTOR (SPGPC)


It uses the same parameters as GPC, but internally contains a Smith Predictor as dead
time compensator.
It is equal to the GPC but it offers the possibility of tuning a ROBUSTNESS FILTER
in the case when the error modelling is enabled.

Pressing on the Robustness filter button, it is possible to choose the constant of the
filter for each output.

Tf is a column vector with a size equal to the outputs of the system. A value different
from 0 makes active the filter when Modelling Error is ON.

7.3 DYNAMIC MATRIX CONTROL (DMC)


This controller used the Step Response Model, that is:
y (t )

g
i 1

u (t i )

where gi are the coefficients of the Step Response.


And the objective function is:
N2

J=

y (t j / t ) w(t j )

jN1

Nu

u (t j 1)

2
Q

j 1

The DMC controller implemented in IMPACT uses the Step response Model stored in
the system file, or a Step Response Model that is calculated from the CARIMA model,
also stored in the file.
The DMC allows to the user the selection of the source of this Step Response Model.
Pressing the button DMC we can see the parameters for this kind of control:

List menu, to choose the Step Response Model, directly from file through matrix
g (or gp if Error Modelling is ON), or from CARIMA model. If some of the two
models are not in the file, the options are nor enabled.
p : Value for Prediction Horizon. N1=1 and N2=p
N: Highest Value for Prediction Horizon. This parameter depends on the model,
if Step Response model from file is active, N must be lower than the length of
the array g. If the CARIMA model is enabled, the program calculates the Step
Response Model with the length N.
m: Control horizon, Nu=m.
Q1 and R1: weighting vectors, similar to the previous controllers.

Press the button Apply to make the control active.

CAUTION 1:
If the system file does not contain the matrix g, the program will use the CARIMA
model to perform the Step response model. In this case the try of enabling the Step
response model from file provokes the next message, changing the option to the
CARIMA model.

CAUTION 2:
If the Step Response model from file is enabled, the possible highest value for the
prediction horizon is the length of g. If this parameter is selected higher, the next
warning message appears, changing N to the highest value.

CAUTION 3:
If p has been selected higher than N, the next error message appears.

CAUTION 4:
p has got a minimum value that is m-1. If p has been selected higher than this one, the
next error message appears, changing automatically to the minimum correct value.

7.4. PREDICTIVE FUNCTIONAL CONTROL (PFC)


This control uses the Space State model, given by:
X (t ) M X (t 1) N u (t 1)
y (t ) Q X (t )

and the next objective function:


J = y (t hk ) w(t hk )
Nh

k 1

This controller has two parameters for tuning:


Prediction Horizon, Nh.
Number of basis functions: nB.

In the case of selecting the PFC, the algorithm has not been implemented with the
possibility of adding CONSTRAINTS, so they are not supported.
This kind of controller always uses the Filter Reference for trajectory, so it is not
enabled the value of alpha is set to 0.
7.5. STATE SPACE MPC (SSMPC)
This control uses the Space State model, given by:

X (t ) M m X (t 1) N m u (t 1)
y (t ) Q m X (t )

The SSMPC controller designed for IMPACT considers two different cases:
Case 1: Non Incremental Model
The cost function is:

w(t j | t ) Q
N2

j N1

Subject to:

J=
x (t j | t )

2
R

u (t j 1 | t )

2
Q

w(t N 2 | t ) Q

x (t N 2 | t )

2
P

x(t i | t ) X , i N1...N 2
Qm x(t i | t ) Y , i N1...N 2
u (t i 1 | t ) U , i N1...N 2
u (t i 1 | t ) K x(t i 1 | t ), i N 3...N 2

(Re st1)

where N1 is considered as 0.
The matrix P and K are computed as follows:
LQ local controller enabled: the LQ regulator is considered as local controller,
and hence
K=KLQR
P= PLQR
LQ controller disabled: the control actions are considered to remain constant.
Then the constraints corresponding to Rest1 is transformed into:
u (t i | t ) u (t i 1 | t ) u (t N 3 1 | t ), i N 3...N 2

and P is considered as P=0.


Case 2: Incremental Model.
The model is transformed into:
xk 1 M m

u k 1 0

z k 1

y k Qm

0 z k

Nm
I

xk N m

u k
uk I

The cost function is:


J

w(t j | t ) Q
N2

jN1

x(t j | t )

2
R

u (t j 1 | t )

2
Q

w(t N 2 | t ) Q

x(t N 2 | t )

subject to:
x(t i | t ) X , i N1...N 2
Qm x(t i | t ) Y , i N1...N 2
u (t i 1 | t ) U , i N1...N 2
u (t i 1 | t ) K X x (t i 1 | t ) KU u (t i 1 | t ), i N 3...N 2

(Re st 2)

The two possibilities through the LQ controller are:


LQ controller enabled: The local controller of the augmented plant is the LQR.
Thus,
K=[KX , KU]= KLQR P= PLQR

LQ controller disabled: The increments of the control actions are considered to


be zero, and hence
K=0 P= 0

Attending to this configuration, the parameters for this controller inside IMPACT are:

Incremental Model: Pressing on this button it will be used the Incremental


model for the control.
LQ Controller: To active the local control press the button LQ local Control.

2
P

N1: Initial value for the prediction horizon. Its value is fixed to 1.
N2: Final value for the prediction horizon.
N3: Control horizon.
Q1: Control weighting vector.
R1: Reference weighting vector.

And the aspect of the parameters menu for SSMPC is:

8. EXPERIMENT
SAMPLE TIME

It establishes the number of samples of the experiment. Initially it has a duration of 100.
FILTER FOR REFERENCE TRAJECTORY.
IMPACT allows setting the way of choose the reference trajectory w(t) in the cost
function where it appears.
It can be done in two different ways:
1.Filter for reference trajectory ON. It means that the reference is estimated in all the
prediction horizon in the way:
w(t k ) w(t k 1) (1 )ref (t k )
k 1...N
(alpha) is a parameter between 0 and 1(the closer to 1 the smoother the approximation)
that constitutes an adjustable value that influence the dynamic response of the system.

2.Filter OFF. The reference trajectory is equal to ref in the entire prediction horizon.

ref contains the set-point for the experiment in each instant, and it is loaded from file or
built in the experiment through the option DEFINE SET-POINT.
REFERENCE KNOWN A PRIORI
Impact allows the user to set if the future reference is known a priori or not. If this is
known the system can react before the change has effectively been made, thus avoiding
the effects of delay in the process response.
In SSMPC and PFC the reference has to be known a priori, so this field is ON.

SET-POINT DEFINITION
CONSTANT SET POINT
When the system is loaded, appear the set-point constant values stored in the variable
vrefc from the system file.
It could be changed into different values for the experiment.

Selecting CONSTANT SP, IMPACT creates a set-point vector for each output with the
needed size (based on the prediction horizon) stored in variable ref.
DEFINE SET-POINT

This field allows using a dynamic set-point in the experiment.

It opens a new window with the different ways of selection:

It loads the value of


vrefv on set-point

It builds a new set-point


using steps in reference

It could be done in two different ways:


Variable SP from file:
It takes the vector built in the system file and stored on the variable vrefv.
Define Variable SP.
This tool allows building a set-point though steps. The number of steps in the
set-point is defined in the list NUMBER OF STEPS, until a maximum of 3
steps.
This option displays a new window, SET POINT BUILDER, where it is
possible to set the step time, the values and draw the new set-point.

Press Draw to see the new set-point, Accept to validate the changes and close the
window, and Exit to Close it without saving.
CAUTION 1:
Every time that the Time of the experiment is redefined the Set-Point definition mode
turns to CONSTANT SP.
CAUTION 2:
The variable set-point defined in the file corresponds to a experiment time, that is, if
vrefv has a length of 100, this corresponds to a experiment time of 100. If this time is
not equal to this length, IMPACT fits the reference vector to the time. This is made in
two ways:
1. If vrefv contains a number of points lower than the experiment time, the
program extends the vector till the length corresponding to the experiment time
with a value constant and equal to the last value of vrefv.
2. If vrefv contains a number of points higher than the experiment time, the
program cuts the vector to the length corresponding to the experiment time, and
the rest is not considered.
In these two cases, a warning dialog is displayed and changes internally made:

CONSTRAINTS
The button CONSTRAINTS open a window that gives the possibility of setting the
restrictions for the controllers.
These constraints are the next ones:
Constraints on incremental inputs.
Constraints on inputs.
Constraints on outputs.
These are enabled for GPC,SPGPC, DMC and SSMPC controllers.
Constraints on states.
Only enabled for SSMPC controller.
Monotonic Constraints
Non-Minimum Phase Constraints.
Only enabled for GPC, SPGPC and DMC controller. They can not be used
simultaneously.
The algorithm implemented by IMPACT for PFC controller does not allow using
constraints, so they all are not enabled for it.
The CONSTRAINTS window has this appearance:

To active some of the constraints mark the corresponding radiobutton and press
APPLY. In the main window appears an information about the constraints enabled.

The button CONSTRAINTS turns green to indicate that it is active.


CAUTION:
Press the button APPLY to make the changes, but try not to use the Close Window
button in the right upper corner. If you want to cancel the constraints, enter again in
the window and make all ones inactive.

NOISES AND DISTURBANCES


IMPACT includes the possibility for adding noises and disturbances to the outputs
signals in the experiment.
Noises: It is a coloured white noise added to the output signal in a range
given by user.
Disturbances: It is a signal added to the output signal in a time given by user.
In both cases we can activate the noises or disturbances setting ON in the pop-up
menu:

The Noise Window.


Impact allows setting the ouput signal with added noise, simply enabling the
corresponding radio button.
It is possible to define the amplitude of the noise, writing the values for the highest
and the lowest value to be added.

The Disturbances Window


In the same way that in noise case, we activate the output signal through the
corresponding radio button.
There are two possibilities to select the disturbance:
Impulse Disturbance: disturbance produced in a sample time.
Step Disturbance, produced between two sample times.
The value of the disturbance can be edited in the frame closest to the output. A value
equal to 0 indicates the same thing that if the output were not enabled.
There are three times that can be selected by user:
Time for Impulse disturbance: The time where the disturbance is added to
the output signal.
Start time for Step disturbance.
End time for Step Disturbance.

In the two cases the user will select the output that will be disturbed and its value.
Select the times for disturbance and press APPLY IMPULSE or APPLY STEP to
validate the changes, or CANCEL to Exit without activating noise or disturbances.

GRAPHICS
These buttons allows the user choose what graphics will be displayed after the
calculation made by APPLY BUTTON.

Pressing Apply and not activating any of the GRAPHICS button, the program plots the
output signals of the system by defect.
Plots that can be added are

Delta u: It plots the incremental inputs.


U: It plots the inputs of the system.
Set-Points: reference drawn together with the output signals
States: Only for SSMPC.

Some information about the control and the experiment has been added in the plots.
This information contains the selected parameters for the controller, and it they are
enabled, the features added to the experiment, such as Error Modelling, Disturbances or
Noise.

The keys for some words of the plot title are:


LQ: LQ controller ON for SSMPC controller.
INC: Incremental ON for SSMPC controller.
ERR MOD: Error Modelling ON.
DIST: Disturbances added in the experiment.
NOISE: Noise added in the experiment.
RKNOWN: Reference known a priori.
RFILTER: Filter for reference ON.

In the case of selecting STATES plots for the SSMPC, these graphics are drawn
into a new window.
9. INDICATIONS TO PERFORM AN EXPERIMENT
We recommend following these indications in order to execute correctly the experiment:
1. Select the system.
If you need to make some modifications or simply to see its values, go into the
System Info Window.
2. Select the controller and its parameters.
This step is necessary every time to change the system, that is because the
parameters have to be reloaded in a correct way. That is, if you select a 2x2
system and its control, the matrices R1 and Q1 will take values of size 2x1;
therefore if you change the to a 1x1 system these matrices will not be correct,
unless you reload the control and force the change.
3. Fill the experiment parameters.
It is convenient to follow this order filling these fields.
Set the experiment time.
Select the Filter for the Reference trajectory and the value of alpha (when
it is possible).
Select if the Reference is known a priori.
Select the set-point (Constant or Variable).
Fill the constraints if the experiment requires it.
Add noises or disturbances.
Select the graphics to be drawn
4. Press the button Apply
Then the simulation is performed in two stages. In the first one the system and
the experiment parameters are validated, and a message like this appears in order
to advise the user that all the parameters have been filled correctly:

Pressing OK the simulation loop starts, a message about its evolution is


displayed:

If the experiment is completed IMPACT will displayed the graphics. If some


error occurs an error window appears (See 11).

10. ACCESSING VARIABLES THROUGH MATLAB WORKSPACE


Every time IMPACT performs a simulation, some variables are ready in Matlab
workspace. The most of them are not important, because they are used for the interface
and to store additional information to execute correctly the experiment.
Some of them can be useful for other purposes and they are available for any other
Matlab application.
Variables that stores the graphical outputs:

Timeplot: Vector with the sample times.


Ypplot: Column vector with the outputs.
Refplot: Column vector with the set-points.
Upplot: Column vector with the inputs.
urealplot: Column vector with the incremental inputs.
xplot: Column vector with the states (only for SSMPC).

Other accessible variables:


YP: Column vectors with the outputs.
ref: Column vector with the set-points.
UP: Column vector with the incremental inputs.
ureal: Column vector with the inputs.
xplot: Column vector with the states (only for SSMPC).
ruidos: Vector with noise added to the output signal.
Ypert: Vector with disturbances added to the output signal.
These variables appear complete and they are cut by IMPACT to obtain the plot
variables.
GPC, SPGPC and DMC:
G: GPC matrix for GPC and SPGPC, and Dynamic Matrix for DMC.
H: is equal to GRG+Q
R: Reference Weighting Matrix.
Q: Control Weighting Matrix.
PFC:
Bb: Matrix for base functions.
YB: Matrix that stores the response for each of the base functions in every
instant of the horizon.
X: Column vector with the states.
Xp: Column vector with the states considering the process model.
SSMPC:
A, B, C: Matrices of the system (A is Mm, B is Nm and C is Qm).
X, Y, U, IncU: Matrices for constraints.
K: LQ Local Controller.
P: Weighting matrix for Terminal cost.

11. POSSIBLE ERRORS


Some errors can be produced whilst the IMPACT is executed. Here we give a brief
description about this possibility. We appreciate very much any contribution to detect
them, so do not hesitate to contact the authors for any problem executing IMPACT, in
order to improve the interface and solve these ones.
1. Error in file

The selected system is not appropriate for IMPACT, i.e, the system file has not got the
structure described in point 4.
Some other Error Windows are opened with this one. Close all of them and try with
another system.

2. Non Appropriate system file

It appears when the previous error has been not detected, and System File Window is
pressed. Load other system file.
3. Error in Matlab command window
Missing operator, comma, or semi-colon.
Error in ==> C:\MATLABR11\work\vacNu.m
On line 10 ==> Nu1=eval(get(gco,'String'));
??? Error while evaluating uicontrol Callback.
??? 5
|
Missing operator, comma, or semi-colon.
Error in ==> C:\MATLABR11\work\writeSSMPCpar.m
On line 9 ==> vNu=eval(N3SSMPC);
??? Error while evaluating uicontrol Callback.

This error is due to an error writing some of the parameters of the controller, i.e. to write
a character instead a number, or a parenthesis instead a bracket.
This does not stop IMPACT, so you can continue the simulation realizing that the
correct change has to be done.
4. Error validating data pressing Apply.
If you press Apply in IMPACT interface and some of the parameters introduced are not
correct or have not the correct size, a message like this will appear:

And a message with the source of the error:

In the adverse case, the parameters are considered correct and the simulation loop starts.
5. Error in simulation loop (controller execution).
If during some sample of the simulation loop the controller fails, a message error is
displayed with the time where this occurs.

And some information about the source of the error, for instance:

APPENDIX I
FILES FROM THE BOOK. THE WAY OF PRELOADING AN EXPERIMENT
It is possible to add in the system file the parameters for the controller and the
experiment in order to store and load some specific experiment. This part is not
important for the user that does not need especially to deep in the interface
configuration, but only in its performing.
This possibility has been used by creators of IMPACT in the system files from the
directory Examples MPC, to build the examples and the exercises of the book MPC. In
this manner, it is very simple to load these files and see the results in the easiest way.
Any system with the experiment defined inside the file, is detected by IMPACT,
showing the button LOAD EXPERIMENT in the SYSTEM field:

In this case, simply pressing the button LOAD EXPERIMENT, the controller and the
experiment are configured, and the user only have to press the APPLY button to perform
the preloaded experiment.
1. EXAMPLE SOURCE CODE
IMPACT uses the structure opt to receive all these kind of parameters. You can see the
specific rules to preload the experiments in point 12.2.
The next code is added to a system file to preload the controller and the experiment. It is
a GPC controller and the experiment takes 200 samples, filter reference enabled with
alpha 0.9, constant SP, and constraints on incremental inputs.
%OPTIONS TO FILL THE INTERFACE
%controller DMC
opt.GPC='on';
opt.NGPC=10;
opt.NuGPC=5;
opt.Q1GPC=[1];
opt.R1GPC=[1];
%experiment
opt.time=200;
opt.sp='constant';
opt.reffilter='on';
opt.alpha=0.9;
opt.refknown='on';
opt.constdu='on';
opt.umax=[2];
opt.umin=[-3];

Although this utility has been designed to load in the simplest way the experiment
described in the book, it can be very interesting to the user to create its own options to
add to its files.

2. GLOSSARY OF CODE FOR PRELOADING


Controller and Parameters:
CONTROLLER GPC Parameters
opt.GPC
Prediction horizon
opt.NGPC
Control horizon
opt.NuGPC
Control weighting
opt.Q1GPC
Reference weighting opt.R1GPC

Assignment Value
on
numeric value
numeric value;
[value/s (sep by ;)]
[value/s (sep by ;)]

Example
opt.GPC='on';
opt.NGPC=10;
opt.NuGPC=5;
opt.Q1DMC=[1;.9];
opt.R1DMC=[1;3];

CONTROLLER SPGPC Parameters


opt.SPG
Prediction horizon
opt.NSPG
Control horizon
opt.NuSP
Control weighting
G
Reference weighting
opt.Q1SPG
Robustness Filter
opt.R1SPG
Constants for filter
opt.robust
opt.Tf

Assignment Value
on
numeric value
numeric value;
[value/s (by ;)]
[value/s (by ;)]
on
[value/s (by ;)]

Example
opt.SPG='on';
opt.NSPG=10;
opt.NuSPG=5;
opt.Q1SPG=[1;.9];
opt.R1SPG=[1;3];
opt.robust'on';
opt.Tf=[0.7;0.8];

CONTROLLER DMC

Assignment Value
on
step/carima
numeric value
numeric value;
numeric value;
[value/s (by ;)]
[value/s (by ;)]

Example

Parameters
opt.DMC
Step Response Model
opt.modstep
Min Prediction horizon opt.pDMC
Max Prediction horizon opt.NDMC
Control horizon
opt.mDMC
Control weighting
opt.Q1DMC
Reference weighting
opt.R1DMC
CONTROLLER PFC

Parameters
opt.PFC
Prediction horizon
opt.NPFC
Number of basis functions opt.nBPFC
CONTROLLER
SSMPC
LQ CONTROLLER
INCREMENTAL
Prediction horizon
Control horizon
Control weighting
Reference weighting

Assignment Value
on
numeric value
numeric value;

Parameters

Assignment
Value
opt.SSMPC
on
opt.LQ
on/off
opt.incremental on/off
opt.N2SSMPC numeric value
opt.N3SSMPC numeric value;
opt.Q1SSMPC [value/s (by ;)]
opt.R1SSMPC [value/s (by ;)]

FOR ALL CONTROLLERS


MODELLING ERROR

Parameters
opt.moderror

opt.DMC='on';
opt.modstep='step';
opt.pDMC=15;
opt.NDMC=20;
opt.mDMC=2;
opt.Q1DMC=[1];
opt.R1DMC=[1];

Example
opt.PFC='on';
opt.NPFC=10;
opt.nBPFC=1;

Example
opt.SSMPC='on';
opt.LQ='on';
opt.incremental='off';
opt.N2SSMPC=20;
opt.N3SSMPC=2;
opt.Q1SSMPC=[1];
opt.R1SSMPC=[1];

Assignment Value
on/off

Example
opt.moderror,'on'

EXPERIMENT
Feature

Parameters

Assignment Value

Example

Time
Filter for
Reference
Trajectory
Value of Alpha
Set Point type

opt.time

numeric value

opt.time=25;

opt.reffilter

on/off

opt.reffilter='off';

opt.alpha
opt.sp

opt.alpha=0.9;
numeric value
constant/variable opt.sp='constant';

Reference known
a priori

opt.refknown

off/on

Constraints on
Inc Inp(du)
Value of dumax
Value of dumin

opt.constdu
opt.umax
opt.umin

on
[value/s (by ;)]
[value/s (by ;)]

Constraints on
Inputs (u)
Value of dumax
Value of dumin

opt.constu
opt.Umax
opt.Umin

on
[value/s (by ;)]
[value/s (by ;)]

Constraints on
Outputs (y)
Value of ymax
Value of ymin

opt.consty
opt.ymax
opt.ymin

on
[value/s (by ;)]
[value/s (by ;)]

Constraints on
States (x)
Value of xmax
Value of xmin

opt.constu

on
[value/s (by ;)]
[value/s (by ;)]

Non Minimum
Phase Monotonic
Constraints

opt.constfnm
opt.constmon

Disturbances
Type of
disturbance
Values of
disturbance
Time for impulse
Start time for step
End time for step

opt.disturbances on

opt.vper
opt.tper
opt.t1per
opt.t2per

[value/s (by ;)]


number
number
number

Noise
Outputs with noise
Amplitude of

opt.noise
opt.vnoise
opt.amplitude

on
[value/s (by ;)]
number

opt.xmax
opt.xmin

opt.refknown='on';
opt.constdu='on';
opt.umax=[2];
opt.umin=[-3];

on
on

opt.disturbmode impulse/step

opt.disturbances='on';
opt.disturbmode='step';
opt.vper=[.3;0];
opt.t1per=1;
opt.t2per=120;

opt.noise='on';
opt.vnoise=[0;1];
opt.amplitude=0.025;

noise

CAUTION:
It is important to use the same format of the strings in the structure opt.
Note that opt.GPC=ON is not the same that opt.GPC=on, so please do not use the
capital ones.

Potrebbero piacerti anche