Power loss - Brown out?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    8

    Default Power loss - Brown out?

    I have made a clock (using PIC16F870 & DS1302 RTC) which works fine.

    However, when power is lost to the circuit, the clock looses the time and start's up in its 'set the time' routine. Now I have found a way to attach a backup battery to the DS1302, but I do not know how to get the PIC to skip the 'set the time' routine. From what I can gather this can be done with brown out detection. But I don't understand how that works - or how you set a different start point for the program to run (ie not go through the 'set the time' routine when power comes back)

    Any and all help really appreciated!

  2. #2
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    At the start of your code, check to see if PCON.0 = 0. If it does, a brownout has occurred. Set PCON.0 to 1 and jump past the Set Time routine.

    However, PCON.0 must have been previously set to 1 in your code, probably within the Time Set routine.

    Another approach (that I use on the Xicor X1226) is to read the clock on startup. If is a good value, skip the Set Time routine.

    Hope this helps,
    Paul
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

  3. #3
    Join Date
    Apr 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    that seems simple enough! thanks!

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    A coin cell feeding the RTC and a diode between the RTC VDD and the PIC VDD works well.

    For the code jump add a button. At startup if the time needs reset for some reason hold the button.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default safety diode?

    Quote Originally Posted by mackrackit View Post
    A coin cell feeding the RTC and a diode between the RTC VDD and the PIC VDD works well.

    For the code jump add a button. At startup if the time needs reset for some reason hold the button.
    Thanks mackrackit for this advice - I've got the battery working and added a rest button. I've also been looking into the diode you mentioned - it seems that this is actually essential to prevent the accidental charging of the battery, and hence a possible explosion! What diode would I use here how is it connected? I don't understand your comment about connecting it between the two power sources - is it not simply in series between the ds1302 and the battery?

    The data sheet says:
    "UL recognized to ensure against reverse charging current when used in conjunction with a
    lithium battery."

    Does that mean I can trust the d1302 to protect the battery?

    Thanks again,
    O.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I forgot the DS1302 has two supplies.
    I would connect the DS1302 as shown here but use a diode with the battery, and have the trickle charger turned off. I do not have enough experience with the DS1302 to say about trusting it. http://www.maxim-ic.com/images/appno.../3449Fig02.pdf

    A 1N914 woks for the diode.
    Here is what I was getting at when I posted before. The whole system runs on 3.3 volts.
    Name:  1377.jpg
Views: 248
Size:  141.1 KB
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

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