My wife and I have a heating pad on our bed. In the winter, we turn it on an hour before we go to bed. When we get into bed, we leave it on until we warm up. But if we fall asleep before we turn it down, we’ll wake up a couple of hours later, overheated. Clearly, we need a technological solution.
A simple store-bought timer that turns the heating pad off would not do. (A heating pad goes under the fitted sheet, as opposed to an electric blanket which goes on top of the bed.) On cold nights, we don’t want to turn it off; we just want to turn it down. The pad has five levels, and my wife likes to turn it down to level one or two. I usually turn my side down to zero or 1.
The heating pad controller has two buttons, Up and Down, and five LEDs that indicate the heating level. Inside, it has a Zilog Z8 microcontroller that turns a triac on and off to regulate the 120V power to the heating coils. The Z8 and the LEDs get 4.7V from a transformerless power supply.
My idea was to build a timer using another microcontroller, a two-digit LED display, and two buttons. The user would set a level, e.g. 2, and a time, e.g. 60 minutes. After 60 minutes, my microcontroller would simulate five presses of the Down button, to ensure the heating pad was at a known setting (off), then simulate 2 presses of the Up button.
The circuit is almost trivial: a microcontroller, a two-digit LED display, two buttons, and two wires going to the heating pad controller’s buttons. I didn’t even use a crystal oscillator; the internal oscillator is accurate enough for running the timer in an application such as this.
So it all seemed pretty simple, but power turned out to be the big problem. It’s ironic that a heating pad rated for 70W would break due to my timer, which used 1/1000th as much power. But I was tapping the Z8′s 4.7V supply and when my LED display came on, the Z8 crashed. Even with my display off, the heating pad controller’s LEDs flickered badly. Apparently, the controller’s transformerless power supply couldn’t provide much spare current.
The crash was easy to fix: I increased the current-limiting resistors on my display. This cut my load from 15mA down to 7mA, with a negligible decrease in the display’s brightness. But the heating pad’s LEDs were still flickering. I needed to reduce power consumption further. I replaced the heating pad’s current-limiting resistor too, making its LEDs a little dimmer but saving 2mA. I slowed down my microcontroller from a ridiculous 8MHz to 2MHz – the minimum I needed to refresh the LED display and avoid flicker. I disabled the microcontroller’s unused peripherals. My timer was down to 4.5mA.
Everything seemed to work, except that I noticed that the heating pad didn’t get as warm when my timer was plugged into the controller. My guess was that I was decreasing the current to the triac’s gate. I changed my code to put the microcontroller into sleep mode when possible. That fixed it.
After I built this, my wife came up with another idea of how to use it. (This illustrates the importance of getting end-user feedback.) Instead of turning the heat down in the middle of the night, use the timer to turn the heat on in the evening. So if my wife and I are going to be out from, say, 5 PM to 11 PM, we set the timer to turn the heating pad to level 5 after 4 hours. By the time we get home, the bed is all warmed up for us. I had to modify the code to allow this: when I thought we were only going to use this for turning the heating pad down at night, I implemented a maximum time of 90 minutes. Now, I needed to go up to 9 hours, and display that on a two-digit display. So for any time more than 90 minutes, it displays 2H, 3H, 4H, etc. And while pressing the button originally incremented the time by 10 minutes, once it gets past 90 minutes, the time now increments by an hour for each button press.