Never underestimate the potential for the human element to cause catastrophic devastation, or at least cause you to find yourself with a flaming pool of molten metal burning through your tabletop.

I had spent a good part of this weekend tuning a PID controller to heat an open pot of water to 50°C. This will be used for a cooking method known as sous vide, which translates to "under vacuum." This refers to the traditional vacuum bag that the food (which is commonly meat) is put into to increase heat transfer from the water to the food. It relies on using a temperature-controlled water bath to cook the food to a precise temperature. This method also makes it virtually impossible to overcook (which is easy to do on a stovetop or grill) and enables cooking a rare or medium-rare steak as easy as setting the temperature and letting Mycodo do the rest. Because the temperature is regulated, foods can be cooked for extended times, such as hours or days, to attain your desired tenderness. Some of the most delicious foods I've tasted have been made with sous vide, and I'm excited to be demonstrating the tuning I went through to get my sous vide system up and running.

I had a submersible 120-volt AC heating element, my new Atlas Scientific PT-1000 temperature probe, and a hot water pump. I secured them all to a metal screen and began my long journey of tuning.



To begin tuning a PID, you have to understand some PID theory. I've covered this in the Mycodo manual and other things I've written in the past, so hopefully this explanation can improve upon my previous works by illustrating what I'm talking about with actual data and graphs I obtained from tuning this PID over the past two days.

First, lets discuss some terminology. PID stands for Proportional Integral Derivative. Each word describes a variable that contributes to processing an output value, called the manipulated variable (MV), from an input value, called the process variable (PV). All three P, I, and D variables are summed to produce the MV (P + I + D = MV). The duty of a PID controller is to affect the PV to move to a desired position, called the Setpoint (SP). The difference between the current position and the setpoint is the error (e).

Using water heating as an example, the process variable will be the measurement from a temperature sensor submerged in the water, which at room temperature is 28°C. The manipulated variable will be the number of seconds a heating element submerged in the water will turn on for. Our setpoint will be 50°C, making our initial error = 50-28 = 22. Therefore, at a measurement period of 35 seconds (an output is created from the input every 35 seconds), the heater would be turned on for 22 seconds and off for 13 seconds. This can be referred to as the duty cycle, and in this case would be 22/35 = 62.8%. Over the period of time where this on/off cycle persists with these durations, the heater is energized 68.2% of the time. By increasing the duty cycle, more energy would be put into the system.

The minimum options for Mycodo's PID controller are period (which determines how often a measurement is taken and the heater powered), a relay to power the heater, a sensor to obtain a measurement from, Kp, Ki, Kd, and a setpoint. Kp, Ki, and Kd are three main gains that determine how much each of the P, I, and D variables contribute to the MV. The expanded equation to produce the MV now looks like this: (Kp * P) + (Ki * I) + (Kd * D) = MV. Since P, I, and D are calculated by the controller (we're going to get into this shortly), the gains determine the degree to which each variable contributes to the final MV. So, if all gains are set to 0, the output will of course be 0, meaning the heating element will not turn on at all. And if the Kp is set to 0.1 it will produce a smaller MV than if Kp was set to 1.0.

This makes it simple to use the gains to tune the controller and to enable or disable the contribution of each part of the MV calculation. If...