# LX-2BUPS Upgrade
![top](https://hackmd.io/_uploads/HJNd7AGfC.jpg)
Cheap 5V 3A UPS boards from AliExpress, what could possibly go wrong?
## What's on the board?
- the 1-cell charging IC is linear (TP4056 in SO8) - https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/TP4056.pdf
- The actual supply uses a XYSemi XR2981 boost converter IC - https://cdn.hackaday.io/files/1829407826904960/Xysemi_XR2981.pdf
- the external diode of the boost converter is an SS54 Schottky diode - https://www.farnell.com/datasheets/2920575.pdf
- the output indicator LED is red (lowest V_Fwd)
- the cells to be used with it are in this case NCR18650B - https://www.imrbatteries.com/content/panasonic_ncr18650b-2.pdf
## What's wrong?
In a nutshell, this circuit will deep discharge your cells to 2.0V or below. Why is that?
Setting temperature effects aside, there should be no gradual discharge below 3.0V. At this point they are way below 10% remaining charge (e.g. 3.4 mA discharge would be 0.001C, above the green 0.2C discharge curve below).
![image](https://hackmd.io/_uploads/S16zJAMMC.png)
Next, XR2981 does not stop operating until is reaches 2.6V typ. (UVLO low threshold), and does so using 140µA + whatever is needs to keep the output at its target voltage, with less-than-ideal light-load efficiency.
![image](https://hackmd.io/_uploads/SktpJ0zGA.png)
With an overdriven output, its quiescent current of Iq = 140 µA is also rather large, and does not include the current through the voltage divider.
The feedback bias current is not specified and the only recommendation available is to have around 10 kOhm:
![image](https://hackmd.io/_uploads/H1C5W0ff0.png)
With the bias current around 10-100 nA (made-up range based on other datasheets, like LM2596) and more daring 100 kOhm, that'd give us 1-10 mV error, which is a fraction of the error of the internal reference used for the feedback circuit, and thus more than acceptable. So 100k it is. Here's some precedent for definitely-not-10k divider values: 334 (330k) and EIA-96 code [03D](https://kiloohm.info/eia96-resistor/03D) = 105k, without any parallel capacitors to adjust for feedback pin capacitance:
![nqAQR](https://hackmd.io/_uploads/S1VWG0zGR.jpg)
https://electronics.stackexchange.com/questions/655924/datasheet-xr2981
(also note that the datasheet calls for a 10A rated inductor, specifies a 12A maximum switch current, but then recommends a 5A Schottky diode. Granted, it can handle 5A average, but at lower temperatures, the forward characteristics are indeed unfavorable, and a better diode, or at least a set of two SS54 is clearly preferable when operating at cooler temperatures. At elevated temperatures, the diode reverse leakage may once again increase the no-load current as charge trickles back from the output to the cell).
## Time to fix it.
Two things have to happen:
- prevent deep discharge
- reduce discharge rate while the unit is sitting around doing nothing (it has no off switch...).
Before-after:
![LX-2BUPS before_after](https://hackmd.io/_uploads/HJipQ0Mf0.jpg)
Let's apply the changes highlighted below:
![mods](https://hackmd.io/_uploads/rymfERGzR.jpg)
### Remove the LED resistor R8
R8 was 10k and will later be replaced it with 100k (5V) or 330k (12V variant).
### Swap LEDs D2 (blue) and D6 (red)
Blue leds have a higher threshold voltage, about 2.5-2.6V vs. 1.8V of the red variety. This is necessary since the booster Schottky diode always provides a current path and has inherently high leakage combined with low forward voltage at microamp values. Expect < 0.1V to drop across it. This is why the red LED could dischage a cell to below 2.0V.
### Upgrade the voltage divider R7, R9
Change values from 30k + 10k to 300k + 100k (1% or better).
### Add MAX809 / MCP809T-315I/TT (3.15V)
MAX809 has a lower quiescent current, but MCP809 was available on ebay.
https://ww1.microchip.com/downloads/aemDocuments/documents/APID/ProductDocuments/DataSheets/11194c.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/MAX803-MAX810Z.pdf
- Lift up XR2981 pin 5 off the PCB carefully with <= 290°C, keep stress to package minimal. The pin doesn't need to point up, just lift if off the pad by a few tens of a mm and wick away the solder. Add a bit of flux paste to make clean-up easier.
- Clean region with alcohol and cotton swab, apply a small patch of Kapton tape where the SOT23 pin 2 will go to isolate it from GND.
- Solder MCP809 SOT23 pin 3 onto the scraped and pre-tinned via barrel next to pin 5. (The via barrel connects directly to input voltage rail which Q1-Q4 switch to BAT+ when USB is not connected)
- Solder MCP809 SOT23 pin 1 to the exposed power ground.
- Bridge XR2981pin 5 to MCP809 pin 2 with 0603 and 0805 resistors (values < 10k, but can also be 0R).
![photo_2024-05-03_22-02-08](https://hackmd.io/_uploads/HJ4WDAMMA.jpg)
And that's it.
The board now emits a dim blue glow when it's powered (LED current is 20-25 µA) while mostly discharging the cells through XR2981 Iq and occasional bursts of operation. At 5V output, the 400k divider uses another 12.5 µA, resulting in 200-220 µA total average no-load current.
## Addendum: on-board over-discharge protection
So far overlooked are U2, U3 in "CPC5" packages:
XB7608A "One Cell Lithium-ion/Polymer Battery Protection IC" - http://www.szyucan.com/upfile/IC-PDF/XB7608A.pdf)
![image](https://hackmd.io/_uploads/r1uA5UQzC.png)
http://www.szyucan.com/article_read_543.html
The specs of this device (and a replacement like [RY2203](https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc/2110272030_RYCHIP-Semiconductor-Inc--RY2203_C2908111.pdf)) promise an overdischarge cut-off at 2.3-2.5V. However, when that threshold is reached, the device does not isolate the cell completely:
![image](https://hackmd.io/_uploads/Bk2P68XGC.png)
The parallel connection of U2 and U3 yields a 12.5 kOhm resistance between their terminals when tripped. Unsurprisingly, this also doesn't stop further trickle discharge to 2.0V and below. On the bright side, the additional 8-12 µA consumed by this protection circuitry is more minor.
## Looking elsewhere
There are definitely better (albeit not necessarily cheaper) solutions out there. Below is a selection of power bank ICs with the requisite four LED bar indicator and pushbutton on/off control, but at this point it's probably more attractive to procure a complete power bank PCB for a price similar to the original "UPS" board analyzed above.
- [MP2698](https://www.monolithicpower.cn/cn/documentview/productdocument/index/version/2/document_type/Datasheet/lang/en/sku/MP2698/) "ALL-IN-ONE SOLUTION IC W/ 3.6A BOOST AND 5.0A FAST CHARGING"
- [MP2696A](https://www.monolithicpower.com/en/documentview/productdocument/index/version/2/document_type/Datasheet/lang/en/sku/MP2696A/) "SW CHARGER W/ I2C CONTROL, 3A BOOST"
- [MP2639B](https://www.monolithicpower.com/en/documentview/productdocument/index/version/2/document_type/Datasheet/lang/en/sku/MP2639B/document_id/4934//) "1S Cell Li-ion or Li-polymer Switching Charger Compatible with Wide Input Range and Integrated Programmable OTG"
For example, MP2696A has a no-load Iq = 1mA but with an extra microcontroller that handles the no-load detection and checks whether the target device (e.g. a Raspberry Pi) is in shutdown, the UPS can switch to idle mode with 25µA current draw.
![image](https://hackmd.io/_uploads/HJlKowXGR.png)