Scheduling ADC sampling on ATmega88 while conserving power?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a grudge against the power save modes of the ATmega88. (Well ATmegaX8 really.)

Running on 8 MHz internal clock I try to schedule an ADC conversion every 0.1 seconds using Timer1 set to overflow at 3125 using a 1:256 prescaler.
I set the ADC to auto-trigger on Timer1 overflow and clear this flag again in the conversion-complete interrupt handler so it can re-trigger.
The timer just wraps around so it can trigger it's overflow again, keeping synch.

The problem is it looks like the power-save modes either doesn't allow me to use the Timer1 or triggers ADC conversion automatically upon entering sleep/halt.

Am I reading this correctly?
Any ideas on how to schedule this conversion so I can save as much power as possible inbetween handling each result?

Every 1 second (every 10'th sample) I will exit the interrupt and update my display before going back to sleep but other than that, not much is happening.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using Timer1 overflow is a valid trigger for ADC. After you serviced the ADC interrupt, did you reload Timer1 register with 62411 (65536-3125) ? This is to maintain the correct overflow timing. Also, make sure you clear the T1 overflow flag. I assume that you have the Timer1 overflow interrupt disabled.

Also, this is a bit disturbing.

Quote:
Every 1 second (every 10'th sample) I will exit the interrupt and update my display before going back to sleep but other than that, not much is happening.

You should be exiting the interrupt(s) on every sample. Increment a counter in the interrupt on every sample, then check the count your "Main". When you reach "10", clear the counter and display your information.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To get decent results, you really (in my experience) you need to keep the ADC enabled. After putting everything to deep sleep to be able to run off a few uA you probably want to toss the results of the first conversion after waking up and re-enabling everything. YMMV--try it out.

You may want to do a few conversions for your average every half second as a compromise.

Re timer1--you'll have more options with timer2 for sleep timekeeping. Everything else being equal, starting the conversion after waking up will be the least of your worries.

For deep sleep the cheapest [power] is to use the watchdog timer, but it won't be the most accurate (as a crystal).

But a crystal takes several ms to wake up after being stopped.

What is your power budget?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would also suggest to keep the ADC active all the time and not use deep sleep. To keep power consumption low you could still work with a low voltage (e.g. 2 V) and keep the clock speed low (e.g. 455 kHz / 8). If needed this could be done dynamic as needed, with the clock divider.