HOW TO INTEGRATE THE SLIDING PART OF SLIDING MODE CONTROL SYSTEM

5 次查看(过去 30 天)
Hi, i am currently working on sliding mode control for two tank systems. I have a problem to on the integral part. I need to integrate (x-5)dt from 0 to t, where t is the sampling time. The coding that I use is as belows:
x1d=x(2);
x1_des=5;
x1_des_d=0;
C = 0.45;
e1=x(1)-x1_des;
e1d=x(2)-x1_des_d;
syms t;
s=x1d+(2*C*e1)+((C^2)*int(e1,t,0,t));
I am using s-function for the coding to be run by the simulink where I think I do not need the loop to integrate the equations. Can someone help me and give me advice to solve this problems? Your help is very appreciated.
Thank you.
  9 个评论
Aliff Ashraff
Aliff Ashraff 2020-6-21
编辑:Aliff Ashraff 2020-6-21
function sys=mdlDerivatives(t,x,u)
global x1_des s ismc
%%Parameters took from:%%
%%Sliding Mode Control of Coupled Tanks System: Theory and and Application%%
%%Tabrej Alam (2013)%%
g=981; %gravity mass (cm/s2)
A=208.2; %area of tank 1 and 2 (cm2)
a1=0.58; %area of connecting pipe between tank 1 and tank 2 (cm2)
a2=0.24; %area of outlet pipe (cm2)
%%Dynamic Model%%
% q1=a1*sqrt(2*g*(h1-h2)); %flow rate from tank 1 to tank 2
% q2=a2*sqrt(2*g*h2); %outlet flow rate at tank 2
% x1d=(ismc-q1)/A; %dh1dt=dx1dt
% x2d=(q1-q2)/A; %fdh2dt=dx2dt
k1=((a1)*(sqrt(2*g))/A); %gain constant
k2=((a2)*(sqrt(2*g))/A); %gain constant
h1=((((k1*sqrt(x(1)))+x(2))/k2)^2)+x(1); %water level tank 1%
h2=x(1); %water level tank 2%
f=((k1*k2)/2)*(((sqrt(h2))/sqrt(h1-h2))-((sqrt(h1-h2))/sqrt(h2)))+((k1^2)/2)-(k2^2);
b=(k2/(2*A))*(1/(sqrt(h1-h2)));
x(1)=h2;
x(2)=(-k1*sqrt(h2))+(k2*sqrt(h1-h2));
%%y=x(1)%%
%Model derivatives%
x1d=x(2); %x(1) dot
x2d=f+(b*ismc); %x(2) dot
%%ismc design%%
x1_des=5; %x2_des = desired x2=h2 (cm)
x1_des_d=0; %x2_des_d = x2 desired dot
x1_des_dd=0; %x2_des_dd = x2 desired dot dot
C = 0.45; %0.08,0.45,0.05 %positive constant lambda
e1=x(1)-x1_des; %e1 = error
e1d=x(2)-x1_des_d; %e1d = e1 dot
syms t;
s=x1d+(2*C*e1)+((C^2)*int(e1,t,0,t)); %sliding equation
%%To define ueq%%
%sd=0; %sd = s dot
%sd=f+(b*u)+(2*C*e1d)+((c^2)e1);
%f+(b*u)+(2*C*e1d)+((c^2)e1)=0;
ueq=(-(1/b))*(f+(2*C*e1d)+((C^2)*e1));
%To define udis%%
M=5500; %5500,0.9 %positive constant
udis=(-M)*sign(s);
%%Conventional smc equation%%
ismc = ueq+udis;
sys = [x1d;x2d];
function sys=mdlOutputs(t,x,u)
global ismc x1_des s
sys = [x(1); ismc;s;x1_des];
This is the coding that i used. I need to get '[x(1); ismc;s;x1_des]' as my output. The 's=x1d+(2*C*e1)+((C^2)*int(e1,t,0,t));' is the equation that contains the integral. Before this I used the same coding but with different 's' equation and I get the expected result that I want. But when it si changed with integral part it got problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by