Specifications

Control Based On Multiple Plant Models
4-17
variable, and a spring constant calibration signal, which is a measured disturbance
input.
A1=[0 1;-k1/M1 -b1/M1];
B1=[0 0;-1/M1 k1*yeq1/M1];
C1=[1 0];
D1=[0 0];
sys1=ss(A1,B1,C1,D1);
sys1=setmpcsignals(sys1, 'MV', 1, 'MD', 2);
The setmpcsignals command specifies the input type for the two inputs.
We need another model (with the same input/output structure) to predict movement
when the two masses are joined, as follows:
A2=[0 1;-(k1+k2)/(M1+M2) -(b1+b2)/(M1+M2)];
B2=[0 0;-1/(M1+M2) (k1*yeq1+k2*yeq2)/(M1+M2)];
C2=[1 0];
D2=[0 0];
sys2=ss(A2,B2,C2,D2);
sys2=setmpcsignals(sys2, 'MV', 1, 'MD', 2);
Designing the Two Controllers
Next we define controllers for each case. Both use a 0.2 second sampling period, a
prediction horizon of P = 20, a control horizon of M = 1, and the default values for all
other controller design parameters. The only difference in the controllers is the prediction
model.
Ts=0.2; % sampling time
p=20; % prediction horizon
m=1; % control horizon
MPC1=mpc(sys1,Ts,p,m); % Controller for M1 detached from M2
MPC2=mpc(sys2,Ts,p,m); % Controller for M1 connected to M2
The applied force also has the same constraints in each case. Its lower bound is zero (it
can't reverse direction), and its maximum rate of change is 1000 per second (increasing or
decreasing).
MPC1.MV=struct('Min',0,'RateMin',-1e3,'RateMax',1e3);
MPC2.MV=struct('Min',0,'RateMin',-1e3,'RateMax',1e3);