SCREEN 12 PRINT "Simulation of closed-loop system with `live input'" PRINT "ERROR Phase-plane is shown - velocity against position ERROR" PRINT INPUT "Feedback, damping (suggest 8,2 to start) "; f, d CLS VIEW (2, 20)-(638, 328), 8, 4 WINDOW (-3, -2.5)-(3, 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" LOCATE 25, 1: PRINT "Velocity versus position ERROR"; PRINT " Scale -2.5 to 2.5 in position and velocity"; ' dt = .001 'Make dt larger to speed up running x = 1 'Initial values v = 0 t = 0 target = 0 'until a key is pressed PSET (x - target, v) 'move to the first point DO a$ = INKEY$ IF a$ <> "" THEN target = .4 * (VAL(a$) - 5) PSET (x - target, v) END IF 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 - target, v) 'This displays the result LOOP UNTIL a$ = " " '