1
\$\begingroup\$

Im building a datalogger with a LPC11xx as CPU. It needs to wakeup at 256hz to take ADC samples, but this CPU has very in-accurate timed wakeup from deep-sleep, causing jitter on the sampled data.

So is there a very cheap component that can toggle a GPIO very accurately at 256hz, that wakes up the CPU from deep-sleep (using external interrupt)?

Or maybe even better: do there exists ADC's that have their own build-in clock, so that I can stay in deep-sleep for a whole second, and then read out 256 samples via I2C and go to sleep again?

\$\endgroup\$
11
  • \$\begingroup\$ What's with the hard requirement to sample at 256Hz intervals? (just curious) \$\endgroup\$ Dec 20 '12 at 18:48
  • \$\begingroup\$ @TobyLawrence It's ECG/EEG (heartrate/brainwave) data, for which medical standards dictate that samplerate must be >= 256hz. \$\endgroup\$
    – Muis
    Dec 20 '12 at 18:51
  • 1
    \$\begingroup\$ If it can be greater than 256Hz, then why not run it faster to meet your minimum sample requirement? \$\endgroup\$ Dec 20 '12 at 19:02
  • 1
    \$\begingroup\$ @TobyLawrence The problem is that the timer used to wake up from deep-sleep is very inaccurate (40%) on the LPC11xx series. So how does increasing the samplerate, decrease the jittering? \$\endgroup\$
    – Muis
    Dec 20 '12 at 19:08
  • 2
    \$\begingroup\$ Why the need to put the CPU to sleep at all? My concern is any simple solution to wake the CPU up more accurately could burn more power than just keeping the CPU awake. If the LPC11xx uses too much power, you could keep a low-power micro awake, measuring and buffering data, and like you suggested wake up the LPC11xx very infrequently to collect the data. \$\endgroup\$
    – The Photon
    Dec 20 '12 at 20:29
0
\$\begingroup\$

There are several possibilities for you to consider for this.

1) Look into a somewhat ancient CMOS chip that can still be readily purchased called a CD4536. This device includes an oscillator capability, a programmable divider chain and a one shot pulse output. I have successfully used these in very low power applications with a 32.768kHz crystal attached to the oscillator pins. The divider on this part can then programmed via the strap pins to use 9 stages of divider to get to the desired 256Hz rate. (Or other rates faster or slower if so desired). The output would be connected to the wakeup control pin on your MCU.

2) Another choice is to use any one of a number of popular 8-pin RTC chips. These are very low power and will run off a 32.768kHz crystal. Select an RTC that as a programmable output pin that can generate a square wave signal at a selected frequency. The popular ST M41T81S RTC chip can have its output pin be programmed to generate an exact 256 Hz output frequency. The output would be connected to the wake control pin on your MCU. Some MCUs need a pulse on their wake input that is shorter that the time the MCU expects to stay awake and so it may be necessary for you to capacitively couple the RTC output to the MCU with an RC circuit to produce a narrow pulse off one edge of the RTC square wave output.

\$\endgroup\$
1
  • \$\begingroup\$ I already needed a RTC on the board, since the LPC11xx has no RTC of its own. I will certainly look into the model you're suggesting, since it seems like a perfection solution. \$\endgroup\$
    – Muis
    Dec 21 '12 at 20:51
1
\$\begingroup\$

It looks like the LPC11xx series of parts have a timer that can accept an external crystal. Wire up a 32kHz crystal, set the timer to divide by 128 and have the timer interrupt. I would be very surprised if you could not wake from deep sleep with this mechanism.

Before getting that far though, you mention that the LPC11xx has a very inaccurate wake from deep sleep. It sounds like no matter what method you use to wake it from deep sleep, it is the wake from deep sleep that is the problem. What are the bounds on this wakeup? What if you divide by 64 instead, and only doze for the remaining time? You'd still spend a lot of time in deep sleep, but your "snooze" function would let you get that accurate sample rate.

e.g.

[1.9ms deep sleep] [wake from deep sleep] [1.9ms - wake time doze] sample

If you're using a timer with an external crystal you could very accurately time that third part (1.9ms - wake time).

Honestly though, it sounds like you might be using the wrong chip for this task. I've not used them myself, but I've heard very good things about the MSP430's power consumption. You might be able to achieve better power consumption and get the ADC results you want with a part more suited for extreme low power sampling.

\$\endgroup\$
4
  • \$\begingroup\$ I didn't find it in the LPC11xx data sheet or user manual. Can you elaborate? \$\endgroup\$
    – starblue
    Dec 21 '12 at 8:20
  • \$\begingroup\$ I looked at the counter/timers and assumed. My mistake. I just spent a good 15m on NXP's website but they don't allow you to do a parametric search for a part with a timer with an external crystal input. You can filter on RTC but that leads to larger parts. Looking at the LPC81x it seems that the WDC can be used to perform a similar task to what I described, though. \$\endgroup\$
    – akohlsmith
    Dec 21 '12 at 12:39
  • \$\begingroup\$ @AndrewKohlsmith I already have an external crystal connected to the LPC11xx, but you cannot use a normal timer to wakeup from deep sleep, only the watchdog timer. And the Watchdog Oscilator is very inaccurate. So waking up from deep sleep is always within the same fixed time, thats not the problem, the problem is that when using the Watchdog Oscilator as interrupt-source, it's not accurate. P.S. I also considered the MSP430 when starting this project, but I would rather not start again from scratch. \$\endgroup\$
    – Muis
    Dec 21 '12 at 20:57
  • \$\begingroup\$ @Joshua Does the timer run in deep sleep? If so, you set the WD wakeup to be earlier than what you need and use the timer and doze until the correct sample time. If the timer does not count in deep sleep you may have an insolvable problem. I'd look at the benefits of deep sleep vs. the lowest sleep you can use and still get accurate results; it may not be worth the deep sleep. \$\endgroup\$
    – akohlsmith
    Dec 22 '12 at 2:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.