• 검색 결과가 없습니다.

nlmpcsim

문서에서 Model Predictive Control Toolbox (페이지 167-176)

nlmpcsim

1-76

r

Is a setpoint matrix consisting of N rows and nycolumns, where nyis the number of controlled variables, y:

Where ri(k) is the setpoint for output i at time t = kT, and T is the sampling period (as specified in the step format of model). If the simulation time is larger than NT, the setpoints vary for the first N periods in the simulation, as specified byr, and are then held constant at the values given in the last row of rfor the remainder of the simulation.

In many simulations one wants the setpoints to be constant for the entire time, in which caserneed only contain a single row of nyvalues.

Note thatris the actual setpoint. If you setr=[ ], the default isy0. r

r1( )1 r2( )1 … rn

y( )1 r1( )2 r2( )2 … rn

y( )2

r1( )N r2( )Nrn

y( )N

= … … …

nlmpcsim

4-77 usat

Is a matrix giving the saturation limits on the manipulated variables. Its format is as follows:

Note that it contains three matrices of N rows. N may be different from that for the setpoint matrix,r, but the idea is the same: the saturation limits will vary for the first N sampling periods of the simulation, then be held constant at the values given in the last row ofusatfor the remaining periods (if any).

The first matrix specifies the lower bounds on the numanipulated variables.

For example, umin,j(k) is the lower bound for manipulated variable j at time t = kT in the simulation. If umin,j(k) = –inf, manipulated variable j will have no lower bound at t = kT.

The second matrix gives the upper bounds on the manipulated variables. If umax,j(k) = inf, manipulated variable j will have no upper bound at t = kT.

The lower and upper bounds may be either positive or negative (or zero) as long as umin,j(k)umax,j(k).

, ,

, ,

, ,

, ( ) , ( )

, ,

, ,

, ,

, ( ) , ( )

usat

umin 1, ( )1 … umin n

, u( )1 umin 1, ( )2 … umin n

, u( )2

umin 1, ( )Numin n

, u( )N

=

∆um ax 1, ( )1 … ∆um ax n

, u( )1

∆um ax 1, ( )2 … ∆um ax n

, u( )2

∆um ax 1, ( )N … ∆um ax n

, u( )N umax 1, ( )1 … um ax n

, u( )1 umax 1, ( )2 … um ax n

, u( )2

um ax 1, ( )Num ax n

, u( )N

… … …… ……

nlmpcsim

1-78

The third matrix gives the limits on the rate of change of the manipulated variables. In other words,mpcsimwill force|uj(k) – uj(k – 1)|≤ ∆umax,j(k). The limits on the rate of change must be nonnegative.

Ifusat = [ ], then all the uminvalues will be set to –inf, and all the umaxand umaxvalues will be set to inf.

Note:Saturation constraints are enforced by simply clipping the manipulated variable moves so that they satisfy all constraints. This is a nonoptimal solution that, in general, will differ from the results you would get using the ulimvariable incmpcornlcmpc.

tfilter

Is a matrix of time constants for the noise filter and the unmeasured

disturbances entering at the plant output. The first row of nyelements gives the noise filter time constants and the second row of nyelements gives the time constants of the lags through which the unmeasured disturbance steps pass. If tfilteronly contains one row, the unmeasured disturbances are assumed to be steps. If you settfilter= [ ], no noise filtering and steplike unmeasured disturbances are assumed.

ud0

Equals [u0 d0]. u0 are initial values of the manipulated variables arranged in a row vector having nuelements; nuis the number of the manipulated variables computed bynlmpcsim. d0 are initial values of the measured disturbances arranged in a row vector having ndelements; ndis the number of the measured disturbances. The default isu0 = 0andd0 = 0.

Note: You may use a different number of rows in the matrices r andusat, should that be appropriate for your simulation.

Examples Let us now demonstrate the use of the controllernlmpcsim. Since the plant used in Example 1 is linear, usingmpcsimwould be much faster. The point, however, is to show how masked variables are specified fornlmpcsim.

nlmpcsim

4-79

1 The plant is linear with two inputs and two outputs. It is represented by

The Simulink S-function for this plant is inmpcplant.m. The nominal

steady-state operating condition isy0 = [58.3 1.5]andu0 = [100 1]. The Simulink block to simulate this plant usingnlmpcsimis innlmpcdm1.mand shown in Figure 1-1.

Figure 1-1 Simulink Block for Example 1

The following statements build the step response model and specify the parameter values. Note thatmodeldoes not equal the plant model stored in

dx

---dt –1.2 0

0 –1.5---1

x 0.2

1 u 50

0

+ +

=

y = x

y1, y2 nlmpcsim Demo #1 (Double click on the "?" for more info)

nlmpcsim nlmpcsim t Save Time

y Save Outputs u

Save Inputs

mpcplant Sfunction

Plot Results

?

Load Data Clock

nlmpcsim

1-80

mpcplant.m. The important thing to notice is that bothrandusatare actual variables. They are not deviation variables.

g11=poly(0.4,[1 2]);

g21=poly2tfd(0,1);

g12=poly2tfd(0,1);

g22=poly2tfd(1,[1 1]);

tfinal=8;

delt=0.2;

nout=2;

model=tfd2step(tfinal,delt,nout,g11,g21,g12,g22);

ywt=[1 1];

uwt=[0 0];

M=4;

P=10;

r=[68.3 2];

usat=[100 1 200 3 200 200];

tfilter=[ ];

Kmpc = mpccon(model,ywt,uwt,M,P);

dmodel = [ ];

There are two ways to simulate the closed loop system. We can set the simulation parameters and click on Start under Simulation or via the following statements.

plant=′nlmpcdm1′; y0=[58.3 1.5];

u0=[100 1];

tfsim = 2;

tol=[1e-3];

minstep=[ ];

maxstep=[ ];

[t,yu]=gear(plant,tfsim,[y0 u0],[tol,minstep,maxstep]);

Figure 1-2 shows the response for the setpoint change.

nlmpcsim

4-81 Figure 1-2 Output responses for a setpoint change for Example 1

2 The plant is the paper machine headbox discussed in the section,

“Application: Paper Machine Headbox Control” in Chapter 3. The nonlinear plant model is represented as a Simulink S-function and is inpap_mach.m. The plant has two inputs, three outputs, four states, one measured

disturbance, and one unmeasured disturbance. All these variables are zero at the nominal steady-state. Since the model fornlmpcsimmust be linear, we linearize the nonlinear plant at the nominal steady-state to obtain a linear model. Since the model is simple, we can linearize it analytically to obtain A, B, C, and D.

The Simulink block to simulate this nonlinear plant usingnlmpcsimis in nlmpcdm2.mand shown in Figure 1-3.

nlmpcsim

1-82

Figure 1-3 Simulink Block for Example 2

The following statements build the step response model and specify the parameter values.

A=[-1.93 0 0 0; .394 -.426 0 0; 0 0 -.63 0; .82 -.784 .413 -.426];

B=[1.274 1.274 0; 0 0 0; 1.34 -.65 .203; 0 0 0];

C=[0 1 0 0; 0 0 1 0; 0 0 0 1];

D=zeros(3,3);

% Discretize the linear model and save in MOD form.

dt=2;

[PHI,GAM]=c2dmp(A,B,dt);

minfo=[dt,4,2,1,0,3,0];

imod=ss2mod(PHI,GAM,C,D,minfo);

% Store plant model and measured disturbance model in MPC

% step format Gp, Gw

Np

Nw

nlmpcsim Demo #2 (Double click on the "?" for more info)

nlmpcsim nlmpcsim Step Fcn1

Step Fcn

t Save Time

y Save Outputs

u Save Inputs papmach

Sfunction

Plot Results

Mux

Mux2

Mux

Mux1

? Load

Data

Clock

nlmpcsim

4-83 [model,dmodel]=mod2step(imod,20);

m=5;

p=20;

ywt=[1 0 5]; % unequal weighting of y1 and y3, no control

% of y2

uwt=[1 1]; % Equal weighting of u1 and u2 ulim=[-10 -10 10 10 2 2]; % Constraints on u ylim=[ ]; % No constraints on y

usat=ulim;

tfilter=[ ];

y0=[0 0 0];

u0=[0 0];

r=[0 0 0];

Kmpc=mpccon(model,ywt,uwt,M,P);

Figure 1-4 shows the output responses for a unit-step measured disturbance Np = 1 and a step unmeasured disturbance with Nw = 5.

Figure 1-4 Output responses for a unit-step measured disturbance Np = 1 and a step unmeasured disturbance Nw= 5

See Also mpcsim,nlcmpc

-6 -4 2

0

-2 4

5 10 15 20 25

0 30

Output

Time

Solid: y1 (H2) Dashed: y2 (N1) Dotted: y3 (N2) y1

y2 y3

문서에서 Model Predictive Control Toolbox (페이지 167-176)

관련 문서