next up previous
Next: Open loop simulation Up: Inverted pendulum Previous: Inverted pendulum

Description of the problem

-->//
-->getf('SCI/demos/pendulum/simulation.sci')
-->getf('SCI/demos/pendulum/graphics.sci')
-->//the cart
-->// ----------------
-->//
--> xselect();
--> dpnd()
-->//
-->// equations
-->//----------
-->//state =[x x' theta theta']
-->//
--> mb=0.1;mc=1;l=0.3;m=4*mc+mb;//constants

function [xdot]=ivpd(t,x)
//ydot=ivpd(t,y) non linear equations of the pendulum
// y=[x;d(x)/dt,teta,d(teta)/dt].
// mb, mc, l must be predefined 
//!
g=9.81;
u=0
qm=mb/(mb+mc)
cx3=cos(x(3))
sx3=sin(x(3))
d=4/3-qm*cx3*cx3
xd4=(-sx3*cx3*qm*x(4)**2+2/(mb*l)*(sx3*mb*g-qm*cx3*u))/d
//
xdot=[x(2);
      (u+mb*(l/2)*(sx3*x(4)**2-cx3*xd4))/(mb+mc);
      x(4);
      xd4]


Scilab group