- 3. A simulation environment.
- 4. Step length considerations.
- 5. Modelling a second order system.
- 6. The complication of motor drive limits.
- 7. Practical controller design.
- 8. Adding dynamics to the controller.
- 9. Sensors and actuators.
- 12. Putting it into practice.
- 13. Observers.
- 14. More about the mathematics.
- 16. Solving the state equations.
- 17. Discrete time and the z operator.
- 18. Root locus.
- 19. More about the phase plane.
- 20. Optimisation and an experiment.
- 21. Problem systems.
13. Observers.
//Setup window
ScaleWindow(-1,-1,tmax,1);
DrawAxes(0,-1,tmax,1);
xtarget=0;
x=0;
xest=0;
v=0;
vest=0;
theta=0;
omega=0;
phi=4;
phirate=0;
phitarget=0;
u=0; //Input motor current
Colour("black");
Label("Position/10",tmax/2,.7);
Colour("blue");
Label("Velocity/10",tmax/2,.6);
Colour("red");
Label("Tilt*10",tmax/2,.5);
Colour("green");
Label("Tilt-rate",tmax/2,0.4);
Colour("gray");
Label("Drive u",tmax/2,0.3);
MoveTo (t, x);
Colour("black");
loop();
u=kphi*(phi-phitarget)+kphidot*phirate+ktheta*theta+komega*omega;
Colour("black");
if (u>1){u=1; Colour("red");} //This applies the limit
if (u<-1){u=-1; Colour("red");}
theta=theta+omega*dt;
omega=omega+(80*theta+2*phirate-50*u)*dt;
phi=phi+phirate*dt
phirate=phirate+(-4*phirate+100*u)*dt
x=(theta+phi)*r;
v=(omega+phirate)*r;
t=t+dt;
Colour("black");
Spot(t,x/10);
Colour("blue");
Spot(t,v/10);
Colour("red");
Spot(t,theta*10);
Colour("green");
Spot(t,omega);
Colour("gray");
Spot(t,u);
if(t<tmax){setTimeout("loop();",10);}