Powering from MCU pin - Page 1
Forum section: electronics / beginners

author: Miha
author_rank: Contributor
timestamp: April 24, 2023, 11:41:38 am
content: Helllo.I need to power the accelerometer like LIS2DH12 from a MCU pin in my battery (CR2032) powered device. So not much electric power do I have.The goal is to control a power consumption of accelerometer.Power consumption of accelerometer is about 10 uA, but it requre a good quality of power rail. The DS is requre 10 uF + 0.1 uF capacitors.I think that not good idea to connect large value capacitor to MCU pin.I have only one idea - is good capacitor blocking of all MCU power pins and small capacitor (like 10..100 nF) in the pin of MCU, that powers accelerometer. Even in this case I will have "power on" spikes when accelerometers capacitor will be charge.May be exist common prictise decigion of this problem?

author: ataradov
author_rank: Super Contributor
timestamp: April 24, 2023, 11:11:50 pm
content: Ideally you should use a MOSFET. But if you are limited on board space, you can try to connect a series resistor between the MCU pins and the capacitors. Resistor would limit the current when turning it on or off. This will slow down the power supply rise on the sensor side, make sure that sensor is ok with that.And also make sure that MCU can both source and sink sufficient current to charge and discharge the capacitor, otherwise you'll need a diode too, and at that point might as well use a MOSFET.

author: Kim Christensen
author_rank: Super Contributor
timestamp: April 24, 2023, 11:25:47 pm
content: QuoteIf the resistor voltage drop is too high, you can use this trick if you have two MCU pins.MCU-pin1: This pin is connected directly to the accelerometer's power rail. Set it as an input (tri-state it) but command it's output state as a high.MCU-pin2: This pin is set as an output and is connected via a suitable resistor to the accelerometer's power rail. Set it low initially.To activate the accelerometer's power rail, change MCU-pin2 to a high. Delay for a time to charge the capacitor, and then change MCU-pin1 to an output (Set to high already)To deactivate the accelerometer's power rail, change MCU-pin1 back to an input and at the same time make MCU-pin2 low.

author: langwadt
author_rank: Super Contributor
timestamp: April 24, 2023, 11:33:06 pm
content: Quote from: ataradov on April 24, 2023, 11:11:50 pmyou could set the pin to input and not discharge the capacitor, it is just wasted energy

author: Psi
author_rank: Super Contributor
timestamp: April 24, 2023, 11:39:20 pm
content: I have seen it work fine in a production product with a LIS2DE12 powered from 1 MCU output (15mA source/sink) with simply a 1uF and 100nF in parallel across the GPIO power rail next to the LIS2DE12. This MCU was also powered from a CR2032.Is this in line with regard to what DS says (10uf), no, but it worked in this case just fine.At least for 50hz sample rate and under, I dunno about when using it at full sample rate or other features.One word of warning about CR2032, (unrelated to LIS2DE12), there is a huge difference between brands of CR2032 and how much current you can pull from them due to different ESR and ionic resistance. Test your product on the CR2032 brand you instead to use and fully retest if you change the brand.

author: ataradov
author_rank: Super Contributor
timestamp: April 25, 2023, 12:04:30 am
content: Quote from: langwadt on April 24, 2023, 11:33:06 pmI'd be very careful with that. I don't know about those sensors, but many devices may not work correctly if the voltage drops below certain level, but not to 0V.You can just leave it floating, but then fully discharge on the next power on cycle. This would eliminate full discharge throguh the MCU.

author: jpanhalt
author_rank: Super Contributor
timestamp: April 25, 2023, 12:59:56 am
content: Wouldn't a current limiting diode (attachment) protect the I/O pin (if really needed) too. More expensive than a resistor, but another option.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: April 25, 2023, 01:17:23 am
content: Read your datasheet. Your accelerometer draws half a uA when in "powered down" mode. Use that.It's something like 50 years of power from a CR2032

author: Miha
author_rank: Contributor
timestamp: April 25, 2023, 06:50:33 am
content: Thanks everyone.Using of MOSFEETs is good idea but It can't help with power spikes when we have weak power supply (CR2032). Power spikes can be reduced only by limiting of current (Resistor) or by strengthening power supply (capacitors).Second thing is useless capacitors charging. If I calculated correctly, battery CR2032 (220 mA*h) can charge 10 uF capacitor only 15k times. For my application it is not enough.But good information from @Psi (thanks!), that 1u+0.1uF works good for LIS2DH. Will try this and will try more decrease capacitors value (think about 0.1uF+10nF, or only 22nF).I can use LIS2DH Power down mode, but my application uses also gyroscope, that have no good power down mode.

author: Berni
author_rank: Super Contributor
timestamp: April 25, 2023, 07:29:23 am
content: GPIO pins survive short circuits just fine.The transistors driving the pin have such a high RdsON or such a low channel saturation current that even when sending a logic high into GND they don't let trough more than a few 10s of mA. So the power dissipation is so low that the chips die can cool it.If you want to avoid a pulse of current you can use two GPIO pins. The first one provides power via a 100 Ohm resistor to change up the caps, then the 2nd GPIO pin then provides direct power to it, bypassing the resistor. Multiple IO pins could also be paralleled for more current handling capability (Tho only up to a point, if you try to drive a short circuit with 100 pins simultaneously you will likely kill something).

author: mikerj
author_rank: Super Contributor
timestamp: April 25, 2023, 07:36:05 am
content: Quote from: langwadt on April 24, 2023, 11:33:06 pmAs the capacitor naturally discharges the voltage will drift into the range that likely to turns on both input transistors and cause higher power consumption. Minimising that time is usually a good idea unless more energy is wasted dumping the caps charge.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 25, 2023, 08:03:28 am
content: Quote from: ataradov on April 25, 2023, 12:04:30 amDefinitely agree with this - I once had an accelerometer ( memsic I think) which would get into a state which was unrecoverable via I2C if the power browned out.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 25, 2023, 08:07:18 am
content: The main thing when switching power to devices is to have significantly more capacitance on your power rails than on the load you're switching, especially when you have a high impedance supply like a coin cell. 10uf seems like a lot for a low-power device like an accelerometer.Decoupling is often way over-specced without giving much thought to it - I'd suggest doing tests to see how little you can actually get away with, then using maybe 5x that figure.I wouldn't be at all surprised if 100n or less was just fine.