Ds1307 based digital clock

Status
Not open for further replies.
No, I will use 4 buttons, 1. Set 2. Inc 3. Dec 4. OK

Set will position the cursor on dd mm yy hh mm ss and cycles from dd to ss
Inc and Dec will increment or decrement the values
OK will accept the changes and starts the clock from new settings.
 
Last edited:

No, I will use 4 buttons, 1. Set 2. Inc 3. Dec 4. OK

Set will position the cursor on dd mm yy hh mm ss and cycles from dd to ss
Inc and Dec will increment of decrement the values
OK will accept the changes and starts the clock from new settings.


that will be fab..thanks
 

Check these links http://www.mikroe.com/forum/viewtopic.php?t=15813
http://www.mikroe.com/forum/viewtopic.php?p=84795

Finally, what PIC are you using for your project. I want to know because I have to set ADCON1 register.

Your project is almost complete, but the inc and dec is not happening as expected. maybe it is using hex values

I attach the files.

press set button to enter time setting mode, then pressing set button successively will cycle through week_day, day, month, year, hour, min, sec.

which parameter is chosen that parameter can be incremented or decremented in their own ranges using inc and dec buttons.

after settings has been done press OK button to enter normal time displaying mode.

I will try to implement alarm after this inc and dec problem gets solved.
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v2.rar
    18.5 KB · Views: 90
Last edited:




i am using PIC16F877/PIC16F877A

- - - Updated - - -


please send circuit diagram, i have proteus 6.9 and your simulation is not runing,i will make circuit on my own version
 

Check the simulation attached in my last post.

I2Cx_Wr() takes hex values as argument. The problem is my counters use decimal values. I think that is causing the problem.
 

Attachments

  • ds1307 v2.jpg
    276.3 KB · Views: 99

Check the simulation attached in my last post.

I2Cx_Wr() takes hex values as argument. The problem is my counters use decimal values. I think that is causing the problem.

SET is working, + button increments day/month/hour , - button decrements day/month/hour and OK starts timer again from 00 seconds,, but they need to be pressed for long time, may be 0.5 or 1 second,, but cursor doesn't blink at setting position and hours incremnt to 17PM and decrement to 45AM
 
Last edited:

I have attached the Schematic. What happened to Proteus I sent. Why are you not using it?

Can you send me the decimal value 0 to 89 and its equivalent hex value. I have to finish your project.

I checked that ds1307 gives decimal values from 0 to 99. 0x63 = d99, d153 = 0x99 for year 2099.

so please send me the decimal values 0 - 255 and its equivalent hex values.
 
Last edited:




here is the link for hex to dec conversion table,

https://ascii.cl/conversion.htm

i will use your proteus for next projects,, i am not using it yet so that i don't face any problem that can delay my project,, sorry if you mind
 

Please check the simulation and tell me if it is OK. earlier I thought about setting time from current time, ie., if you enter set mode it will be showing the time it was showing before entering the set mode. I got some problems with that, so I made such that all values will be 00 when set mode is selected.

I have programmed the inc, set, and ok buttons. I still have to code the dec button. please check it anf tell me if it is ok.
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v4.rar
    18.9 KB · Views: 85


(1) there is a problem with AM/PM and hour when they are set,, when hours are incremented they go upto 45 also AM changes to PM when 12 changes to 13,,,
(2) if hour is once decremented below 00 (e.g from 45 to 44/43/42 etc)and then incremented it suddenly goes to 00,,,
(3) if SET is pressed for a long time cursor goes next more than one times(e.g from dd to mm and then yy)
 

Maybe it is because of your Proteus. I don't see any problem here. It is working properly. Tomorrow I will post a video of that.

Check this simulation. I have done dec for day and month. I still have to do dec code for year, hour, min.

Seconds cannot be set, because there is no option to write seconds to ds1307 using I2cx_Wr() function. So you can only set weekday, day, month, year, hour, and minute.

Try to use proteus I sent. It works properly.
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v5.rar
    19 KB · Views: 81



ok i will,, thanks a lot dear for the help you have done and for next work on this project,,
 

OK. It is almost finished. I have done dec coding for weekday, day, month, hour, minute. Only the year has to be coded. Please install Proteus 7.10 and check the simulation. I have compiled the code for 8 MHz. I think if you compile for other clock frequencies you may need to change the debounce delay.

-------------------Update----------------------

It is finished. I have not used blinking cursor. I will try to implement it tomorrow. If possible I will also implement the alarm.
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v6.rar
    19.1 KB · Views: 83
  • PIC16F877A DS1307 RTC Hafiz Imran v7.rar
    19.3 KB · Views: 70
Last edited:


i have installed proteus 7.10 its working well,, thanks a lot for that,, sorry to say but still there is a problem in hour,, some times it goes to 10PM after 15PM,,,,, it means that there is also a problem with AM/PM,,, thanks a lot for all that,
 

explain when actually the problem occurs. can you zip and post your .dsn file?

Yes, there is a problem in hour maybe in others also. I saw that after 10 it goes to 15 in hour. I will try to fix it.

I have fixed the hour problem. Maybe the same problem exist in other parameters also. I have found the method to fix such problems.

Inc the hour at least 2/3 times i.e. from 00 to 23 and again 00 to 23 and tell me if it is working properly.

Do the same thing, inc all the parameters to max and cycle it 2 or 3 times and see when they give wrong values in the 2nd or 3rd round of incrementing.

I will fix them tomorrow.

I think the problem is also in min and year. please inc it 2/3 rounds and tell if if there is problem. I think the first round it increments properly after that in each round it increments to wrong values at some values.

I have tried to fix the error in year and minutes. See if the inc works properly for all parameters. It was a flag problem
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v8.rar
    19.4 KB · Views: 73
  • PIC16F877A DS1307 RTC Hafiz Imran v9.rar
    19.4 KB · Views: 70
Last edited:

explain when actually the problem occurs. can you zip and post your .dsn file?

Yes, there is a problem in horm maybe in others also. I saw that after 10 it goes to 15 in hour. I will try to fix it.

yes there is a problem in hours ,,, the same problem as you just told,,, another error is that if you are using 24hour format then there should be no AM/PM and if you are using 12hour format then AM should change to PM after 12
 

I tried many ways to use the 12 hour format, but couldn't get it. I don't know what value to be written to hour register to make it work in 12 hour format. Anyway I have tried to fix the inc problem in all the parameters. Check it and tell me if it is working properly. I have attached the files in my last post. after that check with dec also. If you mention the problems I will fix it tomorrow.

I can remove the AM/PM if you don't want it in 24 hr format, but I can't code the 12 hr format. If you have any example code of setting rtc to 12 hr format, send it to me.

Try this simulation. I have tried to fix the inc and dec errors. try to inc and dec each value to max and cycle it 2/3 rounds and tell me if there is problem with any parameter.
 

Attachments

  • PIC16F877A DS1307 RTC Hafiz Imran v10.rar
    19.4 KB · Views: 66
Last edited:


yes it will be better to remove AM/PM and change it to 24hour format ,, the only problem is with hour valu,,, that goes to 10 after 15.
 

Check the simulation in my last post. see if the errors are fixed. Read my last post it is updated.

There is one more problem. If you increment to values 16+, 32+, 48+, 63+ and decrement it it decrements a value of 6. It is happening because of decimal to hex conversion. i will fix it tomorrow.
 
Last edited:




yes you are right,, 1st cycle of hour is fine,, in next cycles it goes to 10 after 15,,
another error i just noted is that after 23:59:59 time goes to 00:00:00 but day(sat/sunday/mon...) does not change to the next,, i.e 'fri' does not change to 'sat' and so on.......

AM/PM should also be removed in 24 hour format
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…