Kc = 1.25 Tauc = 1.5 K = Kc * (1 + 1 / (Tauc * s)) L = K * G T = feedback(L, 1) S = feedback(1, L) plt.figure('Figure 2.9') tspan = np.linspace(0, 4, 50) [t, y] = T.step(0, tspan) plt.plot(t, y) [t, y] = S.step(0, tspan) plt.plot(t, y) plt.plot([0, 4], np.ones(2)) plt.xlabel('Time [s]') plt.legend(['y(t)','u(t)']) #TODO there is a descrepancy with the u(t) plot bodeclosedloop(G, K, -1, 2, label='Figure 2.15', margin=True) #TODO there is a descrepancy with the phase plots GM, PM, wc, wb, wbt, valid = marginsclosedloop(L) print 'GM :' , GM print "PM:", np.round(PM*180/np.pi, 1), "deg or", np.round(PM, 2), "rad" print 'wb :' , wb print 'wc :' , wc print 'wbt :' , wbt plt.show()
K = K1[0] # use this code to remove array L = G * K T = feedback(L, 1) S = feedback(1, L) plt.figure('Figure 2.8') tspan = np.linspace(0, 80, 100) [t, y] = T.step(0, tspan) plt.plot(t, y) [t, y] = S.step(0, tspan) plt.plot(t, y) plt.plot([0, 80], np.ones(2)) plt.xlabel('Time [s]') plt.legend(['y(t)', 'u(t)']) #TODO there is a descrepancy with the u(t) plot bodeclosedloop(G, K, -2, 1, 'Figure 2.14', margin=True) GM, PM, wc, wb, wbt, valid = marginsclosedloop(L) print 'GM:', np.round(GM, 2) print "PM: ", np.round(PM, 1), "deg or", np.round(PM / 180 * np.pi, 2), "rad" print 'wb:', np.round(wb, 2) print 'wc:', np.round(wc, 2) print 'wbt:', np.round(wbt, 2) #TODO there is a descrepancy with the wbt value if valid: print "Frequency range wb < wc < wbt is valid" else: print "Frequency range wb < wc < wbt is not valid" plt.show()
T = feedback(L, 1) S = feedback(1, L) plt.figure('Figure 2.8') tspan = np.linspace(0, 80, 100) [t, y] = T.step(0, tspan) plt.plot(t, y) [t, y] = S.step(0, tspan) plt.plot(t, y) plt.plot([0, 80], np.ones(2)) plt.xlabel('Time [s]') plt.legend(['y(t)','u(t)']) #TODO there is a descrepancy with the u(t) plot bodeclosedloop(G, K, -2, 1, 'Figure 2.14', margin=True) GM, PM, wc, wb, wbt, valid = marginsclosedloop(L) print 'GM:' , np.round(GM, 2) print "PM: ", np.round(PM, 1) , "deg or", np.round(PM / 180 * np.pi, 2), "rad" print 'wb:' , np.round(wb, 2) print 'wc:' , np.round(wc, 2) print 'wbt:' , np.round(wbt, 2) #TODO there is a descrepancy with the wbt value if valid: print "Frequency range wb < wc < wbt is valid" else: print "Frequency range wb < wc < wbt is not valid" plt.show()
G = 4 / ((s - 1) * (0.02 * s + 1)**2) Kc = 1.25 Tauc = 1.5 K = Kc * (1 + 1 / (Tauc * s)) L = K * G T = feedback(L, 1) S = feedback(1, L) plt.figure('Figure 2.9') tspan = np.linspace(0, 4, 50) [t, y] = T.step(0, tspan) plt.plot(t, y) [t, y] = S.step(0, tspan) plt.plot(t, y) plt.plot([0, 4], np.ones(2)) plt.xlabel('Time [s]') plt.legend(['y(t)', 'u(t)']) #TODO there is a descrepancy with the u(t) plot bodeclosedloop(G, K, -1, 2, label='Figure 2.15', margin=True) #TODO there is a descrepancy with the phase plots GM, PM, wc, wb, wbt, valid = marginsclosedloop(L) print 'GM :', GM print "PM:", np.round(PM * 180 / np.pi, 1), "deg or", np.round(PM, 2), "rad" print 'wb :', wb print 'wc :', wc print 'wbt :', wbt plt.show()