long countdown timer, how to save power?


Closed Thread
Results 1 to 30 of 30

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Easiest thing in my mind is to get an 8pin RTC, DS1602 type and use that. Then you can put the PIC to sleep and have it wake itself up every roughly XX number of seconds using the WDT timer and the WDT prescaler.
    I think this is absolutely the easiest, perhaps the most accurate way of doing it too, especially since you need the LCD to light up only on manual intervention. I have not used the DS1602, but I have used the Philips PCF 8563, and the current draw is almost immeasurable.

    Regards,

    Anand

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    I do not agree with using an RTC unless your project dictates it. The option of using the WDT(watchdog timer) to wake you from sleep, keep time and sleep again is the best. I use it in my battery powered security system. Use the Prescalar and WDT to decide at what interval you want to wake.

    Of course, you will need to rewrite your code if you have written the timing loops using pause.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Find here an asm example that counts down ( 180 days ! ) ... !

    sooo simple !

    Alain
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jerson View Post
    I do not agree with using an RTC unless your project dictates it. The option of using the WDT(watchdog timer) to wake you from sleep, keep time and sleep again is the best. I use it in my battery powered security system. Use the Prescalar and WDT to decide at what interval you want to wake.

    Of course, you will need to rewrite your code if you have written the timing loops using pause.
    At the moment my code has an interrupt every 1 second using a timer and keeps track that way. I assume that the timer does not continue while in sleep mode, so when you say "wake you from sleep, keep time and sleep again", how does it keep time? Just by adding a constant to a timer every time it wakes up? How accurate would you think that would be over a longer period of time?

    I'm hoping to get an accuracy of +/- 1 min in 30 days.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The Timer1 oscillator will continue running while the chip is in sleep mode.
    With a 32768hz crystal, you'll get an interrupt every 2 seconds. (More accurate than the main crystal)

    When the PIC wakes up (at the normal OSC speed), you simply update the time then go back to sleep. Batterys will last months.

    You don't actually need to use interrupts. If the GIE bit is clear, it will just resume where it left off, so it never leaves the main loop.

    DT

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The Timer1 oscillator will continue running while the chip is in sleep mode.
    With a 32768hz crystal, you'll get an interrupt every 2 seconds. (More accurate than the main crystal)

    When the PIC wakes up (at the normal OSC speed), you simply update the time then go back to sleep. Batterys will last months.

    You don't actually need to use interrupts. If the GIE bit is clear, it will just resume where it left off, so it never leaves the main loop.

    DT
    How would you keep track of the time without using interrupts?

    This is the way I was thinking:

    Timer1 with 32.768kHz OSC who's interrupt routine increments the time variables.

    main:
    [ code to check time variables, update LCD, etc ]
    NAP
    goto main

    And have the WDT off so that it only wakes up when the Timer 1 interrupt triggers.

    Does that sounds like it should work?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    Does that sounds like it should work?
    Yep, that's one good reason why Timer1 works the way it does.
    There's a good explanation on DS39605F-page 107 of the datasheet along with some assembly code on how it all works.

    EDIT: adding a thought... I don't know what would take more power to run and/or be more accurate (a trade off here)...
    A self powered RTC with it's own internal clock that you read once in a great while with a PIC that's sleeping most of the time......OR.....
    A PIC that's woken up X times per second (or less) to update a number internally and put back to sleep...
    Last edited by skimask; - 26th June 2008 at 17:40.

  8. #8
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Any idea what Darrel was talking about when he was saying it could be done without using an interrupt?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. Replies: 5
    Last Post: - 24th February 2009, 18:55
  4. dual 7-segment countdown timer code
    By dr.ragh in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 30th April 2007, 13:19
  5. Long Timer
    By Tissy in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 1st November 2005, 17:24

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