Developing a lighting control unit recently, the author found that available analog or mechanical timers were not sufficiently accurate or convenient. Without further ado, he developed a timer switch driven by a small AVR controller of the type ATtiny2313. The device presented here can switch a load on and off with 1-second accuracy for a period ranging from one second to 99:59:59 hours. By using a very compact LCD display (the HMC16223 with dimensions of just 52 mm x 20 mm) it was possible to construct the prototype inside a standard wall outlet box. The ATtiny2313 is timed using a 4.9152 MHz crystal to produce an internal timebase of exactly 1 second. The LCD is driven in 4-bit mode. Data input is by press buttons, making use of the pull-up resistors built into this little controller. The miniature transformer (9 V, 1.5 W) provides electrical isolation between the AC grid and the operating voltage for controller and LCD.
For small switching loads (below 200 W) the power relay can be replaced by an all-electronic solid state relay (e.g. Sharp S202 S02).
AC power line voltage circuits are not for beginners and it’s vital to observe the relevant safety guidelines at all times!
You are recommended to divide the circuit between two separate boards: LCD, microcontroller and press buttons on one and transformer, rectifier and switching relay on the other.
Here’s how you use the timer switch: When the timer is running the preset time period and time remaining are displayed on the readout:
An alternative format can be selected if you wish:
PRESET 1h 10m 8s
COUNT 0h 9m59s
The four function buttons are used as follows:
START: Start timer for the preset period
STOP: Stop timer, select menu for setting values and options
PLUS: Increment the selected value by 1
MINUS: Decrement the selected value by 1
The following values can be set:
Menu 1: SET HOURS 00
Menu 2: SET MINUTES 00
Menu 3: SET SECONDS 00
Menu 4: SET DISPMODE 0
Push buttons PLUS und MINUS alter the selected value and pressing them both simultaneously resets the value to zero.
A programmed controller is available from the Elektor shop under order code 091044- 41 (www.elektor.com/091044). If you enjoy doing the programming yourself, the fuses of the ATtiny2313 should be set as follows:
EXT. byte: 0xFF – (brownout det. off, no CKDIV8)
HIGH byte: 0xDF – (ext. crystal > 3 MHz)
LOW byte: 0xFD – (64ms startup)
As usual, the hex and source code can be downloaded free from the Elektor website (www.elektor.com/091044).