我正在尝试使用 python 绘制离散 PID 控制器的传递函数。我收到非常奇怪的错误消息,我无法解决。
from pylab import *
from scipy import signal
Ts = 0.001
Kp = 50
Ki = 10
Kd = 300
K1 = Kp + Ki + Kd
K2 = -1 * Kp - (2 * Kd)
K3 = Kd
system = signal.TransferFunction([K1, K2, K3], [1, -1], dt=0.001)
w, mag, phase = system.bode()
print(system)
plt.figure()
plt.semilogx(w, mag) # Bode magnitude plot
plt.figure()
plt.semilogx(w, phase) # Bode phase plot
plt.show()
print("Done")
这给出了这个错误:
Done
C:\Matthijs\Python\matthijs_env\lib\site-packages\scipy\signal\filter_design.py:474: RuntimeWarning: divide by zero encountered in true_divide
h = (npp_polyval(zm1, b, tensor=False) /
C:\Matthijs\Python\matthijs_env\lib\site-packages\scipy\signal\filter_design.py:474: RuntimeWarning: invalid value encountered in true_divide
h = (npp_polyval(zm1, b, tensor=False) /
C:\Matthijs\Python\matthijs_env\lib\site-packages\numpy\lib\function_base.py:1540: RuntimeWarning: invalid value encountered in remainder
ddmod = mod(dd + pi, 2*pi) - pi
我迷路了,因为这应该是一个有效的传递函数。