Implementation of Iterative Learning Control in Matlab/Simulink
41 次查看(过去 30 天)
显示 更早的评论
Hey, am working on the development of an Iterative Learning Controller for a simple transfer function (Initially Low Order), Can anyone help in getting started with the implementation of ILC in Simulink using Matlab fucntions.??
回答(5 个)
John Sam
2018-11-25
Hi,
Has anyone been able to implement ILC in Matlab?
Can someone please share the code of an example simulation.
Thank you.
0 个评论
Mark Sherstan
2018-12-12
This question is a little outdated but has lots of views so I wanted to provide an answer. Here is an example that should push people in the right direction for an open loop ILC MATLAB function. Changing the function to closed loop only requires providing feedback as with any basic control loop.
Start off with some made up transfer function and sampling time and then convert it into discrete time.
Ts = 0.01;
num = [100];
den = [1 120];
sysc = tf(num,den);
sysd = c2d(sysc,Ts,'ZOH');
I am assuming that the cycle repeats every second and follows the peaks 5 - 2 - 4 - 5 - 0 which are evenly spaced apart. This is my refernce signal. Initial conditions are 0, with no pure time delay, and the relative degree is 1 (which can be confirmed above). Running the function below will create a plot of the error, input and output. As the iteration count grows the input and output are adjusted by the learning matrix L (has a coeffcient of 0.95 in this example) so that error eventually goes to zero after 10 or so itterations. Give it a run and try for yourself!
function [ ] = ILC(sysd,Ts)
% Get state space values for ILC
[Ad Bd Cd Dd] = ssdata(sysd);
% Initial condition x0, time range t - assume 1 second, pure time delay n0, relative
% degree r, and matrix size N
x0 = 0;
t = 0:Ts:1;
n0 = 0;
r = 1;
N = length(t);
% Define input vector U and reference J - Refernce = input for this example
Rj = [5*ones(1,20) 2*ones(1,20) 4*ones(1,20) 5*ones(1,20) 0*ones(1,21)]';
U = Rj;
% G0 not formulated as initial condition is 0
% Formulate G
Gvec = zeros(N,1);
rVec = ((r-1):(N-n0-1))';
for ii = 1:length(rVec)
ApowVec = Ad^rVec(ii);
Gvec(ii) = Cd*ApowVec*Bd;
end
G = tril(toeplitz(Gvec));
% Set up ILC
jmax = 15;
l0 = 0.95; L = l0 * eye(N,N);
q0 = 1.00; Q = q0 * eye(N,N);
Uj = zeros(N,1); Ujold = Uj;
Ej = zeros(N,1); Ejold = Ej;
% Run ILC and plot the response for each iteration
for ii = 1:jmax
Uj = Q*Ujold + L*Ejold;
Yj = G*Uj;
Ej = Rj - Yj; Ej(1) = 0;
Ejold = Ej;
Ujold = Uj;
plotter(ii,t,Ej,Yj,Uj,Rj,U)
end
end
function [] = plotter(ii,t,Ej,Yj,Uj,Rj,U)
figure(1)
% Plot the error Ej of the current itteration
subplot(1,3,1);
plot(t,Ej,'LineWidth',1.5);
title('Error, Ej','FontSize',16);
ylabel('Error Response','FontSize',16);
ylim([-5 5])
% Plot the input Uj of the current itteration
subplot(1,3,2);
plot(t,Uj,t,U,'-k','LineWidth',1.5);
title({['Iteration: ', num2str(ii)],'Input, Uj'},'FontSize',16);
xlabel('Time (s)','FontSize',16);
ylabel('Input Response','FontSize',16);
ylim([0 7])
% Plot the output Yj of the current itteration
subplot(1,3,3);
plot(t,Yj,t,Rj,'-k','LineWidth',1.5);
title('Output, Yj','FontSize',16);
ylabel('Output Response','FontSize',16);
ylim([0 7])
pause(0.5);
end
2 个评论
mazin alseadi
2020-11-3
Dear Mr. Mark Sherstan
Please could you kindly send me this codes as a m files , and if you developed it then I will be more thankful !
With respect and appreciate
Harsh
2022-9-16
Rachmad Setiawan
2015-1-28
I want to make an ILC software in Delphi. But I want to make simulation with simulink first. I don't know what I have to do ? Would you mind giving me an explanation
0 个评论
Kim MinSung
2019-4-14
To. Mark Sherstan
May I have a question?
What is a reference about the code mentioned above?
If you answer the reference, it could be more helpful information.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!