Page 1 of 1

Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 7:16 am
by giammi119
Hello everybody,
I have been making projects with various microcontrollers for a few years. Up until now I had been using a latching circuit (taken from the arduino forum) which works for microcontrollers working at 5v.
IMG-6390.jpg
IMG-6390.jpg (77.68 KiB) Viewed 2800 times
From this I started designing a circuit for the blue pill STM32 to power it with a Li-Ion battery. Below is my circuit.
help.png
help.png (24.54 KiB) Viewed 2800 times
The MOSFET would allow me to manage the power supply for the step-up module which would power the microcontroller at 5v.
Unfortunately testing it doesn't work. I would like to ask you for advice to be able to make it work.

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 7:35 am
by ag123
typical lipo batteries are 4.2v max I think, so you need a 3.3v LDO that would take 4.2v and supply 3.3v to the chip.
e.g. and LDO that supplies 3.3v probably fit the use case
https://www.microchip.com/en-us/product/MCP1700
https://www.digikey.com/en/products/det ... FTO/652685
there are many
https://www.aliexpress.com/wholesale?ca ... t=ldo+3.3v

some used a regular diode as a 'hack', the diode needs to remove 0.6v across itself, so lipo at 4.2v - 0.6v = 3.6v, this is the max vdd specified on stm32 spec sheets. But for normal purposes, an LDO is the more formal approach.

if you are powering it from usb i.e. 5v, then definitely use a LDO that supplies 3.3v
e.g. LM1117 3.3v
https://www.ti.com/product/LM1117
again there are many options for this

for stm32 it is quite easy to buy boards in the wild
https://www.aliexpress.com/wholesale?ca ... =stm32f401
then there are original offerings from ST itself
https://www.st.com/en/evaluation-tools/ ... oards.html
https://www.digikey.com/en/product-high ... ent-boards

and more from various vendors
https://www.adafruit.com/product/4382
https://store.micropython.org/
https://www.olimex.com/Products/Duino/S ... e-hardware
https://www.olimex.com/Products/ARM/ST/

edit:
for blue pill, it typically takes power directly from usb 5v and it has a LDO on board. If you are planning alternate supply, it is probably to supply the 3.3v directly e.g. from a lipo battery across a LDO.

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 8:24 am
by giammi119
Hi! thank you for reply.
My idea was to use a step up boost converter 5v to feed the blue pill after the mosfet and manage the power supply.

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 8:33 am
by ag123
i think boost converters are somewhat less stable vs buck converters (step down).
I'd think it is 'easier' if 5v usb charges a lipo battery (with a lipo charger chip), then between lipo battery 4.2v it supplies stm32 via a LDO 3.3v.
I think this is a 'typical' setup for 'portable' devices that perhaps run on lipo batteries.

some of the boards mentioned prior probably has that built on board, not all have that lipo charger though
the (stm32) duino offerings from olimex seem to have that feature

I've been thinking it may be possible to take lipo charging modules like these
https://www.aliexpress.com/wholesale?ca ... ger+module
and connect a diode or LDO 3.3v downstream of the lipo battery to supply the stm32.

A thing is many of those 'blue pill' type boards has LDOs that has a rather high dropout, some of them use ams1117
http://www.advanced-monolithic.com/pdf/ds1117.pdf
that has a dropout of 1V which would work only with a 5v supply.

for a lower dropout those mentioned prior would need to be explored.

on another note you may want to explore a voltage doubler rather than a boost converter
https://en.wikipedia.org/wiki/Voltage_d ... harge_pump

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 5:04 pm
by GonzoG
@ag123
Blue pill (as most other boards) has 3.3V LDO, so supplying it with 5V from boost converter isn't a problem.

But supplying 3.3V LDO with Li-ion/Li-po battery isn't a good idea. LDOs have a voltage drop of 0.4-1V and Li-ion batteries work in 3-4.2V range, so you won't get stable 3.3V.

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 5:18 pm
by ag123
i did some simulations with buck converters
https://github.com/ag88/jbuckconv
it turns out that if the currents are low i.e. load resistance is high say like 1k ohm and above, the inductor plays very little role in the buck converter and that it is mostly a capacitor that discharges which supply the load.
I'm not sure about boost converter though.
hence, i think a voltage doubler could be evaluated to see if it helps, but I'm not sure though.

There are some thoughts that as li-po batteries is charged to a flat 4.2. volts, a *hack* is to simply use a diode that drops 0.6v, so that it gives 3.6v the max allowable for stm32 (at least the f103). Other means could be to use LDO that has low dropouts, many of the mosfets based LDO can give as low as 300mV while supplying 250 mA, that gives it a RDS(on) of about 1.36 ohms, I'd think that's still manageable.
my guess is that some of the low dropout LDOs may still be usable for the purpose e.g.
https://www.microchip.com/en-us/product/MCP1700
another thing is that lipo batteries tend to have quite significant capacity, even a 1000 mAh battery I'd guess could sustain the 4.2-3.7 and maybe a little lower voltages for quite a while, and given the rather low power consumption of stm32, this may be feasible. However, it may not be true if the lipo battery is as well driving other power hungry devices such as an LCD where the backlight is held on.

I've thought about a scheme something like such, stm32 could literally pwm a P-channel mosfet at 5 volts from usb, this pwm is used to charge the lipo battery upstream, this could possibly save the lipo charger, and the LDO downstrem from the li-po battery supplies the stm32. This could work if the lipo battery is after all charged say to around 3.7-4.2v. The scheme could fail if the lipo is too far discharged.
However, as dedicated lipo chargers are rather cost effective these days, it may be easier to just use a dedicated charger upstream at the usb side.

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 7:41 pm
by ozcar
GonzoG wrote: Fri Aug 12, 2022 5:04 pm @ag123
Blue pill (as most other boards) has 3.3V LDO, so supplying it with 5V from boost converter isn't a problem.

But supplying 3.3V LDO with Li-ion/Li-po battery isn't a good idea. LDOs have a voltage drop of 0.4-1V and Li-ion batteries work in 3-4.2V range, so you won't get stable 3.3V.
I wonder to what extent you can run the blue pill on a voltage less than 3.3V?

The datasheet for the F103 processor says it can run on 2.4V (even 2.0V if the ADC is not used).

Re: Power management on stm32 blue pill

Posted: Fri Aug 12, 2022 8:05 pm
by GonzoG
I've run F103 on 2.6V without any problems.
But if you intend to use ADC, it's a problem as ADC's upper voltage limit is limited by Vcc and you need to account for it.