Detailed Steps for Control System Assignment
Step 1: Define a 2nd Order System
A standard form of a second-order system in the S-domain (Laplace domain) is:
G(s) = wn^2 / (s^2 + 2*z*wn*s + wn^2)
where wn is the natural frequency and z is the damping ratio.
For this exercise, let's assume wn = 1 rad/s (common for simplicity), z = 0.5.
This gives us G(s) = 1 / (s^2 + s + 1).
Step 2: Convert the System from the S-domain to the Z-domain
To convert from the S-domain to the Z-domain, use the bilinear transformation:
s = 2(z - 1) / (T(z + 1)), where T is the sampling period.
Substitute s in G(s) = 1 / (s^2 + s + 1) and simplify.
Step 3: Compare with Target Form on Slide 6
The target form is similar to G(z) = 0.5*z_i / (1 - 0.4*z_i). After simplifying G(z), see if it aligns with
this form.
Step 4: Install the Control Library in Python
Ensure you have control installed by running:
pip install control
Step 5: Simulate the Open-Loop System in Python
Define your G(z) transfer function and use Python to plot the response. Example:
import control as ctrl
import [Link] as plt
# Define G(z) transfer function
num = [0.5]; den = [1, -0.4]
Gz = [Link](num, den, True)
# Plot open-loop step response
t, y = ctrl.step_response(Gz)
[Link](t, y)
Step 6: Convert to Closed Loop with a PID Controller in the Z-Domain
Using Black's formula, the closed-loop transfer function is:
G_closed(s) = KH / (1 + KH)
where H is open-loop G(z) and K is the PID controller in Z.
Example for PID:
Kp, Ki, Kd = 1.0, 0.5, 0.1
T = 1.0
H_open_loop = Gz * Kp # modify based on PID
G_closed = [Link](H_open_loop, 1)
Step 7: Simulate the Closed-Loop System in the Z-domain
Repeat the process for step response, but with the PID controller added to simulate the closed-loop.
Step 8: Convert G(s) to a Linear Difference Equation (LDE)
Take the inverse Z-transform of closed-loop G(z) and write as a difference equation:
y[n] = a1*y[n-1] + a2*y[n-2] + b0*u[n] + b1*u[n-1] ... Implement as discrete time simulation.