long countdown timer, how to save power?


Closed Thread
Results 1 to 30 of 30

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Try???
    OSCCON = $16

    Section 2.7.1 in the data sheet.
    Yeah, ive already done that. Which makes the PIC run at 128kHz, but the problem is telling PBP this. Usually would be done with DEFINE OSC value, but thats expecting MHz, not kHz.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Kamikaze47,
    I have an idea of unknown value, having not tried it myself yet.
    Open a new page in PBP and write only Define OSC 4, save it and compile, then open the asm file to see what it wrote, print the page, change the define to other numbers and repeat. Do this so you have several copies to compare, and you might get enough information to manually edit your projects asm file, then you could run that through MPASM. Anyway . . . just an idea.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    good idea, i'll give it a try
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    no luck... it seems to just change DEFINE OSC 4 into #DEFINE OSC 4

    lol
    "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
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Just let PB think it is running at 4mhz. Calculate what it is really running at for pauses and such. Just like is you had a 8 and told PB it had a 4. Everything would be twice as fast.
    Dave
    Always wear safety glasses while programming.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Open a new page in PBP and write only Define OSC 4, save it and compile.......................Anyway . . . just an idea.
    Wayyyyyy to many macro's to mess with to get that too work! But, it is an idea...if a guy has that sort of time!
    Power saving...there is an internal 31-ish khz backup to the backup to the backup oscillator (I think, don't have datasheets on hand, not ambitious enough to look them up).
    But it's not accurate enough to keep any time.
    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.

    Internal oscillator does saves power, for comparisons sake, 2x the power.
    Running slowly saves power, say 4x the power.
    Putting it to sleep saves LOADS of power, say 1000x the power when compared to the other methods.
    In the circuit I'm playing with at the house: PIC18F4685 @ 40Mhz (10Mhz external plus 4xPLL) = about 45mA, like the datasheet says. Running it at 8Mhz internal OSC = about 20mA (little high, but close enough to the datasheet), run it on the 31Khz backup oscillator = roughly 5mA with nothing else going on (tight loop only)...
    BUT...put it to sleep and the mA doesn't even read. It bounces back and forth between zero and one mA.
    Last edited by skimask; - 18th June 2008 at 18:03.

  7. #7
    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

  8. #8
    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.

  9. #9
    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 " !!!
    *****************************************

  10. #10
    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

  11. #11
    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

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