- 31/01/2016 - Added: Hourly chime restriction function
- 27/10/2019 - Fixed: Hourly chime delay error (v3)
- 27/10/2019 - Fixed: Auto mode data showing time increased (v3)
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 |
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.
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 clockFirst, 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 |
Hi again,
ReplyDeleteI 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..
I remember that :)
DeleteAs your request i added it. Please check download section.
7-(a,b,c,f)
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..
ReplyDeleteMay be in the future, Thank you for your idea.
DeleteI 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..
DeleteSorry. I did not check the hex file. Give me a couple of days. After checking, I will upload hex file again.
DeleteOf course dude. Already I made you in a trouble. I think there's hourly chime in first program. Thanks a lot again.
DeleteThe hex file has been updated!
Deletehow to set configuration bit?dont work my circuit...
ReplyDeleteConfiguration is not important. run proteus file. you can observe the circuit is working.
Deleteyes i see proteus file..it working.i am using comon anaode segment and pnp transistor but i think its corect plz hlp me..
ReplyDeleteUse npn transistors such as C945, C1815, BC547
DeleteThank you very much indeed. Tomorrow I'm going to write it. You're so kind..
ReplyDeleteCan I cancel hourly chime?
ReplyDeleteNo you can't, however you can remove the buzzer
DeleteIn the bedroom when sleeping? If remove the buzzer why set for wake? Or hourly awake? But really very nice work. Thanks again..
ReplyDeleteDude, don't sleep. tomorrow I will add another hex file without hourly chime.
DeleteI just remember this. you have a option. when you sleeping, keep the clock in standby mode. hourly chime not functioning. :D
DeleteI 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..
DeleteThere are nothing perfect
DeleteAwaiting your download. I don't sleep. OK..Super dude..:)
ReplyDeleteI added chime restriction function instead of removing it. I think you like it and work for you!
DeleteWhat 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...
DeleteBesides drift correction is very useful. Formerly I put a trimmer parallel or chasis to 32.768 xtal leg. This one is more stabile..
DeleteI think circuit is now perfect. Thank you for your feedback
DeleteI 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?
ReplyDeleteI 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.
DeleteI'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.
ReplyDeleteChime functions control by the Eeprom(6) and (7)
DeleteTo disable it permanently add Eeprom(6)=0x19 and Eeprom(7)=0x00
OK. I solved it. Thanks to you..
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteCheck component connected to RA0, specially R1 and you can hear a beep sound when you press the buttons.
Deleteyes im hear beep sound..but time not display..i think rtc 1307 crystal not correct..
ReplyDeleteWhat 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"Hello again,
ReplyDeleteEverything 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.
You're so kind. Your detailed and untired answers are so politeness. Thank you again stay fine..
ReplyDeletesir,
ReplyDeletecan 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
I got 2 problems
ReplyDelete1.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?
1. Try changing crystal and also check soldering
Delete2. I used 5v buzzer
can u published a code change roiling all text like
Delete"MESAGE"<-TIME<-12.00(DELAY)<-DATE<-12.12.2016<-TEMP<-23.2C<- REPEAT
Y U USE TWO JUMPERS IN 17 AND 18 PIN AND WHERE THE "b" connect?
DeleteMemory not enough for text scrolling. if u like scrolling clock then follow this link.
Deletehttp://scopionz.blogspot.com/2015/01/8x32-led-matrix-clock.html
Do not worry about jumpers. please check ALM_sch.pdf for schematic
DeleteHello Dear Great Effort... Can you upload some Clock Project with DS1307 interfaced with PIC16F84A or PIC16F628A or PIC16F873A etc.
ReplyDeleteAnother 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
Yes, you can skip LM35 and alarm without any changing. the accuracy of circuit is depend on the crystal.
Deletehttp://scopionz.blogspot.com/search/label/DS1307
And whatif i want to use bigger 7 segment displays???
ReplyDeleteThen you have to use transistors to increase the current
DeleteSir on off timer setting old help me sir in this project sir
ReplyDeleteDid you mean Alarm?
ReplyDeletepls can you send the c code for-kushan.walakulu@gmail.com
ReplyDeletei want to made blue common anode clock what i change pls send me a sch
ReplyDeletehttp://scopionz.blogspot.com/2012/08/pic16f88-digital-clock.html
DeletePl. Send c codes of this rtc
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteSir please add component side to zip or to my mail , it will help more convenient to assemble the PCB.And if possible please send me the C code for the same.
ReplyDeletemy e-mail is : parmar_latesh@yahoo.com
Already added. Please check download section
DeleteGreat project!! You should build with dfpayer as a Talking clock if possible
ReplyDeleteThank you for your idea. I will try it
Deletepls can you send the c code for princyceleste15@gmail.com
ReplyDelete