Real time clock ICs


Closed Thread
Results 1 to 40 of 67

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Eng4444,

    Just got home from work and see that you are still having a problem. Just a quick question. Is the ability to set the time with the 3 push buttons really critical for you to show what you have done? If not then you could go to the part of the code that starts with "SETUP PRESET:" and enter the starting time and date manually. I will look over the code here this evening and get back to you on that.

    Adding the capacitors (.1uF) has nothing to do with this problem. They are part of good design practice.

    Just so I understand what has happened: You programmed the micro and the system started running and time and date was being displayed. You went into the set time and date mode and it accepted your time and date changes. Then you pressed the button to send you changes to the RTC and that's when it froze.

    I will look for that part of the code you sent me and compare it with Melanie's posted code. Just out of curiosity, did you copy and paste her code or did you retype the whole thing?

    Let me know. Thanks!

    BobK

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    HI Eng4444,

    The program listing that you sent me has the following last line:

    LCDOut $FE,1,"Memorised"

    Do you have anything after that? There's more to it like the part that writes the new values to the RTC. I got the following from Melanie's code:

    ' Make the User feel happy
    ' Save 12/24 Hours to BCD DS1307's Format
    ' ---------------------------------------
    CounterA=SetHour
    If SetTime=1 then
    If CounterA>12 then CounterA=CounterA-12
    If CounterA=0 then CounterA=12
    endif
    Gosub ConvertBCD
    RTCHour=CounterB

    ' Save the Hours Value

    If SetTime=1 then
    RTCHour.6=1
    ' Save the 12 Hour Mode Flag
    If SetHour=>12 then RTCHour.5=1
    ' Save the 'PM' Flag
    endif
    '
    ' Save Minutes
    ' ------------
    CounterA=SetMin
    Gosub ConvertBCD
    RTCMin=CounterB
    '
    ' Save Seconds
    ' ------------
    CounterA=SetSec
    Gosub ConvertBCD
    RTCSec=CounterB
    '
    ' Save Year
    ' ---------
    CounterA=SetYear
    Gosub ConvertBCD
    RTCYear=CounterB
    '
    ' Save Month
    ' ----------
    CounterA=SetMonth
    Gosub ConvertBCD
    RTCMonth=CounterB
    '
    ' Save Day
    ' --------
    CounterA=SetDay
    Gosub ConvertBCD
    RTCDay=CounterB
    '
    ' Calculate Day of Week & Save
    ' ----------------------------
    ' Melanie's fudge for calculating Days of Week
    ' using PBP's integer math...
    ' by the time someone's clock displays the
    ' the wrong Day of Week, I'll hopefully have long
    ' retired and be past caring...
    ' I wouldn't however go stick this routine in a
    ' Nuclear Power Station to purge the reactor
    ' every Monday morning without checking how far it
    ' will work before the integer math overflows...
    ' In my routine RTCWDay=1 is a Tuesday (the
    ' start of my week) and continues sequentially
    ' until RTCWDay=7 which is a Monday
    CounterA=SetYear+4
    CounterB=SetMonth
    If SetMonth<3 then
    CounterA=CounterA-1
    CounterB=CounterB+12
    endif
    CounterD=(SetDay+(153*CounterB-457)/5+365*CounterA+CounterA/4-CounterA/100+CounterA/400+2) MOD 7
    RTCWDay=CounterD+1
    '
    ' Do the Business
    ' ---------------
    I2CWrite SDApin,SCLpin,$D0,$00,RTCSec,RTCMin,RTCHour,RTCWDa y,RTCDay,RTCMonth,RTCYear,RTCCtrl]
    Pause 1000
    Gosub SetButtonRelease
    Goto ReDisplay
    endif
    Gosub SetButtonRelease
    Goto SetupLoop ' Loop for Next Menu Item
    endif
    '
    ' Menu TimeOut Counter
    ' --------------------
    Pause 1 ' Kill 1mS
    TimeOut=TimeOut+1
    If TimeOut>20000 then goto ReDisplay
    ' User paused too long
    ' Return User to Time & Date Display
    ' This will however bounce the User to the original
    ' Setup Menu start point if the DS1307 has not
    ' been initialised
    Goto SetupEntryLoop ' Loop for Button Press
    '
    End


    Check this out> It could be why you're not working.

    BobK

  3. #3
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Lightbulb Dear BobK,

    i re-donloaded the program but everything is still freezing.

    Time is not advancing (i mean being incremented).


    Melanie didn't answer yet so i think she might have a good answer...


    Today is my Presentation! :-)

  4. #4
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Arrow copy/paste.

    Quote Originally Posted by BobK
    Hi Eng4444,

    did you copy and paste her code or did you retype the whole thing?

    BobK
    i just copied and paste... why to type it again...?

    i wish it will work!

    It's so strange!

    i changed DS1307, PIC 16F628A, cristal 32,768...i changed them all to newer parts.. and then i re-downloaded the program..

    but there is something strange happening.

  5. #5
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Default i asked a professor

    He said that i should keep on clearing the PIC in order to make time advance...

    i dunno what does this mean but there is no "CLEAR" port on the 16f628A datasheet......

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I will check later in the day when I have a few minutes spare... some of us have more important commitments and have to work for a living too...

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I have downloaded the MN1307 program from the MeLabs website.

    I have breadboarded the hardware and wired it per instructions with the exception that I've wired the LCD using DB4 thru 7 rather than DB0 thru 3.

    I have run the program.

    I have verified that it works as advertised.

    I have posted proof here that it works. I have an MPEG video of it ticking away... you want me to email that you?

    I don't post programs that don't work.

    Now your problem...

    It doesn't tick, then the software is just a simple loop that reads the RTC and displays the results on the LCD... this means your RTC isn't working. Also, if on initial first-time power-up it doesn't immediately jump into set-up, then that tells me the RTC isn't communicating with the PIC.

    so...

    1. Verify that SCL and SDA are wired correctly and you haven't swapped them over and you've not got any shorts.

    2. Make sure you have pull-up Resistors on those pins. 10K will work, 4K7 with hindsight is probably better.

    3. Make sure you have a Battery Connected.

    4. If you haven't got a Battery, then connect the Battery pin to Vss.

    5. Make sure your 32kHz Crystal is connected - and it's a good one. Steal one from your average genuine 99-cent Rolex wristwatch if you have any problems.

    6. Ensure you have a good RTC chip.

    If it still doesn't work, go back to step 1 and start over.

    ...i'll pass a whooooooole month in the Carribean!
    Hurry back, because we're all going to miss you when you're gone...
    Attached Images Attached Images  

  8. #8
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Talking Dear Melanie

    Quote Originally Posted by Melanie
    Hurry back, because we're all going to miss you when you're gone...
    __________________________________________________ ______________

    You know?

    i always have found your replies cool. You seem too much easy going and from the calm type.This is wonderful!

    till now, i'm still thinking about that 99 cents watch! From where do you bring all those stupid jokes?

    Keep on the good job!

    Here we reached more than 1000 people who checked this thread! is it enough or we make them 2000?

    Best regards.... ;-)

  9. #9
    Early1's Avatar
    Early1 Guest


    Did you find this post helpful? Yes | No

    Smile

    Thirty years ago when I was in the same position as Eng444, at University working on projects for my Bsc in Civil Engineering, I used a stop watch.

    A mechanical one at that.

    I am realy intrigued as to why any one has gone to so much trouble to re invent the wheel, or egg timer in this case.

    I work in instrumentation and RTC are used extensively because we need to log data with a time and date stamp, and if I was going to build a data logger then I would use a RTC, but then I would not build one because I can buy a very good tested and reliable datalogger for £240.

    Puzzled

    Steve

Similar Threads

  1. real time clock
    By maria in forum Code Examples
    Replies: 44
    Last Post: - 1st March 2022, 12:13
  2. Real Time Clock
    By in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd June 2012, 04:52
  3. real time clock - PCF8583
    By maria in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th April 2010, 15:41
  4. Real Time Clock
    By savnik in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th December 2006, 02:02
  5. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts