A PID controller or controller is a very advanced electronic thermostat that ensures that the temperature, for example of an oven or proofing cabinet, reaches and retains the set temperature very accurately (and as quickly as possible).
PID stands for Proportionally Integrating and Differentiating. A PID controller is a very advanced thermostat (temperature controller). A PID controller differs from the usual on/off thermostat in that the PID controller ensures that the temperature is reached as quickly as possible, but without the temperature “overshooting”. This overshooting both above and below the desired temperature is a typical disadvantage of a traditional (on / off) thermostat.
The overshooting / fluctuating around the desired temperature with traditional thermostats is because it only expands the heating element. When the desired temperature is reached but, although the heating element is turned off, it is still so hot that it still provides a lot of energy, so that the temperature is considerably higher than the desired temperature. Even when the temperature drops below the desired temperature, the heating element is turned on, but that is actually too late, after all, it takes some time before the heating element emits heat. During the temperature drop, you could expect (predict) that the temperature will fall below the set temperature. In fact, the on/off thermostat always reacts too late and thus ensures that the temperature has large fluctuations.
The strength of the oscillation depends on the ratio between the power of the heating element and the actual power required to get and keep the room at temperature. For example, an oven in a kitchen can be equipped with a heating element with a lot of power. As a result, the oven is quickly up to temperature. But the disadvantage is less attractive. Due to the (too) large power, the temperature will rise too far after the oven has reached temperature. Temperature fluctuations from 10 to 20 degrees (and sometimes even more) are normal fluctuations for ovens in the kitchen. This can, for example, lead to the crust colouring too strongly.
All modern professional proofing cabinets and ovens are equipped with PID controllers. That most ovens in the kitchen do not have a PID control is because a simple on / off thermostat is very cheap and a PID control costs a few tens extra.
That the PID control can control the temperature so precisely is because the heating element can be put on and off very quickly, think of several times per second. The PID scheme constantly adjusts the ratio between the “on-time” and the “duty-cycle”. For example, as an example, the heating element can be on for 1/10 second and off for 9/10 seconds, effectively releasing (only) 10% of the power of the heating element. At a ratio of 6/10 seconds on and 4/10 seconds off, the heating element releases 60% of its power.
The PID control can therefore very precisely control the power of the heating element from 0 to 100% in steps of (often less than) 1%, while with a traditional thermostat the heating element is completely on (100%) or completely off (0%). In addition, the PID control has an algorithm (complex formula) that, given the current temperature and the desired temperature. This makes a very accurate prediction of how strongly the heating element must be turned on, so that the large aforementioned temperature fluctuations are prevented.
Practical PID – Arduino Experiment
To demo PID theory in action, I picked up an Arduino® Nano from my messy drawer along with a photoresistor (LDR) and a super bright 3 mm blue LED. The experiment described here is based on components on-hand because I did not have any dedicated PID systems or components within easy reach yet. And, I’m lazy too!
This is the hardware setup diagram.
Note: you should place your LDR so that it aims into the LED output.
In this experiment I am trying a far-famed Arduino PID library (PID_v1) which is simple to set up and use. The tricky part is to set the relevant PID parameters (kp, ki and kd) according to your actual needs and configuration. That means you should note that a PID controller is not usable out of the box. Tuning must be done to ensure that the desired performance is achieved. This can be done by determining the constants beforehand and changed them according to the actual response of the system until the optimum values are achieved. Frankly I have not done much experimentation with tuning but despite the lack of precise tuning, I have had pretty consistent results!
To implement a PID controller in an Arduino sketch, five parameters must be known: Proportional, Integral and Derivative constants, input value and set point value. Well, let’s start with a crude demo code. Here’s the code to implement a PID control system using an Arduino® Nano. See, the simplicity of the code is because of the great PID_v1 Library (https://github.com/br3ttb/Arduino-PID-Library) which requires you to specify only a few values, and you’re good to go!
To see how the well this code works, you can use the Serial Monitor in the normal way or the Serial Plotter comes with your Arduino IDE (1.6.6 and above). When I put y hand over the setup, I casually noticed that the setup quickly reacts and tries to keep the LED brightness at the set point by managing the LED control value.
As you can see in the left portion of the above plot, there’s a slightly annoying hiccup on initial start-up, which I think could be solved with better tuning. However, once it’s settled, there’s hardly any discernible oscillation so far. I have not timed how long this narking phase lasts. I also forgot to measure the oscillation in the actual output point.
I have done a few analogue PID controller projects, but this is my first time preparing a quick primer on PID controllers for the home builder. This was a learning attempt because I read much about PID controllers and conducted a few practical experiments. Someday, I’m going to refine the code demoed here, and make it appropriate for my swimming pool heater/water pump controller project. As might be expected, many great off-the-shelf PID controllers already exist, but I want to break the enigmas and do it cheaper and flexile!
Broodsmakelijk, PID Regelaar, https://broodsmakelijk.nl/glossarium/nederlands/pid%20regelaar electroschematics, PID And Arduino, https://www.electroschematics.com/pid-and-arduino-primer