The circuit section
uses a Type-C port to provide 5V power, employs an ATmega168/328 as the main controller, amplifies the current through an operational amplifier, and uses an on-chip ADC with a TL431 reference voltage source to collect the battery's current and voltage, enabling the monitoring of charging and discharging current and voltage. I/O ports control the enable and current-limiting resistors of a TP4056 to achieve adjustable charging current (30mA steps) for the lithium battery. A PWM output after RC filtering acts as a DAC, which is input to the operational amplifier feedback terminal to control a MOSFET as a constant current source for adjustable current discharging. The main controller controls a 0.91-inch OLED screen and buttons to display and adjust the above functions.
The software section
is a simple program based on Arduino + PlatformIO, quite rudimentary, with the main functions being:
1. Set charging current and prompt when fully charged.
2. Set discharge current and termination voltage and prompt when fully discharged
. 3. Set discharge capacity and prompt when fully discharged.
4. Close the charging and discharging circuit and monitor the real-time voltage and current between the lithium battery and the output terminal.
5. Settings, including
(1) Buzzer enable
(2) Thermistor temperature limit discharge current
(3) Constant current discharge end stage current correction.
The physical display
picture shows the old version PCB, which has a small bug. The new version has fixed it (not tested on the board, but passed the flying wire test). The current measurement principle has been updated (measure voltage -> measure voltage difference), and it has been corrected in the PCB and program (open Current Fix in settings).
Supplement:
This is just for fun. I am not very good at digital and analog electronics. There may be problems in the circuit and software (quite a few). Welcome to criticize and correct. I do not have professional instruments on hand. I used a multimeter to test the current deviation, which was about 0.05A. The charging and discharging function is normal. The statistical data graph is just for fun. When discharging without additional heat dissipation, it is about 0.5A/80℃. I dare not test it higher. The project involves high temperature and lithium battery. Please assess the safety yourself.