Beruflich Dokumente
Kultur Dokumente
Note !
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
Initialization
Some factors which are constant like and the matrix consisting of step response
difference terms are generated by a matlab program. For that purpose Values which are taken.
Prediction Horizon
Control Horizon
Tuning Factor
clear;
close all;
clc;
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
t_vec = 0:T_sampling:100; %
g11 = step(K11,t_vec); %step response coefficients are being
%collected in g11
g11 = [g11;g11(end)*ones(N-length(g11),1)];
for k=1:M+1
for i = k:P
j = k;
G(i,j)= g(i-k+1);
end
end
Fac=(inv(G'*G+lambda*eye(M+1)))*(G');
g_1 = [g;g(N)*ones(P,1)];
temp_g2 = repmat(g_1(1:N)',P,1);
temp_g1 = g_1(2:P+1);
for i = 1:N-1
temp_g1 = [temp_g1 g_1(2+i:P+1+i)];
end
temp_f = temp_g1 - temp_g2;
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
u = [u_temp(1);u(1:end-1,1)];
assignin('base','u',u);
assignin('base','u_old',u_optimal);
end
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
Simulation Results
Set Point
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
DMC on MIMO system
Transfer Matrix Taken
Initialization
No. of past control moves
Prediction Horizon
Control Horizon
Tuning Factor
T_sampling = 0.1;
Ts = 0.01;
u_old_1 = 0;
u_old_2 = 0;
t_vec = 0:T_sampling:199.9;
g11 = step(K11,t_vec);
g12 = step(K12,t_vec);
g21 = step(K21,t_vec);
g22 = step(K22,t_vec);
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
g11 = [g11;g11(end)*ones(P,1)];
g12 = [g12;g12(end)*ones(P,1)];
g21 = [g21;g21(end)*ones(P,1)];
g22 = [g22;g22(end)*ones(P,1)];
G11=zeros(P,M+1);
G12=zeros(P,M+1);
G21=zeros(P,M+1);
G22=zeros(P,M+1);
for k=1:M+1
for i = k:P
j = k;
G11(i,j)= g11(i-k+1);
G12(i,j)= g12(i-k+1);
G21(i,j)= g21(i-k+1);
G22(i,j)= g22(i-k+1);
end
end
Fac=(inv(G'*G+lambda*eye(2*(M+1))))*(G'); % 2(M+1)x 2P
temp_g2_g11 = repmat(g11(1:N)',P,1);
temp_g2_g12 = repmat(g12(1:N)',P,1);
temp_g2_g21 = repmat(g21(1:N)',P,1);
temp_g2_g22 = repmat(g22(1:N)',P,1);
temp_g1_g11 = g11(2:P+1);
temp_g1_g12 = g12(2:P+1);
temp_g1_g21 = g21(2:P+1);
temp_g1_g22 = g22(2:P+1);
for i = 1:N-1
temp_g1_g11 = [temp_g1_g11 g11(2+i:P+1+i)];
temp_g1_g12 = [temp_g1_g12 g12(2+i:P+1+i)];
temp_g1_g21 = [temp_g1_g21 g21(2+i:P+1+i)];
temp_g1_g22 = [temp_g1_g22 g22(2+i:P+1+i)];
end
u = [u1;u2];
save('dmc_mimo_data');
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
Code for DMC
function [u_opt_1,u_opt_2] = fcn(y_meas_1,y_meas_2,temp_f,Fac)
%#codegen
coder.extrinsic('evalin', 'assignin')
r1 = y_meas_1;
r2 = y_meas_2;
y_sp_1 = 1;
y_sp_2 = -1;
alpha = 0.9;
u = zeros(2000,1); % 2Nx1; past moves
u = evalin('base','u'); % Read value from workspace
u_old_1 = 0;
u_old_2 = 0;
u_old_1 = evalin('base','u_old_1');
u_old_2 = evalin('base','u_old_2');
ref_1 = zeros(1,900); % 1,P
ref_2 = zeros(1,900);
for i =1:900 %1:P
r1 = alpha*r1 + (1-alpha)*y_sp_1;
r2 = alpha*r2 + (1-alpha)*y_sp_2;
ref_1(i) = r1;
ref_2(i) = r2;
end
ref = [ref_1';ref_2'];
f_1 = y_meas_1*ones(900,1);
f_2 = y_meas_2*ones(900,1);
y_meas = [f_1;f_2];
f = y_meas + temp_f*u; % Free Response
u_temp = Fac*(ref-f);
u_opt_1 = u_old_1 + u_temp(1);
u_opt_2 = u_old_2 + u_temp(601);
u = [u_temp(1);u(1:999);u_temp(601);u(1001:1999)];
assignin('base','u',u);
assignin('base','u_old_1',u_opt_1);
assignin('base','u_old_2',u_opt_2);
end
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
Simulation Results
Set Point_1 = 1 Set Point_2 = -1
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller
Analysis
For the tuning parameters taken DMC is working good for SISO system with settling time of < 8sec while
PID is taking > 15 seconds to settle.
For MIMO system simulation has been run for two set of set points and results are as follows.
References
Eduardo Camacho, F and Carlos Bordons (2002). Model Predictive Control. London. Springer.
https://github.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-
Horizon-Controller