-
Notifications
You must be signed in to change notification settings - Fork 8
Step Response
Metin Karatas edited this page Feb 29, 2020
·
3 revisions
Create an instance of a control unit (here: P unit wit Kp = 1):
p_control = PControl(1)
Create a list with time steps (1000 steps). The default value of delta t (0.01) is stored in the class control:
time_steps = [x * Control.DELTA_T for x in range(0, 1000)]
Get the outputs for that unit (input is 1 at k > 100 (100 * 0.01 = 1), else 0):
xa_lst_p = [p_control.get_xa(1) if x > 1 else p_control.get_xa(0) for x in time_steps]
That's it. Now you can plot that thing:
plt.plot(time_steps, xa_lst_p, label="P control")
plt.grid()
plt.minorticks_on()
plt.grid(which='major', linestyle='-', linewidth='0.5')
plt.grid(which='minor', linestyle=':', linewidth='0.3')
plt.ylim(top=5, bottom=0)
plt.xlabel('xe in hundreds')
plt.ylabel('xa')
plt.title("control units - step response")
plt.legend()
plt.show()