Your EasyEDA usage duration is brief. In order to avoid advertising information, this action is not supported at present. Please extend your EasyEDA usage duration and try again.
# Overview
TinyUPS is a simple 5V/2.5A uninterruptible power supply with a li-ion battery as a buffer, a load sharing power path management system and an ATtiny13A for monitoring power supply and battery charge level as well as for communication with the connected device.
- Firmware: https://github.com/wagiminator/ATtiny13-TinyUPS
![IMG_20200429_085806_x.jpg](//image.easyeda.com/pullimage/2XsCuAdfqt9wIi8S0v06BNLV0mbNk2amUA6AiitS.jpeg)
![IMG_20200429_085845_x.jpg](//image.easyeda.com/pullimage/ehw9MdOgYZ1FBT7VzwjljH5wGpZlaYVFoSfBCoGl.jpeg)
![IMG_20200429_085907_x.jpg](//image.easyeda.com/pullimage/kT6kqbDiSMt34Geqa3ajQAtOuR0XCEJVwFSN0zOP.jpeg)
# Hardware
The functional principle is shown in the following block diagram:
![block.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyUPS/master/documentation/TinyUPS_block.png)
## Battery Charger
For battery charging the [TP4056](https://datasheet.lcsc.com/szlcsc/1904031009_TPOWER-TP4056_C382139.pdf) is used. The TP4056 is a complete constant-current/constant-voltage linear charger for single cell lithium-ion batteries. The charge voltage is fixed at 4.2V and the charge current (max 1000mA) can be programmed externally with a single resistor (R3). The TP4056 automatically terminates the charge cycle when the charge current drops to 1/10th the programmed value after the final float voltage is reached. Other features include current monitor, under voltage lockout and automatic recharge.
## Battery Protection
For the battery protection (overcharge, overdischarge, overcurrent and short circuit protection) the [DW01A](https://datasheet.lcsc.com/szlcsc/1901091236_PUOLOP-DW01A_C351410.pdf) is used in combination with two [FS8205](https://datasheet.lcsc.com/szlcsc/Fortune-Semicon-FS8205_C32254.pdf) dual MOSFETs in parallel. The DW01A is constantly measuring the voltage across the battery and the current flowing in (when charging) or coming out (when discharging). If something goes wrong it takes the battery out of the circuit by closing the MOSFETs which act like a switch between the negative side of the battery (B-) and ground. The overcurrent protection works by comparing the voltage drop across the MOSFET with the internal 150mV reference of the DW01A. As the RDS(on) of one FS8205 is around 2x25mOhm, the DW01A would close the MOSFET at 150mV/50mOhm = 3A if only one FS8205 were used. By using two FS8205 in parallel, the resistance is cut in half, so the DW01A shuts down at 150mV/25mOhm = 6A and one FS8205 must only handle half of the current (3A) which is well within its specs. In this way, up to 6 amps can flow from the battery into the boost converter with a maximum voltage drop of 150mV.
## DC/DC Converter
To step up the voltage to 5V the [FP6277](https://datasheet.lcsc.com/szlcsc/Feeling-Tech-FP6277XR-G1_C88312.pdf) low-cost synchronous boost converter is used. Instead of a diode that is used in conventional boost converters, it switches a second built-in MOSFET in sync with the first via the PWM signal. This significantly increases efficiency and thus higher output currents are possible. Note that he EP plate of the FP6277 requires a good conductive connection to the corresponding plate on the PCB.
## Power Path Control
Although it would be possible to supply the connected device via the battery and charge the battery at the same time, this is absolutely not a recommended way. In this case, most charging ICs such as the TP4056 are unable to determine whether the battery is fully charged because the current never drops below 1/10th of the programmed charging current value which would tell the device to terminate the charging cycle. The battery would be charged forever, which would destroy it in the long run. A load sharing system was therefore integrated, which separates the battery from the load when an external power is present. While the battery is being charged, the connected device is powered by the external power supply. For more details on the working principle of the load sharing power path management circuit refer to [Microchip's Application Note 1149](http://ww1.microchip.com/downloads/en/appnotes/01149c.pdf).
## Microcontroller and COM Port
The [ATtiny13A](http://ww1.microchip.com/downloads/en/DeviceDoc/doc8126.pdf) is used for monitoring power supply and battery charge level as well as for communication with the connected device. The ATtiny tells the connected device that it has to shut down by pulling the SHUTDOWN line to LOW. The SHUTDOWN pin of the tinyUPS is an open collector output. The connected device must have an internal or external pullup resistor on the SHUTDOWN line! This is necessary because of the different voltage levels. The connected device can request a shutdown by setting the REQUEST line to HIGH. The REQUEST line can further be controlled via the built-in button.
# Software
## Firmware for the Microcontroller
The control parameters are defined at the beginning of the code and can be adapted to the needs of the user.
```c
// Control parameters
#define SHUTDOWNLEVEL 3000 // supply voltage threshold in mV for auto shutdown
#define USERPOWERLEVEL 3500 // supply voltage when user is allowed to power on
#define POWERONLEVEL 4300 // supply voltage threshold in mV for auto power on
#define BOOTUPTIMER 60 // time in seconds the connected device needs to boot up
#define SHUTDOWNTIMER 30 // time in seconds the connected device needs to shut down
#define REQUESTTIMER 20 // duration in 100ms request/button has to be low to shut down
```
If external power is connected to the tinyUPS the input voltage or vcc of the ATtiny13 is delivered by this source, otherwise by the battery. The ATtiny13 monitors the input voltage and tells the connected device to shutdown by pulling the SHUTDOWN-line low when the input voltage falls below a certain threshold (SHUTDOWNLEVEL). This happens when the external power source is diconnected or disabled and the battery level falls below this threshold. After waiting a certain time (SHUTDOWNTIMER) to allow the connected device to safely shut down, the ATtiny13 deactivates the boost converter and turns off the power to the connected device.
A shutdown can also be initiated by pressing and holding the button or by setting the REQUEST-line to high (>0.7V) for 2 seconds. After such shutdowns the power will not be turned on again automatically.
```c
// Check if power has to be turned off
while(1) {
vcc = getVcc(); // get battery voltage
if (vcc 3) + 1; // set timer for bootup
```
The ATtiny13 spends most of the time in power-down sleep mode to save energy. The watch dog timer wakes it up every 8 seconds. It will also wake up if the button was pressed or the REQUEST-line was changed (pin change interrupt). After doing its stuff the ATtiny13 sleeps again.
```c
// Watch dog timer intervals
#define WDT1S (1
Forked project will be set private in personal workspace. Do you continue?
Clone
Project
The Pro editor is about to be opened to save as. Do you want to continue?
private message
Send message to wagiminator
Delete
Comment
Are you sure to delete the comment?
Report
ATtiny13 TinyUPS SMD
Simple 5V/2.5A Uninterruptible Power Supply (UPS) for RaspberryPi and other Devices
Announcer: Stefan Wagner
Creation time: 2020-03-30 18:59:04
Published time:
2022-04-07 19:57:34
*
Report type:
Please select report type
*
Report reason:
Please fill in the reason for your report and the content is 2-1000
words
*
Upload image:
+
Upload image
*
Email address:
Please fill in your email address
Report
*
Report type:
Please select report type
*
Report reason:
Please fill in the reason for your report and the content is 2-1000
words
*
Upload image:
+
Upload image
*
Email address:
Please fill in your email address
Report
Submitted successfully! The review result can be viewed in the personal
center, review notification.
Kind tips
Your EasyEDA usage duration is brief. In order to avoid advertising information, this action is
not supported at present. Please extend your EasyEDA usage duration and try again.
Share
Project
Copy
Copy
Scan the QR code and open it on the mobile terminal