3
\$\begingroup\$

I'm trying to understand some apparently anomalous observations of the discharge profile of a 1S lithium battery. I'm using this battery to run a Raspberry Pi Zero W, back-powering the Pi via the +5V pins of the GPIO header (I'm not using anything on the Pi that needs 5V). My goal is to detect when the battery needs to be recharged.

To support hot-swapping the batteries, my device includes multiple power connectors feeding its power rail. Each connector has a diode in series to prevent large current flows between batteries.

To allow the Pi to monitor battery voltage, the power rail is connected through a voltage divider to an input channel of an MCP3002 ADC, taking VREF from the Pi's 3V3. I've written some code which reads the ADC and adjusts for the divider and estimated diode drop to produce a voltage that closely matches what my voltmeter shows.

My understanding is that after a full charge the battery voltage should decrease from ~4.2V to ~3.7V, then remain steady for most of the discharge, then fall off until the cell is depleted. The actual results I'm seeing are these: That's two trials (red and blue) with two different batteries; the solid line is a 1-hour moving average. The end of the data is when the Pi died. There is no appreciable decrease in voltage to warn of the impending cutoff.

The battery is said to contain a "protection board", and a little exploratory surgery reveals that this is implemented with a DW01 and a pair of MOSFETs in what appears to be the application circuit from the datasheet. I'm not an EE, but I was unable to find any indication in that document that such a circuit would provide voltage regulation.

I'm stumped.

Edit: It's been suggested that the Pi's regulator wants 5V, and may be causing trouble at the low end of the battery voltage. From the the Pi's schematic, the regulator is a PAM2306. Looking at the datasheet for that part, it seems like it should be happy with anything from 2.5 to 5V, and it explicitly says that it allows the use of a single lithium cell.

Edit 2: Testing @mkeith's hypothesis about VREF dropping in parallel with VBAT gave me the following data: Because the ADC is essentially reporting the ratio between the sampled voltage and VREF, and because as they drop in parallel that ratio remains constant, the reported battery voltage remains steady as the actual voltage drops.

I think my solution is to either regulate VREF down to something that will remain stable until the battery dies (which is a pain since the PCBs are already made), or just accept that the result is unreliable below 3.65V or so.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Yes the reg will work down to 2.5V but it won’t output 3.3V since it has no boost capability. \$\endgroup\$
    – Frog
    May 26, 2021 at 8:37
  • 1
    \$\begingroup\$ What are you powering the ADC from? \$\endgroup\$
    – Alnitak
    May 26, 2021 at 9:06
  • 2
    \$\begingroup\$ @Alnitak It takes Vref from the Pi's 3.3V rail. \$\endgroup\$
    – John Auld
    May 26, 2021 at 9:17
  • 2
    \$\begingroup\$ Next time, log the battery current as well. I expect it's fairly steady until the flattened portion, when it starts falling off. \$\endgroup\$
    – user16324
    May 26, 2021 at 14:58
  • 1
    \$\begingroup\$ That discharge curve is kind of weird, so I can totally sympathize with you for being perplexed. You are right to be perplexed. \$\endgroup\$
    – user57037
    May 27, 2021 at 2:32

2 Answers 2

9
\$\begingroup\$

The things other people are saying in their answers are true. The regulator is likely dropping out and may eventually cut off, etc. But I think there is one more piece to the puzzle.

I have seen this before. The ADC data are wrong. Once the regulator drops out, VCC is no longer 3.3V. VREF for the ADC is also no longer 3.3V. So all the voltages you calculate after about 20 hours are not the true voltage. What happens is, basically the ADC returns a fixed result for any VBAT lower than around 3.62 volts or so (looking at your graph).

A 12 bit ADC returns Vin/Vref * 4095. If you have a divider on VBAT, then Vin = VBAT * divide_factor.

And Vref = VBAT-VDO where VDO is the dropout voltage.

So the ADC returns 4095 * VBAT * divide_factor / (VBAT - VDO).

VDO is approximately constant, but since it is small this result changes very little with VBAT.

To confirm, hook the unit up to a lab power supply and take some data at different voltages.

All the data after about 20 hours are incorrect because VREF is no longer 3.3V.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ That makes a lot of sense, and a little spreadsheet modeling of your idea produces a curve that looks a lot like what I have observed. I don't have access to a variable power supply (other than the batteries), but I can probably rig another Pi to monitor 3V3 on the first one to test your hypothesis. \$\endgroup\$
    – John Auld
    May 27, 2021 at 5:19
  • 1
    \$\begingroup\$ Good idea. You can also just charge the battery in stages. Charge it a bit, compare volt meter with reported voltage, charge a bit, compare, etc. \$\endgroup\$
    – user57037
    May 27, 2021 at 5:27
  • 1
    \$\begingroup\$ I ended up just manually sampling VREF and VBAT during the flat part of the curve. I'll update the question with the results. TL;DR: you're right. \$\endgroup\$
    – John Auld
    May 27, 2021 at 22:40
2
\$\begingroup\$

you're powering a device which expects 5V, there is an on board voltage regulator which uses that to create 3V3 for the chip itself. Hardware specs here. At 3V6 you are probably very close to the dropout voltage of the internal regulator. You only need to drop below the dropout voltage for the smallest amount of time (for instance caused by a momentary spike in load current, which gets more important as the cell internal impedance rises), and the pi will reset. So you never get to the last part of the discharge curve.

The datasheet for the regulator is here. Although the input voltage range is specified as 2.5V minimum, the sheet clearly states that this is a step-down regulator. So that minimum will not apply for 3V3 out.

I couldn't find the dropout voltage explicitly stated, but I did notice this (page 11):

100% Duty Cycle Operation As the input voltage approaches the output voltage, the converter turns the P-Channel transistor continuously on. In this mode the output voltage is equal to the input voltage minus the voltage drop across the P-Channel transistor ...

So this is clearly telling us that the regulator will not step up. As you get too close to 3V3, your output will fall below 3V3 at some point.

This explains your measured observations very well.

\$\endgroup\$
4
  • \$\begingroup\$ I hadn't thought of that, although the datasheet for the regulator suggests that this is not the problem. I'll update the question with the additional information. \$\endgroup\$
    – John Auld
    May 26, 2021 at 8:35
  • \$\begingroup\$ what regulator is on the board? what is the dropout according to its datasheet? \$\endgroup\$
    – danmcb
    May 26, 2021 at 8:41
  • 1
    \$\begingroup\$ I've added some additional detail to the question. \$\endgroup\$
    – John Auld
    May 26, 2021 at 8:45
  • \$\begingroup\$ I also edited my answer. See above. \$\endgroup\$
    – danmcb
    May 26, 2021 at 8:54

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.