Introduction:

In control systems, compensating a plant is crucial for achieving desired stability and performance. One effective technique is to use a PI (Proportional-Integral) controller, which combines the benefits of an integrator and a zero close to it. This tutorial provides a step-by-step guide on designing and analyzing a PI controller for plant compensation using Python code. We will consider a third-order plant with poles at -1, -2, and -5, and explore the impact of a PI controller with a zero at -0.1. Through root locus analysis and step response plots, we will demonstrate how the PI controller enhances the system's performance compared to the uncompensated plant. By the end of this tutorial, you will have a solid understanding of PI control and its application in plant compensation.

Mathematical formulation of a PI controller

The expression for the PI controller is:

$$ H_c(s) = K_p + \frac{K_i}{s} = K\frac{s + z_c}{s} $$

where $K_p$ is the proportional gain, $K_i$ is the integral gain, $K$ is the overall gain, and $z_c$ is the PI controller zero location.

In this case, the PI controller has a zero at -0.1, so the expression becomes:

$$ H_c(s) = K\frac{s + 0.1}{s} $$

The presence of the zero near the pole at the origin allows for better shaping of the root locus and achieves the desired zero steady state error.

Design Algorithm:

Step 1: Define the plant transfer function. Let's consider a plant with the following transfer function:

import control as ctrl

K = 5
Gs = ctrl.zpk([], [-1, -2, -5], K)

This represents a third-order system with poles at -1, -2, and -5, and a gain of 1.

Step 2: Analyze the plant's stability and performance. Before designing the compensator, it's important to analyze the plant's stability and performance. We can do this by plotting the root locus and step response of the plant.

import matplotlib.pyplot as plt

plt.figure(figsize=(15, 10))
plt.subplot(1, 2, 1)
ctrl.rlocus(Gs, grid=True)
plt.title('Root Locus of Plant')
plt.xlim([-6, 2])
plt.ylim([-3, 3])

plt.subplot(1, 2, 2)
T = ctrl.feedback(Gs, 1)
t, y = ctrl.step_response(T)
plt.plot(t, y)
plt.title('Closed-Loop Step Response of Plant')
plt.show()

From the root locus and step response, we can observe the plant's stability and performance characteristics.

Step 3: Design a PI controller with an integrator and a zero close to it.

To improve the steady state response and preserve the root-locus shape (stability), we add a zero close to the integrator pole. This forms a PI controller.

The transfer function of a PI controller with a zero at -0.1 and compensated open-loop transfer function are: