4
\$\begingroup\$

I'm trying to design a simple device based on ESP32 board, which will control stepper motors from a battery pack (26650 series).

I'm struggling with the battery level control part (red/blue colour on the diagram) and I'm not sure if I designed it correctly.

The 100uf capacitor marked on the diagram is a Aluminium Organic Polymer Capacitors 25V 100uF 20% ESR=40mOhms

Battery level resistors: Vishay

I'm aware that I should use a capacitor for the stepper drivers, but I'm not sure whether or not to use an additional capacitor for battery level readings?

enter image description here

\$\endgroup\$
  • 2
    \$\begingroup\$ Few basic things: 1) Your voltage divider circuit will drain the battery by itself (about 1mA). 2) You are unlikely to get any sensibly correct state-of-charge estimation out of this reading. \$\endgroup\$ – Eugene Sh. Apr 9 at 18:08
  • 1
    \$\begingroup\$ You want the battery check voltage divider to draw little current, so I think you need much larger resistors in it. \$\endgroup\$ – zeta-band Apr 9 at 18:10
  • \$\begingroup\$ @zeta-band, I chose these resistors especially based on their low power rating (and tolerance) 1/10W(0.1%) \$\endgroup\$ – Artur Filipiak Apr 9 at 18:23
  • 1
    \$\begingroup\$ "Low power rating" has nothing to do with anything here. Also you mean 26650 in series, not in parallel, right? \$\endgroup\$ – Ale..chenski Apr 9 at 18:33
  • 1
    \$\begingroup\$ What is the purpose of monitoring? Do you want to monitor the overall battery voltage over long time, or do you need to know the instant voltage drop when your motors are actively running? \$\endgroup\$ – Ale..chenski Apr 9 at 18:42
7
+50
\$\begingroup\$

If you really needed to save on power and you put the microprocessor to sleep, using a circuit with a p-ch mosfet could save power and not drain the battery while the microprocessor is sleeping. Otherwise a high impedance resistor divider would be appropriate.

enter image description here

Source: Low current battery monitoring

The ADC looks linear as shown below. I could not find any information on the impedance of the ADC an any of Expressif's documentation, so I'd assume that the impedance is low (100k worst case) and design around that.

enter image description here
Source: https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/index.html

Make sure you follow the ADC guidelines:

2.1.6 ADC It is recommended that users add a 0.1 uF filter capacitor to a pad when using the ADC function.
• Pins SENSOR_VP or SENSOR_VN will trigger an input glitch lasting for 80 ns once SARADC1, or SARADC2, or Hall sensor is initialized.
2. Schematic Checklist and PCB Layout Design
• Pins SENSOR_VP or SENSOR_VN is recommended for use as ADC.
• If SENSOR_VP and SENSOR_VN are used as GPIOs, while ADC is supported by other pins in the circuit design, users need to do settings in software to avoid the input glitch.
Source: https://espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf

\$\endgroup\$
  • \$\begingroup\$ Well... as far as I can see, the ADC on ESP32 seems to be far away from linear (it's noisy and need some sort of deep calibration github.com/espressif/esp-idf/issues/164 ). But it's enough for me to estimate battery life. Thanks for the idea of switching on/off the measuring circuit (voltage divider) when needed. \$\endgroup\$ – Artur Filipiak Apr 28 at 11:53
4
\$\begingroup\$

Your idea is fine for a simple battery level detector but there needs to be some changes. The ADC on the ESP32 has an input range of 0 to ~3.3V. This means your divider needs to be designed so at maximum battery voltage the value at the GPIO pin is not outside this range. If I understand your schematic correctly you have a maximum of 8.4V from the battery and a minimum level of 5V? In this case your divider should be set up to output just under 3.3V with 8.4V across it.

V(out) = V(in)*(R2/(R1+R2))

(R2 corresponding to the blue resistor in your schematic and R1 the red resistor)

use 8.4 for V(in) and 3.3 for V(out) and we get a ratio of R1 = R2 * 1.55

You want your current to be low, so choose higher resistor values. The power rating of the resistor represents the maximum power the resistor COULD absorb before burning up. It is not the power they consume at any voltage or condition, which is defined by Ohms law. I would suggest resistors in the hundreds of kilohm or a few megaohm that satisfy the equality above. For example we can use your previous values and multiply by 100 to get 570k and 330k as a good solution. Then just test for an ADC value that represents 5V which is about 1.8V at the GPIO pin.

In regards to the capacitor, it would reduce noise at the pin by adding a small (100nF) capacitor from the GPIO pin to ground. Below is a schematic of these suggestions, you may even consider higher resistor values.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Thanks for the answer, but I found ADC pins on ESP32 board very inaccurate (non linear?). I'll have to investigate on this topic further. Thumb up for providing me some highlights regards resistors, thanks! \$\endgroup\$ – Artur Filipiak Apr 17 at 20:07
  • \$\begingroup\$ If you are NOT planning to draw less than 1W load or run more than 20h, there is no need to worry about V sense draining the battery, but you do need to learn about errors from noise. filters, shielding, twisted pair etc and Ohm's Law. Your example in question draws only 7 mW max at 8.4V \$\endgroup\$ – Sunnyskyguy EE75 Apr 22 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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