AN73468 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Author: Archana Yarlagadda, Rajiv Badiger Associated Project: Yes Associated Part Family: All PSoC 3 and PSoC 5LP Parts ® Software Version: PSoC Creator™ 3.3 or Higher Related Application Notes: AN55102 More code examples? We heard you. To access an ever-growing list of hundreds of PSoC code examples, please visit our code examples web page. You can also explore the PSoC 4 video library here. AN73468 explains a single-cell Lithium-Ion (Li-ion) battery charger implementation using PSoC 3 or PSoC 5LP. Two types of implementations — linear and switching type are supported. An attached PSoC Creator project, which includes a charge display tool, demonstrates Li-ion battery charging. Contents Introduction Introduction .......................................................................1 Li-Ion Battery Charging Profile ..........................................1 Project Implementation......................................................3 PSoC Creator Project ........................................................4 Battery Parameter Measurement .................................4 Charging Algorithm in Firmware ...................................7 External Current Control Circuit....................................8 Battery Protection Logic ...............................................9 Calibration ....................................................................... 11 Test Setup and Results ................................................... 12 USB Communication .................................................. 12 Charge Display Tool ................................................... 12 Conclusion ...................................................................... 12 Appendix A: Buck Circuit Component Selection.............. 13 Appendix B: Schematic and Bill of Materials for Switching Method of Current Control ......................... 15 Appendix C: USB Driver Installation ................................ 17 Appendix D: Software Tool Installation and Setup .......... 18 Appendix E: Alternative Implementation Options with Tradeoffs ......................................................................... 20 Biasing Thermistor using IDAC .................................. 20 Over Voltage and Over Current Protection ................. 20 Battery Current Control with PWM ............................. 21 Document History ............................................................ 22 Li-ion batteries are used in a wide range of systems such as cameras, cell phones, electric shavers, and toys. The charging circuit for the batteries can either be an integral part of the system (online charging) or an external plug-in circuit (offline charging). With its wide range of devices, PSoC offers a cost-effective solution in both segments. And with its configurable digital and analog features, PSoC 3 or PSoC 5LP enables implementation of other critical tasks required in the system. Consider a case of an electric shaver that uses Li-ion battery charger logic and a motor to drive the shaver blade. Both of these major tasks can be run from a single PSoC 3 or PSoC 5LP device, which results in lower cost and small PCB size. Small size is important in batteryoperated (portable) systems. Li-Ion Battery Charging Profile The charge profile used for charging is the constant current (CC) – constant voltage (CV) method. The Li-ion batteries have different states of charging, based on the voltage of the battery as shown in Figure 1. These are: www.cypress.com Pre-charging (tstart) or activation (tact) Rapid charge or fast charge Constant current (trapid) Constant voltage (tconst_voltage) Charge complete Document No. 001-73468 Rev. *D 1 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger value while the battery voltage is at Vfull, the charging is considered complete and the current is reduced to zero. Figure 1. Charge Profile for Li-ion Battery This multi-stage process helps to remove the effects of battery source impedance or any track or connector resistance between the charging system and the battery. The constant current stage features rapid charge until a safest operating voltage (full charge voltage) is reached. The constant voltage stage ensures that the voltage value being read corresponds to the battery voltage and does not include voltage drop across any series resistances. Besides voltage, temperature of the battery should also be monitored for safety reasons. Figure 2 shows a simplified block diagram of a battery charger system. Figure 2. Block Diagram of Battery Charger If the battery voltage is less than the activation voltage (Vactivation), the charging process starts with the pre-charge stage where small amount of current (Iactivation- typically 10% of the battery capacity) is provided to check if the battery is in good condition. Time limit (tstart) is kept low for this stage. If the battery voltage does not rise above Vactivation in tstart time, battery is considered faulty and charging is stopped. When the battery voltage rises above Vactivation, activation stage is entered where charging is continued with the same amount of current. This brings the battery voltage to the rapid charging voltage level. If the battery does not rise to the specified rapid charge voltage within the activation timeout period tact, the battery is considered dead. The activation stage is used when the Li-ion batteries are completely discharged. In most cases, the batteries are not completely discharged and they go directly into the rapid charge stage. In the rapid charge stage, the charge current is kept equal to the capacity specified for the battery. This constant current is applied until the battery reaches its specified full charge voltage (Vfull). In this region, the accuracy of voltage measurement is very important for the safety of the battery. The tolerable error in measurement is generally less than ±1% of Vfull. This application note uses calibration scheme to achieve this target. After the constant current stage, the battery goes to the constant voltage stage. In this stage, the battery voltage is maintained at a constant level. This requires a decrease in the charging current as the time progresses. When the current value reaches the termination current (Itermination) www.cypress.com Supply Current control circuit charging current + Charging Algorithm Battery parameter measurement T - Battery Pack The battery parameter measurement senses the three parameters of the battery: voltage, current, and temperature. These should be maintained within the battery safe range. The logic for controlling these parameters is implemented in the charging algorithm, which can be applied in hardware or in a combination of firmware and hardware. The output of the charging algorithm changes the charge current through the external current control circuit. The current control circuit can be either linear or switching. This application note shows the firmware implementation of both the linear and switching type of charge control. The benefit of a firmware implementation is its adaptability to change in the charging profiles. The complete block diagram and the functions of each block are explained first, followed by explanation of the PSoC Creator implementation. Document No. 001-73468 Rev. *D 2 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Project Implementation for additional features related to the battery protection. For more information on each of these blocks and the components used, see PSoC Creator Project. The external current control can be either linear or switching type of implementation. The switching circuit is shown in Figure 3, and the linear circuit is explained in External Current Control Circuit section. The rest of the circuit and firmware implementation apply to both methods. Figure 3 shows the overall block diagram for implementation of the Li-ion battery charger with a PSoC 3 and PSoC 5LP device. The implementation is divided into the measurement, charging algorithm, and external current control blocks as explained earlier. Additionally, a protection block is added Figure 3. Block Diagram for Li-ion Battery Charger with PSoC Q1 L1 To Battery MOSFET Gate Driver (ADP3120) D2 Q2 C1 D1 FDC6561 External current control DC 3.3V / 5V regulator PSoC 3 / PSoC 5LP Vdd Battery protection logic GND IDAC Charge Control Algorithm RIRef1 RVRef Vbatn RIRef2 + RTp CPU RVS1 - Vbatp Battery Pack Battery parameters measurement Timers RTm T Ibatn PWM Generator RTRef ADC RVS2 Vbatp Vbatn Vbatn Ibatp Ibatn Ibatp RFilt RTp RTm Debug Logic VDAC Ibatn CFilt RS RTp USB www.cypress.com Document No. 001-73468 Rev. *D 3 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger PSoC Creator Project This section guides you through implementation of the design in PSoC 3 and PSoC 5LP. The complete block diagram is shown in Figure 3, and this section explains each function in detail along with the PSoC components selected to implement them. Battery Parameter Measurement Figure 4 shows the battery parameter measurement function in PSoC 3 and PSoC 5LP. The three parameters of interest — voltage, current, and temperature are measured using an ADC. Figure 4. Top Design: Battery Parameter Measurement The Delta-Sigma ADC component is multiplexed to measure multiple parameters. For temperature measurement, the standard “Thermistor Calculator” is used in the project. The details about this custom component are provided in application note AN66477 ® PSoC 3 and PSoC 5LP Temperature Measurement with Thermistor. The bias required for this component is generated using the VDAC8 component. Figure 5. DelSig ADC Configuration The CPU configures the AMUX channel and reads the ADC to get the parameter values. The configuration of each of these components is described in the following sections. Delta-Sigma ADC In the project, the ADC is used to measure battery voltage, charging current, and temperature. Figure 5 shows the ADC_DelSig component configuration. www.cypress.com Document No. 001-73468 Rev. *D 4 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger When multiplexing multiple channels to the ADC, set the ADC to Multi-Sample mode. This mode resets the ADC modulator every time a sample is taken, so that the readings for one channel do not affect another channel. The resolution is set to 16 bits with a measurement input range of ±2.048 V. Based on these settings, the resolution obtained for voltage, current, and temperature is shown in Table 1. Figure 6. AMux_ADC Configuration Table 1. Resolution of Parameters Based on ADC Settings Parameter Voltage Resolution 62.5 uV / K Notes K is the scaling factor of the resistor potential divider connected across the battery. R vs 1 K= R vs 1 + R vs 2 In this design, the following resistors are used: R vs 1 = 499 kΩ The channel selection is done in firmware. Table 2 shows the allocation of channels. Table 2. Channel Allocation for AMUX R vs 2 = 392 kΩ Channel In this design, RS is 0.2 Ω. This gives current resolution of 0.312 mA. 0 Voltage Pin_VBatp Pin_VBatn 1 Current Pin_IBatp Pin_IBatn 2 Temperature Pin_RTp Pin_VBatn 3 Temperature Pin_RTm Pin_VBatn Parameter This gives measurement resolution of 142 uV. Current 62.5 uV / RS Temperature ±0.01 °C Range: 0 to 50 °C RTref = 10 kΩ ± 1% at 25 °C The conversion rate is set to 9800 samples per second, which can be changed depending on your application requirement. In the ADC settings, differential measurement is used, because it removes the effect of common mode voltage. Common mode voltage can be a PCB trace voltage drop because of current, induced noise, or offsets. Port Connections + - VDAC The project uses the VDAC8 component to generate the reference voltage required for the thermistor temperature measurement. Figure 7 shows the configuration of this component. Figure 7. VDAC8 Configuration The DelSig ADC has an input buffer at its differential input. The gain and mode of this buffer are configurable. For this project, “Buffer Gain” is set to 1 and “Buffer Mode” is set to level shift. Level shift mode enables the measurement of voltages close to PSoC ground rail. This is required for current measurement because the voltage across the current sense resistor is very close to the PSoC ground. For example, with a 0.2 Ω current sense resistor and 30 mA termination current, voltage across the sense resistor is 6 mV. Note These settings are applicable for all the parameters measured. For details of other parameters, see the DelSig ADC component datasheet. AM U X The project uses the AMUX component to multiplex different inputs to the ADC. Figure 6 shows the configuration of the AMux_ADC. Four channels are defined, each with a differential type. www.cypress.com Document No. 001-73468 Rev. *D 5 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger The VDAC output range is set to 4.08 V. This gives a resolution of 16 mV/bit. The VDAC output voltage is used to bias the Thermistor. Make sure that you do not set the VDAC8 output higher than what the ADC DelSig can measure. Note that the ADC measurement range is set to ±2.048 V. In this project, the VDAC output is set to 2.0 V. This voltage is divided across the reference resistor and the thermistor. External Circuitry This section gives details about the external components required for the battery parameter measurement. These components appeared in previous block diagrams and in Figure 9. Figure 9. External Connections - Measurement + Thermistor Component The Thermistor Calculator component is a standard Creator component used with this project. RTp RTRef RTm T RVS1 - Vbatp Battery Pack RVS2 Vbatn Ibatp RFilt Ibatn This component requires one resistor for reference connected in series with the Thermistor. The component takes the ADC readings of both the thermistor voltage and the reference resistor voltage to find the temperature. The configuration of this component is shown in Figure 8. Figure 8. Thermistor Configuration In this design, external reference resistor RTRef of 10 kΩ is connected in series with the Thermistor. Thermistor resistance values at different temperature values are provided for calibration. This design uses Thermistor NTSD1XH103FPB. Its resistance values at three different temperature values (0 °C, 25 °C, and 50 °C) are given to the component for calibration. For more information about this component, see ® application note AN66477 – PSoC 3 and PSoC 5LP Temperature Measurement with Thermistor. www.cypress.com CFilt RS Voltage Sense Voltage sense is implemented by attenuating the battery voltage to the range of the ADC, using the resistors - RVS1 and RVS2. The sum of these resistor values should be greater than 100 kΩ to minimize the loss of charge current through the resistors. The present design uses RVS1 of 499 kΩ and RVS2 of 392 kΩ. Current Sense The current sense is implemented by using a small value resistor on the low side of the battery. The RS resistor shown in Figure 9 is used for current sense. The value of this resistor should be such that the maximum current allowed through the battery is less than the power rating of the resistor. There is a trade-off between the signal integrity (requires higher RS) and power dissipation (requires lower RS). Typically, for a charge current of 1 A, a resistor value less than 0.5 Ω can be used to prevent more than 0.5 W of power dissipation. The actual number for the allowed power dissipation will depend on your target application specification. This design uses RS of 0.2 Ω. The voltage across RS is filtered using an RC low-pass filter to remove switching noise. You must set the cut-off frequency of the filter to be much lower than the switching frequency. Temperature Sense The VDAC gives a constant voltage to the thermistor (RT) and its reference resistance (RTRef). This method has the benefits of offset and gain error cancellations. A Thermistor component is used for the implementation of the temperature measurement. The reference resistor RTRef value should be close to the thermistor resistance at the middle of the temperature range. Document No. 001-73468 Rev. *D 6 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger An alternative method of implementation is to use an IDAC for constant current implementation. In this method, a constant current is passed through the thermistor, and the change in voltage due to change in thermistor resistance is noted. Appendix E: Alternative Implementation Options with Tradeoffs shows this option and its implementation. Charging Algorithm in Firmware In the project, the CPU has the following major tasks: Run the calibration algorithm Update the state machine Read the battery voltage, charging current, and temperature Update the PWM duty cycle Figure 10 shows the firmware flowchart. Figure 10. Flowchart for Battery Charging Start Initialize all components Calibration activated? Yes No Get the scale factor from the Flash location Calculate scaling factor and update Flash location No Scan time flag is set? Yes Read the battery voltage, current and temperature Update the charging state machine Update the PWM duty cycle Execute other tasks(if present) www.cypress.com Document No. 001-73468 Rev. *D 7 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger The following is a description of the state machine for the attached project, as shown in Figure 11. Figure 11. Charger State Machine Diagram reset No Battery Battery Error Const Voltage Activation As explained earlier, there are two major stages in battery charging: Constant current (CC) and Constant voltage (CV) stage. Both stages require control of charging current. This is achieved by controlling the voltage applied across the battery. Two methods can accomplish this: Initialization Charge Complete External Current Control Circuit Wait For Temperature Rapid Charge Linear regulator Switching regulator Linear Regulator This method involves controlling the bias of the series pass transistor (Q2 in Figure 12) to control the current to the battery. The PWM signal is fed to the external RC lowpass filter to get an average DC voltage to bias transistor Q1. Controlling the duty cycle of PWM controls the average DC voltage at the output of the filter. This controls the collector current of Q1 and, therefore, the battery charging current (collector current of Q2). Transistor Q2 also prevents reverse powering of PSoC and reverse current into the supply. This type of implementation supports limited charging current, for a reasonable cost of the pass transistor. It has the benefit of lower footprint than the switching method. The state machine is updated based on the voltage, temperature, and current charging state of the battery. Figure 11 shows the state machine for the charging process. No Battery state: The battery is not connected and the charge current is set to zero. Initialization state: The battery is connected, the voltage is less than the activation voltage, and the charge current is set to activation current. Activation state: The battery reaches the activation voltage within some time limit. In this state, the charge current is maintained at the activation value. Rapid Charge state: The voltage is at the rapid charge voltage. The charge current is set to the highest possible value. Constant Voltage state: The battery voltage is at the rated value, and the current is slowly decreased, while ensuring the battery voltage remains at the rated voltage. The current in this state decreases until the termination current is reached. Charge Complete state: In this state, battery is completely charged. Charging process is stopped. Figure 12. Linear Current Control Circuit Q2 Supply VDC Battery charging current PSoC PWM Q1 R C Switching Regulator This method involves the use of buck or boost switching regulator. This application note uses a buck type switching regulator to supply the required current through the battery. It is implemented using an external MOSFETFDC6561 and Gate driver ADP3120. During this sequence of steps, if the battery voltage, current, or temperature is out of the specified limits for that state, the state is set to “Battery Error” and the charge current is set to zero to protect the battery. www.cypress.com Document No. 001-73468 Rev. *D 8 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Figure 13. Switching Buck regulator Circuit on how to select the external components for a buck regulator, see Appendix A: Buck Circuit Component Selection. Supply VDC PSoC PWM PWM MOSFET Gate Driver Driver Enable Q1 Q2 L1 D1 To Battery D2 C1 Diode D1 is connected across the lower MOSFET to give a freewheeling current path during the dead time when both MOSFETs are off. This dead time is set by the MOSFET gate driver. Diode D2 is used to prevent current from the battery from flowing back to the supply when the supply voltage is less than the battery voltage. A switching regulator is useful for high-charging currents (>1A) due to its high efficiency. PSoC 3 / PSoC 5LP gives a PWM signal of 500 kHz to the external MOSFET gate driver. The gate driver has two outputs, which drive the gate terminal of two N-channel MOSFETs configured for the buck regulator. Values of inductor L1 and output capacitor C1 are chosen for a desired ripple current and voltage. For more information Battery Protection Logic Figure 14 shows the over voltage and over current protection logic implementation in PSoC 3 / PSoC 5LP. The output of the comparators controls the PWM generator as shown. Figure 14. Top Design - Battery Protection www.cypress.com Document No. 001-73468 Rev. *D 9 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger When the battery voltage or battery charging current exceeds the limit set using IDAC8_Ref, the output of comparator goes to zero and is latched in “sticky 0” latch, which disables the PWM. It also causes an interrupt to the CPU to take the required action. ControlReg_BlockComp is a control register used to enable or disable the latching of comparator output. Comparator output is latched on the rising edge of the PWM_Sync signal. The PWM_Sync signal is generated in such a way that the switching spikes will not trigger the OV/OC protection. During ADC channel switching, comparator output latching is disabled by writing a zero to the ControlReg_BlockComp control register to prevent misfire. External Circuitry This section includes the external resistor circuit required along with the internal setup for over voltage and over current implementation. Figure 16. External Circuitry - Battery Protection To generate the PWM signal, a custom component “DitheredPWM” is created. It provides higher resolution than the regular PWM component. The configuration of each of the components used in this implementation is explained below: IDAC8 IDAC8_Ref is used to generate the reference current required to obtain the battery current and voltage limits. The settings for the IDAC are shown in Figure 15. IDAC is configured in sourcing mode in 2.04 mA range. Its value is set based on the threshold voltage required for over voltage and over current in addition to the resistors (RVRef, RIRef1, and RIRef2) selected. Figure 15. IDAC8 Configuration for OV-OC Circuit The IDAC current is passed through resistances RVRef, RIRef1, and RIRef2 to develop reference voltages. These resistances must be chosen based on the following equations: RVref = Vmax ∗ RVscale I DAC _ VREF ( ) Where RVscale = RVs 2 (RVs1 + RVs 2 ) RI Re f 1 = RI Re f 2 = I max ∗ Rs (I DAC _ CREF ) I DAC _ VREF ∗ RV Re f (I DAC _ CREF ) − RI Re f 1 In these equations, RVs1, RVs2, and RS are chosen based on the requirements described in Battery Parameter Measurement. Vmax and Imax are defined by the battery chosen. For the sake of calculation, the current in the two resistor paths are assumed first and the resistor values are calculated based on these values. The IDAC_VREF is the current through RVRef. The IDAC_CREF is the current through the reference resistor string, and equal to difference of total IDAC current and IDAC_VREF. www.cypress.com Document No. 001-73468 Rev. *D 10 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Dithered PWM Dithered PWM is the custom component included in the project. This design gives high resolution by dithering the duty cycle between two adjacent values. High resolution in the PWM duty cycle is required in the switching method to get a fine variation in current through the battery. Figure 17 shows the design of the Dithered PWM component. These internal components are included for your reference and are placed automatically when the Dithered PWM component is placed. Timers Two timers shown in Figure 18 are used in the project for generation of timeouts and interrupts. Timer_Scan: This 16-bit timer gives periodic interrupts to the CPU to execute the charging state machine. Timer_TimeOut: This sets the time limit during various stages of battery charging. When a timeout interrupt occurs, charging is stopped. Figure 18. Timers for Battery Charger Figure 17. Dithered PWM Design The PWM component generates two PWM signals: pwm1 and pwm2. The pwm2 duty count is kept one more than the pwm1 duty count. Out of the two PWMs, one is selected at a time depending on the PrISM component output. The PrISM component generates a pseudorandom sequence with configurable average duty cycle (or pulse density). It receives a clock input from the terminal count output of the PWM component. By varying the pulse density of the PrISM component, a very fine variation in duty cycle is obtained between two adjacent duty cycle values of the PWM component. With 8-bit PWM and the PrISM component, you can get a resolution of 16 bits in the duty cycle. The most significant 8 bits of the 16-bit duty cycle value is loaded into the PWM component and the lower significant 8 bits are loaded into the PrISM component. The Dithered PWM is required for the switching method of implementation. You can use it for the linear method to maintain the same project for the two methods, but a standard Cypress library 16-bit PWM is also sufficient for the linear method. Appendix E: Alternative Implementation Options with Tradeoffs shows this option of implementation. Other details on custom components can be found in the PSoC Creator Component Author guide. www.cypress.com Calibration During charging, a Li-ion battery requires accurate control of voltage when it is at near full charge; < 0.75% error is widely accepted. As the battery voltage is scaled down using resistors, the scaling factor needs to be accurately known. The error introduced by Delta-Sigma ADC is less than 0.2% error across process, temperature, and supply voltage variations. Therefore, ADC error is negligible. The majority of error is introduced by the potential divider resistor tolerances. Highly accurate resistors with tolerance values as low as 0.01% are available but they are costly. An alternative is to use a low-cost, hightolerance (1% or 5%) resistor and measure scaling factor in the factory. During this factory calibration, a known voltage can be given in place of the battery. The scaled voltage read by the device divided by the known input voltage is the scaling factor. In this project, the calibration routine is written which can be invoked by grounding Pin_Calibration (P1[7]). Pin_Calibration is configured in pull-up mode. When the PSoC device is reset, Pin_Calibration is polled to see if it is grounded. If it is, it enters the calibration routine. Otherwise, it takes the scale factor from a flash location. Document No. 001-73468 Rev. *D 11 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger The flash location will be programmed initially with an approximate value. When the device enters the calibration routine, it assumes a known reference voltage is provided at the battery terminals points. (In this project, 4.2 V is assumed as the reference voltage.) After reading the voltage, scaling factor is calculated and flash location is updated. A USB component was added to the project, and data from the USB was plotted on a tool developed in C#. The LCD component is also placed to display voltage, current, temperature, and PWM duty cycle count. The additional components required for development and not for production are shown in Figure 20. Figure 20. Components for Debug and Display Test Setup and Results A PCB was designed with the external components, for the switching method battery charger, shown in Figure 2. The board was designed to be an expansion board for CY8CKIT-001, as shown in Figure 19. Appendix B gives the Bill of Materials (BOM) and the schematic for this PCB board. Gerber files for this board is also given provided. Figure 19. Battery Charger EBK and CY8CKIT-001 USB Communication A USB driver is required for USB communication. The INF file is included with this application note. Appendix C: USB Driver Installation explains the driver installation. Charge Display Tool You can plot the battery charging graphs using the tool provided with this application note. The details of setting up this tool are provided in Appendix D: Software Tool Installation and Setup. An example plot of the charging process is shown in Figure 21. Figure 21. Charge Display Tool for Display and Debug Conclusion Li-ion battery charging can be done in multiple ways. The firmware method of control and the linear and switching method implementations are discussed in this application note. www.cypress.com Document No. 001-73468 Rev. *D 12 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Appendix A: Buck Circuit Component Selection This section helps you select inductor value, output capacitor, and MOSFET. The following assumptions are made: Supply voltage Vin: 12 V Full charge battery voltage: 4.2 V Rapid charging current: 1 A PWM switching frequency: 500 kHz Inductor ripple current: 300 mA The selection of the components for the buck regulator is as follows. Inductor L Selection Inductor voltage is given by: L = (Vin - Vout)× Duty (Fsw× Iripple) For this application, IRipple is assumed to be 30 mA with a charging current of 1 A. The duty cycle at Vout = 4.2 V (battery full charge voltage) is around 0.35. The actual duty cycle will be a little larger to pump current in the battery. For a PWM frequency of 500 kHz, this gives an inductor value close to 18 uH. A slightly larger value of inductance of 22 uH is chosen to keep a margin of safety. The current handling capability of the inductor should be greater than (load current + ripple current). Load current is the battery charging current, which is 1 A maximum. Because the assumed ripple current is close to 300 mA, the inductor should be able to handle minimum current of 1.3 A. The following graph shows the ripple current for a given inductor value for the assumptions mentioned previously. Output Capacitor C Selection C= (ripple current × Ton) (ripple voltage - (ripple current × ESR)) A low ESR capacitor should be selected to have low ripples in the output voltage. The 30 mΩ ESR capacitor is selected for this application. Duty is assumed to be 50% max; this gives Ton as 1 us. Capacitance of 22 uF gives the ripple voltage around 26 mV across the output. This ripple voltage drops across the internal resistance of the battery. Ripple current is taken as 350 mA for inductor value of 22 uH to keep a margin of safety. www.cypress.com Document No. 001-73468 Rev. *D 13 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger The following graph shows the variation in output voltage ripple for capacitance value for the assumptions mentioned previously. Dual MOSFET Selection MOSFET selection is based on the load requirement, ripple current, and the supply voltage. Drain current rating: Both the MOSFETs will handle load current + ripple current that gets bypassed through the output capacitor. Therefore, the MOSFET continuous current rating should be greater than (1 A+0.35 A=1.35 A). Drain-Source and Gate-Source voltage rating: This should be greater than the supply voltage. FDC6561 dual MOSFET IC is selected, which has a 30 V drain-source voltage rating, a 20 V gate-source voltage rating, and a continuous drain current rating of 2.5 A. www.cypress.com Document No. 001-73468 Rev. *D 14 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Appendix B: Schematic and Bill of Materials for Switching Method of Current Control This section includes the schematic and the BOM for the EBK to test the battery charger functionality is provided. The main board (CY8CKIT-001) has the PSoC and USB functionality, and the rest of the external circuitry is on this expansion board. www.cypress.com Document No. 001-73468 Rev. *D 15 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Table 3. Bill of Materials (BOM) Manufacturer Manufacturer Part Number Reference Quantity Description 1 ON SEMICONDUCTOR ADP3120AJRZ U1 1 IC MOSFET DVR DUAL 12 V 8-SOIC 2 FAIRCHILD SEMICONDUCTOR (VA) FDC6561AN U2 1 MOSFET N-CHAN DUAL 30 V SSOT6 3 NXP SEMICONDUCTORS (VA) PMEG3020EH,115 D1,D2,D3 3 SCHOTTKY RECT 30 V 2 A SOD123F 4 Generic Generic L1 1 INDUCTOR PWR UNSHIELD 22 UH SMD 5 Generic Generic BAT 1 HOLDER BATT 1/LI-ION PROTECTED 6 Generic Generic C4 1 CAP AL POLY CHIP 22UF 16V ESR 30 mΩ SMD 7 Generic Generic R9 1 2.2 kΩ 1% 0805 8 Generic Generic R4 1 330 kΩ 5% 0805 9 Generic Generic R6 1 2.2 kΩ 5% 0805 10 Generic Generic R5 1 0.2 Ω 1/4 W 1% 0805 SMD 11 Generic Generic R3 1 499 kΩ 5% 0805 12 Generic Generic R12 1 10 kΩ 5% 0805 13 Generic Generic R1,R2 2 10 Ω 1/4 W 5% 0805 SMD 14 Generic Generic R10 1 15 kΩ 1/4 W 1% 0805 SMD 15 Generic Generic R8 1 0.0 Ω 1/8W 0805 SMD 16 Generic Generic R7 1 15 kΩ 1% 0.125 W 0805 17 Generic Generic C1, C5 3 CAP CERM .01 UF 5% 16 V NP0 0805 18 Generic Generic C6 1 CAP CER 10 UF 16 V X5R 20% 0805 19 Generic Generic C3 1 CAP CER .47 UF 16 V X7R 0805 20 Generic Generic C8, C9 1 CAP .10 UF CERAMIC X7R 0805 22 Generic Generic H1 1 CONN HEADER R/A 40POS GOLD SMD 23 Generic Generic R11 1 THERMISTOR 10 kΩ NTC 0805 SMD 24 Generic Generic C2 1 CAP CER 0.1 UF 50 V X7R 0805 www.cypress.com Document No. 001-73468 Rev. *D 16 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Appendix C: USB Driver Installation When the demo board is connected to the computer through a USB cable, the “Found New Hardware” message will appear, as shown in the following figure. Click Next on this screen and select Install from a list or specific location (Advanced). Click Next. The following screen appears. Use the Browse field to find the INF file. Click Next to complete and finish the installation. www.cypress.com Document No. 001-73468 Rev. *D 17 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Appendix D: Software Tool Installation and Setup Step 1: Click on the Setup file in the charge display tool folder provided with this application note. Step 2: Follow the sets as guided by the tool for installation. Step 3: Open the tool from Startup > Cypress Semiconductor > Charge display. Step 4: Connect the COM associated with Li-ion battery charger. Step 5: Enter the parameters of the ADC and the resistors chosen into the appropriate fields Voltage Measurement Differential Measurement: Select the box if the ADC is a differential ADC. Clear the box if it is a single-ended ADC. ADC resolution: Select the same resolution used for the ADC ADC Range: Select the same range used for the ADC Voltage Divider: This is the hardware voltage scale used for the battery voltage attenuation. = RVsense 2 (RVsense1 + RVsense 2 ) Current Measurement Differential Measurement: Select the box if the ADC is a differential ADC. Clear the box if it is a single-ended ADC. ADC resolution: Select the same resolution used for the ADC ADC Range: Select the same range used for the ADC www.cypress.com Document No. 001-73468 Rev. *D 18 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Current Gain: Choose the appropriate gain, if additional gain is added to current measurement Sense Resistor: Enter the current sense resistor value RIsense Temperature Measurement Temp Scale: The thermistor component returns the temperature value scaled up by 100. For example, it returns 2345 when the temperature is 23.45 °C. This value can be scaled down in firmware or passed onto the tool as it is and scaled in the tool. Graph Parameter Setup When you click Choose settings, the following form for the graph settings appears. This can be used to change the voltage and current threshold levels displayed on the charge display tool, shown in the earlier figure. All the parameters have to be matched to the parameters set in the battery charger project to make sure that the thresholds line up. www.cypress.com Document No. 001-73468 Rev. *D 19 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Appendix E: Alternative Implementation Options with Tradeoffs This section shows the alternate implementation methods. The differences between the two methods are only to show different options and tradeoffs during an implementation. You can choose any method that is suitable for your application. Biasing Thermistor using IDAC A second approach to measuring temperature with advantages of lower pin and memory usage is provided in this section. In this method, an IDAC is used to source a known amount of current through the thermistor, and the voltage across it is measured to obtain its resistance. The disadvantages are the accuracy will be lower, since the offset and gain errors are not being accounted for, and the coefficients of the thermistor have to be provided by you in firmware. Over Voltage and Over Current Protection The method explained for the OV/OC in the earlier sections of this application note has the advantage of using one IDAC. Its disadvantage is the complication introduced in calculating the external resistors. Some modifications of the circuit are given in this section to show the options for tradeoffs. Two IDACs are used instead of one to generate the reference voltages for OV and OC. This makes the resistor selection less complicated for the user than the single IDAC method explained in switching method. The second option shown is to route the signal from the IDAC to the comparator internally, instead of connecting the two pins externally. This option saves a pin, but requires manual routing between the IDAC and the comparator. This is to make sure that the IDAC connection to the resistor is made at the same location as the connection to the comparator. When automatic routing is used, additional switches are used between the comparator connection and the pin, which causes the voltage seen at the comparator to be different from the voltage at the pin and makes the fault detection erroneous. www.cypress.com Document No. 001-73468 Rev. *D 20 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Battery Current Control with PWM The charge current passed to the battery is decided based on the state of the battery. The dithered PWM was used in the main section of the application note as the duty cycle required for the switching method is high. The dithered PWM can be used for the linear method to maintain consistency in the project used. If you are interested in linear method alone, you can use the standard PWM instead of the dithered PWM for linear method to save additional component and memory usage. The connections for linear method with a regular PWM, instead of a custom Dithered PWM component, is shown in following figure. A PWM-DAC is formed by using external RC low-pass filter. The voltage obtained at the output of the low-pass filter controls the current through Q1 and thereby Q2. The current through Q2 is the charge current to the battery. www.cypress.com Document No. 001-73468 Rev. *D 21 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Document History ® Document Title: PSoC 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger – AN73468 Document Number: 001-73468 Revision ECN Orig. of Change Submission Date Description of Change ** 3475721 RJVB 12/26/2011 New application note. *A 3512389 RJVB 01/30/2012 Updated project files. No technical updates. *B 3818140 SREH 11/20/2012 Updated to include PSoC 5LP. Project files updated. Update to Battery Protection logic. Updated Software Version as “PSoC® Creator™ 3.0 or Higher”. *C 4227505 SREH 12/20/2013 Updated attached associated projects to Creator 3.0. Updated in new template. Completing Sunset Review. Updated Software Version as “PSoC® Creator™ 3.3 or Higher”. Updated attached associated projects to Creator 3.3 SP1. Updated project to use standard component. *D 5048763 SREH 03/01/2016 Updated the following diagrams: Thermistor Calculator Component. Battery Parameter Measurement. Charge Display Tool for Display and Debug Appendix D images. www.cypress.com Document No. 001-73468 Rev. *D 22 PSoC® 3 and PSoC 5LP - Single-Cell Lithium-Ion (Li-ion) Battery Charger Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. PSoC® Solutions Products ® ® ARM Cortex Microcontrollers cypress.com/arm cypress.com/psoc Automotive cypress.com/automotive PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP Clocks & Buffers cypress.com/clocks Cypress Developer Community Interface cypress.com/interface Lighting & Power Control cypress.com/powerpsoc Memory cypress.com/memory PSoC cypress.com/psoc Touch Sensing cypress.com/touch USB Controllers cypress.com/usb Wireless/RF cypress.com/wireless Community | Forums | Blogs | Video | Training Technical Support cypress.com/support PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 951341709 Phone Fax Website : 408-943-2600 : 408-943-4730 : www.cypress.com © Cypress Semiconductor Corporation, 2011-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you under its copyright rights in the Software, a personal, non-exclusive, nontransferable license (without the right to sublicense) (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units. Cypress also grants you a personal, non-exclusive, nontransferable, license (without the right to sublicense) under those claims of Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely to the minimum extent that is necessary for you to exercise your rights under the copyright license granted in the previous sentence. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited. CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, lifesupport devices or systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and Company shall and hereby does release Cypress from any claim, damage, or other liability arising from or related to all Unintended Uses of Cypress products. Company shall indemnify and hold Cypress harmless from and against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of Cypress products. Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective owners. www.cypress.com Document No. 001-73468 Rev. *D 23