Wednesday, August 28, 2013

LPC800 Mini Kit sous vide cooking controller


This project uses a LPC800 Mini Kit evaluation board as a sous vide cooking controller together with a DS18B20 temperature sensor and a modified timer unit and a rice cooker. A simple user interface (using just one microswitch and one LED) allows the user to select a set temperature. PID control and other techniques are used to heat and maintain water at the set temperature. An optional computer attached via a serial port captures debugging and temperature logging data. The firmeware source is open source and is available on GitHib. A video overview of the project is here.


NXP sent a free LPC800 Mini Kit board a few weeks ago.  As part of the promotion they are running a "LPC800 simplicity challenge"... for weird and wacky apps using the LPC810 (open until end August 2013). This is my entry for this competition.

The LPC810 comes in a 8 pin DIP package of which two pins are reserved for power and ground. It costs about $1 in single quantities and that price drops to less than half in large quantities. The LPC800 Mini Kit board features this LPC810 but also a side connector for a serial port, two micro switches and a blue LED as well as some prototyping space.

I've been experimenting with sous vide cooking recently. This is cooking technique were meats and vegetables are sealed in a vacuum packed bag and slow-cooked in a bath of hot water at a very carefully controlled temperature. In this application temperature accuracy and control is paramount. For example: when cooking beef steak, the difference between a rare and a well done steak is just 5°C (10°F) (from 55°C to 60°C). Moreover if the water temperature is under 50°C (120°F) bacteria can multiply raising food safety risks.

Any appliance that heats water electrically can (in theory) be converted into a sous vide cooker. My choice was a 400W rice cooker which was on special at Lidl a few weeks ago (for €20?). The sous vide controller measures the temperature of the water and toggles the state of the heating element to precisely (and accurately) control the water temperature.

I used a hacked mains timer unit for the element control. I removed the user interface components of the device and broke out the low voltage relay control line. I've written about this in a previous blog post. For electrical safety I electrically isolated this with a Lite-On LTV-817S opto-isolator.

My first attempt at water proofing a DS18B20
temperature sensor.
For temperature sensing I used a DS18B20 digital temperature sensor. This is a three lead device (TO-92 package) which requires just one digital IO line to operate (the other to leads are for power and ground). The choice of a digital sensor avoids the need for analog to digital conversion (the LPC810 has no regular ADC capability). Water proofed probes using this sensor exist and I have one on order, but I'm not expecting it to arrive for a few weeks. So I improvised my own water proofed probe.

My first attempt involved a small section of PVC tubing. I injected silicon bathroom sealant into about 5cm (2 inch) of tube and then shoved in the sensor soldered to a 1 meter length of cabling. It's important that all the exposed metal is enclosed in the sealant. Failure to do so will result in the rapid corrosion of the sensors leads due to electro-chemical effects and a failure of the sensor in a matter of hours.

The water proofing worked, but the performance was terrible. Its performance was measured by allowing the sensor to cool to room temperature and then dunking it in hot water. The resulting exponential curve as a result of the step function of being dropped into water reveals the sensors 'time constant'. Using curve fitting this was found to be 67 seconds.

My second attempt at making a water proof DS18B20 involved soldering it to 3 wires of ribbon cable, then dunking that into a tube of silicone sealant so that the sensor and the exposed metal was well covered. I cut of the sealant at the very top of the sensor so that the top of the DS18B20 package was exposed directly to water. This worked much better with step time constant of just 13 seconds.

User interface

I was very limited in what I can do for the user interface (UI)  because the LPC800 Mini Kit has just one user LED (blue) and two microswitch. One switch I need for reset,  so that leaves just one switch and LED available. I could of course add extra hardware communicating SPI or I2C, but for this challenge I wanted to restrict myself to only the hardware available on the LPC800 Mini Kit. Also with just 4kBytes of program memory, there is little space to implement a complicated UI.

My temperature range of interest is from 55°C to 60°C for cooking beef steak. So I took advantage of that narrow range in the UI design. The operation is actually quite simple: After reset the user presses the switch marked "ISP" once for each degree over 54°C. So, for example, for a set temperature of 57°C three button presses are required. After a brief pause the LED will blink back the selection.

At any time during normal operation the user can query the temperature of the water by pressing the ISP button. The temperature will be read back by blinking the LED. There will be two sets of blinks with a pause between them. The first set reads out the temperature and the second set the units. So 54°C will be 5 blinks, pause, then 4 blinks. A zero digit is represented by one very short blink.

Temperature Logging

Debugging information and temperature logging data is sent using the LPC810's built in UART (serial port). An optional connected computer can then be used to chart the data in real time. The serial port is also used to re-flash the firmware. Temperature can be charted using gnuplot using a simple script like this: [insert]

Temperature Control Algorithm

This is still a work in progress. PID (proportional, integral, differential) control is usually used in these applications. However I found that it was difficult to avoid an initial overshoot. So I started to experiment with a two-phase approach. The first phase is the warm up: a test heating with the element on for 90 seconds and measuring the temperature change as result of this. The remaining time can then be calculated to bring the water right up to temperature. The second phase hands over control to a PID algorithm.

An interesting limitation of the Cortex M0 / M0+ MCUs is the lack of hardware floating point support. With just 4kBytes of program memory linking in float point library is not an option.  So I've used fixed point to implement the control algorithm.

The firmware

I'm using LPCXpresso, although the code can also be compiled with the GCC ARM compiler for bare metal systems. The firmware is open source and is available here: It compiles to about 4kBytes, unfortunately leaving very little room for enhancement.

Power requirements

So far I've been using the serial cable linking it to the laptop to power the controller. However this could easily work off a battery.  The ARM Cortext M0+ is designed for super low power applications and in this application the unit spends much of it's time idle. The UI requires practically no power at all (the odd LED blink).  In the program space available I've attempted to apply simple measures to reduce power consumption. For example all timing, delays etc is accomplished with the SysTick timer and anytime the program needs to wait for an event I invoke the WFI (wait for interrupt) instruction. I am not using deep sleep / power down modes at this time.


The LPC800 Mini Kit makes a successful sous vide cooker controller. The user interface is basic but is simple to use and understand. There is just enough program space and plenty of SRAM to implement the UI, control loop and serial port logging.

Project risk assessment and disclaimer

There are two risks to be aware of if attempting a similar project: first there is a potential shock hazard in designing a switching unit to control the heating element. The second is a food safety: cooking meats at too low temperature (<50°C) will result in bacteria growth and can cause food poisoning. There are many of sources of information on sous vide cooking on the internet so do your research! I would recommend validating the set temperature with a second thermometer until the firmware has proved reliable. If you undertake this project, I take no responsibility for your actions.

No comments: