SCREEN 12 PRINT "Simulation of closed-loop system with `live input'" PRINT "Phase-plane is shown - velocity against position" PRINT INPUT "Feedback, damping (suggest 8,2 to start) "; f, d CLS VIEW (2, 20)-(638, 348), 8, 4 WINDOW (-2.5, -2.5)-(2.5, 2.5) LINE (-2.5, 0)-(2.5, 0), 9 LINE (0, -2.5)-(0, 2.5), 9 PRINT "Press number keys 0 to 9 to change the target, to quit" ' dt = .001 'Make dt larger to speed up running x = 4 'Initial values v = 0 t = 0 target = 0 'until a key is pressed PSET (x, v) 'move to the first point DO a$ = INKEY$ IF a$ <> "" THEN target = .4 * VAL(a$) - 2 u = f * (target - x) - d * v 'u is determined by feedback x = x + v * dt 'This is the simulation v = v + u * dt ' t = t + dt LINE -(x, v) 'This displays the result LOOP UNTIL a$ = " " '