Slow Cooker

In late 2020, a friend of mine gifted me an old slow cooker when she moved abroad. I hadn't used a slow cooker before, but it gave me an idea.

Once or twice in the past I have made yoghurt, by heating whole milk in a specific sequence and mixing in a live culture from a commercial yoghurt. This worked really well, but was a bit of a pain simply because it requires precise temperature management, and it's not always easy to maintain a precise 43°C for several hours using a standard fan oven.

So when I received the slow cooker, then, it gave me an idea! I would modify it to be a programmable, temperature-controlled slow cooker, suitable for the usual casseroles and curries, but also for recipes that require more precise temperature management, like yoghurt.

The general gist was to use a microcontroller to monitor the temperature of the contents using a submersible temperature probe, and maintain the programmed temperature by turning the cooker on and off using a relay.

You can see the repository of code for this project on my Gitlab page.

Temperature Control

In order to give precise power control without any form of throttling, I decided to implement a low-frequency PWM control over the power, starting with a PWM frequency of 60 seconds, and a duty cycle range of around 10% - 90%, to avoid rapid switching of the relay. The duty cycle would be decided using a PID feedback loop, to monitor and maintain the temperature with a minimum of oscillation.

An early prototype simply used an on-off output, whereby the cooker would run at full power if the temperature was below the target, and be off otherwise. I added a simple hysteresis to turn off slightly early when the temperature was rising. Even with this simple system, the contents were kept within around 1.5°C of the target, which is plenty precise for any reasonable application of this machine. Of course though, that wasn't good enough for me, as I knew I could do better!

In order to tune the PID without hundreds of hours of experimentation, I logged the temperature curves of the cooker filled with water as it heated at full power, and as it cooled when the element was switched off. I imported these data into Excel (usually I might have used Python, but for this quick-adjustment, highly visual application, I found Excel a better choice) and wrote a simple model for the system, including exponential heating and cooling and a time delay between input and result. I then wrote a simple PID algorithm to maintain a temperature, and tested a range of PID parameters until the model showed the behaviour I wanted.

UI

I wanted a good UI for the system, so that the user could easily and intuitively start the program they wanted.

I wanted to use a simple 16 x 2 segment LCD display, with a couple of buttons for control.

I used the approach of 'minimum viable product' in order to learn and develop the system as I went; early versions had a single menu which showed the current temperature and allowed the user to change the target temperature. Since then, I have added a range of capabilities, including the ability to add multiple steps, where the system holds a given temperature indefinitely, or for a fixed time, or for a fixed time only after the temperature is reached, as the user decides.

Over time, I have tuned the UI to be smooth, responsive, and to work as expected with rapid or simultaneous button presses, using state control and object-oriented methods.