Wednesday, 21 May 2014

Relay timer controller for 240v main with a PIC, max7219 and 4-way 7 segment display

This is a simple timer/relay controller; it's for our UV exposure unit, but could easily be used as a countdown timer to switch any 240v mains load (up to 5A or 10A depending on the type of relay used).

The idea behind it is pretty simple - the interface consists of four buttons and a 4-way 7-segment display. Two of the buttons are for minutes and seconds, the other two buttons are for up/down (plus/minus). Hold down the appropriate minute or hour button, and press the plus/minus buttons to increase/decrease the amount of time on the display.

While the display is showing a time, the relay is activated and the 240v mains load is switched on. Every second, the time decreases. When the time reads zero, the relay is released, and the 240v load is switched off.

We did consider having a large "go" button but eventually decided it was unnecessary. As long as the time on the display is above zero, the relay will activate and switch on the mains 240v load. So as soon as you start to enter a time, the relay will switch on our UV lamps, for example. As soon as you release both the hours and minutes button for more than one second (to indicate that the time has been set) the countdown timer begins.

While this does mean that the timer is on for maybe a few seconds more than actually shown on the screen (if you spend 5 seconds setting the time to 2min 30sec, for example, the unit is actually activated for 2m 35 seconds) it also means we have an important fail-safe for our UV exposure box - namely that we can't end up with a scenario where the UV lamps are switched on and the countdown timer is not running (which could, potentially, lead to massive over-exposure of our UV sensitive paints).

We're quite happy - for this project at least - to compromise a little accuracy for ease-of-use and to simplify the hardware design slightly.