PID Temperature Controller Circuit Design

A temperature controller compares a measurement with a set point and adjusts the power delivered to a heater. The electronics are straightforward; the difficulty is that heat moves slowly, and a loop that is tuned for a fast response will oscillate in a way that the arithmetic alone does not suggest.

The Loop and Its Parts

A PID loop has three terms. The proportional term responds to the present error, the integral term removes the steady state offset, and the derivative term responds to the rate of change and damps the response.

The proportional term alone leaves a permanent offset, because the output only exists while there is an error. The integral term accumulates the error and removes the offset, at the cost of a slower approach and of overshoot if it is set too aggressively.

The derivative term is the one that is often omitted in temperature control, because the measurement is noisy and differentiating noise produces a large output. Where it is used, the measurement is filtered first or the derivative is applied to the set point rather than to the error.

thermal mass and Time Constants

thermal mass is the heat capacity of the object being controlled, and it sets the time constant of the response. A small sensor on a large block takes minutes to respond, and no amount of loop tuning changes the physics.

A practical rule is that the loop period should be several times the dominant time constant, and the integral time should be of the same order. Values copied from a different application are a common source of poor control.

The heater itself has a time constant as well, and the delay between applying power and seeing a change in the sensor is the dead time of the loop. Dead time is what limits the achievable bandwidth more than anything else.

Temperature controller board driving a heater element

sensor lag and Placement

sensor lag is the delay between the temperature of the object and the temperature the sensor reports. It comes from the thermal resistance between the sensor and the surface, the mass of the sensor itself and the mounting.

A sensor clamped to a heater with a poor thermal joint reports the heater rather than the load, and the loop controls the wrong temperature. The error is largest during transients, which is exactly when the loop is working hardest.

Placing the sensor at the point whose temperature matters is the only reliable approach. Where that is impossible, the loop is tuned for the measurement it has, and the difference between the reading and the true value is documented.

Output Types and duty cycle

The output is either a linear power stage or a switched one. A switched output uses pulse width modulation or a slow on off cycle, and the duty cycle is the fraction of the period for which the heater is on.

A mechanical relay cannot be switched quickly and it wears out, so the period is long, often ten or twenty seconds. That long period interacts with the loop and effectively adds dead time, which has to be included in the tuning.

A solid state relay or a transistor output can be switched at a higher rate and gives smoother control. Where the heater is mains powered, the switching is usually synchronised with the mains zero crossing to reduce the electrical noise generated.

Thermocouple input and heater drive layout on a temperature controller PCB

Tuning the PID loop

Tuning starts with the proportional term alone. The gain is raised until the loop oscillates with a constant amplitude, and the period of that oscillation gives the natural period of the system. The integral and derivative terms follow from it.

The classic rules derived from that experiment give a starting point, and the final values come from observing the response to a step change in the set point. Overshoot, settling time and steady state error are the three things to watch.

A loop that oscillates slowly has too much integral action, while one that oscillates quickly has too much proportional gain. The frequency of the oscillation is a direct clue to which term to reduce.

Limits and Anti Wind Up

The output cannot be negative and it cannot exceed the maximum power of the heater. When the loop demands more than the hardware can provide, the integral term continues to accumulate and the loop then overshoots when the demand comes back into range.

Anti wind up clamps the integral term at the output limits or stops integrating while the output is saturated. It is a few lines of code and it is the difference between a controller that overshoots by ten degrees and one that overshoots by one.

The same reasoning applies at the bottom of the range, where a cooling output is unavailable and the heater is off. A controller that expects to cool and cannot will sit at the limit with the integral term winding up.

Accuracy and the Measurement

The control accuracy cannot be better than the measurement accuracy. An offset in the sensor reading appears directly as an offset in the controlled temperature, and a noisy reading is transferred into the output.

Averaging the measurement over several samples reduces the noise that reaches the loop. The averaging time has to be short compared with the loop period, or it adds its own dead time and destabilises the response.

Self heating of the sensor is a common source of offset. A resistance sensor driven with too much current reads high by a fixed amount that is largest in still air, and the loop then holds the object below the intended temperature.

Safety and Fault Handling

A heater that is left on with a failed sensor can destroy the equipment or start a fire. The controller therefore needs an independent over temperature cutout, usually a thermal fuse or a thermostat, that operates regardless of the software.

The sensor itself should be checked for plausibility. A reading outside the physical range, or one that does not change when power is applied, indicates a fault, and the output should be removed and the condition reported.

A break in the sensor circuit is the failure that most often leads to overheating, because a broken thermocouple reads as a low temperature and the loop turns the heater fully on. Detecting the open circuit rather than interpreting it as a cold reading is essential.

Verification and Faults

Verify the loop with a step change and record the response, including the overshoot and the time to settle. That trace is the evidence that the tuning is correct, and it can be compared after any change to the hardware.

Check the temperature at the sensor and at the point that matters with a second instrument. A difference that grows with power indicates a thermal gradient that no tuning can remove.

A loop that controls well at one set point and poorly at another is usually non linear, because the losses from the object depend on its temperature. Gain scheduling, with different parameters for different ranges, is the usual answer. The release checks that keep such a controller consistent are collected in our PCB design release checklist, and the assembly points are listed in judging PCB quality. The measures that keep the small sensor signal clean are described in our guide to mixed signal board design.

FAQ

Do I need the derivative term? Often not for a slow thermal system. Use it where the loop must react quickly and the measurement is filtered well enough to differentiate.

Why does my controller overshoot on start up? Integral wind up while the output is saturated. Clamp the integral term at the output limits.

How do I choose the switching period? From the actuator. A relay needs ten or twenty seconds, a solid state output can switch much faster and gives smoother control.

Leave A Comment