Close

Developing a TEC Cooler with PID Control: A Unidirectional Approach

A project log for JASPER: Peltier cooler for lasers

Peltier cooler for lasers used in FTIR and Raman spectrometers, maintaining temperature and wavelength stability for optimal performance

mohamed-faizan-tabassumMohamed Faizan Tabassum 03/03/2025 at 10:580 Comments

Code can be found here

At CheckAG, we're currently developing a Thermoelectric Cooler (TEC) control system for precise temperature regulation — a critical part of many of our spectrometry projects. I wanted to share the initial steps of implementing PID control for the TEC and some design choices we've made along the way.

Understanding PID Control

PID control — Proportional, Integral, and Derivative control — is a widely used feedback control method for dynamic systems. It works by continuously calculating the error between the desired setpoint (target temperature) and the current value (actual temperature), then adjusting the output (PWM to the TEC module) based on three terms:

The control signal is computed as:

Output=Kp×Error+Ki×∫Errordt+Kd×d(Error)dt Output = Kp \times Error + Ki \times \int Error dt + Kd \times \frac{d(Error)}{dt}

In our setup, we used these initial PID constants:

float Kp = 420, Ki = 32, Kd = 1365;

Unidirectional Control for the Peltier Module

A key design choice we made is to use unidirectional control rather than bidirectional control. Typically, bidirectional control allows a Peltier module to both cool and heat by reversing the current flow. However, we opted for unidirectional control for two reasons:

  1. Simplicity: It reduces hardware complexity since we don't need an H-bridge or additional switching components.
  2. Ambient heating: When the MOSFET is off, the TEC naturally warms back to ambient temperature due to passive heat exchange. This allows us to rely on the environment to heat the TEC when necessary.

Our control logic works like this:

The PID controller's output is simply mapped to a PWM signal controlling the MOSFET’s gate:

analogWrite(PELTIER_PWM, controlSignal);

PID Tuning: Ziegler-Nichols Method

Tuning the PID gains is crucial to getting stable and accurate temperature control. We used the Ziegler-Nichols method for tuning, which follows these steps:

  1. Set Ki and Kd to zero.
  2. Increase Kp until the system oscillates at a constant amplitude — this is the ultimate gain (Ku).
  3. Measure the oscillation period (Pu) — the time it takes for one full oscillation cycle.
  4. Calculate Kp, Ki, and Kd using these formulas:
Kp Kd
0.5 * Ku 0
0.45 * Ku 0
0.6 * Ku Kp * Pu / 8

After tuning, we landed on:

Kp = 420;
Ki = 32;
Kd = 1365;

Final Thoughts

This unidirectional control design simplifies the hardware and leverages natural thermal dynamics to heat the TEC. The PID controller, tuned using Ziegler-Nichols, balances responsiveness and stability.

I'll continue to share updates as we refine the system further. Let me know if you'd like to dive deeper into any part of this — from the PID algorithm to the hardware design!

What do you think? I'd love to hear your thoughts, suggestions, or even experiences with TEC control systems!

Discussions