
Main functions: In the event of a power outage, the battery continues to provide power and notifies the NAS system to shut down via USB-serial port.
Initially designed to fit a power bank casing, due to size and heat dissipation considerations, three 18650 power batteries were used, with an output current of less than 3A, roughly sufficient for a small host.
Three batteries were chosen because a BM3452 12V electric screwdriver was readily available for disassembly, and the three batteries, when fully charged, have a voltage of 12.6V, allowing for direct output. However, using three batteries increases circuit complexity: When the main power supply is 19V, the Buck converter step-down is used; when the main power supply is 12V, the Buck circuit does not work, the inductor and MOSFET consume energy, and there is a voltage drop of about 0.5V, preventing the battery from fully charging (this is not necessarily a bad thing, considering the limited chance of power outages, reducing battery voltage extends battery life).
2. The output battery voltage range is from 9V to 12.6V. To achieve a stable 12V output, Buck-Boost is more suitable. The JW3651 is selected, with an output of 3A.
3. The UPS needs to communicate with the host computer. The inexpensive PY32F002A is chosen, paired with the mature CH340C, avoiding the compatibility and stability issues of Wi-Fi and Bluetooth.
4. Real-time monitoring of the battery pack and individual battery voltages allows for the selection of appropriate power paths based on input, output, and battery pack conditions.
1) When the main power supply is available, the voltage is stepped down to 12.6V via a Buck converter for direct output. If the battery pack voltage is lower than the predetermined voltage, charging is initiated simultaneously.
2) When the main power supply is lost, the battery pack outputs 12V via a buck-boost converter
. 3) When the battery pack voltage is between 11-12.6V, direct output bypasses the inductor and two MOSFETs, resulting in higher efficiency.
Actual board testing revealed several issues. After adjustments using jumper wires (the PCB layout has been modified but not verified), the design functionality was achieved.

Problems, takeaways, and regrets:
1. Choosing three batteries is not cost-effective. With two batteries, buck charging and boost power supply are possible; with four batteries, boost charging and buck power supply are possible, simplifying the circuit and control logic. In actual testing, the battery voltage rarely exceeds 12V, with boost being the primary voltage. A Boost chip could be used instead. The Buck chip needs to provide both external power supply and battery charging current simultaneously. The measured SCT2450 inductor heats up to approximately 60 degrees Celsius.
2. Due to the presence of the protection board, there is sometimes a significant voltage difference between the battery negative terminal and ground, which makes it difficult to measure the battery voltage. The final solution is to unify the voltage division to the battery negative terminal and measure the negative terminal voltage separately. During charging and discharging, the current is reversed, which may result in negative voltage. After raising the voltage, the input is

3. The charging current limit design is 0.56A, but it actually reaches 1A. The analysis shows that the PMOS is not turning off quickly enough. When R38 is 1K, the waveform is as shown in the figure. The rising edge is relatively slow, which delays the turn-off. It can be improved by replacing it with a larger package

and a smaller resistance value resistor. 4. The communication function is not yet fully completed. At present, it realizes the periodic sending of input and output and battery voltage information through the serial port, and receiving commands from the host and returning corresponding status information. The host program is relatively simple and can be written according to different NAS platforms.
5. Future upgrade ideas: replace with a larger box, a 4-cell scheme, boost charging with low current, buck power supply, replace the protection chip with one with equalization function (BM3451, pin 28), use OLED to display the status, and use IN3221 to detect input and output voltage and current.
6. Regret: There has never been a power outage.