1
\$\begingroup\$

Sorry for the newbish question. I didn't find here any questions and answers that can help me with this issue so I decided to ask it.

I'm designing my first circuit with STM32L071KZ microcontroller and it powers via VBUS(USB, 5V) as a primary supply and 2xAA alkaline batteries(3V) as secondary supply.

the power supplies are regulated to 3.3V so the microcontroller and the rest of the circuit are powered by regulated voltage and not directly from VBUS or batteries.

I would like to monitor the batteries voltage level and when it drops below the specific threshold(For example, 2.2V) I will indicate it to the user.

I wonder how to wire things up. microcontroller's VDD is 3.3v and it equals to VDDA. If I got it right, when I will sample the voltage of the battery I will get a constant value because the sample is the ratio between the VDD and VDDA.

This is my power circuit block diagram to make things clear:

enter image description here

Thanks alot!

\$\endgroup\$
7
  • \$\begingroup\$ Do you really have to supply the controller with 3.3 Volts? It would happily run on anything between 1.8V and 3.6V, and it has it's own power supply supervisor facilities, see Programmable Voltage Detector and Brown Out Threshold in the Reference Manual. Of course if you need exactly 3.3V outputs, it does not apply. \$\endgroup\$ Jul 25, 2018 at 11:03
  • 2
    \$\begingroup\$ You have the ADC perform a measurement on the internal bandgap voltage reference - much the same as my answer here to a question about doing this in a PIC. Your STM32's reference is different (1.224V instead of 1.024V), but the principal is the same. \$\endgroup\$
    – brhans
    Jul 25, 2018 at 11:29
  • \$\begingroup\$ @brhans measuring internal reference prior to measuring analog input might help improve accuracy somewhat (through the calculation of actual Vref+ from Vrefint). However that's not what your referenced answer is about. \$\endgroup\$
    – Maple
    Jul 25, 2018 at 20:35
  • 1
    \$\begingroup\$ @Maple - my referenced answer describes how to use the internal bandgap in order to measure the micro's Vdd. It's not using that bandgap as the ADC's reference. Vdd is the ADC's reference and the bandgap is the input being measured. Since the bandgap is constant and Vdd is varying, the ADC's result is used as a measure of Vdd. No voltage dividers are required. \$\endgroup\$
    – brhans
    Jul 25, 2018 at 20:59
  • \$\begingroup\$ That is exactly what I said, assuming Vref+ is calculated this way (not Vdd or Vdda) prior to measuring actual ADC input. Vdd/Vdda are not ADC references in STM32, Vref+ is. The 1.224V you mentioned above is Vrefint, and it cannot be used as ADC reference at all. \$\endgroup\$
    – Maple
    Jul 25, 2018 at 21:30

1 Answer 1

2
\$\begingroup\$

You need to make sure the batteries you use will never exceed 3.3V. If that is a possibility with fresh batteries you should consider adding voltage divider to bring ADC input down to acceptable range. This will increase power consumption from the batteries though. The usual cure for this is to add MOSFET switch between the battery and ADC, controlled by another MCU pin. The MCU will open the switch periodically, measure voltage and close it back. See this question for example.

Also the diode between Boost DC-DC and Vdd will drop some voltage (depending on current and diode), so you might want to adjust boost output to slightly higher voltage.

Note that Boost converter will drain battery even if USB is connected. Furthermore, your LDO must produce higher voltage than DC-DC for diode to close, something like 3.4~3.5V

So, i would suggest either use barrel DC adapter and a jack with mechanical switch that will disconnect battery when power plugged in, or another MOSFET switch that will disconnect battery when USB voltage present. See this question for relevant discussion.

Other than that your circuit looks OK.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.