How to Bring USB-Rechargeable LiPo Power to Your Custom PCB Using the MCP73871

by markahofmeister in Circuits > Electronics

430 Views, 0 Favorites, 0 Comments

How to Bring USB-Rechargeable LiPo Power to Your Custom PCB Using the MCP73871

batt-1.jpg

The ability to make a device portable, rechargeable, and powerful opens up infinite doors for custom hardware. Unfortunately, it's not as simple as hooking up 2 battery leads to a PCB's power rail - doing so won't provide good power integrity and can be dangerous. In this tutorial, we'll be using Microchip Technology's MCP73871 integrated circuit (IC) to implement safe and effective LiPo powering and USB charging to our custom PCB.

This tutorial uses (and assumes knowledge of) Altium Designer, but the use of Altium Designer is not necessary - it's only for demonstrating the design process.

Even if you decide to use an IC that is different from the MCP73871, the concepts discussed in this tutorial can still be applied to a single-cell LiPo charging circuit.

Understand the Purpose of the MCP73871

Lithium Polymer (LiPo) and Lithium Ion batteries have delicate cell chemistry. If they get too cold, too hot, draw too much current, or are discharged beyond a certain point, their cell capacity can greatly diminish or break. Furthermore, if they are charged with too high or low of a voltage, or too high of a current, the cell health further diminishes and they can catch fire. Furthermore, designing a system to remain fully operational while the battery is charging presents a challenge.

We could design all of the supporting circuitry to meet all of these requirements, but this presents a challenge:

  • Safety - Inexperience with Lithium cell batteries can lead to us overlooking some crucial edge cases of cell operation, possibly resulting in cell damage or a fire.
  • Testing - To ensure that your circuitry works, you'll have to test it across all ranges of battery operation and charging conditions. Without specialized equipment, this can be difficult to achieve in your lab.
  • Cost and Complexity - A BMS will require more than a few extra components and design work to implement all of our necessary features. This requires more cost and much more design complexity.

Therefore, why not use an IC that does all of this for us already? If you're purchasing a BMS from a reliable manufacturer, BMS ICs have a ton of integrated features that were designed by experts in the subject and rigorously tested to ensure that the ICs work as advertised. One such IC is Microchip Technology's MCP73871.

The MCP73871 is a load-sharing IC, meaning that we can simultaneously power our system and charge the battery independently of each other. In the absence of a power source to charge the battery and power the system, the battery MCP73871 will automatically switch to allow the battery to power the system. Furthermore, the MCP73871 is designed with an option to specifically run off of USB power. Since I designed my STM32 Audio Dev Panel with USB charging, this is a feature that I'd like in a BMS IC.

Determine How to Configure Functionality

Looking at the MCP73871's datasheet, we find that it supports:

  • Load-sharing
  • Selection of our input power source (AC-DC wall adapter or USB)
  • Programmable Charge Voltage
  • Programmable fast-charge current levels
  • Programmable Charge Termination Setpoint
  • Programmable Cell Temperature Monitor
  • Programmable Safety Timer
  • Power Good, Low Battery, and Full Battery Indicators.

That's a lot. The features are such that, rather than talking to the chip through a serial interface like I2C or uploading code like we would to a microcontroller, these options are configured in hardware. In other words, we connect pins to specific voltages or external components to tell the chip what we'd like it to do. We'll look further at the MCP73871's datasheet, which will describe the functions in greater detail.

Add Connections for Your Battery, Charging, and Power Output

1.png
2.png

We find a Pin Function Table on page 17 of the MCP73871's datasheet. This table describes the function of each pin, the nature of the logic (push-pull, open-drain, and so on), and the required connection for different cases. First, we'll make 4 basic connections:

  1. IN, VPCC (Pins 2, 18, 19) - This is the input for the power supply to charge the battery and power the system when it is present, which in our case is USB. We'll tie these pins to the +5V USB input net.
  2. VBAT, VBAT_SENSE (Pins 14, 15, 16) - This is the input for the battery. Current will flow from the +5V USB power into the battery through this pin when a USB cable is present and will flow from the battery to the power the rest of the system when USB power is not present. We'll tie these pins to the VBATT net.
  3. OUT (Pins 1, 20) - This is the power output terminal to power the rest of the system. Regardless of whether USB or the battery is powering the system, it always flows from this pin. We'll tie these pins to the system power net.
  4. VSS (Pins 10, 11) - This is the negative terminal of the IC. Tie these pins to the ground net.

Add Decoupling Capacitors

1.png
2.png
3.png

Section 6.1.1.3 of the datasheet describes the necessity of decoupling capacitors to filter out high-frequency noise from DC power rails and to counterbalance the inductive nature of the battery in the system's control loop. Furthermore, the example typical application circuit (page 2) shows decoupling capacitors on the battery, USB, and system output pins. We'll copy these capacitor placements and values in our design.

Enable/Disable Binary Functionalities

1.png
2.png
3.png

Next, we'll look at the functions that can be binarily enabled/disabled.

  1. SEL (Pin 3) - This pin tells the IC whether to expect USB Power or wall power. Since we're using USB power, we'll tie this pin to ground, as directed by the datasheet.
  2. TE (Pin 9) - This enables/disables a safety timer to stop charging after a certain time (as described by section 3.14 on page 19.) We're not using this functionality, so we'll tie it to +5V USB, since this pin is active-low, as directed by the datasheet.
  3. CE (Pin 17) - This pin enables battery charging. We'd like to use this functionality, so we'll tie this pin to +5V USB, as directed by the datasheet.
  4. PROG2 (Pin 4) - This pin selects the charging current limit. There are two options - 100mA and 500mA. I'd like the option to do both, so I'll add a DIP switch to swap between connecting this pin to +5V USB and ground. Remember to include a pull-up/pull-down resistor to prevent floating conditions.

Alternatively, all of these pins can be connected to GPIO pins of a microcontroller and connected to high or low voltages electrically, as shown in the typical application circuit (page 2.)

Configure the Analog-programmable Pins

1.png
2.png
3.png
4.png

The PROG1 and PROG3 pins are analog pins, meaning that we can't tie them directly to +5V or ground.

The PROG1 pin sets the maximum allowed charging current, which should be limited to 1C for a LiPo battery. 1C is the current (in amps) that your battery can output for 1 hour. For example, a 1000mAh capacity LiPo battery has a charge current 1C equal to 1000mA, or 1A. However, we're using USB charging, so our current is limited to 500mA.

Section 4.5 (page 23) describes the equation that dictates the charging current limit. Since our limit must be 500mA, we'd select (1000V) / (500mA) = 2000 Ohms = 2 kOhms, which we'll connect between the PROG1 pin and ground.


The PROG3 pin sets the current termination point - i.e., when the charging current falls below this threshold, we cease battery charging and consider it fully charged. Section 4.7 describes how to configure this threshold, with an equation similar to that of PROG1. I might charge at 100mA current, so I'll select a value lower than this. A 15 kOhm resistor gives us (1000V) / (15,000 ohms) = 67 mA, so we'll use that value. As we did with PROG1, we'll connect this 15 kOhm resistor between PROG3 and ground.

Configure the Thermistor

1.png
2.png
3.png

An NTC thermistor can be connected to Pin 5, which is a temperature-dependent resistor. If the ambient temperature goes above or below a certain threshold, charging will cease, as charging in extreme temperatures can cause battery cell damage.

Section 3.15 provides us with a bit more clarity on this pin's operation: it has a 50 uA bias current, meaning that a resistor connected between this pin and ground will always draw 50 uA of current. The THERM pin's voltage changes, then, if the value of the resistor changes. If the THERM pin sees a voltage lower than 0.25V or greater than 1.25V, charging ceases.

Section 6.1.1.5 tells us how to actually configure this function with hardware. 2 equations are given, which can be solved simultaneously to tell us the values of fixed-value series and parallel resistors.

If your application requires thermal monitoring, work through this math and select resistors by all means. However, I don't need this functionality, so I'll connect a fixed-value resistor of 15 kOhms, which always keeps a voltage of (50 uA) * (15 kOhms) = 0.75V at the THERM pin. Therefore, this pin should never cut off charging.

Configure UI Output LEDs

1.png
2.png
3.png

The MCP73871 also has pins to signify charging status. Table 5-1 gives us a truth table describing these open-drain outputs.

  • Power Good (PG) - This pin goes low when USB power is present.
  • Low Battery Indicator (STAT1/LBO) - This pin goes low when the system is being powered by the battery and the battery reaches a low voltage, as well as when the battery is being charged.
  • Charge Complete Indicator (STAT2) - This pin goes low when the USB power is present and the battery is not being charged.

These pins could be connected to a microcontroller (with a pull-up resistor,) but I'll simply be connecting an LED and current-limiting resistor to each. Since the status indicator pins go low when they activate, they'll be acting as the "ground" of my LED circuits. I only need to see these LEDs when USB is connected, so I'll use +5V USB to power these LEDs.

Add Documentation!

1.png

It's always good to add notes to your schematic to document why you chose to configure your circuit this way for yourself and others.

(Optional) Add a Regulator

1.png

The output of the MCP73871 will either be +5V from USB or whatever the battery cell voltage is, anywhere from 3.2V - 4.2V. If your system requires a lower voltage like 3.3V or 1.8V, you can regulate this voltage down using a low-dropout regulator. I'm using the XC6210B332MR-G from Torex Semiconductors, but you can use any regulator that meets your needs. Alternatively, you can use a boost converter to get higher voltages, but be sure that you won't overdraw your battery.

PCB Layout

1.png

Additional care must be taken when laying out your PCB. Use wide traces and polygons to minimize trace inductances and keep your traces/power rails as short as possible. Use many stitching vias to deliver power to multiple layers, as vias have a particularly large inductance.

PCB Order

pcbway_logo.png

My favorite PCB manufacturer is PCBWay, who do an excellent job fabricating and assembling my PCBs every single time. If you're using a small QFN IC like the MCP73871, I'd recommend having the professionals at PCBWay solder up your boards for you. They always send me images of the assembled PCBs for my inspection, too!

Test

Test your system with both USB and battery power. To be safe, make sure to charge your system in a LiPo-safe charging container to contain any fires or explosions that result from improper design.