The RTC provides year, month, date, hour, minute and second information. The end date of months is automatically adjusted for months fewer than 31 days including leap year compensation up to year 2100. It can operate either in 24-hour format or 12-hour format with AM/PM indicator.
DS1307 comes with built-in power sensing circuit which senses power failures and automatically switches to back up supply. We can provide a 3V CMOS Battery for that. The DS1307 RTC uses an external 32.768 kHz Crystal Oscillator and it does not requires any external resistors or capacitors to operate.
DS1307 Block Diagram |
In this project, I used ds1307 as real time clock ic and PIC16f88 as micro-controller. To save micro-controller pins there are four input keys which are all connected to a single analogue input pin. This pin also drives one of the seven segment display LEDs so it has to be switched between input (to read the analogue voltage) and output (to drive the led). Each key pulls the analogue input to a different voltage level which you can easily read using the ADC (RA0).
Circuit Diagram |
Set Time
Mode : Pressing mode button cycles the display showing 3 different data.
Mode 1 : Time only
Mode 2 : Seconds only
Mode 3 : Stand-by
Set : To change the value, set button must be pressed.
Set 1 : Edit mode, show Minute
Set 2 : Edit mode, show Hour
Set 3 : Return to clock mode
Up and Down : After Pressing set button, you can change the values indicated on clock by using this buttons.
UP : Values ++
In clock mode it will also change the 12/24Hr format.
Down : Values --
In clock mode it will do nothing.
Clock Accuracy:
The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error will be added by crystal frequency drift caused by temperature shifts. External circuit noise coupled into the oscillator circuit may result in the clock running fast.To ensure the crystal oscillates correctly you must ensure that;
- Crystal uses 12.7pf load capacitance (correct crystal type).
- The crystal is close to the IC.
- The tracks are short.
- The chip supply has lots of decoupling (capacitors from +5V to GND). e.g. A 100n and a 10n
- There are no signal tracks near to the crystal.
- For a PCB: It has a guard ring and a ground plane and away from digital signals.
DS1307 Datasheet
PIC16F88 Datasheet
Pin Connection |
I Used mikroC for compile this project.
Also you can get PCF8583 version from here.