I have a system where a setpoint temperature can be set. A heater and a cooler is connected to the object. Right now both the heater and the cooler regulate on the temperature separately with separate PID controllers. This ofcourse causes them to "battle", and also I imagine they could be stuck in a position where both the heater and cooler is working.

What is the general approach to these types of problems?

  • 4
    \$\begingroup\$ A single PID with a driver for the heater and the cooler? Positive output: heater, negative output: cooler \$\endgroup\$
    – clabacchio
    Apr 18, 2012 at 15:25
  • \$\begingroup\$ What is implementing the PID algorithm? Are these devices which you have bought, or did you implement them yourself on a microcontroller? \$\endgroup\$ Apr 18, 2012 at 16:21
  • \$\begingroup\$ Both my pid controllers are in software. The cooler is just a watercooler where I can control the fan speed and the heater is a simple resistance. clabacchio: without any range in between they will still battle each other, no? \$\endgroup\$
    – Rolle
    Apr 18, 2012 at 19:55

4 Answers 4


There are three common solutions to this:

  1. Set the setpoints a bit apart. Make the heater setpoint a little lower than the cooler setpoint. These need to be far enough apart so that overshoot from one doesn't trigger the other. If you can tolerate the resulting temperature range, this is the easiest thing to do if you already have existing separate heating and cooling systems.

  2. Include a switch so that only one of the heater or cooler can be on at a time. Some home thermostats are like that. You generally know whether you need to cool or heat, so it's up to you to throw the switch appropriately when you want to switch over.

  3. Use a single controller. This is the architecturally obvious and best way to do it if you can design the overall system. A single controller tries to maintain temperature, and it automatically switches between the heater and cooler as appropriate. This kind of controller can even implement a break-before-make timeout during switchover and other fancy things.

  • \$\begingroup\$ Actually everything is in software, so I can control it everything from a single place. But as you say in 1), I think its good to have some range in between to avoid constant on/off switching when I am right on target \$\endgroup\$
    – Rolle
    Apr 18, 2012 at 19:58

The output of your PID controller should be a signed value. A positive value means 'heat up' and a negative value means 'cool down'. so your code would be like this:

output = PID_Calculation();

if (output > 0)
  • 1
    \$\begingroup\$ How does this apply to the OP's case where he has two seperate controllers? \$\endgroup\$
    – The Photon
    Apr 18, 2012 at 15:55
  • \$\begingroup\$ Well, it depends where the controllers are implemented. I assumed he had two software controllers running on the same MCU. \$\endgroup\$ Apr 18, 2012 at 15:58

There are a few things you can do:

  1. Use a MIMO control system (i.e., look at controlling two processes with one controller)
  2. Introduce Hysteresis loop
  3. only one can be on at a time

Hysteresis reduces the sensitivity of the system to change.

The way this is done:

  • Create a threshold for turning the heater on/off
  • When the heater is turned on
  • lower the temperature required to turn the heater/cooler off

What this means is: If the heater is off have a on threshold to turn it on If the heater is on have a lower threshold to turn it off

you MUST not allow both systems (heater, cooler) to work simultaneously. so if the house is


The general approach is to implement deadbanding.

A deadband (sometimes called a neutral zone) is an area of a signal range or band where no action occurs (the system is dead). Deadband is used in voltage regulators and other controllers. The purpose is common, to prevent oscillation or repeated activation-deactivation cycles (called 'hunting' in proportional control systems).

You may also be dealing with hysteresis.

Hysteresis is the dependence of a system not only on its current environment but also on its past environment. This dependence arises because the system can be in more than one internal state. To predict its future development, either its internal state or its history must be known.1 If a given input alternately increases and decreases, the output tends to form a loop

In layman's terms you can think of hysteresis as overshoot. In other words when one turns on a heater and then turns it off at a certain temperature the temperature may continue to rise somewhat even after the heater is turned off. Of course a PID controller should handle this, but you have two independent controllers which may be battling each other.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.