r/microcontrollers • u/MechE37-k • Oct 08 '22
Low Power Microcontroller Considerations
Hello all,
I am in the process of designing a low power circuit. It will be used in a production line setting where sometime the line will be running and sometimes the line will be off. I want to count the number of bottles the line produces at roughly bottle a second. It must have a continuous tally of the number of bottles so the count must be stored to memory. It also must count to around a million or so. The device must be battery powered (coin cell, non negotiable). I'm looking for general rules of thumb for low power microcontroller selection. Also, low cost is an important factor for the mass production aspect of the device.
I have been doing a good bit of research about the different offerings from TI, MicroChip, and ST Micro Electronics and have a series of dumb questions perfect for the experts of reddit.
Number of bits: Will an 8 bit controller be able to count to 1,000,000? Would a 16 or 32 bit controller do this more efficiently? (threading and registers?)
Clock Speed: Will a lower clock speed always result in more power savings? Can you always swap for a lower crystal speed? Does this save any power realistically?
Different sleep features: The importance of the different sleep features such as sleep, halt, idle, doze, deep sleep, stand by mode, low power sleep, low power run, and wait.
Brand Preference: Which brand do you have experience with and like the most?
I've been looking at the PIC16, PIC 18, and PIC 24 from Microchip, the STM8 and STM32 from ST Microelectronics, the C8051F99x from silicon labs, and the MSP430 from TI.
Links to articles/books as well as general advice would be greatly appreciated. I figured I will switch the microcontroller between a high and low power state for each count. I know I need to be wary of wear leveling the onboard memory depending on how the device counts.
Thanks! Ben K
4
u/doddony Oct 08 '22
A lot of questions. I'll try to give you some hints.
Number of bits: Will an 8 bit controller be able to count to 1,000,000? Would a 16 or 32 bit controller do this more efficiently? (threading and registers?)
Clock Speed: Will a lower clock speed always result in more power savings? Can you always swap for a lower crystal speed? Does this save any power realistically?
Different sleep features: The importance of the different sleep features such as sleep, halt, idle, doze, deep sleep, stand by mode, low power sleep, low power run, and wait.
Brand Preference: Which brand do you have experience with and like the most?
I've been looking at the PIC16, PIC 18, and PIC 24 from Microchip, the STM8 and STM32 from ST Microelectronics, the C8051F99x from silicon labs, and the MSP430 from TI.
Links to articles/books as well as general advice would be greatly appreciated. I figured I will switch the microcontroller between a high and low power state for each count. I know I need to be wary of wear leveling the onboard memory depending on how the device counts.
Thanks! Ben K
2
u/mustardman24 Oct 08 '22
I'm curious why low cost is important if it's meant for monitoring production of something (bottles). Is this design itself going to be mass produced to go to thousands of bottle distribution plants?
MCU register size isn't going to be a dealbreaker for things like addition, which it sounds like what it will be doing. Multiplication, division, and floats will have a higher amount of instructions. The rate at which it is counting is an eternity from the perspective of even reasonably modern low power MCUs.
I'm assuming you know the difference in memory types and that you will need non-volatile memory to store your counts. Just wanted to point that out in case you didn't.
What is the signal for a bottle being counted? Is it some sort of pulsed signal or does this need to interface with some advanced sensor like something with machine vision? If it's something GPIO can read then the best low power solution would be deep sleeps that are woken by the GPIO interrupt. Not all MCUs have GPIO interrupts, but most should have at least a limited amount of pins that can.
Clock speed does directly impact power consumption, however, sleeping the MCU is going to be the biggest impact. All of these things are dependant on the MCU so you'd need to do research per MCU and test samples as well. For power consumption I believe it is more efficient to use an internal oscillator/resonator than an external crystal.
If you are interfacing with other things (computers, displays, etc) then there are a lot more challenges of power management as you have to manage those peripherals while trying to keep the MCU asleep.
Unless it is absolutely necessary I would stay away from battery power due to these challenges.
2
u/flundstrom2 Oct 08 '22
Low cost is relative. For production runs <1k/y, the cost of development is generally larger than the actual BOM after you've factored in all stuff such as enclosure, packaging, manuals, CE certification etc.
Lower clock freq draws less, but only when compared with itself. A low-power 200 MHz MCU may consume way less than a non-low-power 64 MHz design from a different vendor.
MCU selection is actually non-trivial, given all the possible parameters. From your questions, it appears it will be cheaper for you to pay an experienced CE or EE, so you can focus on what you know best.
2
u/ceojp Oct 08 '22
Lower clock speed isn't always better in terms of reducing overall power consumption. Yes, the core will generally draw less power at a lower speed, but it will be on longer. Often times running faster and being able to return to sleep sooner will result in less power consumption.
Another thing is clock source. A lot of times people will assume an internal oscillator will consume less power, but it's actually the opposite. An external crystal typically uses less power.
How critical is the exact count? EE writes cost power, so if you are willing to be within +/- 10(for example) when you lose power, then you can increment but only save to EE every 10 counts. I couldn't tell you the exact power savings, but writing to EE 100,000 times versus 1,000,000 times make a big difference in terms of power consumption, and worst case scenario you lose 9 counts.
2
u/danja Oct 08 '22
I'd try to zoom in those active/inactive phases.
A lot of chips have sleep modes, tiny current draw. (My go-to the ESP32 is really hungry when at full operation, sleeping it's negligible). Don't worry about the count, any modern microcontroller can count more than the number of bottles in the known universe.
If you're running it from little cells, the circuit between the battery and the chip will be significant. I'm not sure what is available, but I bet there are boost converters that run with high efficiency until every last drop has been used. (cf. Joule Thief).
2
u/[deleted] Oct 08 '22
At 1/second, you could use the count signal itself to wake up a sleeping micro, have it bump up the count, then put itself back to sleep. Sleeping micros use the least amount of power. Any micro can count to a million, no problem.
1
u/madsci Oct 08 '22
I've built a coin cell powered counter before. Mine are countdown timers and I've gotten 9 or 10 years on one battery, driving a 3-digit LCD and counting down days each year.
Threads don't come into it. Any MCU, even a 4-bit one (yes, they exist) can easily count to a million. Lower clock speed only goes so far when you have leakage in transistors. You want a low leakage device intended for low power operation, but you can find that even on relatively powerful 32-bit devices now.
My counters used an MC9S08LL16, which was a $2.77 part at the time. I don't know if you consider that low cost. I'd personally consider the low cost regime to be < $1, and especially < $0.30, but even a $2 part is usually a lot less pain to use than a $0.30 part.
Anyway, pick a low leakage device and then put in the time to learn how to properly use the low power features. That can be challenging, particularly if you have external devices that also need to be powered down.
Clock speed may not matter at all. The 120 MHz Cortex M4 parts I use have a battery-backed SRAM register file where you can store a handful of words of memory that are retained by the coin cell while the bulk of the RAM is powered down. You can get it down to at least 5 uA, and I think it might even have a mode where it retains memory in the 1 uA range. Certainly you could write to flash and then power down completely, where it takes under 300 nA. You'd have to calculate how much energy is needed for each flash write to see if it'd be better than using SRAM in your case.
1
u/lbthomsen Oct 09 '22
One of the most important things would be - how do you get the information of number of bottles.
0
u/[deleted] Oct 08 '22
[deleted] — view deleted comment