Пример #1
0
import sys
import numpy as np
from matplotlib import pyplot as plt

sys.path.append('../../control_engineering_lib')
import control_engineering as lib


path="../csv"
t1,s1=lib.step_response([0.75],[1,0.5,1])
t2,s2=lib.step_response([0.75],[1,-2,1])

np.savetxt("%s/fig1.csv" % path,np.matrix([t1,s1]).T,header="t,s", delimiter=",")
np.savetxt("%s/fig2.csv" % path,np.matrix([t2,s2]).T,header="t,s", delimiter=",")

#system1
t3,s3=lib.step_response([1,3,2],[1,10,33,46,30])
np.savetxt("%s/fig3.csv" % path,np.matrix([t3,s3]).T,header="t,s", delimiter=",")

#system2
t4,s4=lib.step_response([1,3],[1,6,10,-2,-15])
np.savetxt("%s/fig4.csv" % path,np.matrix([t4,s4]).T,header="t,s", delimiter=",")

#critere du revers
w,mag,phase=lib.bode([2],[1,3,3,1])
np.savetxt("%s/fig5_bode.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")

t5,s5=lib.step_response_BF([2],[1,3,3,1])
np.savetxt("%s/fig5_BF.csv" % path,np.matrix([t5,s5]).T,header="t,s", delimiter=",")

w,mag,phase=lib.bode([20],[1,3,3,1])
Пример #2
0
import sys
import numpy as np
from matplotlib import pyplot as plt

sys.path.append("../../control_engineering_lib")
import control_engineering as lib


path = "../csv"
t, s = lib.step_response([2], [1, 4, 3], amp=1)
plt.plot(t, s)  # normalized
plt.xlabel("t")
plt.title("Step response")
plt.show()


# save file
np.savetxt("%s/fig1.csv" % path, np.matrix([t, s]).T, header="t,s", delimiter=",")
Пример #3
0
import sys
import numpy as np
from matplotlib import pyplot as plt

sys.path.append('../../control_engineering_lib')
import control_engineering as lib

show_cor=1
#Cnum=12.66

num=3/2.0;
den=[3,1]
t=np.linspace(0,18,401)

t,s=lib.step_response(num,den,2,t)
plt.plot(t,s,label="Système orginal")
plt.xlabel('Temps (s)')
plt.ylabel('Sortie')

if show_cor==1:
    #correcteur P
    Cnum = float(input('Valeur du gain: '))
    Cden=1
    t,s=lib.step_response_BF_cor(Cnum,Cden,num,den,1,t)
    plt.plot(t,2*s,label="Système corrigé")


plt.axhline(y=2,color='k',ls='dashed',label="Entrée")
plt.legend()
plt.show()