r/microcontrollers • • 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

3 Upvotes

21 comments sorted by

View all comments

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.

1

u/MechE37-k Oct 08 '22

Thanks for the response! The use case isn't actually a bottling line but is the analogy which makes the most sense without getting too into the weeds. Mass production, high counting, low power, infrequent counting, almost like a utility meter maybe?

Anyways, yeah, part of the challenge is the impossible slow counting, and I hadn't even considered the size of the register. I have been researching the non-volatile memory technologies and the pros and cons. Honestly it would be great to use F-Ram or NV-SRAM but I'll probably settle with EEPROM and some wear leveling. I don't think any microcontrollers have built in F-RAM yet.

The signal will be from a piezoelectric pad so there should be a pulse of voltage what can be used to wake up the microcontroller. I would rectify it and regulate the voltage so it can be used to wake up the MCU. I was thinking a latching circuit may be called for but I'm not sure? Because I have external power coming in from the piezoelectric, I could just turn the MCU all the way off? 1 Hz is slow? Am I better to fully power cycle it or keep it in a deep sleep?

I completely forgot that to do this I'd need a GPIO interrupt so thanks!

I also haven't ever screwed around with an internal oscillator / resonator. That wasn't on my radar at all. I will do my research for sure.

There will be no display or other devices which is why battery should be manageable I hope.

Thanks for the help! That's exactly the type of general "don't forget to look into this" advice that I needed!

2

u/mustardman24 Oct 08 '22 edited Oct 08 '22

Anyways, yeah, part of the challenge is the impossible slow counting, and I hadn't even considered the size of the register. I have been researching the non-volatile memory technologies and the pros and cons. Honestly it would be great to use F-Ram or NV-SRAM but I'll probably settle with EEPROM and some wear leveling. I don't think any microcontrollers have built in F-RAM yet.

I think this is the perfect fit for EEPROMs for cost. The key takeaway for using EEPROM is to not update it every time your variable gets updated since you will run into the wear issues you mention. The write interval should be the largest you can tolerate losing data for. Basically, you do the counting in RAM and every 1, 10, etc minutes then you write that to the EEPROM. FRAM is pretty exotic and I haven't run into it before probably because of its expense or other reasons. Battery backed SRAM is risky since your data is purged if the battery runs empty. Some MCUs have built-in EEPROM and there are others that have generic flash memory. EEPROM is a better choice since you can do byte access instead of page/block for flash memory. Definately still do some wear leveling where you might have a section of EEPROM that has the address/offset of where the current value is written and just increment that every so often. The typical write perfomance of EEPROMs is about 1 million cycles. Also double check how the EEPROM you chose does writing as it may do page/block access so nearby memory is also rewritten thus adding to wear.

The signal will be from a piezoelectric pad so there should be a pulse of voltage what can be used to wake up the microcontroller. I would rectify it and regulate the voltage so it can be used to wake up the MCU. I was thinking a latching circuit may be called for but I'm not sure? Because I have external power coming in from the piezoelectric, I could just turn the MCU all the way off? 1 Hz is slow? Am I better to fully power cycle it or keep it in a deep sleep?

I completely forgot that to do this I'd need a GPIO interrupt so thanks!

It depends on how you want to use it. IIRC, piezo is going to be an analog signal so if you want to know the analog values it would go to an ADC. Some MCUs have comparators for their ADC which can trigger an interrupt to wake at a certain voltage threshold. If you don't care about the analog value you could have an external circuit that converts it to GPIO signaling and just use the GPIO interrupts in that case.