def testDamp(self): """Test damp()""" A = np.array([[-0.2, 0.06, 0, -1], [0, 0, 1, 0], [-17, 0, -3.8, 1], [9.4, 0, -0.4, -0.6]]) B = np.array([[-0.01, 0.06], [0, 0], [-32, 5.4], [2.6, -7]]) C = np.eye(4) D = np.zeros((4, 2)) sys = ss(A, B, C, D) wn, Z, p = damp(sys, False) # print (wn) np.testing.assert_array_almost_equal( wn, np.array([4.07381994, 3.28874827, 3.28874827, 1.08937685e-03])) np.testing.assert_array_almost_equal( Z, np.array([1.0, 0.07983139, 0.07983139, 1.0]))
print('GHp1/(1+GHp1) = ', cloop1) print('GHp2/(1+GHp2) = ', cloop2) print('GHp3/(1+GHp3) = ', cloop3) # # Polos e zeros de malha fechada # comando pole() obtem os polos do sistema # e zero() obtem os zeros do sistema # print('\nPOLOS E ZEROS DE MALHA FECHADA') print('-------------') print('Polos e zeros cloop1') print('Polos = ', co.pole(cloop1)) print('Zeros = ', co.zero(cloop1)) print('COEF. DE AMORTECIMENTO E FREQ. NATURAL') print('_____Polos____________zeta_______omegan') co.damp(cloop1) print('-------------') print('Polos e zeros cloop2') print('Polos = ', co.pole(cloop2)) print('Zeros = ', co.zero(cloop2)) print('COEF. DE AMORTECIMENTO E FREQ. NATURAL') print('_____Polos____________zeta_______omegan') co.damp(cloop2) print('-------------') print('Polos e zeros cloop3') print('Polos = ', co.pole(cloop3)) print('Zeros = ', co.zero(cloop3)) print('COEF. DE AMORTECIMENTO E FREQ. NATURAL') print('_____Polos____________zeta_______omegan') co.damp(cloop3) #
# exercicio de atraso / PI #G = co.tf(1,[1,3,2]) * co.tf(1,[1,10]) #Gc = 64 ##Gc2 = co.tf(64*np.asarray([1,0.1]),[1,0]) #Gc2 = co.tf(64*10*np.asarray([10,1]),[100,1]) # exercicio de avanço / PD G = co.tf(1,[1,10,24,0]) Gc = 63 Gc2 = co.tf(100*np.asarray([1/3,1]),[1/12,1]) #avanco #Gc2 = co.tf(191*np.asarray([1/6,1]),[1]) #PD T = np.linspace(0,20,3000) co.damp(co.feedback(G*Gc,1)) y,t = co.step(co.feedback(G*Gc,1),T) u,t = co.step(co.feedback(Gc,G),T) co.damp(co.feedback(G*Gc2,1)) y2,t = co.step(co.feedback(G*Gc2,1),T) u2,t = co.step(co.feedback(Gc2,G),T) plt.subplot(2,1,1) plt.plot(t,y,t,y2) plt.grid() plt.legend(['y1','y2']) plt.subplot(2,1,2) plt.plot(t,u,t,u2) plt.grid() plt.legend(['u1','u2'])
plt.figure(figsize=(10, 8)) for K in KPKD: KP, KD = K KI = 4 # To construct the closed-loop transfer function Gcl from theta^d to theta , # we have a number of options: # (1) we can use the command "feedback" as introduced earlier. ###### Gcl = cm.feedback((KP + KD * s) * G, 1) # PD controller # Gcl = cm.feedback((KP + KD * s + KI/s) * G, 1) # PID controller print(Gcl) print(cm.pole(Gcl)) cm.damp(Gcl, True) ###### # (2) If you are interested to know how Eq. (6.18) is derived, # you may want to use the following general rule: # +++++++++++++++++++ # Gcl = <Transfer function of the open loop between the input and output>/(1 # + <Transfer function of the closed loop>) # +++++++++++++++++++ # Accordingly: ###### # Gcl = (KP*G + KD*s*G)/(1 + KP*G + KD*s*G) ###### # Gd = (G) / (1 + (KP + KD * s) * (G)) Gd = (G) / (1 + (KP + KD * s + KI/s) * (G))
"""**Importação Matplotlib** """ import matplotlib.pyplot as plt """**Analise:**""" y,t=ctr.step(GEx2) wn=5 z=0.6 F=ctr.tf([wn**2],[1,2*z*wn,wn**2]) y,t=ctr.step(F) plt.plot(t,y) plt.xlabel('Tempo, Segundos') plt.ylabel('Saída $y(t)$') plt.title('Resposta ao degrau unitário:') plt.grid() print(F) ctr.damp(F) ctr.stepinfo(F)