Chapter 21: Loop Shaping and Servo Design

Lesson 3: Integrators and Low-Frequency Loop Shape

This lesson analyzes how integral action shapes the low-frequency behavior of the open-loop transfer function, how it determines system type and steady-state accuracy, and how to tune integrators within a loop-shaping workflow. We connect integral action to frequency-domain specifications for tracking and disturbance rejection and illustrate implementation in Python, C++, Java, MATLAB/Simulink, and Wolfram Mathematica, with emphasis on servo and robotics-style control loops.

1. Conceptual Role of Integrators in Loop Shaping

Consider a unity-feedback loop with plant \( P(s) \) and controller \( C(s) \). The loop transfer function is

\[ L(s) = C(s)P(s), \qquad T(s) = \frac{L(s)}{1 + L(s)}, \qquad E(s) = \frac{R(s)}{1 + L(s)}, \]

where \( T(s) \) is the closed-loop transfer function from reference \( R(s) \) to output \( Y(s) \), and \( E(s) \) is the error transform. Loop shaping means adjusting \( L(s) \) in the frequency domain to achieve prescribed tracking, disturbance rejection, and robustness properties.

An integrator is the factor \( \dfrac{1}{s} \) (or more generally \( \dfrac{\omega_I}{s} \)) in the controller. Its key conceptual effects are:

  • It increases the system type, changing the steady-state error behavior for polynomial (step, ramp, parabolic) inputs (recall Chapter 8).
  • It forces \( |L(\mathrm{j}\omega)| \) to grow unbounded as \( \omega \to 0 \), greatly reducing low-frequency errors and constant disturbances.
  • It adds \( -90^\circ \) of phase and a magnitude slope of \( -20 \,\text{dB/dec} \) above its break frequency, which can degrade phase margin if placed too aggressively.

The following diagram summarizes the signal flow for a servo loop with integral action:

flowchart TD
  R["Reference r(t)"] --> E["Error e(t) = r(t) - y(t)"]
  E --> C["Controller C(s) with integrator"]
  C --> U["Control input u(t)"]
  U --> P["Plant P(s)"]
  P --> Y["Output y(t)"]
  Y -->|"feedback"| E
        

In servo design, integrators are the main mechanism to enforce zero steady-state error to steps (type 1) or ramps (type 2) while the remaining loop-shaping elements refine transient response and robustness.

2. System Type, Integrators, and Steady-State Error

Recall from Chapter 8 that the type of a unity-feedback system is the number of integrators (poles at the origin) in the loop transfer function \( L(s) = C(s)P(s) \). Suppose

\[ L(s) = \frac{K_0}{s^n} \,\tilde{L}(s), \]

where \( \tilde{L}(s) \) has no pole at the origin and \( K_0 > 0 \). Then the system is type \( n \).

For standard test inputs (step, ramp, parabolic) and stable closed loop, the steady-state error constants (from Chapter 8) are:

\[ K_p = \lim_{s \to 0} L(s), \qquad K_v = \lim_{s \to 0} s L(s), \qquad K_a = \lim_{s \to 0} s^2 L(s). \]

For a type 0 system (\( n = 0 \)), \( K_p \) is finite, \( K_v = 0 \), \( K_a = 0 \). Adding a single integrator (\( n = 1 \)) makes \( K_p \) infinite and \( K_v \) finite; the system becomes type 1. Adding a second integrator makes it type 2, etc.

In unity feedback, with reference \( r(t) \) and error \( e(t) = r(t) - y(t) \), the steady-state error for step, ramp, and parabolic inputs (with unit amplitudes) is:

\[ e_{\text{ss}}^{\text{step}} = \frac{1}{1 + K_p}, \quad e_{\text{ss}}^{\text{ramp}} = \frac{1}{K_v}, \quad e_{\text{ss}}^{\text{parabolic}} = \frac{1}{K_a}. \]

Thus, integrators directly control the steady-state accuracy:

  • Type 0: nonzero step error, infinite ramp error.
  • Type 1: zero step error, finite ramp error, infinite parabolic error.
  • Type 2: zero step and ramp error, finite parabolic error.

In loop shaping, we exploit this by embedding integrators in \( C(s) \) so that \( L(s) \) has the desired type while keeping stability margins acceptable (see Chapter 17).

3. Low-Frequency Loop Shape Induced by Integrators

Let the controller contain one integrator with break (or “crossover”) frequency \( \omega_I \):

\[ C_I(s) = \frac{K_I \,\omega_I}{s}. \]

(Here \( K_I \) is a dimensionless gain and \( \omega_I \) carries the unit scaling.) Assume the plant has finite DC gain \( P(0) \). For small frequencies \( \omega \), the loop magnitude behaves as

\[ |L(\mathrm{j}\omega)| \approx \frac{K_I \,\omega_I |P(0)|}{\omega}, \]

so on a Bode magnitude plot, the integrator imposes a \( -20 \,\text{dB/dec} \) slope in the low-frequency range where the plant is approximately constant.

With two integrators, \( L(s) \propto \dfrac{1}{s^2} \), giving a \( -40 \,\text{dB/dec} \) low-frequency slope, etc. Loop-shaping guidelines for low frequency typically ask for:

  • Large magnitude of \( L(\mathrm{j}\omega) \) over the reference and disturbance band.
  • A slope such that the transition to the bandwidth is smooth (no abrupt “kinks”).
  • Enough phase margin at the crossover frequency (see Chapter 17).

When placing an integrator:

  • Too small \( \omega_I \) (integrator too slow): low-frequency gain is not high enough over the disturbance band; tracking and disturbance rejection suffer.
  • Too large \( \omega_I \) (integrator too aggressive): the phase contribution of the integrator extends into the crossover region, reducing phase margin and risking oscillations.

A common heuristic is to place the integrator break one decade below the desired bandwidth, so that its phase lag is mostly “spent” well before crossover, while the resulting low-frequency gain is still large.

flowchart TD
  A["Specify accuracy specs in time or frequency"] --> B["Compute required error constants (Kp, Kv, Ka)"]
  B --> C["Choose system type (number of integrators)"]
  C --> D["Select integrator gain and break frequency"]
  D --> E["Check phase and gain margins at crossover"]
  E --> F["If margins insufficient, adjust gains or add lead/lag"]
        

4. Design Example – Ramp Accuracy via Integral Action

Consider a first-order plant

\[ P(s) = \frac{K_g}{T s + 1}, \]

controlled by a pure integral controller

\[ C(s) = \frac{K_I}{s}. \]

The loop transfer function is

\[ L(s) = C(s)P(s) = \frac{K_I K_g}{s (T s + 1)}. \]

This is a type 1 system. The velocity error constant is

\[ K_v = \lim_{s \to 0} s L(s) = \lim_{s \to 0} \frac{K_I K_g}{T s + 1} = K_I K_g. \]

For a unit ramp reference \( r(t) = t \), the steady-state error is

\[ e_{\text{ss}}^{\text{ramp}} = \frac{1}{K_v} = \frac{1}{K_I K_g}. \]

Suppose we require \( e_{\text{ss}}^{\text{ramp}} \leq 0.05 \). Then we need \( K_I K_g \geq 20 \). If the plant has \( K_g = 2 \), the minimum integral gain is \( K_I = 10 \).

In a full loop-shaping design, we would next:

  1. Plot the Bode diagram of \( L(s) \) for that \( K_I \).
  2. Check the crossover frequency and stability margins.
  3. Possibly reduce \( K_I \) and add phase lead compensation to recover margin.

This process connects integral action quantitatively to low-frequency loop shape and steady-state accuracy.

5. Python Lab – Low-Frequency Shaping with python-control

We now implement the previous example using Python and the python-control library, which is frequently used in robotics and mechatronics research along with roboticstoolbox for robot models.


import numpy as np
import matplotlib.pyplot as plt

# Core control library (python-control)
import control as ct

# Plant: first-order model of a robot joint or motor: P(s) = K_g / (T s + 1)
K_g = 2.0
T = 0.5
P = ct.tf([K_g], [T, 1.0])

# Design target: ramp steady-state error e_ss_ramp <= 0.05
# We know e_ss_ramp = 1 / (K_I * K_g), so K_I * K_g >= 20 => K_I >= 10.
K_I = 10.0  # Choose just at the bound
C_int = ct.tf([K_I], [1.0, 0.0])  # C(s) = K_I / s

L = C_int * P
T_cl = ct.feedback(L, 1)  # unity-feedback closed-loop transfer function

# Frequency response to inspect low-frequency shape
w = np.logspace(-2, 2, 400)
mag, phase, omega = ct.bode(L, w, Plot=False)

plt.figure()
plt.subplot(2, 1, 1)
plt.semilogx(omega, 20 * np.log10(mag))
plt.ylabel("Magnitude (dB)")
plt.grid(True, which="both")

plt.subplot(2, 1, 2)
plt.semilogx(omega, phase * 180.0 / np.pi)
plt.ylabel("Phase (deg)")
plt.xlabel("Frequency (rad/s)")
plt.grid(True, which="both")
plt.suptitle("Loop transfer function L(j omega) with integral action")
plt.tight_layout()
plt.show()

# Time-domain simulation for step and ramp inputs
t = np.linspace(0.0, 10.0, 1000)
t_step, y_step = ct.step_response(T_cl, T=t)

# Ramp response: simulate by feeding an equivalent input through closed loop
# We approximate r(t) = t by integrating a unit step (command shaping).
# Alternatively, directly simulate via forced_response with r(t) = t.
r_ramp = t
t_ramp, y_ramp, x_ramp = ct.forced_response(T_cl, T=t, U=r_ramp)

e_ramp = r_ramp - y_ramp
e_ss_ramp_est = e_ramp[-1]
print("Estimated ramp steady-state error:", e_ss_ramp_est)

plt.figure()
plt.plot(t_ramp, r_ramp, label="r(t) = ramp")
plt.plot(t_ramp, y_ramp, label="y(t)")
plt.plot(t_ramp, e_ramp, label="e(t)")
plt.xlabel("Time (s)")
plt.ylabel("Signals")
plt.grid(True)
plt.legend()
plt.title("Ramp tracking with integral action")
plt.show()
      

In robotics applications, the plant P could be a transfer function extracted from a joint-space model (e.g., via roboticstoolbox), while the integrator and additional shaping elements form the main joint servo loop.

6. C++ Implementation – Discrete-Time Integrator in a Servo Loop

In embedded and robotics software (e.g., ROS-based controllers), integral action is usually implemented in discrete time. Below is a minimal C++ snippet representing a PI controller where the integral part shapes low-frequency behavior. This could be used inside a loop that runs at a fixed control period (for example, a ROS control node).


#include <cmath>

class PIController {
public:
    PIController(double Kp, double Ki, double u_min, double u_max)
        : Kp_(Kp), Ki_(Ki), u_min_(u_min), u_max_(u_max),
          integral_(0.0) {}

    double update(double ref, double y, double dt) {
        double e = ref - y;

        // Discrete-time integrator: integral += e * dt
        integral_ += e * dt;

        // Simple anti-windup by clamping the integral term
        double u_int = Ki_ * integral_;
        if (u_int > u_max_) {
            u_int = u_max_;
            integral_ = u_max_ / Ki_;
        } else if (u_int < u_min_) {
            u_int = u_min_;
            integral_ = u_min_ / Ki_;
        }

        double u = Kp_ * e + u_int;

        // Saturate final control signal as well
        if (u > u_max_) u = u_max_;
        if (u < u_min_) u = u_min_;

        return u;
    }

private:
    double Kp_;
    double Ki_;
    double u_min_;
    double u_max_;
    double integral_;
};

// In a robotics control loop (pseudo-code):
// PIController joint_pi(5.0, 10.0, -12.0, 12.0);
// while (robot_running) {
//     double dt = computeDt();
//     double q_ref = getJointRef();
//     double q_meas = getJointPosition();
//     double u = joint_pi.update(q_ref, q_meas, dt);
//     sendTorqueToActuator(u);
// }
      

Here the low-frequency gain is dominated by Ki_, which must be chosen to satisfy steady-state accuracy requirements while respecting actuator limits and desired stability margins.

7. Java Implementation – Integral Servo for a Motor Axis

Java is widely used in educational and industrial robotics frameworks (e.g., FIRST robotics). The following class implements a simple PI controller focusing on the integral action that shapes low-frequency tracking behavior.


public class PIController {
    private double Kp;
    private double Ki;
    private double integral;
    private double uMin;
    private double uMax;

    public PIController(double Kp, double Ki, double uMin, double uMax) {
        this.Kp = Kp;
        this.Ki = Ki;
        this.uMin = uMin;
        this.uMax = uMax;
        this.integral = 0.0;
    }

    public double update(double ref, double y, double dt) {
        double e = ref - y;

        // Integrator
        integral += e * dt;

        double uInt = Ki * integral;
        double u = Kp * e + uInt;

        // Saturate
        if (u > uMax) {
            u = uMax;
        } else if (u < uMin) {
            u = uMin;
        }

        return u;
    }

    public void reset() {
        integral = 0.0;
    }
}

// Example of usage in a periodic control loop:
// PIController axisPI = new PIController(5.0, 10.0, -1.0, 1.0);
// double dt = 0.01; // 100 Hz
// while (true) {
//     double ref = referenceGenerator();
//     double y = sensorMeasurement();
//     double u = axisPI.update(ref, y, dt);
//     applyMotorVoltage(u);
//     Thread.sleep((long)(dt * 1000));
// }
      

Again, the low-frequency loop shape is chiefly determined by the integral gain Ki, while Kp primarily affects the transient response and bandwidth.

8. MATLAB/Simulink – Loop Shaping with Integral Action

MATLAB and Simulink are standard tools for loop shaping in control and robotics. Using Control System Toolbox and Robotics System Toolbox, we can design a servo for a robot joint or actuator. Below is a MATLAB script that reproduces the first-order example with integral action and shows its Bode and step responses.


% Plant: P(s) = K_g / (T s + 1)
K_g = 2.0;
T = 0.5;
s = tf('s');
P = K_g / (T * s + 1);

% Integral controller: C(s) = K_I / s
K_I = 10.0;
C = K_I / s;

L = C * P;
T_cl = feedback(L, 1);  % unity-feedback closed loop

figure;
bode(L);
grid on;
title('Loop transfer function L(s) with integral action');

figure;
step(T_cl);
grid on;
title('Closed-loop step response with integral controller');

% In Simulink, the equivalent diagram uses:
% - "Sum" block for e(t) = r(t) - y(t)
% - "Integrator" block with gain K_I for C(s)
% - Transfer Fcn block for P(s)
% This controller can be connected to a robot joint model from Robotics System Toolbox.
      

For servo systems in robotics, the same structure appears inside each joint-space or Cartesian-space loop, with the integrator providing the necessary low-frequency gain for accurate tracking of position or velocity trajectories.

9. Wolfram Mathematica – Frequency Response with Integral Action

Wolfram Mathematica provides symbolic and numeric tools for analyzing the effect of integrators on loop shape. The following code constructs the plant and integral controller, computes the closed-loop transfer function, and plots the Bode magnitude of the loop.


(* Define Laplace variable *)
s = ComplexExpand[I*ω] /. ω -> s; (* symbolic placeholder; for TF models we can use s directly *)

Kg = 2.0;
T = 0.5;
Ki = 10.0;

(* Plant and controller as transfer-function models *)
P = TransferFunctionModel[{Kg}, {T*s + 1}, s];
C = TransferFunctionModel[{Ki}, {s}, s];

L = SystemsModelSeriesConnect[C, P];
Tcl = SystemsModelFeedbackConnect[L, 1];

(* Bode magnitude of loop transfer function *)
BodePlot[L,
  {ω, 0.01, 100},
  PlotLayout -> "Magnitude",
  FrameLabel -> {"Frequency (rad/s)", "Magnitude (dB)"},
  GridLines -> Automatic
]

(* Time response to a step input *)
stepResp = OutputResponse[Tcl, UnitStep[t], {t, 0, 10}];
Plot[stepResp, {t, 0, 10},
  AxesLabel -> {"t (s)", "y(t)"},
  PlotLabel -> "Closed-loop step response with integral action",
  GridLines -> Automatic
]
      

Such symbolic tools are useful for verifying analytic expressions for error constants and checking how the number and location of integrators shape the low-frequency spectrum of \( L(s) \).

10. Problems and Solutions

Problem 1 (Ramp Accuracy Design): A unity-feedback system has plant \( P(s) = \dfrac{3}{0.4 s + 1} \) and integral controller \( C(s) = \dfrac{K_I}{s} \). The reference is a ramp \( r(t) = t \). Determine the minimum value of \( K_I \) such that the steady-state ramp error is at most \( 0.02 \).

Solution:

The loop transfer function is

\[ L(s) = C(s)P(s) = \frac{K_I}{s} \cdot \frac{3}{0.4 s + 1} = \frac{3 K_I}{s (0.4 s + 1)}. \]

This is a type 1 system. The velocity error constant is

\[ K_v = \lim_{s \to 0} s L(s) = \lim_{s \to 0} \frac{3 K_I}{0.4 s + 1} = 3 K_I. \]

For a unit ramp, the steady-state error is \( e_{\text{ss}}^{\text{ramp}} = \dfrac{1}{K_v} \). The requirement \( e_{\text{ss}}^{\text{ramp}} \leq 0.02 \) implies

\[ \frac{1}{3 K_I} \leq 0.02 \quad \Rightarrow \quad 3 K_I \geq 50 \quad \Rightarrow \quad K_I \geq \frac{50}{3} \approx 16.67. \]

Any \( K_I \) greater than or equal to approximately \( 16.7 \) satisfies the ramp accuracy requirement, subject to acceptable stability margins.


Problem 2 (Effect of Integrator on Constant Disturbances): Consider the unity-feedback loop with plant \( P(s) \) and controller \( C(s) \). An additive disturbance \( d(t) \) enters at the plant output, so that \( y(t) = \tilde{y}(t) + d(t) \), where \( \tilde{y}(t) \) is the disturbance-free output. Show that the transfer function from \( D(s) \) to \( Y(s) \) is

\[ G_{d \to y}(s) = \frac{P(s)}{1 + C(s)P(s)}, \]

and explain why adding an integrator to \( C(s) \) eliminates the steady-state effect of constant disturbances when the closed loop is stable.

Solution:

With unity feedback and an output disturbance, the loop equations in the Laplace domain are

\[ E(s) = R(s) - Y(s), \quad U(s) = C(s) E(s), \quad Y(s) = P(s) U(s) + D(s). \]

Eliminating \( E(s) \) and \( U(s) \) gives

\[ Y(s) = P(s) C(s) (R(s) - Y(s)) + D(s) \quad \Rightarrow \quad (1 + C(s)P(s)) Y(s) = C(s)P(s) R(s) + D(s). \]

Thus

\[ Y(s) = \frac{C(s)P(s)}{1 + C(s)P(s)} R(s) + \frac{1}{1 + C(s)P(s)} D(s). \]

The transfer function from disturbance to output is therefore

\[ G_{d \to y}(s) = \frac{1}{1 + C(s)P(s)} = \frac{P(s)}{P(s) + C(s)P(s)P(s)}, \]

which is equivalent to the given expression after factoring \( P(s) \). Now let the disturbance be constant: \( d(t) = d_0 \), so \( D(s) = \dfrac{d_0}{s} \). The steady-state disturbance effect is

\[ y_{\text{ss}}^{(d)} = \lim_{t \to \infty} y_d(t) = \lim_{s \to 0} s G_{d \to y}(s) D(s) = d_0 \lim_{s \to 0} G_{d \to y}(s). \]

If \( C(s)P(s) \) contains at least one integrator, \( |C(s)P(s)| \) grows without bound as \( s \to 0 \), so

\[ \lim_{s \to 0} G_{d \to y}(s) = \lim_{s \to 0} \frac{1}{1 + C(s)P(s)} = 0, \]

provided the closed loop is stable. Hence the steady-state output deviation due to a constant disturbance is driven to zero when an integrator is present in the loop.


Problem 3 (Bode Slope and System Type): The low-frequency magnitude Bode plot of \( L(\mathrm{j}\omega) \) for a unity-feedback system shows:

  • At very low frequencies, a slope of approximately \( 0 \,\text{dB/dec} \).
  • Above a small break frequency, a slope of approximately \( -20 \,\text{dB/dec} \).

(a) What is the system type? (b) What does this imply for the steady-state step and ramp errors?

Solution:

(a) At very low frequencies, the slope is zero, which suggests that \( L(\mathrm{j}\omega) \) tends to a constant as \( \omega \to 0 \). This is characteristic of a type 0 system (no integrators). The subsequent \( -20 \,\text{dB/dec} \) slope reflects a pole at nonzero frequency, but not at the origin.

(b) A type 0 system has finite \( K_p \) and zero \( K_v \). Therefore, the step steady-state error is nonzero (\( e_{\text{ss}}^{\text{step}} = 1/(1 + K_p) \)), while the ramp steady-state error is infinite (\( e_{\text{ss}}^{\text{ramp}} = \infty \)). To improve ramp tracking, at least one integrator must be introduced in the loop.


Problem 4 (Zero Steady-State Step Error with Integral Action): Prove that a stable unity-feedback system with loop transfer function \( L(s) \) having exactly one integrator (type 1) has zero steady-state error for a unit step reference \( r(t) = 1 \).

Solution:

For a unit step, \( R(s) = \dfrac{1}{s} \). The error transform is

\[ E(s) = \frac{R(s)}{1 + L(s)} = \frac{1}{s (1 + L(s))}. \]

The steady-state error is

\[ e_{\text{ss}} = \lim_{t \to \infty} e(t) = \lim_{s \to 0} s E(s) = \lim_{s \to 0} \frac{1}{1 + L(s)}. \]

Because the system is type 1, we can write \( L(s) = \dfrac{\hat{L}(s)}{s} \) where \( \hat{L}(s) \) is finite and nonzero at \( s = 0 \). Then as \( s \to 0 \),

\[ |L(s)| = \left|\frac{\hat{L}(s)}{s}\right| \to \infty, \]

so

\[ e_{\text{ss}} = \lim_{s \to 0} \frac{1}{1 + L(s)} = 0. \]

Hence any stable type 1 unity-feedback system achieves zero steady-state error for constant references, which is the main motivation for integrating action in servo controllers.

11. Summary

In this lesson we examined integrators as the key mechanism for shaping the low-frequency behavior of the loop transfer function in servo design. We related the number of integrators (system type) to the steady-state error constants and showed how integral action forces large low-frequency gain, improving tracking and disturbance rejection for low-frequency signals at the cost of additional phase lag.

We studied how to choose the integral gain and break frequency to meet ramp accuracy specifications while preserving stability margins, and we illustrated implementation in Python, C++, Java, MATLAB/Simulink, and Mathematica, emphasizing servo and robotics contexts. These insights provide the foundation for more advanced trade-off analysis in terms of sensitivity and complementary sensitivity functions in the next chapter.

12. References

  1. Bode, H. W. (1945). Network Analysis and Feedback Amplifier Design. D. Van Nostrand Company.
  2. Evans, L. J. (1954). Control systems synthesis by root locus method. Transactions of the American Institute of Electrical Engineers, Part II: Applications and Industry, 73(5), 562–572.
  3. Horowitz, I. M. (1963). Synthesis of Feedback Systems. Academic Press.
  4. Truxal, J. G. (1955). Automatic Feedback Control System Synthesis. McGraw–Hill.
  5. MacFarlane, A. G. J., & Kouvaritakis, B. (1977). A design technique for linear multivariable feedback systems. International Journal of Control, 25(4), 657–678.
  6. Åström, K. J., & Hägglund, T. (1995). PID Controllers: Theory, Design, and Tuning. Instrument Society of America.
  7. Middleton, R. H., & Goodwin, G. C. (1988). Improved finite word length characteristics in digital control using delta operators. IEEE Transactions on Automatic Control, 33(10), 947–958.
  8. Skogestad, S., & Postlethwaite, I. (2005). Multivariable Feedback Control: Analysis and Design (2nd ed.). Wiley. (Chapters on integral action and low-frequency robustness.)
  9. Francis, B. A., & Wonham, W. M. (1976). The internal model principle of control theory. Automatica, 12(5), 457–465.
  10. Doyle, J. C., Francis, B. A., & Tannenbaum, A. R. (1992). Feedback Control Theory. Macmillan. (Sections on integrators and loop shaping.)