In [1]:
#112회 Lag Compensator 풀이
import control as ct
import numpy as np
import matplotlib.pyplot as plt
In [2]:
num_gain = [24.5]
den_gain = [1]
sys_gain = ct.tf(num_gain, den_gain)
sys_gain
Out[2]:
$$\frac{24.5}{1}$$
In [3]:
#transfer fucntion
num_G1 = [10]
den_G1 = [1, 5]
sys_G1 = ct.tf(num_G1, den_G1)
sys_G1
Out[3]:
$$\frac{10}{s + 5}$$
In [4]:
#Sensor
num_H = [2]
den_H = [1, 2]
sys_H = ct.tf(num_H, den_H)
sys_H
Out[4]:
$$\frac{2}{s + 2}$$
In [5]:
sys_H-1
Out[5]:
$$\frac{-s}{s + 2}$$
In [6]:
# transfer fucntion
# sysT = sys_gain*sys_G1/(1+sys_gain*sys_G1*(sys_H-1))
sysT = ct.feedback(sys_gain*sys_G1,sys_H )
sysT
Out[6]:
$$\frac{245 s + 490}{s^2 + 7 s + 500}$$
In [7]:
sysTopenloop = ct.feedback(sys_gain*sys_G1,sys_H-1 )
sysTopenloop
Out[7]:
$$\frac{245 s + 490}{s^2 - 238 s + 10}$$
In [8]:
#total system 
sysTuc = ct.feedback(sysTopenloop,1)
# sysTuc = sysT/(1+sysT)
sysTuc
Out[8]:
$$\frac{245 s + 490}{s^2 + 7 s + 500}$$
In [9]:
time, response = ct.step_response(sysTuc)
plt.plot(time, response, label='Step Response')
plt.show()
In [10]:
s = ct.TransferFunction.s
G_s = sysTopenloop
E_s = 1 / (1 + G_s)
# Final Value Theorem to find steady-state error
sse_step = ct.evalfr(E_s, 0)  # Evaluate E(s) at s=0
print(f"Steady-State Error for Step Input: {sse_step}")
Steady-State Error for Step Input: (0.02+0j)