Author Topic: Low power uC with ADC  (Read 1474 times)

0 Members and 1 Guest are viewing this topic.

Offline GodzillaTopic starter

  • Contributor
  • Posts: 33
  • Country: it
Low power uC with ADC
« on: October 14, 2021, 02:05:06 pm »
Hello guys, im trying to build a simple board that has to be supplied by 2 AA batteries, so i was looking for a suitable low power microcontroller. I want the batteries to last as much as possible (1yr min) and the micro will only turn on once every hour for as little time as possible. The micro must have an ADC, i dont need fancy stuff like tons of channels or high resolution, but i need to read voltage on a couple of sensors on the board. Do u have any suggestions?
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14073
  • Country: de
Re: Low power uC with ADC
« Reply #1 on: October 14, 2021, 03:30:45 pm »
2 AA cells could provide some 2.4 to 3.2 V. Some µCs are OK to directly run from this.

With some 2000 mAh and some 10000 hours one would have an average current available of some 0.2 mA. For a low power µC this is a lot, when most of the time in a standby mode.
It would start to get a little challanging if you have power from a little LI coin cell with maybe 20 mAh and thus 2 µA total.

So take your choice of a reasonable modern 8 bit µC. This cold be STM8 , AVR, PIC16, PIC18, some 8051 variants or MSP430. They should all work.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
Re: Low power uC with ADC
« Reply #2 on: October 14, 2021, 04:31:26 pm »
The main techniques for lowering microcontroller power consumption are:

- put the microcontroller in sleep mode as much as possible
- use a lower clock frequency (even 32 KHz when you can)
- turn off peripherals (timers, adc, ...) when they are not needed; this includes off-chip devices
- run directly from the battery or use a voltage regulator with a low quiescent current

This video is targeted at AVR microcontrollers but the ideas apply equally well to other devices:

Atmel: picoPower Labs - Basic Power-Saving Techniques -- Microchip Makes
https://youtu.be/bdWV-tOTVSE

 

Offline GodzillaTopic starter

  • Contributor
  • Posts: 33
  • Country: it
Re: Low power uC with ADC
« Reply #3 on: October 14, 2021, 04:56:32 pm »
2 AA cells could provide some 2.4 to 3.2 V. Some µCs are OK to directly run from this.

With some 2000 mAh and some 10000 hours one would have an average current available of some 0.2 mA. For a low power µC this is a lot, when most of the time in a standby mode.
It would start to get a little challanging if you have power from a little LI coin cell with maybe 20 mAh and thus 2 µA total.

So take your choice of a reasonable modern 8 bit µC. This cold be STM8 , AVR, PIC16, PIC18, some 8051 variants or MSP430. They should all work.

I've found  the STM8AL31E88TCY that seems to have everything that i need, do i need decoupling caps even if i run them directly from battery? If yes, do i need them for every rail (VDD1,VDD2, etc..)?

The main techniques for lowering microcontroller power consumption are:

- put the microcontroller in sleep mode as much as possible
- use a lower clock frequency (even 32 KHz when you can)
- turn off peripherals (timers, adc, ...) when they are not needed; this includes off-chip devices
- run directly from the battery or use a voltage regulator with a low quiescent current

This video is targeted at AVR microcontrollers but the ideas apply equally well to other devices:

Atmel: picoPower Labs - Basic Power-Saving Techniques -- Microchip Makes
https://youtu.be/bdWV-tOTVSE



The micro will stay on sleep almost all the time. Im gonna use it with the lower clock possible. I may need to turn it on with a timer interrupt unless it has other fancy features for the wake up. It will run directly from battery.
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5835
  • Country: es
Re: Low power uC with ADC
« Reply #4 on: October 14, 2021, 06:16:09 pm »
Yes, decoupling caps are a must, they compensate high frequency current transients, a battery has internal resistance, the traces also add impedance, specially at high frequencies.
Just 1uF+100nF will do the job for a low current mcu, costing close to nothing.
It'll probably work correctly without them, but some day you'll find a strange bug causing data corruption, lockups, random resets...
Definitely, you don't want that to happen onceyour product was shipped, causing 1000s of RMAs and lots of losses.

Read the datasheet for the AC characteristics.
The MCUs have static current consumption + dynamic depending on the frequency of operation.
Usually, there's a sweet spot where the best performance and consuption is achieved.
Checking the datasheet, 16Mhz has the most efficient speed/power ratio.
So, run the code as fast as you, and for any delay, instead of waiting, start a timer and set the core in the lowest power mode until the timer wakes it.
That way it'll be extremely efficient.
« Last Edit: October 14, 2021, 06:34:33 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3321
  • Country: nl
Re: Low power uC with ADC
« Reply #5 on: October 14, 2021, 08:00:11 pm »
Definitely use decoupling capacitors.
Your uC may seem to work without it, but it increases the chances of hard to debug "weird" things.

Sleeping for a year on two penlights and doing a bit of simple work every hour is a relatively simple task for most microcontrollers.

If you design really carefully you may get 3, maybe even 5 or more years out of your penlights.
Some modern microcontrollers go as low as a few hundred nA while still being able to do useful work. If you really want to hunt the average power consumption down, it becomes an art. Often a higher clock frequency can get things done quicker, and putting your uC to deep sleep sooner, so the average power consumption goes down, but running at 20MHz while waiting in a loop until your ADC has done a conversion is counter productive. You can put it in a low(-er) power mode during such waits, but crystals have long startup times and this may become a noticeable factor.

In the lowest power down mode, usually all clocks are stopped, and a microcontroller can not wake itself anymore. You will need to keep at least some kind of timer running.
You also have to consider all external circuitry carefully. Radio's often have high (peak) currents, and quickly become a dominant factor. For ultra low power, the leakage of even an electrolytic capacitor may be dominant. External IC's, often have a "power down" mode, but may still use too much current when powered down. Current leakage though a BJT used as a power switch may be smaller then though a MOSfet, and both are highly temperature dependent.

And when choosing a microcontroller family you have make a lot of other choices too. Personally I do not touch any microcontroller if it does not run GCC. (Maybe SDCC is acceptable for some projects if the uC is already chosen in a pre-existing project).
For some microcontroller families you need an EUR100 programmer, while for some others you can buy a programmer for a handful of pennies. How important are such costs to you?

Another important factor is how much effort you want to put into a single project? If you're satisfied with a year of battery life, you can choose a controller based on a big family, so you can use similar microcontrollers for all your other projects. If you want to go to 5+ years, you do not have that luxury and must select on low power consumption.

Accurate power measurement is a must during development and this also becomes more cumbersome for very low current measurements.

A simple & cheap way to measure current is to put a shunt resistor in the power line (For example 10k will have 100uA/volt), and then put a silicon diode in parallel. Below approx 200mV leakage through the diode won't be too big (but highly temperature dependent). This gives you a relatively high resolution for low current measurement and at the same time limit voltage drop to 700mV or so when the uC wakes up.

Another method is to use a capacitor instead of a battery as power source, ad a Fet-input opamp as buffer to measure the battery voltage and monitor how fast the battery voltage drops. You can even add a schmitt-trigger to top up your capacitor and count the number of times the capacitor needs to be recharged. Adding a second microcontroller to regulate and count charge pulses is a single afternoon project.

These methods may not give very accurate absolute values for current consumption, but it does make it easy to compare what influence the software and sleep mode have during tests.
« Last Edit: October 14, 2021, 08:15:59 pm by Doctorandus_P »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3321
  • Country: nl
Re: Low power uC with ADC
« Reply #6 on: October 14, 2021, 08:25:36 pm »
Some time ago I've chosen STM32. It started with the "Blue Pills", the "Maple Mini". Later I bought a few "Black Pills" with STM32F411, but I still have not used them much.

ST claims that the STM32U5 series has 110nA shut down mode, but also needs 350uA with RAM and an active RTC, and 19uA/MHz. Those are probably the most important numbers to compare with other microcontroller families, but I do not know how much the marketing arseholes force the engineers to lie about such numbers, so you always have to verify.
 

Offline GodzillaTopic starter

  • Contributor
  • Posts: 33
  • Country: it
Re: Low power uC with ADC
« Reply #7 on: October 14, 2021, 09:08:10 pm »
Definitely use decoupling capacitors.
Your uC may seem to work without it, but it increases the chances of hard to debug "weird" things.

Sleeping for a year on two penlights and doing a bit of simple work every hour is a relatively simple task for most microcontrollers.

If you design really carefully you may get 3, maybe even 5 or more years out of your penlights.
Some modern microcontrollers go as low as a few hundred nA while still being able to do useful work. If you really want to hunt the average power consumption down, it becomes an art. Often a higher clock frequency can get things done quicker, and putting your uC to deep sleep sooner, so the average power consumption goes down, but running at 20MHz while waiting in a loop until your ADC has done a conversion is counter productive. You can put it in a low(-er) power mode during such waits, but crystals have long startup times and this may become a noticeable factor.

In the lowest power down mode, usually all clocks are stopped, and a microcontroller can not wake itself anymore. You will need to keep at least some kind of timer running.
You also have to consider all external circuitry carefully. Radio's often have high (peak) currents, and quickly become a dominant factor. For ultra low power, the leakage of even an electrolytic capacitor may be dominant. External IC's, often have a "power down" mode, but may still use too much current when powered down. Current leakage though a BJT used as a power switch may be smaller then though a MOSfet, and both are highly temperature dependent.

And when choosing a microcontroller family you have make a lot of other choices too. Personally I do not touch any microcontroller if it does not run GCC. (Maybe SDCC is acceptable for some projects if the uC is already chosen in a pre-existing project).
For some microcontroller families you need an EUR100 programmer, while for some others you can buy a programmer for a handful of pennies. How important are such costs to you?

Another important factor is how much effort you want to put into a single project? If you're satisfied with a year of battery life, you can choose a controller based on a big family, so you can use similar microcontrollers for all your other projects. If you want to go to 5+ years, you do not have that luxury and must select on low power consumption.

Accurate power measurement is a must during development and this also becomes more cumbersome for very low current measurements.

A simple & cheap way to measure current is to put a shunt resistor in the power line (For example 10k will have 100uA/volt), and then put a silicon diode in parallel. Below approx 200mV leakage through the diode won't be too big (but highly temperature dependent). This gives you a relatively high resolution for low current measurement and at the same time limit voltage drop to 700mV or so when the uC wakes up.

Another method is to use a capacitor instead of a battery as power source, ad a Fet-input opamp as buffer to measure the battery voltage and monitor how fast the battery voltage drops. You can even add a schmitt-trigger to top up your capacitor and count the number of times the capacitor needs to be recharged. Adding a second microcontroller to regulate and count charge pulses is a single afternoon project.

These methods may not give very accurate absolute values for current consumption, but it does make it easy to compare what influence the software and sleep mode have during tests.

Sadly the batteries will also run a small DC motor every once in a while (twice a day) for like 10 sec every time. So the run consumption of the uC will be negligible at that point. I saw that that stm8 has a sleep mode with RTC enabled, and i was thinking about using that for waking it up every hour and accordingly to datasheet it should only drains tens of uA. About the programming part im almost a newbie, ive only used Atmega and ESP in the past so st8 is totally new, and i was thinking about using SPI (ST-LINK) to flash the firmware if it is an option. I was thinking about making a simple PCB with just the battery connector and the uC with caps and many solder points for the GPIOs, just to be able to play a bit with it a bit before making the final board...

Also for the motor part, im not sure if there are many low current DC motor around, and i think that the consumption will be heavily dependent on the load, is there anything that is well known to work well with batteries?

For the measurament part i was thinking about using a simple uA meter to see the exact consumption during sleep, do u think that is not enough accurate?
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6733
  • Country: pl
Re: Low power uC with ADC
« Reply #8 on: October 14, 2021, 09:44:16 pm »
Never used those parts, but ATtiny412 datasheet gives 0.71µA typ / 6µA max at 85°C in standby with RTC.
That's SO8 with ADC on all pins and internal 32kHz oscillator or option to use a watch crystal for better time accuracy.
Somewhat similar to classic AVR, but new peripherals, different registers, etc.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
Re: Low power uC with ADC
« Reply #9 on: October 15, 2021, 12:29:38 am »
For the measurament part i was thinking about using a simple uA meter to see the exact consumption during sleep, do u think that is not enough accurate?

What specific simple uA meter do you have?

The main problem with low current measurements is the burden voltage. Another problem measuring microcontroller power consumption is that a microcontroller's activity is usually very spikey.

For accurately measuring low currents you might have a look at:

- µCurrent Gold -- https://www.eevblog.com/projects/ucurrent/
- CurrentRanger -- https://lowpowerlab.com/guide/currentranger/

For measuring spikey power consumption:

- BattLab-One -- https://bluebird-labs.com/  (~$100)
- Otti Arc -- https://www.qoitech.com/otii/ (~$700)

and I'm sure there are some other products out there.

 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Low power uC with ADC
« Reply #10 on: October 15, 2021, 12:40:35 am »
I have atmega328's that will run over a year on a pair of AA cells, the trick is to run them at 1MHz on the internal oscillator and have them go to sleep whenever they are not actively being used. Most modern microcontrollers have low power modes for battery applications, a pair of AA's is actually quite a lot of capacity compared to a lot of stuff, the real challenge is getting a reasonable life out of a CR2032 cell.

This was one of the resources I used.
https://lowpowerlab.com/
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3282
  • Country: ua
Re: Low power uC with ADC
« Reply #11 on: October 15, 2021, 02:40:58 am »
you can use MSP430 they are ultra low power.

I was used MSP430F149 for ultra low power device which was expected to work several years from lithium battery. It has 60 kB flash, 2 kB RAM, 12 bit ADC, hardware timers which can be used as hardware counter and other stuff. But it was about 20 years ago, so this model may be too old and you can find more new one from MSP430 series with more memory and other resources.
« Last Edit: October 15, 2021, 02:48:06 am by radiolistener »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Low power uC with ADC
« Reply #12 on: October 15, 2021, 05:43:03 am »
The MSP430 was one of the early low power microcontrollers but I think most others on the market have caught up quite a while ago.
 

Offline cgroen

  • Supporter
  • ****
  • Posts: 631
  • Country: dk
    • Carstens personal web
Re: Low power uC with ADC
« Reply #13 on: October 15, 2021, 06:57:18 am »
For the measurament part i was thinking about using a simple uA meter to see the exact consumption during sleep, do u think that is not enough accurate?

What specific simple uA meter do you have?

The main problem with low current measurements is the burden voltage. Another problem measuring microcontroller power consumption is that a microcontroller's activity is usually very spikey.

For accurately measuring low currents you might have a look at:

- µCurrent Gold -- https://www.eevblog.com/projects/ucurrent/
- CurrentRanger -- https://lowpowerlab.com/guide/currentranger/

For measuring spikey power consumption:

- BattLab-One -- https://bluebird-labs.com/  (~$100)
- Otti Arc -- https://www.qoitech.com/otii/ (~$700)

and I'm sure there are some other products out there.

I use a couple of Joulescopes, these are really (really!) a good investment.
On the talk about clock frequency, I have had several projects where it was better to run a high(er) clock frequency when the CPU wakes up in order to finish the work it is doing faster. Often it is not so that the current consumption is doubled when frequency doubles, so getting "stuff" done faster means lower consumption overall. This is where the (f.ex) Joulescope comes in handy, you get full transparency in the numbers!
 

Offline GodzillaTopic starter

  • Contributor
  • Posts: 33
  • Country: it
Re: Low power uC with ADC
« Reply #14 on: October 15, 2021, 09:38:44 am »
I have atmega328's that will run over a year on a pair of AA cells, the trick is to run them at 1MHz on the internal oscillator and have them go to sleep whenever they are not actively being used. Most modern microcontrollers have low power modes for battery applications, a pair of AA's is actually quite a lot of capacity compared to a lot of stuff, the real challenge is getting a reasonable life out of a CR2032 cell.

This was one of the resources I used.
https://lowpowerlab.com/

At first i thought about using the 328 cuz im familiar with arduino, but after a bit of research i saw that it consume hundreds of uA during sleep so i discarded it...

Never used those parts, but ATtiny412 datasheet gives 0.71µA typ / 6µA max at 85°C in standby with RTC.
That's SO8 with ADC on all pins and internal 32kHz oscillator or option to use a watch crystal for better time accuracy.
Somewhat similar to classic AVR, but new peripherals, different registers, etc.

you can use MSP430 they are ultra low power.

I was used MSP430F149 for ultra low power device which was expected to work several years from lithium battery. It has 60 kB flash, 2 kB RAM, 12 bit ADC, hardware timers which can be used as hardware counter and other stuff. But it was about 20 years ago, so this model may be too old and you can find more new one from MSP430 series with more memory and other resources.

Are they easier to develop than stm8?

For the measurament part i was thinking about using a simple uA meter to see the exact consumption during sleep, do u think that is not enough accurate?

What specific simple uA meter do you have?

The main problem with low current measurements is the burden voltage. Another problem measuring microcontroller power consumption is that a microcontroller's activity is usually very spikey.

For accurately measuring low currents you might have a look at:

- µCurrent Gold -- https://www.eevblog.com/projects/ucurrent/
- CurrentRanger -- https://lowpowerlab.com/guide/currentranger/

For measuring spikey power consumption:

- BattLab-One -- https://bluebird-labs.com/  (~$100)
- Otti Arc -- https://www.qoitech.com/otii/ (~$700)

and I'm sure there are some other products out there.



Everything here is out of budget for the moment exepct for the uCurrent Gold, but it seems out of stock atm.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3282
  • Country: ua
Re: Low power uC with ADC
« Reply #15 on: October 15, 2021, 11:00:17 am »
Are they easier to develop than stm8?

yes, you can write code in C and debug it inside device through JTAG interface.

It has about 1 uA current consumption in standby mode.
« Last Edit: October 15, 2021, 11:04:13 am by radiolistener »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: Low power uC with ADC
« Reply #16 on: October 15, 2021, 11:07:43 am »
Don't make the mistake of putting an electrolytic cap across the battery.
I did that on a hobby thing once, it was flat in 1 month just from the cap leakage current.
Use ceramic caps instead.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
Re: Low power uC with ADC
« Reply #17 on: October 15, 2021, 03:56:11 pm »
...
At first i thought about using the 328 cuz im familiar with arduino, but after a bit of research i saw that it consume hundreds of uA during sleep so i discarded it...
...

That might be old/inaccurate information or the chips tested might be fake:

Sleep Mode breaks on cheap Pro-Mini? Testing ATMEGA328 - is it counterfeit? - Kevin Darrah
https://youtu.be/PlGycKwnsSw

Also:

Arduino Low Power Project - 200 nA Atmega328p -- Eric Oud Ammerveld
https://youtu.be/plkn13dOgpU
« Last Edit: October 15, 2021, 04:14:19 pm by ledtester »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Low power uC with ADC
« Reply #18 on: October 15, 2021, 09:42:59 pm »
Everything here is out of budget for the moment exepct for the uCurrent Gold, but it seems out of stock atm.

They were out of stock a couple years ago when I tried to order one too so I built my own. The design is open source so you can do that. I had a batch of blank PCBs made and then sold the extras at cost to other members here.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3032
  • Country: us
Re: Low power uC with ADC
« Reply #19 on: October 16, 2021, 02:48:02 am »
This blog post contains more specifics on lowering atmega328p power consumption:

https://blog.duk.io/sleeping-atmega328-on-1ua-with-timer-wakeup/

 
The following users thanked this post: james_s


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf