#112회 Lag Compensator 풀이
import control as ct
import numpy as np
import matplotlib.pyplot as plt
num_gain = [24.5]
den_gain = [1]
sys_gain = ct.tf(num_gain, den_gain)
sys_gain
#transfer fucntion
num_G1 = [10]
den_G1 = [1, 5]
sys_G1 = ct.tf(num_G1, den_G1)
sys_G1
#Sensor
num_H = [2]
den_H = [1, 2]
sys_H = ct.tf(num_H, den_H)
sys_H
sys_H-1
# 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
sysTopenloop = ct.feedback(sys_gain*sys_G1,sys_H-1 )
sysTopenloop
#total system
sysTuc = ct.feedback(sysTopenloop,1)
# sysTuc = sysT/(1+sysT)
sysTuc
time, response = ct.step_response(sysTuc)
plt.plot(time, response, label='Step Response')
plt.show()
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)