TP4056 18650 Charging Circuit: PROG and DW01A Protection

Projeler Beginner 12 min read Published:
TP4056 ile 18650 şarj devresi: PROG direnci hesabı ve DW01A koruma

To build an 18650 charging circuit with the TP4056, you connect a resistor (RPROG) between the IC’s PROG pin and ground; this resistor sets the charge current. Both datasheets used in this article give the same formula: IBAT (mA) ≈ 1100 / RPROG (kΩ). Accordingly, 1.1 kΩ gives approximately 1000 mA and 2.2 kΩ approximately 500 mA. The IC terminates charging by holding the battery at 4.2 V. However, it does not protect the battery against over-discharge or short circuits. For that, a DW01A protection IC and two N-channel MOSFETs are added alongside it. Below you will find the schematic, the resistor calculation, the LED states and the answer to the question most often asked on forums: “can a load be connected while charging?”

The values in this article are taken from the TP4056 (TPOWER), TP4056X (Top Power ASIC) and DW01A (Puolop) datasheets. The two charger ICs use the same pinout, but some thresholds differ. Where they differ, the IC being discussed is stated explicitly.

Single-cell Li-ion charging circuit schematic with the TP4056: 5 V input, 10 µF capacitors, PROG resistor, red CHRG and green STDBY LEDs, TEMP pin connected to ground
Basic TP4056 charging circuit. Because the TEMP pin is connected to ground, battery temperature is not monitored; RPROG sets the charge current.

What is the TP4056 and how does it charge?

The TP4056 is a linear charger IC for single-cell lithium-ion and lithium-polymer batteries that uses the constant current / constant voltage (CC/CV) method. The power transistor is inside the IC, so no external MOSFET, current-sense resistor or reverse-current diode is needed. Charging proceeds in three stages:

  1. Precharge (trickle): If the battery voltage is below 2.9 V, the IC starts with a small current. In the TP4056 datasheet this current is typically 120 mA with RPROG = 1.2 kΩ, roughly one tenth of the programmed current.
  2. Constant current: Once the battery exceeds 2.9 V, the full current set by RPROG is supplied.
  3. Constant voltage: As the battery approaches 4.2 V, the voltage is held constant and the current decreases on its own. Charging terminates when the current falls to one tenth of the programmed value (C/10).

After charging ends, the IC keeps monitoring the battery voltage. If the voltage falls below 4.1 V on the TP4056 or 4.12 V on the TP4056X, a new charge cycle starts automatically.

Li-ion charging stages graph: precharge below 2.9 V, then constant current, constant voltage at 4.2 V, and charge termination when the current falls to C/10
TP4056 charging stages. The curves are not measurements but a representative drawing of the stages; the threshold values are taken from the datasheet.

TP4056 pin connections

The TP4056 and TP4056X come in an 8-pin SOP package with an exposed metal pad underneath; the TP4056X also has a smaller MSOP-sized (EMSOP8) version. Both have the same pin order:

Pin Name Function
1 TEMP Connects to the divider output of the NTC thermistor in the battery. If not used, connect it to ground.
2 PROG The RPROG resistor connected to ground sets the charge current. During the constant-current stage this pin is at 1 V.
3 GND Ground
4 VCC Input (typically 5 V, USB or adapter)
5 BAT Battery positive terminal. The charge current and the 4.2 V regulation voltage are supplied here.
6 STDBY Open-drain output. Pulls to ground when charging is complete (green LED lights).
7 CHRG Open-drain output. Pulls to ground while charging (red LED lights).
8 CE Enable input. Active high; charging stops when low. Usually connected to VCC.

TP4056 and TP4056X key values

Parameter TP4056 (TPOWER) TP4056X (Top Power ASIC)
Operating input voltage (VCC) 4 V – 6 V (typ. 5 V) 4.0 V – 8.0 V (typ. 5 V)
VCC absolute maximum −0.3 V – 7 V −6.5 V – 12 V (input reverse-polarity protection)
Charge termination voltage 4.2 V ±1% (4.158 – 4.242 V) 4.2 V ±1% (4.158 – 4.242 V)
Current formula I = 1100 V / RPROG I = 1100 V / RPROG (±10%)
Precharge threshold typ. 2.9 V typ. 2.9 V
Recharge threshold 4.1 V 4.12 V
Temperature limit (current foldback) 125 °C 145 °C
Internal power transistor resistance typ. 500 mΩ typ. 650 mΩ
Input current in standby mode typ. 50 µA typ. 70 µA
Battery drain with no input 2 µA max. 2 µA max.
Battery reverse-polarity protection not in the datasheet yes (BAT: −4.2 V – 8 V)
TP4056TPower · EE01369-1$0.803 In StockView

PROG resistor calculation: how do I set the charge current?

Many sources online give the formula as 1200 / R and say “1.2 kΩ = 1 A”. The datasheets of the two ICs in this article, however, give the formula with the constant 1100 (in the TPOWER datasheet, 1200 appears only in one test-condition line; the formula and the current table are based on 1100). According to the table in the TP4056X datasheet, 1.2 kΩ gives approximately 900 mA; 1000 mA requires 1.1 kΩ. Check the datasheet of the manufacturer you bought the IC from.

Write the current you want in mA, divide 1100 by that number, and read the result in kΩ. For example, for 500 mA: 1100 / 500 = 2.2 kΩ. Comparison with standard values:

RPROG By formula (1100 / R) TP4056X datasheet table
1.1 kΩ 1000 mA 1000 mA
1.2 kΩ 917 mA 900 mA
2 kΩ 550 mA 580 mA
2.2 kΩ 500 mA typ. 500 mA, 450 – 550 mA (electrical characteristics table)
5 kΩ 220 mA 250 mA
10 kΩ 110 mA 130 mA

As the table shows, at low currents the actual current comes out slightly higher than the formula. If you need a precise value, go by the table. The TP4056 (TPOWER) datasheet gives typically 1100 mA (1000 – 1200 mA) for 1 kΩ and typically 550 mA (500 – 600 mA) for 2 kΩ.

How should you choose the current? The battery is what really determines the current. The datasheet of the 18650 or LiPo battery you use states a “standard charge current” and a “maximum charge current”; do not exceed it. For small-capacity LiPo batteries (a few hundred mAh), 1 A can be far too high. In that case, increase RPROG to reduce the current.

Example: how hot does the TP4056 get?

In a linear charger IC, the voltage difference between the input and the battery is turned into heat. The TP4056X datasheet approximates the dissipated power as P = (VCC − VBAT) × IBAT. With a 5 V input, charging a battery at 3.7 V with 1 A:

P = (5 V − 3.7 V) × 1 A = 1.3 W

When the battery is around 3.0 V, this value rises to 2 W. That is a lot of power for a small package such as SOP-8, so it is normal at the 1 A setting for the IC to get hot enough to burn your finger. When the die temperature reaches 125 °C on the TP4056 or 145 °C on the TP4056X, the IC protects itself by reducing the charge current; charging then takes longer. To reduce the heat:

  • Solder the exposed pad underneath to a copper area on the PCB and make this area as large as possible.
  • If you don’t really need the current, increase RPROG (for example, 500 mA with 2.2 kΩ).
  • The TP4056X datasheet explains that part of the heat can be dissipated outside the IC by adding a small power resistor in series with the input line. If the resistor is too large, VCC drops and charging slows, so choose the value according to the example in the datasheet.

Components and connections

The schematic above is a simplified version of the typical application in the datasheets, without the NTC. The TP4056 datasheet uses a 1 Ω resistor in series with the input capacitor and a single shared 1 kΩ for the two LEDs; the TP4056X datasheet places a 0.4 Ω resistor in series with the input line. These small resistors are optional. Bill of materials:

Component Value Connection
U1 TP4056 or TP4056X SOP-8, exposed pad soldered to a copper area
C1 10 µF Between VCC (4) and ground, close to the IC
C2 10 µF Between BAT (5) and ground
RPROG 1.1 kΩ – 10 kΩ Between PROG (2) and ground
LED1 + R1 Red LED, 1 kΩ From VCC to the CHRG (7) pin
LED2 + R2 Green LED, 1 kΩ From VCC to the STDBY (6) pin
TEMP (1) directly to ground If battery temperature will not be monitored
CE (8) to VCC Charging always enabled

If your battery has an NTC thermistor lead, it can be connected to the TEMP pin through a two-resistor divider. The IC stops charging if the TEMP voltage falls below 45% or rises above 80% of VCC. How to calculate the divider resistor values is explained with formulas in the TP4056X datasheet. For a first project, connecting TEMP to ground is the simplest approach; both datasheets allow this connection.

If you are going to use a ceramic input capacitor, note one detail. The TP4056X datasheet states that some ceramic capacitors can produce a voltage spike when plugged into a live source. Its recommendation is to add a 1.5 Ω resistor in series with the X5R capacitor.

What do the LEDs tell you?

State Red (CHRG) Green (STDBY)
Charging on off
Charge complete off on
Input voltage low or battery temperature out of range off off
No battery connected (only 10 µF on BAT) flashing on

The table is based on the TP4056 datasheet. The red LED flashing with no battery connected is not a fault: as the capacitor on BAT charges and discharges, the IC starts and ends charging. The TP4056 datasheet gives this period as about 3 seconds, and the TP4056X datasheet as 1–4 seconds.

Battery protection circuit with the DW01A

The TP4056 only manages charging. If the battery voltage drops too low while it is powering a load, or if the output is shorted, the TP4056 does not step in. The DW01A is an IC that protects a single-cell Li-ion/Li-polymer battery against overcharge, over-discharge and overcurrent. It drives two N-channel MOSFETs connected in series with the battery’s negative line: one cuts off discharge (OD) and the other cuts off charge (OC).

DW01A battery protection circuit schematic: VCC supplied from the battery positive through 100 Ω and 0.1 µF, two series N-channel MOSFETs driven by the OD and OC pins, VM pin to the P negative terminal through 1 kΩ
DW01A protection circuit. The charger circuit and the load connect not to the battery’s own negative terminal but to the P− terminal after the MOSFETs.

The connections follow the typical application in the DW01A datasheet:

  • VCC (5): Supplied from the battery positive terminal through a 100 Ω resistor. A 0.1 µF capacitor is placed between VCC and GND.
  • GND (6): Connects to the battery’s own negative terminal (B−).
  • OD (1): Drives the gate of the MOSFET that cuts off discharge (M1). M1’s source is at the battery negative terminal.
  • OC (3): Drives the gate of the MOSFET that cuts off charge (M2). The drains of the two MOSFETs are common; M2’s source is the external negative terminal P−.
  • VM (2): Connects to the P− terminal through a 1 kΩ resistor. Current sensing and charger detection are done through this pin.
  • TD (4): A test pin for shortening the delay times; in the datasheet’s typical application it is left unconnected.

The TP4056’s BAT output and the load positive connect to the battery positive (P+ = B+), while the TP4056’s GND and the load negative connect to the P− terminal. If you connect the battery negative directly to the TP4056’s ground, you bypass the protection circuit.

DW01A protection thresholds

Protection Trip Release Typical delay
Overcharge 4.30 V ±0.05 V 4.10 V ±0.05 V 110 ms
Over-discharge 2.50 V ±0.1 V 2.90 V ±0.1 V 55 ms
Overcurrent (VM voltage) 150 mV ±20 mV when the load is removed 7 ms
Short circuit (VM voltage) typ. 1.36 V (0.82 – 1.75 V) when the load is removed 400 µs

The DW01A’s own current is typically 3.0 µA at VCC = 3.6 V and at most 4 µA in the power-down state after over-discharge (VCC = 1.8 V). It does not noticeably drain the battery in storage. According to the datasheet, it can charge a battery that has dropped to 0 V.

Note that the overcharge threshold (4.30 V) is above the TP4056’s 4.2 V charge termination voltage. In normal operation the DW01A does not interfere with charging; it steps in only if the charger IC fails. In this way the DW01A backs up the charger IC.

What is the overcurrent limit in amps?

The DW01A does not measure current directly. It looks at the voltage drop that forms as the current passes through the combined on-resistance of the two MOSFETs. If this voltage exceeds 150 mV, the load is cut off. The cutoff current is found approximately as follows:

Icutoff ≈ 150 mV / (RDS(on) M1 + RDS(on) M2)

Example: if the combined on-resistance of the MOSFETs you chose is 50 mΩ, protection trips at around 150 / 50 = 3 A. This number is only an example. On-resistance varies with gate voltage and temperature; read the value at a gate voltage close to the battery voltage from your own MOSFET’s datasheet. In this application, dual N-channel MOSFETs with a low gate threshold that combine both MOSFETs in a single package are widely used.

DW01APuolop · EE01432-1$0.1995577 In StockView

Can a load be connected to the battery while charging?

This is the question asked most often on forums: can the circuit keep running while charging? The circuit runs, but charging may not terminate properly.

The reason is how the end of charge is detected. The TP4056 ends charging when the current out of the BAT pin falls below one tenth of the programmed value (when the PROG pin stays below 100 mV for a certain time). The IC cannot tell whether this current is going to the battery or to a load connected in parallel with the battery. For example, you set the current to 1000 mA and your circuit draws 150 mA continuously. Even after the battery is full, 150 mA keeps flowing from BAT, the current never falls below 100 mA, and charging never ends. The battery is held at 4.2 V for a long time and the green LED does not light.

The reverse also happens: after charging ends, the load connected to BAT is supplied by the battery. The TP4056X datasheet states this explicitly. When the battery voltage falls back to the recharge threshold, a new cycle starts.

Practical solutions:

  • If the load current is much smaller than one tenth of the programmed charge current (a few mA), the problem does not show up in practice.
  • Switch the load off while charging. The CE pin only stops charging; it does not disconnect the load. A separate switch is needed to disconnect the load.
  • Build a “load sharing” (power path) circuit that supplies the load directly from 5 V when input is present and from the battery when it is not. It is usually done with a P-channel MOSFET and a Schottky diode. This circuit is not in the TP4056 datasheets; when designing it, pay attention to the direction of the MOSFET’s body diode.

Common mistakes

  • Calculating with the 1200 formula: expecting 1 A with 1.2 kΩ and getting about 900 mA. Check the datasheet formula for the IC you use.
  • Exceeding the battery’s current limit: charging small LiPo batteries at 1 A. Choose the current according to the battery’s datasheet.
  • Using an unprotected battery: connecting a bare 18650 cell to a load without a protection circuit. The battery can discharge below 2.5 V or deliver high current into a short circuit.
  • Inserting the battery backwards: the TP4056 datasheet does not mention battery reverse-polarity protection. The TP4056X has this protection.
  • Applying an input voltage above the operating range: the TP4056’s operating range is at most 6 V and its absolute maximum is 7 V (the TP4056X’s operating range is at most 8 V). Do not connect a 9 V or 12 V adapter directly.
  • Not soldering the exposed pad: the heat does not spread, the IC reduces the current and charging takes longer.
  • Expecting 5 V from the battery: in this circuit the battery voltage stays between the DW01A’s 2.5 V discharge limit and 4.2 V. A boost converter is needed to power a 5 V board such as an Arduino. When choosing a linear regulator for 3.3 V circuits, check the dropout voltage; details are in the 7805 vs. AMS1117 comparison article.

Measurement steps after building the circuit

  1. With TEMP connected to ground, apply 5 V without a battery. The green LED should light and the red LED should flash every few seconds.
  2. Connect the multimeter between BAT and ground. The voltage swings between the recharge threshold and 4.2 V, so the multimeter may show an unsteady value around 4.1–4.2 V.
  3. Insert the battery with the multimeter connected in series as an ammeter. If the battery is between about 3 V and 4 V and the IC has not overheated, the current you measure should be close to the value you calculated with RPROG. As the battery approaches 4.2 V or the IC heats up, the current drops.
  4. Measure the PROG pin during the constant-current stage. You should read about 1 V. The voltage on this pin is proportional to the charge current: if you read 0.5 V, the current has dropped to half of the programmed value.
  5. When charging is complete, the green LED should light and the battery voltage should be in the 4.158 – 4.242 V range.

Frequently asked questions

Can a 2-cell (7.4 V) battery be charged with the TP4056?

No. The TP4056 and TP4056X are only for single-cell Li-ion or Li-polymer batteries and charge up to 4.2 V. Two cells in series require a multi-cell charger IC and cell balancing.

What is the maximum TP4056 charge current?

According to the datasheets, a continuous charge current of at most 1 A is supplied. For the TP4056X, the lowest resistance in the table is 1.1 kΩ, corresponding to 1000 mA. The current can drop on its own as the IC heats up.

Can a LiFePO4 battery be charged with the TP4056?

No. The charge termination voltage of LiFePO4 batteries is lower than 4.2 V, and the TP4056 overcharges this battery. Choose a charger IC suited to the chemistry.

Why does the TP4056 get so hot?

Because it operates linearly, power equal to the voltage difference between the input and the battery times the charge current is turned into heat. At 1 A and a 5 V input this is 1–2 W. The IC reduces the current itself when it overheats. To lower the heat, solder the exposed pad to a large copper area or reduce the charge current.

Can the TP4056 be used without a DW01A?

Yes, if you use a battery with its own built-in protection circuit (a protected battery). With a bare cell, however, there is no over-discharge or short-circuit protection on the load side. That is why a protection circuit with a DW01A and two MOSFETs needs to be added.

Conclusion

To build a safe 18650 charging circuit with the TP4056, it is enough to pay attention to three things. Choose RPROG using the datasheet formula of the IC you use (1100 / R for the two ICs in this article) and the current your battery allows. For heat, solder the exposed pad to a copper area. Add a protection circuit made of a DW01A and two N-channel MOSFETs to the battery negative line. If the circuit will also power a load while charging, take into account that the load can delay the end of charge.

TP4056XTop Power · EE01278-3$0.3890 In StockView

You can find other charger ICs in the Battery Charger ICs category and protection ICs in the Battery Management ICs (BMS) category. If you want to build an adjustable bench supply, take a look at the LM317 adjustable power supply article, and to measure the MOSFETs in the protection circuit, the MOSFET testing article.

References

Products in this article

More from Projeler