import matplotlib.pyplot as plt from utils import tf from utilsplot import bode # Trasfer function of L(s) s = tf([1, 0], 1) L = 3*(-2*s + 1)/((10*s + 1)*(5*s + 1)) plt.figure('Figure 2.7') plt.title('Bode plots of L(s) with Kc = 1') bode(L, -2, 1) plt.show()
import matplotlib.pyplot as plt from utils import tf from utilsplot import bode G = tf([5], [10, 1], deadtime=2) plt.figure('Figure 2.2') plt.title('Bode plots of G(s)') bode(G, -3, 1) plt.show()
# 1 to 4 are the important frequency domain measures used to assess # performance and characterise speed of response s = tf([1, 0], 1) Kc = 0.05 # plant model G = 3 * (-2 * s + 1) / ((10 * s + 1) * (5 * s + 1)) # Controller model K = Kc * (10 * s + 1) * (5 * s + 1) / (s * (2 * s + 1) * (0.33 * s + 1)) # closed-loop transfer function L = G * K # magnitude and phase of L plt.figure('Figure 2.19') bode(L, -2, 1) # From the figure we can calculate w180 # w180 = 0.44 GM, PM, wc, wb, wbt, valid = marginsclosedloop(L) print('GM:', np.round(GM, 2)) print('PM:', np.round(PM * np.pi / 180, 2), "rad or", np.round(PM, 2), "deg") print('wb:', np.round(wb, 2)) print('wc:', np.round(wc, 2)) print('wbt:', np.round(wbt, 4)) # Response to step in reference for loop shaping design # y = Tr, r(t) = 1 for t > 0 # u = KSr, r(t) = 1 for t > 0 plt.figure('Figure 2.20')
import matplotlib.pyplot as plt from utilsplot import bode from utils import tf s = tf([1, 0]) for power in range(1, 4): G = 1/(s + 1)**power bode(G) plt.show()
import matplotlib.pyplot as plt from utils import tf from utilsplot import bode s = tf([1,0], 1) G = 30*(s + 1)/((s + 10)*(s + 0.01)**2) plt.figure('Figure 2.3') bode(G, -3, 3) plt.title('Figure 2.3: Bode plot of transfer function ' + r'$L_1 = \frac{30(s + 1)}{(s + 10)(s + 0.01)^2}$' + '\n', fontsize = 13, y = -1) plt.show()
import matplotlib.pyplot as plt from utils import tf from utilsplot import bode s = tf([1,0], 1) G = 30*(s + 1)/((s + 10)*(s + 0.01)**2) plt.figure('Figure 2.3') bode(G, -3, 3) plt.show()
import matplotlib.pyplot as plt from utilsplot import bode from utils import tf s = tf([1, 0]) for power in range(1, 4): G = 1 / (s + 1)**power bode(G) plt.show()