Chapter 3: PID Tuning Methods
Why Tuning Matters
Poorly tuned PID controllers can cause:
- Slow response
- Excessive overshoot
- Oscillations
- Instability
Ziegler-Nichols Method
Step Response Method
- Apply step input to open-loop system
- Measure delay time (L) and time constant (T)
- Calculate gains:
| Controller | Kp | Ti | Td |
|---|---|---|---|
| P | T/L | - | - |
| PI | 0.9T/L | L/0.3 | - |
| PID | 1.2T/L | 2L | 0.5L |
Ultimate Gain Method
- Set Ki = 0, Kd = 0
- Increase Kp until sustained oscillation
- Record Ku (ultimate gain) and Tu (period)
| Controller | Kp | Ti | Td |
|---|---|---|---|
| P | 0.5Ku | - | - |
| PI | 0.45Ku | Tu/1.2 | - |
| PID | 0.6Ku | Tu/2 | Tu/8 |
def ziegler_nichols_ultimate(Ku, Tu, controller_type='PID'):
if controller_type == 'P':
return {'Kp': 0.5 * Ku}
elif controller_type == 'PI':
return {'Kp': 0.45 * Ku, 'Ki': 0.45 * Ku / (Tu/1.2)}
elif controller_type == 'PID':
Kp = 0.6 * Ku
Ti = Tu / 2
Td = Tu / 8
return {'Kp': Kp, 'Ki': Kp/Ti, 'Kd': Kp*Td}
Cohen-Coon Method
Better for systems with significant dead time.
def cohen_coon(K, T, L):
r = L / T
Kp = (1.35/K) * (T/L + 0.185)
Ti = 2.5 * L * (T + 0.185*L) / (T + 0.611*L)
Td = 0.37 * L * T / (T + 0.185*L)
Ki = Kp / Ti
Kd = Kp * Td
return {'Kp': Kp, 'Ki': Ki, 'Kd': Kd}
Manual Tuning Guidelines
- Start with Kp only, increase until oscillation
- Add Ki to eliminate steady-state error
- Add Kd to reduce overshoot
- Fine-tune iteratively
Next: Chapter 4 - State-Space Representation!