- 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.
21. Problem systems.
function setup(){
t=0;
tmax = 200;
demand=60;
ambient=20;
tank=ambient;
pipe= Array(100);
for(i=0;i<101;i++){pipe[i]=ambient;}
tout=ambient;
a=0.1; // Time constant about ten seconds
b=7; // Will give 70 degrees temperature rise for u=1.
dt = .1;
integral=0;
tint=20;
fbgain=document.getElementById("fb").value/100;
tint=document.getElementById("fi").value*100;
ScaleWindow(-5,-5,tmax,110);
DrawAxes(0,0,tmax,100);
Label('Proportional+Integral',150,85);
Colour("black");
Label('Output temperature',150,80);
Colour("blue");
Label('Target temperature',150,75);
Colour("magenta");
Label('Integral %',150,70);
Colour("red");
Label('Power %',150,65);
Colour("black");
t = 0;
i=0;
MoveTo(t,tank);
loop();
}
function loop(){
integral=integral+(demand-tout)*dt/tint;
if(integral>1){integral=1;}
if(integral<0){integral=0;}
u=(demand-tout)*fbgain+integral;
if(u>1){u=1;}
if(u<0){u=0;}
tank=tank+(a*(ambient-tank)+b*u)*dt;
tout=pipe[i];
pipe[i]=tank;
i=i+1;
if(i>99){i=0;}
t = t + dt;
Colour("blue");
Spot(t, demand);
Colour("magenta");
Spot(t, integral*100);
Colour("red");
Spot(t, u*100);
Colour("black");
Spot(t, tout);
if (t<tmax){setTimeout('loop()',10);}
}