State Space Control for the Pendulum-Cart System: A short tutorial on using Matlab® and Simulink®

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2018
  • This is a short tutorial on using Matlab® and Simulink® in control engineering. Specifically, it is about designing and testing of a (digital) state feedback controller including a state observer for a simplified model of the so-called pendulum-cart system.
    This tutorial can be seen as a supplement to the exercises of the lecture “CAE in der Regelungstechnik” by LRS at TUK.
    By: Alen Turnwald
    Note that it is presumed that you are already familiar with the concepts of linear control and systems in state space.
    For the preliminaries, please refer to the corresponding lectures and literature.
    The completeness and correctness of the statements in the video are NOT guaranteed.
    -- Edit:
    - At 9:43: B has to be changed to C after copying! (This ist done during a cut.)
    The simulation is also available at:
    github.com/turnwald/CAE_Exercise
    Homepage: www.eit.uni-kl.de/liu/

ความคิดเห็น • 105

  • @_ch1pset
    @_ch1pset 4 ปีที่แล้ว +135

    For Matlab version R2019b, the subsystem of the simulink model needs to be as such:
    input gain must be Matrix(K*u) : should read B*u
    output gain must be Matrix(u*K) : should read u*B
    and feedback gain must be Matrix(K*u) (u vector) : should read A*uvec
    I spent hours bashing my head against the wall on this. Despite having taken a systems class, I am mostly clueless when it comes to reading these diagrams, but I kind of understand it. I just need to spend more time with it.

    • @tyl1275
      @tyl1275 4 ปีที่แล้ว

      It's really useful. Thank you. And I also made some other adjustments , then the model can run correctly.

    • @galaxymariosuper
      @galaxymariosuper 4 ปีที่แล้ว +1

      Bro.... Thank you!!!

    • @tsuyaosone1535
      @tsuyaosone1535 4 ปีที่แล้ว +4

      Lmao, a life saver right here

    • @tsuyaosone1535
      @tsuyaosone1535 4 ปีที่แล้ว +2

      Bro, you literally saved my life lol

    • @tsuyaosone1535
      @tsuyaosone1535 4 ปีที่แล้ว +2

      Can people actually like and up his comment so everyone could see this update

  • @2682guna
    @2682guna 4 ปีที่แล้ว +11

    Thank you for the tutorial.. This is the only video that I could find in youtube that explains a state feedback and observer design construction in a clear and concise manner. Please do keep them coming...

  • @vacant4
    @vacant4 5 ปีที่แล้ว

    the animation and your LaTeX document look so nice! well done with this project

  • @fernandochicaiza6636
    @fernandochicaiza6636 5 ปีที่แล้ว +11

    For new versions of Matlab (2018b), the block of A matrix must be configured like Matrix (K*u) (u vector). Nice Video EIT!

    • @junu51211
      @junu51211 4 ปีที่แล้ว

      Thank a lot! Could you explain to me the difference between 'Matrix (K*u)' and 'Matrix (K*u) (u vector)'?

  • @zhc3404
    @zhc3404 4 ปีที่แล้ว +1

    thank you sir! your vedio helps me a lot

  • @user-vr7pm5rx2f
    @user-vr7pm5rx2f 3 ปีที่แล้ว

    YOU ARE SO GREAT! PROFESSOR . a student from china

  • @radyafariez4849
    @radyafariez4849 3 ปีที่แล้ว

    really helpful! thank u so much

  • @demirelus141
    @demirelus141 2 ปีที่แล้ว

    Thank you very much. Very usefull

  • @edenyanko9521
    @edenyanko9521 6 ปีที่แล้ว +1

    thank you so much !

  • @kiranganji3235
    @kiranganji3235 3 หลายเดือนก่อน

    Love you sir ❤ from India

  • @mc7931
    @mc7931 4 ปีที่แล้ว +18

    Could you talk about how to create the animation model?

  • @Impedancenetwork
    @Impedancenetwork 5 ปีที่แล้ว +1

    Peisham has the same question I do. How did you create the inverted pendulum animation in Figure 1? I need to learn how to do that.

  • @muhammadarifanwar1339
    @muhammadarifanwar1339 4 ปีที่แล้ว

    Sir how can we consider the exogenous (reference +disturbance ) input in the state-space model in Simulink?

  • @bipinkoirala2962
    @bipinkoirala2962 3 ปีที่แล้ว

    How do you control the pendulum angle to not rotate beyond certain angle (say 5 degree)?

  • @jameskalenga7546
    @jameskalenga7546 3 ปีที่แล้ว +3

    Hello sir, can you please share the link of that document you used for the pendulum analysis. Thank you

  • @salehabuali8879
    @salehabuali8879 หลายเดือนก่อน

    thank you

  • @angelsscroll
    @angelsscroll 9 หลายเดือนก่อน

    Thank you sir! Can I obtain a procedure for deriving the equations of motion for that system?

  • @thewordoflife764
    @thewordoflife764 3 ปีที่แล้ว

    Hallo Allen, this is very insightful, thanks. I already sent you a message via Research gate.

  • @raktimmazumdar5794
    @raktimmazumdar5794 5 ปีที่แล้ว

    sir, I am trying to design a MPC controller for active suspension system by using the MATLAB script and simulink rather than using the in-built MPC block available in the matlab.. can you please make a video to how to do it... or atleast guide me somehow!! PLEASE.. thank you.

  • @amirsamanmirjalili7103
    @amirsamanmirjalili7103 2 ปีที่แล้ว

    Hey can you please tell me where can I read about those dynamic equations

  • @jhoancastillo4819
    @jhoancastillo4819 ปีที่แล้ว

    how do you make the animation? thanks for the video !!

  • @le4523
    @le4523 3 ปีที่แล้ว

    Can anyone tell me, how to combine the Matlab control with an Adams subsystem?

  • @giacomobertocchini8321
    @giacomobertocchini8321 3 ปีที่แล้ว

    How you create the animation model?

  • @hiuuw1806
    @hiuuw1806 หลายเดือนก่อน

    how to get A, B C D matrix of linearization formula?

  • @p.z.8355
    @p.z.8355 5 ปีที่แล้ว +1

    How do you choose the sampling time for the zero-order-hold ? Is it the lowest sampling time of the sensors or some average sampling time of the sensors and I interpolate the sensor values which have a lower sampling time ?

    • @rptulrs2023
      @rptulrs2023  5 ปีที่แล้ว

      This is the sample time you choose for you controller depending on your requirements and rsources

  • @aboodhariry755
    @aboodhariry755 2 ปีที่แล้ว

    hello when ever i try to type the observer matrix i get an error that it is not defined i need a solution for that if anyone can you help me please.!!

  • @warriorforjesus2980
    @warriorforjesus2980 3 ปีที่แล้ว

    Hey you have taken in simulink model x0 is a variable but in my Matlab model it was not taking so help me

  • @sumaiyaeasmin923
    @sumaiyaeasmin923 ปีที่แล้ว

    Hello, at 14.57 min, you said a term 'input of word', what you mean by that?

  • @aadilahmed67
    @aadilahmed67 6 ปีที่แล้ว +1

    What is g_q variable in Plant/constant1 block? I get the error for invalid setting in block. I set it to 1 and my simulatiion ran slowly.
    A warning i am receiving is "Matching "Goto" for "From" 'Plant/output/From2' not found"

    • @rptulrs2023
      @rptulrs2023  6 ปีที่แล้ว

      Hi,
      g_q is the input matrix. Set it to [1;0]. Aslo, I added a newer version of the simulation to GitHub that does not contain g_q.

  • @sidalitifoura620
    @sidalitifoura620 2 ปีที่แล้ว

    DANKE !!

  • @ahmedelsherbiny139
    @ahmedelsherbiny139 3 ปีที่แล้ว +1

    Can u explain the plant ?how can I do it,?
    Please 🙏

  • @daniielaom10
    @daniielaom10 3 ปีที่แล้ว

    Do you have a project to furuta pedulum ?

  • @martinbubel7431
    @martinbubel7431 5 ปีที่แล้ว +4

    At 27:12, when the observer feedback is created, the author writes "-Ob" into the Gain-Block. But shouldn't it be the transponsed (Ob^T)? At least according to the literature I found...

    • @hugo12hugo6
      @hugo12hugo6 4 ปีที่แล้ว +2

      Thank you!

    • @ahmedelsherbiny139
      @ahmedelsherbiny139 3 ปีที่แล้ว

      can u explain more please ??? i have problem with this part

  • @muhammadqaisarali
    @muhammadqaisarali 2 ปีที่แล้ว

    I am wondering, how we can control inverted Pendulum, juts on the knowledge based on position x?.
    As output of plant is just position, which Is used in observer, to estimate states.
    This implies that there is no need of angle measurement for balancing, but we know that for balancing robots and pendulums, it is necessary to have potentiometer or MEMS to measure angle of pendulum..
    I believe, if we have just theta in output, means C=[ 0 0 1 0], then self balancing can be achieved, knowledge of position is not a must have thing in balancing, but theta is must..

  • @leonardorocabejar7307
    @leonardorocabejar7307 3 ปีที่แล้ว

    Thank you very much.

  • @ogunsadebenjaminadeiyin2729
    @ogunsadebenjaminadeiyin2729 4 ปีที่แล้ว

    Great

  • @abishekysharma444
    @abishekysharma444 4 ปีที่แล้ว

    Hey I'm getting ports or dimensions error in subsystem while I run the x0 for integrator
    What should I do?

    • @tsuyaosone1535
      @tsuyaosone1535 4 ปีที่แล้ว

      Watch Chipset's comment and like it so people can see

  • @user-vk2sv9vt8l
    @user-vk2sv9vt8l 14 วันที่ผ่านมา

    How do replace it with a plant at 29:49

  • @sapir20067
    @sapir20067 3 ปีที่แล้ว

    Hi I just start learning about state space and staff so I tried to follow your video and I have a problem in the signal that come out of the observer, it's doesn't look like the one that come from the original system at all and i don't know why, I tried to change the des_pole accurse from *1 to 0.1 to change the simple time if I remember right but it's barely did some thing
    can you help me?

    • @lonelybag7143
      @lonelybag7143 3 ปีที่แล้ว

      Hi, the problem is that Cd is a Row vector, not like C as a column vector, thus in observor bolck, the output should be Cd * uvec, and also the ob feedback gain should be u*-Ob and puls a transpose bolck. This is because x_dot should be a 4 row vector.

  • @CUSenthilKumar
    @CUSenthilKumar 3 ปีที่แล้ว

    why he is using the gain matrix before the output 9:40

  • @nischalsehrawat2130
    @nischalsehrawat2130 5 ปีที่แล้ว

    Hi, why does the cart move in opposite direction first then in the correct direction?

    • @rptulrs2023
      @rptulrs2023  5 ปีที่แล้ว +1

      This effect is called non-minimal phase behaviour

    • @nischalsehrawat2130
      @nischalsehrawat2130 5 ปีที่แล้ว

      @@rptulrs2023 Thanks, this behaviour is also visible in some Boston Dynamics robots as well. I tried to figure out and found that such systems are indeed non - minimal phase systems

  • @mohammadalirashidioun9738
    @mohammadalirashidioun9738 3 ปีที่แล้ว

    Thanks sir it was so practical 😍

  • @Govin25
    @Govin25 5 ปีที่แล้ว +6

    How can i add a PID instead of an LQR

  • @alexc5798
    @alexc5798 ปีที่แล้ว

    why does he multiple by B for output instead of C?

    • @user-pb9pe4kf4o
      @user-pb9pe4kf4o 3 หลายเดือนก่อน

      i also have the same doubt

  • @kaywanasivand3598
    @kaywanasivand3598 11 หลายเดือนก่อน

    👌👌👌👌👌

  • @assholeniggamothafuc
    @assholeniggamothafuc 6 ปีที่แล้ว

    Error in port widths or dimensions. Output port 1 of 'untitled/System/Integrator' has 4 elements. This port does not accept the dimensions (or orientation) specified by the output signal.
    Component:Simulink | Category:Model error
    Error in port widths or dimensions. Input port 1 of 'untitled/System/Gain2' is a [1x4] matrix.
    this error comes when I run the system. How do I fix it?

    • @rptulrs2023
      @rptulrs2023  6 ปีที่แล้ว

      I'm not sure which integrator this is, but a very common mistake is that the gains do not have the right multiplication type. In this case, double-click on the gain block and change "Multiplication" from "Element-wise" to "Matrix". Other reasons could be the initial values of the integrators or the orientation of the controller vector which shall be, then, transposed.

    • @zhaobingkun4950
      @zhaobingkun4950 5 ปีที่แล้ว

      I have the same question about that. The integrator is the one at 8.20 in the video. I do change the 'Multiplication' and the initial values is what you input in the video. I do not understand what you mean orientation of the controller cause at that time there is no controller@@rptulrs2023

    • @zhaobingkun4950
      @zhaobingkun4950 5 ปีที่แล้ว +6

      I think the gain in the right side is wrong. it should be B' not B

    • @Hzo420
      @Hzo420 5 ปีที่แล้ว

      @@zhaobingkun4950 You saved me so much time, thanks mate.

    • @fbtlwns07
      @fbtlwns07 5 ปีที่แล้ว

      @@zhaobingkun4950 thanks I had same error with you but I solve it like you thanks!

  • @hermanndanny8502
    @hermanndanny8502 6 ปีที่แล้ว

    Hallo kann man noch mehr Erklärungen haben??

    • @rptulrs2023
      @rptulrs2023  6 ปีที่แล้ว +1

      Was für eine Erklärung?

  • @abeltamikasetiarini2469
    @abeltamikasetiarini2469 3 ปีที่แล้ว

    At 29.25 --> Invalid dimensions specified for input port 1 in 'MyModel/Observer/Gain3'. The gain specified has dimensions [1x4], while the input is being set to have the dimensions [1]. These dimensions are not suitable for generating the matrix product of the gain with the input signal
    Component:Simulink | Category:Model error
    Error in port widths or dimensions. Output port 1 of 'MyModel/Observer/Sum1' is a one dimensional vector with 1 elements.
    Component:Simulink | Category:Model error

    • @abeltamikasetiarini2469
      @abeltamikasetiarini2469 3 ปีที่แล้ว

      I using matlab R2017b

    • @abdelkader6347
      @abdelkader6347 3 ปีที่แล้ว

      try to ad apostrophe transpose the matrix if for example the gain is Cd make it Cd'

    • @abdelkader6347
      @abdelkader6347 3 ปีที่แล้ว

      have you tried to derive the state space representation

    • @abeltamikasetiarini2469
      @abeltamikasetiarini2469 3 ปีที่แล้ว

      @@abdelkader6347 I just tried the simulation and am trying to understand it. does this video fit in the journal?

    • @abeltamikasetiarini2469
      @abeltamikasetiarini2469 3 ปีที่แล้ว

      @@abdelkader6347 Do you know or have literature similar to this video?

  • @user-vr7pm5rx2f
    @user-vr7pm5rx2f 2 ปีที่แล้ว

    at 31:06 ,I replaced “[K_d ,~ ,~] = dlqr(Ad,Bd,Q,R,N);” with “[K_d ,s ,e] = dlqr(Ad,Bd,Q,R,N);” ,and the result of e is [0.98929,
    0.97981,0.968874,0.33317],,The values in e are all greater than 0, is it because this is calculated in the discretization?

  • @thelion2720
    @thelion2720 5 หลายเดือนก่อน

    🇵🇸🇵🇸🇵🇸

  • @aa5new
    @aa5new 3 ปีที่แล้ว

    Let us slow down the experiment a bit. According to the description the idea is to use a proprietary software which is Matlab which runs only in Windows. Secondly, the idea is not to run the controller in a simulator but to execute it on a real robot. And third, instead of running a physics engine like Box2d the idea is to program the forward model from scratch with differential equations.

  • @gouravjangra6548
    @gouravjangra6548 2 ปีที่แล้ว

    Provide the code

  • @mollyday831
    @mollyday831 5 ปีที่แล้ว +2

    Could you talk about how to create the animation model?

    • @rptulrs2023
      @rptulrs2023  5 ปีที่แล้ว +5

      Hi, it is basically a "series of figures" that are plotted in a triggered Matlab functoin in Simulink. Take a look into the plot-file to follow that. I will try to make a short video on creating such animations as soon as I have some free time.

    • @EdwardYamunaque
      @EdwardYamunaque 5 ปีที่แล้ว +2

      @@rptulrs2023 "I will try to make a short video on creating such animations" ohh yes

    • @abdelkader6347
      @abdelkader6347 3 ปีที่แล้ว

      @@rptulrs2023 thank you for this work!
      is it possible to control this system with pid controller