Relay Timer with ATmega8 AVR MCU

Relay Timer Thumb

Timers 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)

Relay Timer Thumb

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=; 
volatile char clock_second=; 
volatile char clock_minute=; 
volatile char clock_hour=;

My Prototype.

I used the xBoard MINI as a base board for making the timer. The external components attached were the LCD and 3 push buttons.

Using the Timer

The user interacts with the timer using 3 push buttons and the LCD module. The function of 3 keys are :-

  1. Select Key – Select Different items like hour,minute and start. It moves the arrow on screen to indicate which option is currently selected.
  2. Up/Increase Key – Increase the value. For example, select “minute” using “select” key and press this to increase its value.
  3. Down/Decrease Key – Same as above but it decreases the value.

Read more: Relay Timer with ATmega8 AVR MCU

 

Leave a Comment

Your email address will not be published. Required fields are marked *