Atmega8 sleep modes

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

Hi!

I am a little bit confused, that's why I decided it's best to ask the pros.

I'd like to reduce current consumption of my uC/pcb. First of all, after more reading, I plan to reduce it by dropping the external crystal oscilator (16Mhz, CKOPT on). I believe that 8Mhz or maybe even 4Mhz, supplied by internal oscilator are going to be enough. The 3% errors that I read about might be acceptable.

However, I have read about different power modes which allow to shut down different parts (like ADC/USART etc.)

The problem is that the board is made for sensor monitoring and therefore uses the ADC and sends the data over USART. I was wandering wether I could make a reading every 1 sec and "sleep" in between (eventually even shutting down the ADC while sleeping).
The board can also receive commands via USART (regarding the channels to monitor and the sampling frequency). So, I think there is no way you shut down USART and still be able to receive an USART interrupt right?

I really don't know for which sleep mode to go, and not sure how to do it. Your advice will be most welcome.

If you'd like me to post code, I don't have anything against it. Anyway, the system does this:
-periodical readings of specified ADC channels (period is established using a TIMER interrupt)
-USART transmission of the read values right after the reading is done
-USART receiving of commands (interrupt)to set samplig sequence (affects timer compare value), and monitored channels
- storage of settings in EEPROM right after USART comand is received and applied.
- loading of settings from EEPROM when (re)booting.

The software system uses short interrupts which set flags and these flags are checked in the main, infinite loop. Only if a flag is set will things happen (like ADC readings, USART reading etc).

I find it to be a decent system architecture, but please consider that this is my first ever program for uC.
Taking measures to also reduce power consumption would make it much better. Please advice.

Thank you,
Bogdan

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

Quote:

Atmega8 sleep modes

Quote:

I'd like to reduce current consumption of my uC/pcb.

First mistake is using mega 8 then. Ditch it in favour of a mega88PA which has all the additional power saving features on board.

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

clawson: thanks, I'll surely keep that in mind for future work! But I still want to find out the best solution for the ATMega8 :) (too involved with it right now)

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

I saw that the idle mode reduces power consumption from 3.6mA to 1.0mA. As it stops only CPU and I assume that I can wake it up with the same timer interrupt used to get the ADC readings, it looks like a good solution. But would another power mode be better recommended?
Also, please forgive my ignorance, I don't really understand the relation of this consumption (3.6mA) to the time a battery lasts. I say this because I connected the board to a supposedely 500mA battery (cheap GP Greencell) and it sucked it dry in under 3 hours (20 adc samples/second). Should this mean that the pcb actually consumed around 170mA? Or, it only means that those batteries are not good?
Sorry for a possibly silly question, newbie to the field here.

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

You might want to try to disable the ADC when you are not using it. It has a huge drain. Also if you know when your UART comm is going to happen then you can turn it off until then.

I am working on a similar project. Let me know what you found out.

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

Quote:

clawson: thanks, I'll surely keep that in mind for future work! But I still want to find out the best solution for the ATMega8 (too involved with it right now)

But it's a simple port and the chips are pin compatible. What you are doing is akin to taking a tractor to a drag race.
Quote:

Also, please forgive my ignorance, I don't really understand the relation of this consumption (3.6mA) to the time a battery lasts. I say this because I connected the board to a supposedely 500mA battery (cheap GP Greencell) and it sucked it dry in under 3 hours (20 adc samples/second)

Battery capacities are not given in mA but mAh - that is milliamps per hour. If your 500mA quoted here is really 500mAh then at 3.6mA current draw you would expect that to last for 500/3.6=139 hours. If the battery is drained in 3 hours then it suggests the current draw is actually 500/3=167mA

Are you talking about AA cells here? These days they typically have a capacity between 2400mAh and 4000mAh. If your "500mA" is really "500mAh" I guess you are talking about a cell much smaller than AA size?

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

Hi Clawson,

It's a 9V battery, I'll give a picture with the board and battery:

Regarding the port, I read the datasheet and I know that everything is the same (and will port for future). But I believe that the questions remain the same. In the given circumstances, for which sleep mode to go?
Also, I'm interested in personal experiences with ADC noise reduction sleep mode. I'm curios of situations where it was necessary to apply. I am going to monitor some fabrication machines with that and future boards.
And I don't really understand what would draw all that current in this boards case. I assume those batteries are also not too good.

Thanks

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

I understood that the MAX232 also draws around 8mA. It could (should?) be replaced with a MAX3222?
Also, I think that using the ULN2803 also adds to the the drawn current for each led. The board was designed by a coleague which was nice enough to let me use it to learn. The ULN is there to allow driving external circuits, but I think it draws current for each led connected through it as well, and I'll remove it in the new design (only LEDs and USART will be the outputs). If you haev an idea about how much the ULN added to current consumption it would be great to know (the leds seem to be powered from unregulated 9V supply)

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

Well my idea for the sleep problem was to put it in the power down mode and use the watch dog timer to wake up every 15ms. The start the ADC and set it into ADC noise reduction mode. Then once it was done with the measurement send it off and then put it back into power down mode.

My communication is mostly one way so I dont really care if some one is sending me something. This might not be the case for you.

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

what is power consumption in power down mode?

 

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

Praful Prajapati wrote:
what is power consumption in power down mode?

Page 1 of the mega8 datasheet has this:

 

 

Is there some reason to doubt it?

 

BTW the equivalent part of the mega88 datasheet says:

 

Makes you wonder why anyone would continue to use the mega8 in this day and age doesn't it?

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

but m also disabling ADC function during power down mode!

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

Praful Prajapati wrote:
but m also disabling ADC function during power down mode!

And the analog comparator?

 

In short, the Mega88 has the PRR register to disable unused peripherals.

 

Indeed, "engineering is the art of making what you need from what you have", and if what you have is a Mega8 and

Stormofwar wrote:
consider that this is my first ever program for uC

then with some of the approaches you described you can do a decent job with a Mega8.  A better job with a Mega8A.  And a much better job with Mega88-family.

 

What is your power budget?  I've outlined it several times here.  What average current draw do you desire?

https://www.avrfreaks.net/comment...

https://www.avrfreaks.net/comment...

https://www.avrfreaks.net/comment...

 

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.