Shop OBEX P1 Docs P2 Docs Learn Events
SLEEP - longer sleep periods — Parallax Forums

SLEEP - longer sleep periods

John KauffmanJohn Kauffman Posts: 653
edited 2007-10-09 07:28 in General Discussion
SX/B SLEEP – longer sleep periods
·
I’d like advice on how to get SLEEP times on the order of
  • 10 seconds
  • 1 minute
  • 10 minutes
  • 1 hour
I’m running a data-collection application on very low power so I want to sleep between samples. Various projects have samples rates are as listed above. From reading Gunther & SX/B Help it seems that the max built-in time for a wake-up is the watchdog timer set for PS2…0 = 111 for 2.3 seconds. I’d like to keep the SX in sleep mode for much longer.
·
Here are my thoughts so far:
  • External capacitor/resistor circuit that triggers a B pin for wakeup. Cheap and easy, but probably not very consistent times
  • External 555 & its cap+resistor that triggers a B pin. Less fluctuation then just cap. Price still good. But 555 will draw power all the time.
  • External real time chip (DS1302). Wake up SX every 2.3 seconds and compare last data collection time with current time. Expensive, but DS1302 may be on board anyhow for time stamp of data.
  • There is a chip similar to DS1302 that has an alarm feature that could trigger a RB pin (DS1306). Again, probably only useful if project includes this chip anyway for time stamping data.
  • Wake the SX every 2.3 seconds and keep a variable to count the number of wakes, then after x number of wakes collect data. A byte variable would get me up to 256*2.3 secs = about ten minutes (two bytes to get to 40 hours). This is an all software solution, but it seems a waste to use the current to wake up every 2.3 seconds for a few cycles just to increment the variable. Perhaps this uses less current then running any of the external solutions above.
  • Combos. If want sample every 250 seconds, then do the wake every 2.3 sec and increment the variable, then after 100 increments, start checking the DS1302 on each wake and trigger the data collectin based on reading the DS1302 data.
·Any thoughts?

Comments

  • BeanBean Posts: 8,129
    edited 2007-10-08 15:30
    John Kauffman said...
    Wake the SX every 2.3 seconds and keep a variable to count the number of wakes, then after x number of wakes collect data. A byte variable would get me up to 256*2.3 secs = about ten minutes (two bytes to get to 40 hours). This is an all software solution, but it seems a waste to use the current to wake up every 2.3 seconds for a few cycles just to increment the variable. Perhaps this uses less current then running any of the external solutions above.
    • Combos. If want sample every 250 seconds, then do the wake every 2.3 sec and increment the variable, then after 100 increments, start checking the DS1302 on each wake and trigger the data collectin based on reading the DS1302 data.
    John the above quote is the method I would use.

    Note that the watchdog timer is very inaccurate, so reading a DS1302 at every wake-up would keep things timed better.

    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My goal is to live forever...Or die trying.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • pjvpjv Posts: 1,903
    edited 2007-10-08 16:58
    Hello John;

    There are several methods to get the results you are looking for, but the best one depends on more specific detail of your requirements.

    As each if the approaches has positives and negatives, and often these are at cross-purposes, specifically, what is the requirement and order of importance of:

    Timing precision....
    Lowest current...
    Lowest cost....
    Duration of program once running.....

    Answering these will help set the "best" direction for your project. The more extreme your specs, the bigger the challenge.

    I am working on a design that wakes once per second to a precision of a few tens of microseconds, draws an average of 50 microAmps of power so AA cells will run it for 3 years, and will operate outdoors at minus 40C for less than $10.00

    So, the question is ...... what specs are important to you.

    Cheers,

    Peter (pjv)
  • John KauffmanJohn Kauffman Posts: 653
    edited 2007-10-09 03:13
    Thanks PJV. I'm with you on the trade offs.

    I was hoping was that someone would say: "Hey John you fogrot about the x feature which allows you to multiple the sleep time by up to a thousand."

    But that is OK. The solutions listed (and Bean's advice) will solve the rpoblem.
  • BeanBean Posts: 8,129
    edited 2007-10-09 07:28
    John,
    Look at my "magic 8-ball" code here http://forums.parallax.com/attachment.php?attachmentid=48918
    See how the "wakeCnt" variable is used to do something after many watchdog wake-ups.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My goal is to live forever...Or die trying.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
Sign In or Register to comment.