Timer are widely used in industrial and domestic application for automating tasks. Microcontrollers can be used to design versatile and accurate timers with ease. Here I present a simple timer that can be used to turn on/off a load after user specified time.
The Timer uses a standard 16×2 lcd module for user interface (UI). User can set the time using a 3 button keypad.
After that Timer is started. While count down is in progress, the time left is displayed on screen.
The program use our LCD driver library more details of which can be found in here. Use avr-gcc + AVR Studio to compile.
The prototype was developed using xBoard MINI, a low cost easy to use ATmega8 development board. The program was burned to the MCU’s flash memory using eXtreme Burner – AVR Software and Hardware. A basic knowledge of working with different tools of AVR development is required, so please refer to following articles.
Note:
- Fuse Must be set as follows, HIGH FUSE=C9 LOW FUSE=FF (Very Important)
- If display is blank please adjust RV1
Part List
|
||
01 | ATmega8-16 PU | U1 |
02 | 16×2 LCD Module | LCD1 |
03 | 16 MHz Crystal | X1 |
04 | BC548 Transistor | Q1 |
05 | 1N4007 Diode | D1 |
06 | 4.7K Resistor | R1,R2 |
07 | 10K Variable Resistor | VR1 |
08 | 22pF Disk Capacitor | c1,c2 |
09 | 0.1uF Disk Capacitor | c3,c4 |
10 | Large Push Buttons | s1,s2,s3 |
11 | PCB Mountable Relay | RL1 |
Schematic (Circuit Diagram)
Program
/******************************************************
A Simple Device Timer project designed using ATmega8
AVR MVU. The Timer is usefully for keeping a device
"ON" for a specific period of time. After the set
time elapse the timer automatically turns the load off.
The Timer uses a standard 16x2 lcd module for user interface
UI. User can set the time using a 3 button keypad.
After that Timer is started. While count down is in
progress, the time left is displayed on screen.
The program use our LCD driver library more details
of which can be found in Web site.
Use avr-gcc + AVR Studio to compile.
******************************************************/
#include <avr/io.h>
#include <avr/interrupt.h>
#include "lcd.h"
//Connection of Load
#define LOAD_DDR DDRC
#define LOAD_PORT PORTC
#define LOAD_POS PC0
//Global variable for the clock system
volatile unsigned int clock_millisecond=0;
volatile char clock_second=0;
volatile char clock_minute=0;
volatile char clock_hour=0;
For more detail: Relay Timer with ATmega8 AVR MCU