Thread Subject: Sliding mode control in Simulink

Subject: Sliding mode control in Simulink

From: Arnaud Miege

Date: 6 Mar, 2003 09:27:22

Message: 1 of 4

Hi!! I am trying to implement a sliding mode controller in Simulink
and am having some trouble. The controller works fine in Matlab, but
I can't find an easy way to make it work in Simulink.


What I would like the controller to do is:


if U_kmh<20
    KFB = KFB_20*U_kmh/20;
    AAk = AA_20*U_kmh/20;
    BB0k = BB0_20*U_kmh/20;
    H = H_20*U_kmh/20;
elseif U_kmh<30
    KFB = (1-(U_kmh-20)/10)*KFB_20 + (1-(30-U_kmh)/10)*KFB_30;
    H = (1-(U_kmh-20)/10)*H_20 + (1-(30-U_kmh)/10)*H_30;
    AAk = (1-(U_kmh-20)/10)*AA_20 + (1-(30-U_kmh)/10)*AA_30;
    BB0k = (1-(U_kmh-20)/10)*BB0_20 + (1-(30-U_kmh)/10)*BB0_30;
elseif U_kmh<40
    KFB = (1-(U_kmh-30)/10)*KFB_30 + (1-(40-U_kmh)/10)*KFB_40;
    H = (1-(U_kmh-30)/10)*H_30 + (1-(40-U_kmh)/10)*H_40;
    AAk = (1-(U_kmh-30)/10)*AA_30 + (1-(40-U_kmh)/10)*AA_40;
    BB0k = (1-(U_kmh-30)/10)*BB0_30 + (1-(40-U_kmh)/10)*BB0_40;
% etc...
elseif U_kmh<90
    KFB = (1-(U_kmh-80)/10)*KFB_80 + (1-(90-U_kmh)/10)*KFB_90;
    AAk = (1-(U_kmh-80)/10)*AA_80 + (1-(90-U_kmh)/10)*AA_90;
    BB0k = (1-(U_kmh-80)/10)*BB0_80 + (1-(90-U_kmh)/10)*BB0_90;
    H = (1-(U_kmh-80)/10)*H_80 + (1-(90-U_kmh)/10)*H_90;
elseif U_kmh<100
    KFB = (1-(U_kmh-90)/10)*KFB_90 + (1-(100-U_kmh)/10)*KFB_100;
    AAk = (1-(U_kmh-90)/10)*AA_90 + (1-(100-U_kmh)/10)*AA_100;
    BB0k = (1-(U_kmh-90)/10)*BB0_90 + (1-(100-U_kmh)/10)*BB0_100;
    H = (1-(U_kmh-90)/10)*H_90 + (1-(100-U_kmh)/10)*H_100;
else
    KFB = KFB_100;
    AAk = AA_100;
    BB0k = BB0_100;
    H = H_100;
end


xestdot = (AAk+BB0k*KFB-H*CC0)*xest + H*y;
u = KFB*xest;


where AA_xx, BB0_xx, KFB_xx and H_xx are matrices that have been
previously defined. I would then integrate xestdot into xest and feed
it back with the other inputs (U_kmh and y). I managed to sort of
make it work using if action subsystems but it falls over if I go
over the same speed range twice.


The other thing is that I'm planning to use this in real-time on xPC
target so it must be able tu run in real-time. Anybody has any ideas?


Many thanks,

Subject: Sliding mode control in Simulink

From: PRANVANAND S

Date: 5 Jan, 2012 17:20:09

Message: 2 of 4

"Arnaud Miege" <am304@eng.cam.ac.uk> wrote in message <eeba5c2.-1@WebX.raydaftYaTP>...
> Hi!! I am trying to implement a sliding mode controller in Simulink
> and am having some trouble. The controller works fine in Matlab, but
> I can't find an easy way to make it work in Simulink.
>
>
> What I would like the controller to do is:
>
>
> if U_kmh<20
> KFB = KFB_20*U_kmh/20;
> AAk = AA_20*U_kmh/20;
> BB0k = BB0_20*U_kmh/20;
> H = H_20*U_kmh/20;
> elseif U_kmh<30
> KFB = (1-(U_kmh-20)/10)*KFB_20 + (1-(30-U_kmh)/10)*KFB_30;
> H = (1-(U_kmh-20)/10)*H_20 + (1-(30-U_kmh)/10)*H_30;
> AAk = (1-(U_kmh-20)/10)*AA_20 + (1-(30-U_kmh)/10)*AA_30;
> BB0k = (1-(U_kmh-20)/10)*BB0_20 + (1-(30-U_kmh)/10)*BB0_30;
> elseif U_kmh<40
> KFB = (1-(U_kmh-30)/10)*KFB_30 + (1-(40-U_kmh)/10)*KFB_40;
> H = (1-(U_kmh-30)/10)*H_30 + (1-(40-U_kmh)/10)*H_40;
> AAk = (1-(U_kmh-30)/10)*AA_30 + (1-(40-U_kmh)/10)*AA_40;
> BB0k = (1-(U_kmh-30)/10)*BB0_30 + (1-(40-U_kmh)/10)*BB0_40;
> % etc...
> elseif U_kmh<90
> KFB = (1-(U_kmh-80)/10)*KFB_80 + (1-(90-U_kmh)/10)*KFB_90;
> AAk = (1-(U_kmh-80)/10)*AA_80 + (1-(90-U_kmh)/10)*AA_90;
> BB0k = (1-(U_kmh-80)/10)*BB0_80 + (1-(90-U_kmh)/10)*BB0_90;
> H = (1-(U_kmh-80)/10)*H_80 + (1-(90-U_kmh)/10)*H_90;
> elseif U_kmh<100
> KFB = (1-(U_kmh-90)/10)*KFB_90 + (1-(100-U_kmh)/10)*KFB_100;
> AAk = (1-(U_kmh-90)/10)*AA_90 + (1-(100-U_kmh)/10)*AA_100;
> BB0k = (1-(U_kmh-90)/10)*BB0_90 + (1-(100-U_kmh)/10)*BB0_100;
> H = (1-(U_kmh-90)/10)*H_90 + (1-(100-U_kmh)/10)*H_100;
> else
> KFB = KFB_100;
> AAk = AA_100;
> BB0k = BB0_100;
> H = H_100;
> end
>
>
> xestdot = (AAk+BB0k*KFB-H*CC0)*xest + H*y;
> u = KFB*xest;
>
>
> where AA_xx, BB0_xx, KFB_xx and H_xx are matrices that have been
> previously defined. I would then integrate xestdot into xest and feed
> it back with the other inputs (U_kmh and y). I managed to sort of
> make it work using if action subsystems but it falls over if I go
> over the same speed range twice.
>
>
> The other thing is that I'm planning to use this in real-time on xPC
> target so it must be able tu run in real-time. Anybody has any ideas?
>
>
> Many thanks,

Subject: Sliding mode control in Simulink

From: PRANVANAND S

Date: 5 Jan, 2012 17:21:08

Message: 3 of 4

Hi...


can u post ur code to me...


will try for u.

"Arnaud Miege" <am304@eng.cam.ac.uk> wrote in message <eeba5c2.-1@WebX.raydaftYaTP>...
> Hi!! I am trying to implement a sliding mode controller in Simulink
> and am having some trouble. The controller works fine in Matlab, but
> I can't find an easy way to make it work in Simulink.
>
>
> What I would like the controller to do is:
>
>
> if U_kmh<20
> KFB = KFB_20*U_kmh/20;
> AAk = AA_20*U_kmh/20;
> BB0k = BB0_20*U_kmh/20;
> H = H_20*U_kmh/20;
> elseif U_kmh<30
> KFB = (1-(U_kmh-20)/10)*KFB_20 + (1-(30-U_kmh)/10)*KFB_30;
> H = (1-(U_kmh-20)/10)*H_20 + (1-(30-U_kmh)/10)*H_30;
> AAk = (1-(U_kmh-20)/10)*AA_20 + (1-(30-U_kmh)/10)*AA_30;
> BB0k = (1-(U_kmh-20)/10)*BB0_20 + (1-(30-U_kmh)/10)*BB0_30;
> elseif U_kmh<40
> KFB = (1-(U_kmh-30)/10)*KFB_30 + (1-(40-U_kmh)/10)*KFB_40;
> H = (1-(U_kmh-30)/10)*H_30 + (1-(40-U_kmh)/10)*H_40;
> AAk = (1-(U_kmh-30)/10)*AA_30 + (1-(40-U_kmh)/10)*AA_40;
> BB0k = (1-(U_kmh-30)/10)*BB0_30 + (1-(40-U_kmh)/10)*BB0_40;
> % etc...
> elseif U_kmh<90
> KFB = (1-(U_kmh-80)/10)*KFB_80 + (1-(90-U_kmh)/10)*KFB_90;
> AAk = (1-(U_kmh-80)/10)*AA_80 + (1-(90-U_kmh)/10)*AA_90;
> BB0k = (1-(U_kmh-80)/10)*BB0_80 + (1-(90-U_kmh)/10)*BB0_90;
> H = (1-(U_kmh-80)/10)*H_80 + (1-(90-U_kmh)/10)*H_90;
> elseif U_kmh<100
> KFB = (1-(U_kmh-90)/10)*KFB_90 + (1-(100-U_kmh)/10)*KFB_100;
> AAk = (1-(U_kmh-90)/10)*AA_90 + (1-(100-U_kmh)/10)*AA_100;
> BB0k = (1-(U_kmh-90)/10)*BB0_90 + (1-(100-U_kmh)/10)*BB0_100;
> H = (1-(U_kmh-90)/10)*H_90 + (1-(100-U_kmh)/10)*H_100;
> else
> KFB = KFB_100;
> AAk = AA_100;
> BB0k = BB0_100;
> H = H_100;
> end
>
>
> xestdot = (AAk+BB0k*KFB-H*CC0)*xest + H*y;
> u = KFB*xest;
>
>
> where AA_xx, BB0_xx, KFB_xx and H_xx are matrices that have been
> previously defined. I would then integrate xestdot into xest and feed
> it back with the other inputs (U_kmh and y). I managed to sort of
> make it work using if action subsystems but it falls over if I go
> over the same speed range twice.
>
>
> The other thing is that I'm planning to use this in real-time on xPC
> target so it must be able tu run in real-time. Anybody has any ideas?
>
>
> Many thanks,

Subject: Sliding mode control in Simulink

From: Thomas Marullo

Date: 5 Jan, 2012 18:19:08

Message: 4 of 4

Try using a Matlab Embedded Function Block. You can write your MATLAB code it in and it should work.

"Arnaud Miege" <am304@eng.cam.ac.uk> wrote in message <eeba5c2.-1@WebX.raydaftYaTP>...
> Hi!! I am trying to implement a sliding mode controller in Simulink
> and am having some trouble. The controller works fine in Matlab, but
> I can't find an easy way to make it work in Simulink.
>
>
> What I would like the controller to do is:
>
>
> if U_kmh<20
> KFB = KFB_20*U_kmh/20;
> AAk = AA_20*U_kmh/20;
> BB0k = BB0_20*U_kmh/20;
> H = H_20*U_kmh/20;
> elseif U_kmh<30
> KFB = (1-(U_kmh-20)/10)*KFB_20 + (1-(30-U_kmh)/10)*KFB_30;
> H = (1-(U_kmh-20)/10)*H_20 + (1-(30-U_kmh)/10)*H_30;
> AAk = (1-(U_kmh-20)/10)*AA_20 + (1-(30-U_kmh)/10)*AA_30;
> BB0k = (1-(U_kmh-20)/10)*BB0_20 + (1-(30-U_kmh)/10)*BB0_30;
> elseif U_kmh<40
> KFB = (1-(U_kmh-30)/10)*KFB_30 + (1-(40-U_kmh)/10)*KFB_40;
> H = (1-(U_kmh-30)/10)*H_30 + (1-(40-U_kmh)/10)*H_40;
> AAk = (1-(U_kmh-30)/10)*AA_30 + (1-(40-U_kmh)/10)*AA_40;
> BB0k = (1-(U_kmh-30)/10)*BB0_30 + (1-(40-U_kmh)/10)*BB0_40;
> % etc...
> elseif U_kmh<90
> KFB = (1-(U_kmh-80)/10)*KFB_80 + (1-(90-U_kmh)/10)*KFB_90;
> AAk = (1-(U_kmh-80)/10)*AA_80 + (1-(90-U_kmh)/10)*AA_90;
> BB0k = (1-(U_kmh-80)/10)*BB0_80 + (1-(90-U_kmh)/10)*BB0_90;
> H = (1-(U_kmh-80)/10)*H_80 + (1-(90-U_kmh)/10)*H_90;
> elseif U_kmh<100
> KFB = (1-(U_kmh-90)/10)*KFB_90 + (1-(100-U_kmh)/10)*KFB_100;
> AAk = (1-(U_kmh-90)/10)*AA_90 + (1-(100-U_kmh)/10)*AA_100;
> BB0k = (1-(U_kmh-90)/10)*BB0_90 + (1-(100-U_kmh)/10)*BB0_100;
> H = (1-(U_kmh-90)/10)*H_90 + (1-(100-U_kmh)/10)*H_100;
> else
> KFB = KFB_100;
> AAk = AA_100;
> BB0k = BB0_100;
> H = H_100;
> end
>
>
> xestdot = (AAk+BB0k*KFB-H*CC0)*xest + H*y;
> u = KFB*xest;
>
>
> where AA_xx, BB0_xx, KFB_xx and H_xx are matrices that have been
> previously defined. I would then integrate xestdot into xest and feed
> it back with the other inputs (U_kmh and y). I managed to sort of
> make it work using if action subsystems but it falls over if I go
> over the same speed range twice.
>
>
> The other thing is that I'm planning to use this in real-time on xPC
> target so it must be able tu run in real-time. Anybody has any ideas?
>
>
> Many thanks,

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com