Warning: mysql_query(): Unable to save result set in /home/efkids/public_html/cake/libs/model/datasources/dbo/dbo_mysql.php on line 411

Warning: Cannot modify header information - headers already sent by (output started at /home/efkids/public_html/cake/libs/model/datasources/dbo/dbo_mysql.php:411) in /home/efkids/public_html/app/controllers/projects_controller.php on line 163

Warning: Cannot modify header information - headers already sent by (output started at /home/efkids/public_html/cake/libs/model/datasources/dbo/dbo_mysql.php:411) in /home/efkids/public_html/app/controllers/projects_controller.php on line 164
EFKids - PIC Basic - Interfacing With Real Time Clock DS1307
Post a Comment
Back to Projects
< PrevNext >
  Welcome Guest !
Learn Basics
Learn About Components

PIC Basic - Interfacing With Real Time Clock DS1307


This project is first part of a series of projects designed to experiment and understand how PIC microcontroller can be effectively used to interface with external circuit and get data from and control external devices.

To see a list of all basic PIC projects planned in this series please click here. To get a basic understanding of PIC microcontrollers and how to use them please click here. This link covers the basic FAQ of PIC for newbies as there is a lot of literature available on the web for advanced users.

In this project we will see how a digital clock can be constructed using a Real Time Clock (RTC) chip (DS1307) and PIC. This chip comes with a very accurate built in clock which is extremely accurate compared to timer (555) based clocks. This also has a built in calendar till 2100 (including leap year compensation). Hence date, month and day can also be displayed accurately.DS1307 also has automatic power-fail detect and switch circuitry and supports back-up power source in case main power supply fails.

DS1307 has only 8 pins and we use only two pins for communicating with it using a protocol called I2C. In essence I2C uses a data and clock line (called BUS) to send data by pulsing the clock line one bit at a time. All components that are connected to the BUS get the data and they can use it or ignore it based on the address data that was send at the beginning of a communication session. There is a lot literature available on the web and you can read more about I2C.

In this project we are using PIC16F72 as this is relatively less expensive and supports more features compared to PIC16F84A (but there is more literature, help and sample projects available for 16F84A). 16F72 also has 2K program memory compared to 1K program memory available for 16F84A. This project requires a larger embedded program as we use I2C and need logic for setting time and date on push button interrupts.

Circuit is relatively simple as shown in the above diagram. I am using an LCD to debug the program. If you don’t want it, you can avoid it. I am using IC 4011 to de-bounce (avoid multiple logic signals going when you press the button once) the push button switches.

Seven segment LEDs are driven using driver IC 4511. This IC supports with a latch (pin 5) when this latch pin is maintained high the data is updated on the driver and subsequently it is brought low and then high. (When latch is high the last data is preserved on the LED display). The data to the LEDs are fed through IC74174 shift register. Each LED driver (4511) expects the display value in 4 bits nibbles, Hence for a 6 digit display we require a register of 24 bits. IC74174 is a six bit register and we need 4 ICs to support 24 bit data.

Below schematic shows the LED display circuitry.

Below circuitry shows shows schematic used for LCD display. This LCD display uses 3 wire configuration to save PIC pins :).

I am not using display multiplexing in this project as it may require more program space on the PIC. With multiplexing we may be able to manage with one driver IC and couple of shift registers. Multiplexing of the display will be demonstrated in another project.

Photograp below shows assebled clock. Components are assembled on seperate boards so that they can be reused in other projects.
Also go through the datasheets for PIC16F72 to get a good understanding of other details of the microcontroller.
The C compiler used for this project is Hi-TECH light
Click to view PIC code
The compiled HEX file. (this can be directly burned into your PIC)
click here

List of parts used in the project
Ref Part type Part Name Value Count Info
 7Seg CC1-6DISPLAYSeven Segment Display 14 mm--6 See Picture
 Bat1BATTERYPACKButton Cell Holder CR20323V1 See Picture
 Bat2BATTERYPACKBattery Pack 12V AA12V1 See Picture
 C2,C3CAPACITORCapacitor 27pF27pF2 See Picture
 C4,C5ELECCAPACITORElectrolytic Capacitor 10uF10uF2 See Picture
 C6,C8ELECCAPACITORElectrolytic Capacitor 220uF220uF2 See Picture
 C7,C1CAPACITORCapacitor 100n100n2 See Picture
 Cr1CRYSTALCrystal 32.768 KHz32.768 Khz1 See Picture
 Cr2CRYSTALCrystal 4.0 MHz4.0MHz1 See Picture
 IC1ICPIC16F7216F72PIC1 See Picture
 IC11-16ICIC 7417474174IC6 See Picture
 IC2ICIC LM78057805IC1 See Picture
 IC3ICIC DS1307DS1307IC1 See Picture
 IC4ICIC 74147414IC1 See Picture
 IC5-10ICIC 45114511IC6 See Picture
 NRPCBPCB Gen Purpose DD 4x34x3inch1 See Picture
 NRHOLDERIC Base 16 Pin16Pin17 See Picture
 POT1POTPot Meter 10K10K1 See Picture
 R1,R2,R5,R8 RESISTORResistor 10K10K4 See Picture
 R3,R6 RESISTORResistor 220Ohm220Ohm2 See Picture
 R4,R7RESISTORResistor 6.8K6.8K2 See Picture
 R9-50RESISTORResistor 470Ohm470Ohm42 See Picture
 S1-2SWITCHMini Push ON--2 See Picture

Approximate cost for building this project is Rs 1354.00

Note: In addition to the above components you may also require a breadboard and power supply / batteries for building this project.

Post a comment or question
Post Type:
Please login to post a comment or question
Click here to login or register
Social Likes
Join EFKids Club

text image
* Enter the text above for captcha
Join EFKids Club to get notified when new projects are added.

Electronics For Kids Copyright 2010 - 18 .   EFKids
About EFKids

Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0