Tuning PI Controllers for Thermoelectric Coolers

SIMC tuning and why TECs are great

The code and plotting notebook for the following is available here

Summary

This article discusses tuning a thermoelectric cooler (TEC) controller for real-world applications and highlights the unique advantages of TECs. The plant is characterized as a delay-integrator thermal system using a step response and apply Skogestad’s SIMC method for PI tuning. We then explore considerations specific to systems that both heat and cool versus those that only do one and how the models respond to external forcing.

Introduction

We use thermoelectric coolers (TECs) across several projects, including the compact LC120 diode laser controller and our SiPM modules. More recently, we’ve been developing temperature control systems for lab-on-a-chip platforms, which demand an unusual combination of low cost, compact size, and precise thermal regulation. These setups often rely on resistive heaters and external chillers, and tuning them has given me a renewed appreciation for the the bidirectionality of TECs.

TECs heat and cool, we should appreciate them for this. A nice card is probably in order.

For the model and tuning I’ll be following this enlightening chapter from Sigurd Skogestad and Chriss Grimholt’s book Multivariable Feedback Control Analysis And Design (Dr. Skogestad kindly has the chapter available for download here). For more on PIDs Åström’s Advanced PID Control is excellent.

Temperature Control Model

Temperature control systems are usually modelled as either a delay + first order system (one pole):

$$G(s) = \frac{k}{\tau s + 1}e^{-s\theta}$$

or a delay + integrator

$$G(s) = \frac{k'}{s}e^{-s\theta}.$$

Note you can approximate a first order system as an integrator process if the time constant \( \tau \) is large compared to the delay ( \( \tau >> \theta \) ). k’ is then the slope of the integrator \(k' \equiv \frac{k}{\tau_1}\).

Characterizing

Skogestad and Grimholt list a few including a heuristic approach from the response of the closed loop system. I’m using the open loop step response but there are other approaches that will allow you to tune with a closed loop.

Say we have a current controlled device, set a fixed current and record the temperature change over time.

Ideal delay + integrator model open loop step response.

So now we fit the delay and integrator using a piecewise function as the functional form:

import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt

def delay_integrator_model(t, K, theta, y0):
    """Step response of a delay + integrator system."""
    y = np.piecewise(t,
                     [t < theta, t >= theta],
                     [lambda t: y0,
                      lambda t: y0 + K * (t - theta)])
    return y

def fit_delay_integrator(t_data, y_data, diff_thresh=0.1):
    """
    Fit a delay + integrator model to data.

    Parameters:
    - t_data: time array (1D)
    - y_data: output values (1D)
    - plot: if True, plots the result

    Returns:
    - popt: Fitted parameters [K, theta, y0]
    - pcov: Covariance matrix of the parameters
    """
    # Initial guesses: slope, delay, baseline
    K0 = (y_data[-1] - y_data[0]) / (t_data[-1] - t_data[0])
    theta0 = t_data[np.argmax(np.diff(y_data) > diff_thresh)]
    y0 = y_data[0]
    p0 = [K0, theta0, y0]

    # Fit the model
    popt, pcov = curve_fit(delay_integrator_model, t_data, y_data, p0=p0)
    return popt, pcov

Simulation

Tuning

$$ K_c \equiv k_p = \frac{1}{k'} \cdot \frac{1}{\tau_c + \theta} $$$$ \tau_i = 4(\tau_c + \theta) $$

k’ is the slope and \( \theta \) is the delay so we’re left with only \( \tau_c \) as the tuning parameter. A lower \( \tau_c \)​ gives higher responsiveness (or tightness) and higher values give more stability and less overshoot (or ‘robustness’).

For ease of simulation and clarity the following is done in discrete time with the PI controller being updated at a frequency \( \nu \):

$$ k_p = \frac{1}{k' \cdot (\theta + \tau_c)} $$$$ k_i = \frac{k_p}{ t_i} \cdot \frac{1}{\nu} $$

Set point increase response for different values of \( \tau_c \).

Actuator Limits and Integrator Windup

The controller usually does not have an unlimited current output (we’re working on that) so we need to introduce limits to the actuator. Adding a limit will introduce windup, where the integrator accumulates error when the output is saturated leading to:

  • Overshoot
  • Delayed settling
  • Undesired oscillations
  • Generally bad things

An simple effective anti-windup strategy is to conditionally update the integral only when the control output is not saturating. When the actuator is saturated and slew limited then the integrator is frozen. This approach, typically called ‘conditional integration’, significantly reduces overshoot and eliminates ringing seen in the saturated case.

There’s a good paper by Anstrom and Rundqwist discussing this and a couple other methods and Stability and Stabilization of Linear Systems with Saturating Actuators by Sophie Tarbouriech et. al dedicates 1/3 of the book to the topic. Åström’s Advanced PID Control covers the topic briefly but thoroughly.

Using conditional integration shows a big improvement in the overshoot. For digital PI controllers, conditional integration is trivial to implement and highly effective—it simply freezes the integrator when the actuator hits its limit. For analog systems alternative approaches are likely simpler.

Set point change showing the effect of windup and conditional integration.

Heat Leak Model

To simulate parasitic conductive heat transfer to the environment:

def linear_heat_leak(temp, ambient, factor):
    return (ambient - temp) * factor

This linear model works for conduction-dominated systems. For systems where convection or radiation dominates, a quadratic or quartic model may be more appropriate. I’m using forcing units of Amps/C\(^0\) which is essentially the combination of the thermal resistance and the TEC efficiency.

Conductive cooling model of an object to ambient

Closed loop response with a conduction of \( I/\Delta T \) = 70 mA/C.

Asymmetric Actuators

Unidirectional actuators, such as heaters, require some external restoring force to stay at a set point with bidirectional forcing. For applications like cooling APDs, laser diode, or heating bio-samples, this is a fair assumption but it needs to be considered when designing your system.

The following uses the tuned filter from previously with symmetrical and asymmetrical current limits of -1/1A and 0/1A. A small thermal conduction constant of 5mA/C is used.

If the set point is close to the ambient temperature then the stability of the system depends on that small restoring force. Here’s what can happen with the set point equal to the ambient with random forcing:

Closed loop response with random forcing near ambient. Since the unidirectional actuator can't cool then there can be significant error in response to biderectional forcing.

The issue goes away if the device stays in its region of linear control. This figure shows random forcing but with a large dT.

Moving the set point away from the ambient improves the accuracy with bidirectional forcing.

In the case of only negative forcing, such as cold convection on a heater, the symmetrical and asymmetric controllers perform similarly. The overshoot issue remains so if that is a problem then a more stable setting should be used (i.e. a higher \( \tau_c \)).

Negative only forcing (such as cooling of a heater) keeps us only in the heating regime so there is no significant difference between the symmetrical and asymmetrical actuators.

One additional thing to keep in mind that if the restoring force is small then overshoots and any forcing events take a long time to settle.

Closed loop response with forcing. The asymmetrical actuator cannot respond to the positive forcing without external forcing.

Conclusion

SIMC tuning improves on Ziegler-Nichols while still being easy to auto-tune with the results of a step response. It simplifies the PI gain to a single tuning parameter which allows simple setting of ’tight’ or ‘stable’ control depending on your requirements. Be careful when using asymmetrical actuators and think about the restoring force. When you have an actuator as nice as a TEC it’s worth taking some time to appreciate it.