Post a Comment
Back to Projects
< PrevNext >
  Welcome Guest !
Learn Basics
Learn About Components

PIC Basic - Interfacing With Real Time Clock DS1307

  PRO132

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
 LCDDISPLAYLCDLCD 16x2 JHD162AJHD162ALCD1 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:
Comment:
Please login to post a comment or question
Click here to login or register
Posts from the Users
Posted by: Gowtham Kumar
Date: 2017-07-14 09:14:29
Type: Question
Hello Sir, When I Compile this code ,its showing that there is no installed hi tech drivers for pic16f72.Need help to resolve this.
Posted by: Ernest Barnes
Date: 2015-01-12 18:04:46
Type: Comment
Hi If possible can you send me the schematic for this diagram as the pictures you have here is exremely confusing and difficult to make out what is what. my email id is ernsetfbarnes@gmail.com thanking you Ernest
Posted by: Towsif Akhtar
Date: 2014-12-14 13:34:48
Type: Suggestion
dear admin good afternoon. with due respect i would like to inform you that in this pic16F72 schematic diagram you have connected the RTC ds1307 on a wrong pin it should pin 14 or RC3/SCK/SCL and pin 15 or RC4/SDI/SDA. please kindly check your diagram.
Posted by: Gavin Li
Date: 2014-09-13 04:42:29
Type: Comment
VERY GOOD!
Posted by: Mahesh Shetty
Date: 2013-04-02 09:47:11
Type: Question
sir can you please send me the circuit of the programmer that you used to programme the micro-controller in this project to my email. my email id:maheshjshetty@gmail.com
Posted by: Mahesh Shetty
Date: 2013-04-02 09:41:08
Type: Comment
sir please send me the pcb file of this circuit.
Posted by: Elango V
Date: 2012-08-30 00:15:11
Type: Question
sir which program softwear using this project what are the functions is this ,are give me a softwear.elangovsmart@gmail.com
Posted by: Brijesh Dhori
Date: 2012-07-26 17:56:02
Type: Comment
what to do with this programm? How to install it in this circuit? Plz any one help me out.... my id is brijeshdhori007@gmail.com
Posted by: Dinesh Bm
Date: 2012-03-16 09:09:44
Type: Comment
getting one syntax error in the above codes
Posted by: Vinoth Dhanaraj
Date: 2012-02-25 15:16:34
Type: Question
Can i interface the Rtc DS1307 and PIC16F716
Posted by: Amrik Singh
Date: 2011-09-20 22:45:51
Type: Comment
will you please send me your adresse & contact number at my email add- amrik.singh3437@gmail.com phone no-9811403498 THANK YOU
Posted by: Amrik Singh
Date: 2011-09-09 15:09:04
Type: Question
Sir please help me for providing programmed pic 16f72 for rtc clock DS 1307. I programme the ic from market but it did not working. If programmed pic is available please tell me the cost & from where i get it please give me your postal adresse & contact number. Thank You
Posted by: Rana Priya
Date: 2011-07-24 15:20:51
Type: Comment
can u plzzz send me pdf file of this project .i want to work on it
Posted by: Uattend Attend
Date: 2011-07-22 15:13:07
Type: Comment
Really amazing post.I have already did many projects of micro controller.Uattend brings a special sort of amazing product.Time clocks which automatically mark your attendance and time.
Posted by: Anonymous
Date: 2011-03-24 08:48:59
Type: Comment
how much is the cost for this project????
Posted by: Anonymous
Date: 2011-03-24 08:45:58
Type: Comment
like this project a lot like to have the soft copy of it
Posted by: Anonymous
Date: 2011-01-12 00:40:05
Type: Question
how many cost for this project
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 - 17 .   EFKids
About EFKids