Saturday, November 8, 2014

DS1307 Real Time Seven Segment Alarm Clock Circuit - 16F88

Views:

Update

  • 31/01/2016 - Added hourly chime restriction function

DS1307 Alarm Clock
Alarm Clock

This is the newest clock I made using DS1307 real time clock IC. Not like other clock circuits I posted, this clock circuit built in all necessary function such as hourly chime, alarm, time drift correction, etc. In addition, it also include temperature sensor as optional function.

This clock has eight display modes (including standby mode).
  • Mode 1 – Display Seconds
  • Mode 2 – Display Time
  • Mode 3 – Display Date
  • Mode 4 – Display Year
  • Mode 5 – Display Alarm
  • Mode 6 – Display Temperature
  • Mode 7 – Show Time, Date and Temperature continuously
  • Mode 8 – Stand By Mode

DS1307 Alarm Clock
DS1307 Alarm Clock

This PIC project uses PIC16F88 micro-controller, DS1307 Real Time Clock, LM35 temperature sensor, and SSD-5461AG common cathode seven segment display. (If you cannot find that display then use four common cathode seven segment displays).

The PIC16F88 used its internal oscillator and it runs at 8MHz. We can reduce cost and complexity of circuit and can save micro-controller’s pin by using internal oscillator.RA0 and RA1 configured as digital and analogue alternatively to drive seven segment and read voltage of LM35.

The DS1307 (RTC) Real Time Clock is an 8-pin device using an I2C interface. It has eight read/write registers that store the information. This IC will do the timekeeping and it not only keeps track of time but also the date and the day of the week. DS1307 RTC is fully Binary Coded Decimal (BCD) clock/calendar. Therefore, the data read from DS1307 should be converted to BCD format. The most important is the Clock Halt Bit (CH), which is, bit 7 of address 0. This is the register that controls 'seconds' and the CH bit has to be preserved otherwise the chip stops the clock. Writing zero to this bit resets the CH bit so that the clock runs. So when the first usage we must set ‘seconds’. Otherwise clock fail to run.

DS1307 Alarm Clock circuit
Alarm Clock's Internal

Time Setting

Using MODE button you can change the display mode and the current status will save to Eeprom.
SET button can be used for edit the time, date, alarm etc. When you pressed the SET button, clock entered to the Edit mode and two displays will turn off. You can be able to edit values on other display by pressing UP and DOWN buttons. To edit turn off displays value pressed SET button again. Press the SET button again to return clock to normal mode. If the clock is in normal mode UP button also can used to change the time format (12hr or 24hr) and DOWN button can used to turn on or off alarm.

When time changed to 12hr mode LED will indicate the AM/PM status. Alarm on will indicated by the decimal point of last seven segment display. If you wish, you can also connect separate LED for it.

Error correction

Surprisingly making an accurate 32kHz oscillator is a difficult. This is because low speed oscillator drivers are designed for low power operation. That means high impedance and therefore low current, which makes the driver extremely sensitive to noise (or any nearby signals, which can capacitive couple to the crystal wire). Because that when using DS1307 we cannot get accurate time. Therefore, I added simple error correction mechanism for this clock

First, set the clock to current time (time of computer or internet) and keep it run up-to 24 hours.
After 24 hours, check the time of clock with time of computer. If time is drift, check how many seconds are drifted..?  (Use clock mode 1 to view seconds)

E.g. 1:  PC time:  16:30:00 Clock time:  16:30:05
+5 seconds drifted. So we have to reduce time.

I used Eeprom (2) to store this values and default value is 30 (0x1E).  See the Eeprom figure.
Now simply overwrite it with 25 (0x19). You must use hex values for it.

E.g. 2:  PC time:  16:30:00 Clock time:  16:29:58
-2 seconds drifted. So we have to increase time.
Overwrite Eeprom (2) value with 32 (0x20).

Hourly Chime Restriction

You can able to stop hourly chime function for specific time period using this setting. Device Eeprom address 6 and 7 use for this. default values are 0x00 and 0x18 (0 and 24)

Eeprom(6) ≤ Chime Restriction < Eeprom(7)

Eg: Stop Chime from 21.00 to 6.00
Eeprom(6) = 0x06 and Eeprom(7) = 0x15
6 ≤ Chime Restriction < 21

Eeprom of 16F88
Eeprom of 16F88

Posted By :

Please Note: All contents provided on this blog are for non-commercial purposes only.
Any question..? Feel Free to Ask!

Drop your Comments below. Please report broken links to here
  1. Hi again,
    I made former 16f88 clock and it's great. You are wisdom really! I requested before 7 number "f" digit and you sended me. (a,b,c,+f).
    Also I request you 7 number with "f" digit added if possible. I appreciate you. I hope you've been not exerted by me. Thanks a lot..

    ReplyDelete
    Replies
    1. I remember that :)
      As your request i added it. Please check download section.
      7-(a,b,c,f)

      Delete
  2. You are great guy. Thank you so much. I think it's time to sell those nice projects..For example "DIY KIT" on internet shopping sites..As if I'm going to first buyer..Stay fine..

    ReplyDelete
    Replies
    1. May be in the future, Thank you for your idea.

      Delete
    2. I hope so much. Amateurs like me use this circuits. But you last sended "7-abcf" hex is short and do not show temp. etc. What's the problem? First hex file is 22.9 Kb. "7-abcf" is 19 kb. Also date, sec, etc. not working at all..I'm really confused. I only want to add "f" digit to 7. Already I fashed and disturb you. Thank you again..

      Delete
    3. Sorry. I did not check the hex file. Give me a couple of days. After checking, I will upload hex file again.

      Delete
    4. Of course dude. Already I made you in a trouble. I think there's hourly chime in first program. Thanks a lot again.

      Delete
    5. The hex file has been updated!

      Delete
  3. how to set configuration bit?dont work my circuit...

    ReplyDelete
    Replies
    1. Configuration is not important. run proteus file. you can observe the circuit is working.

      Delete
  4. yes i see proteus file..it working.i am using comon anaode segment and pnp transistor but i think its corect plz hlp me..

    ReplyDelete
    Replies
    1. Use npn transistors such as C945, C1815, BC547

      Delete
  5. Thank you very much indeed. Tomorrow I'm going to write it. You're so kind..

    ReplyDelete
  6. Replies
    1. No you can't, however you can remove the buzzer

      Delete
  7. In the bedroom when sleeping? If remove the buzzer why set for wake? Or hourly awake? But really very nice work. Thanks again..

    ReplyDelete
    Replies
    1. Dude, don't sleep. tomorrow I will add another hex file without hourly chime.

      Delete
    2. I just remember this. you have a option. when you sleeping, keep the clock in standby mode. hourly chime not functioning. :D

      Delete
    3. I was wear mourning! That's great. I assemble the "super" clock but thought this problem. You're right when display turns off chime isn't working. But have look for time it's closed. Big job. Thanks again. You never offend me..:) Best regards..

      Delete
  8. Awaiting your download. I don't sleep. OK..Super dude..:)

    ReplyDelete
    Replies
    1. I added chime restriction function instead of removing it. I think you like it and work for you!

      Delete
    2. What can I say I don't know. I'm so glad, you're so kind. Today is Sunday so tomorrow I'm going to add it. Appreciate you...

      Delete
    3. Besides drift correction is very useful. Formerly I put a trimmer parallel or chasis to 32.768 xtal leg. This one is more stabile..

      Delete
    4. I think circuit is now perfect. Thank you for your feedback

      Delete
  9. I have PICKIT2. I couldn't change eeprom. Either "f". Restricted file doesn't have "f" segment. And which button shall I use for chime to turn it on/off?

    ReplyDelete
    Replies
    1. I didn't use PICKIT2. please try searching on internet about this problem. otherwise you can use software like WinPic800. after editing, save file and re-open using PICKIT2.

      Delete
  10. I'm repairing lcd clocks. Many of their chime indicator like this: Middle dots (88:88) blink(beacon) means chime on. Dots are steady means chime off.

    ReplyDelete
    Replies
    1. Chime functions control by the Eeprom(6) and (7)
      To disable it permanently add Eeprom(6)=0x19 and Eeprom(7)=0x00

      Delete
  11. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Check component connected to RA0, specially R1 and you can hear a beep sound when you press the buttons.

      Delete
  12. yes im hear beep sound..but time not display..i think rtc 1307 crystal not correct..

    ReplyDelete
    Replies
    1. What happen when you press mode button continuously, did you saw 'time, date, alarm, temp' messages. then the problem probably RTC or crystal. also check BAT1

      Delete
  13. "Hello again,
    Everything is perfect but temp. values higher 2-3 degrees. Can we calibrate it? I seperate LM35 correctly."

    Dear serkan, Sorry! I deleted your comment by mistake.
    You can't calibrate it. Due to low memory of ic I divide adc value by 2 instead of 2.048. However I don't think its a big problem. See Proteus file. it work fine and some times only 1 degrees may shift. Try adding small resistor to pin 1. I think that's the only solution.

    ReplyDelete
  14. You're so kind. Your detailed and untired answers are so politeness. Thank you again stay fine..

    ReplyDelete
  15. sir,
    can u send me a c and other code files to my mail,im still learning pic programming. nice project.have a good day...
    kushan.walakulu@gmail.com

    ReplyDelete
  16. I got 2 problems
    1.some times stop clock and its work when i touch the crystal one pin,why is that?
    2. what type of speaker using for this?

    ReplyDelete
    Replies
    1. 1. Try changing crystal and also check soldering
      2. I used 5v buzzer

      Delete
    2. can u published a code change roiling all text like
      "MESAGE"<-TIME<-12.00(DELAY)<-DATE<-12.12.2016<-TEMP<-23.2C<- REPEAT

      Delete
    3. Y U USE TWO JUMPERS IN 17 AND 18 PIN AND WHERE THE "b" connect?

      Delete
    4. Memory not enough for text scrolling. if u like scrolling clock then follow this link.
      http://scopionz.blogspot.com/2015/01/8x32-led-matrix-clock.html

      Delete
    5. Do not worry about jumpers. please check ALM_sch.pdf for schematic

      Delete
  17. Hello Dear Great Effort... Can you upload some Clock Project with DS1307 interfaced with PIC16F84A or PIC16F628A or PIC16F873A etc.
    Another question about this project... Can we skip the LM 35 and Alarm etc in the actual circuit to be economical and simple, and what is the accuracy of this clock???
    Keep smiling

    Rana

    ReplyDelete
    Replies
    1. Yes, you can skip LM35 and alarm without any changing. the accuracy of circuit is depend on the crystal.
      http://scopionz.blogspot.com/search/label/DS1307

      Delete
  18. And whatif i want to use bigger 7 segment displays???

    ReplyDelete
    Replies
    1. Then you have to use transistors to increase the current

      Delete
  19. Sir on off timer setting old help me sir in this project sir

    ReplyDelete

 

on line

Labels

Recent comment

Visitors

Free counters!
Copyright © 2012 - Scorpionz™.,All rights reserved | Powered by Blogger