Sliding Mode Controller for the Double Integrator
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, My name is Dayal, I am a student of College of Engineering Trivandrum (CET). I am now working on sliding mode control. I have taken a second-order system and tried to control it using sliding mode control. I have tried it in simulink and the system output is not reaching its set point and the phase portrait is going out from zero. So i leave it and tried to work in matlab. Am not familiar with matlab, so if any body have any idea about sliding mode control in matlab or simulink, please help me.
I have taken only a simple second-order system, its canonical representation is given by
A = [0 1;0 0]
B = [0; 1]
X = [x1; x2]
and the control law is given by U = sgn[sigma(x1, x2)]
where sgn(sgima) = 1 when sigma > 0, and -1 when sigma < 0.
If anybody has any idea to do it in simulink or in matlab, please help me...
1 Kommentar
Jetendra kumar Borra
am 31 Mär. 2016
in simulink direct sign block is available, in m file write the code in if loop if s>0 f=1 else if s<0 f=-1 end, where f is sgn(s)
Antworten (2)
Sardar Shazali Sikander
am 29 Mai 2014
Dear Dayal, I have implemented SMC in simulink so I can try to help you but I think you have not given the full detail of your problem. Regards, Sardar Shazali
0 Kommentare
Sam Chak
am 17 Jan. 2024
Hi @DAYAL ND
Not sure if you'll see this or not. After all, this problem was posed around 12 years ago. I rarely come across SMC codes on MATLAB Answers unless I search for them in the File Exchange. Simulink has a Sliding Mode Controller block that was introduced in R2018a, but I haven't tried it yet.
Here is the simulation of Sliding Mode Control for the Double Integrator in MATLAB. Please note that the discontinuous control action from classical sliding mode control will cause high-frequency oscillations around the sliding surface, a phenomenon known as 'chattering'.
%% Old Method: call specific ode solver
% tspan = [0 12]; % simulation time
% x0 = [0; 0]; % initial state values
% [t, x] = ode45(@odefcn, tspan, x0);
%% New Method: create an ode object (introduced in R2023b)
F = ode;
F.InitialValue = [0; 0];
F.ODEFcn = @odefcn;
sol = solve(F, 0, 12); % auto-select ode solver for this problem
t = sol.Time;
x = sol.Solution;
F % Display the ode object to identify the chosen solver
%% Plot results
figure(1)
plot(t, x), grid on
xlabel({'$t$ / sec'}, 'interpreter', 'latex', 'fontsize', 14)
ylabel({'$\mathbf{x}$'}, 'interpreter', 'latex', 'fontsize', 14)
title('Time responses of the states')
legend({'$x_{1}(t)$', '$x_{2}(t)$'}, 'interpreter', 'latex', 'location', 'best', 'fontsize', 14);
figure(2)
% plot(x(:,1), x(:,2)), grid on, axis([0 2 -1 1]) % Old method
plot(x(1,:), x(2,:)), grid on, axis([0 2 -1 1]) % New method
xline(1), yline(0)
xlabel({'$x$'}, 'interpreter', 'latex', 'fontsize', 14)
ylabel({'$\dot{x}$'}, 'interpreter', 'latex', 'fontsize', 14)
title('Phase Portrait shows Chattering')
%% Sliding Mode Control for Double Integrator
function [dxdt, u] = odefcn(t, x)
% State matrix
A = [0 1;
0 0];
% Input matrix
B = [0;
1];
% Setpoint (Reference signal)
sp = 1;
% Classical sliding mode control law
e1 = x(1) - sp; % Error signal
e2 = x(2);
sigma = e1 + e2; % Sliding surface
K = 1; % Switching gain
u = - K*sign(sigma);
% Matrix Differential Equation (2nd-order state-space)
dxdt = A*x + B*u; % x" = u
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu General Applications finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!