Dual Time Digital Alarm Clock

Here we are introducing a simple project using PIC16F873A/876A. A Dual time Digital clock with alarm. The PIC used is a 28 pin high performance RISC microcontroller from Microchip Inc, and having a 4K/8K byte program memory. It is a flash based and a member of PIC16F87XA family of low cost, CMOS, fully static, 8 bit microcontrollers. It requires less external components thus reducing cost and total power consumption
Features at a glance
  • Dual time (Standard time + another time - GMT)
  • Counts seconds, minutes, hours, day, date, month and year
  • Alarm
  • 12 hour / 24 hour time format
  • Leap year correction valid up to 2100
Working principle
The heart of this circuit is the inbuilt Timer1 module in PIC16F87XA. It is primarily intended for a 32 KHz crystal, and it will continue to run even in SLEEP. This module can be easily used to implement a real-time clock, an inexpensive 32.768 KHz watch crystal and two 33 pf capacitors are used to complete the circuit. The Timer1 is clocked by this crystal oscillator.
Since Timer1 is a 16 bit counter, the 32.768KHz crystal will cause the Timer1 to overflow in every two seconds or 65536 counts, for this reason TMR1 register pair (TMR1H:TMR1L ) is initialized to 0x8000, so that it will overflows in every seconds. The Timer1 overflow generates an interrupts, and in every interrupt the clock will be updated (in SLEEP, this interrupt will wake up the processor).
At power failure, the processor goes to SLEEP, and turn off all displays. In SLEEP it consumes minimum power (20µA approx) so a battery is sufficient. The device will wake-up from the sleep when any key is pressed, and shows time for 10 seconds, and again goes to sleep if no key is pressed. This will help to show time and to set alarm when power is not available.
The processor will find end of every month and also make compensation for leap years, so no further adjustments are required when time is set once.
If the alarm is enabled and current time matches with the alarm time, the alarm will start to function for a minute. Any key press will stop the alarm, but if you not disable it, it will function again in the next time.
Day of week is displayed with 7 LEDs.
This circuit will work in 3V, if PIC16LF873A or PIC16LF876A is used instead of PIC16F873A or PIC16F876A
Operational use
Two keys are provided for various operations of this clock. A brief press of MODE key will changes Standard time -> Alarm time -> Date and Month -> Dual time -> Standard time and so on. Press down this key for one second cause to enter Adjust mode and the right most digit will start to blink. Brief presses of ADJ key increment the blinking digit. Brief press of MODE key change the blinking digit to one left, and finally saves the changes. To set the year press down any key while starting. To enable or disable alarm press down ADJ key for one second. The alarm can function with the back up power if main power is not.
The PCB design shown here can be used or this circuit can be easily assembled with a common PCB. If you are using the PCB design shown here, it may be cut in to two parts and as shown by dotted line in the silkscreen so that the display side can be wired separately. The hex code to program PIC16F873A/876A, Circuit and PCB Design are available at Downloads in this site. I used Multi PIC programmer and IC-Prog to program the microprocessor. You will get further assistance through this site if required. Your suggestions and comments are always welcome and please put on Forums
Clock image 1 Clock Image 2
Click on image to enlarge

Post a Comment

Copyright © Rough Record. Designed by OddThemes