An137_lithium Ion Battery Charger Using c8051f300

download An137_lithium Ion Battery Charger Using c8051f300

of 36

description

SI Labs, Lipo charging AN137

Transcript of An137_lithium Ion Battery Charger Using c8051f300

  • Rev. 1.3 7/13 Copyright 2013 by Silicon Laboratories AN137Silicon Laboratories Confidential. Information contained herein is covered under non-disclosure agreement (NDA).

    AN137

    LITHIUM ION BATTERY CHARGER USING C8051F300

    IntroductionDriven by the need for untethered mobility andease of use, many systems rely on rechargable bat-teries as their primary power source. The batterycharging circuitry for these systems is typicallyimplemented using a fixed-function IC to controlthe charging current/voltage profile.

    The C8051F30x family provides a flexible alterna-tive to fixed-function battery chargers. This appli-cation note discusses how to use the C8051F30xfamily in Li-Ion battery charger applications. TheLi-Ion charging algorithms can be easily adapted toother battery chemistries, but an understanding ofother battery chemistries is required to ensureproper charging for those chemistries.

    The code accompanying this application note wasoriginally written for C8051F30x devices. Thecode can also be ported to other devices in the Sili-con Labs microcontroller range.

    Key Points On-chip high-speed, 8-bit ADC provides supe-

    rior accuracy in monitoring charge voltage (critical to prevent overcharging in Li-Ion applications), maximizing charge effectiveness and battery life.

    On-chip PWM provides means to implement buck converter with a very small external inductor.

    On-chip Temp sensor provides an accurate and stable drive voltage for determining battery temperature. An external RTD (resistive tem-perature device) can also be used via the flexi-ble analog input AMUX.

    A single C8051F30x platform provides full product range for multi-chemistry chargers, expediting time to market and reducing inven-tory.

    V Pos (+)

    V Neg (-)

    LED

    BuckConverter

    Sense Resistor

    Li-IonCells

    8k FLASH, PWM,Temp Sensor,

    Precision Time Base

    8051F30x

    CygnalIntegratedProducts

    ResistorDivider

    LDO

    PWM Out

    AIN

    Figure 1. Lithium Ion Battery Charge Block Diagram.

  • AN137

    2 Rev. 1.3

    Charging BasicsBatteries are exhaustively characterized to deter-mine safe yet time-efficient charging profiles. Theoptimum charging method for a battery is depen-dent on the batterys chemistry (Li-Ion, NiMH,NiCd, SLA, etc.). However, most charging strate-gies implement a 3-phase scheme:

    1. Low-current conditioning phase

    2. Constant-current phase

    3. Constant-voltage phase/charge termination

    All batteries are charged by transferring electricalenergy into them (refer to the references at the endof this note for a battery primer). The maximumcharge current for a battery is dependent on the bat-terys rated capacity (C). For example, a batterywith a cell capacity of 1000mAh is referred to asbeing charged at 1C (1 times the battery capacity) ifthe charge current is 1000mA. A battery can becharged at 1/50C (20 mA) or lower if desired.However, this is a common trickle-charge rate andis not practical in fast charge schemes where shortcharge-time is desired.

    Most modern chargers utilize both trickle-chargeand rated charge (also referred to as bulk charge)while charging a battery. The trickle-charge currentis usually used in the initial phases of charging tominimize early self heating which can lead to pre-mature charge termination. The bulk charge is usu-ally used in the middle phase where the most of thebatterys energy is restored.

    During the final phase of battery charge, whichgenerally takes the majority of the charge time,either the current or voltage or a combination ofboth are monitored to determine when charging iscomplete. Again, the termination scheme dependson the batterys chemistry. For instance, most Lith-ium Ion battery chargers hold the battery voltageconstant, and monitor for minimum current. NiCd

    batteries use a rate of change in voltage or tempera-ture to determine when to terminate.

    Note that while charging a battery, most of the elec-trical energy is stored in a chemical process, but notall as no system is 100 percent efficient. Some ofthe electrical energy is converter to thermal energy,heating up the battery. This is fine until the batteryreaches full charge at which time all the electricalenergy is converted to thermal energy. In this case,if charging isnt terminated, the battery can bedamaged or destroyed. Fast chargers (chargers thatcharge batteries fully in less than a couple hours)compound this issue, as these chargers use a highcharge current to minimize charge time. As one cansee, monitoring a batterys temperature is critical(especially for Li-Ion as they explode if over-charged). Therefore, the temperature is monitoredduring all phases. Charge is terminated immedi-ately if the temperature rises out of range.

    Li-Ion Battery Charger - HardwareCurrently, Li-Ion batteries are the battery chemistryof choice for most applications due to their highenergy/space and energy/weight characteristicswhen compared to other chemistries. Most modernLi-Ion chargers use the tapered charge termination,minimum current (see Figure 2), method to ensurethe battery is fully charged as does the examplecode provided at the end of this note.

    Buck Converter

    The most economical way to create a tapered ter-mination charger is to use a buck converter. A buckconverter is a switching regulator that uses aninductor and/or a transformer (if isolation isdesired), as an energy storage element to transferenergy from the input to the output in discretepackets (for our example we use an inductor; thecapacitor in Figure 3 is used for ripple reduction).Feedback circuitry regulates the energy transfer viathe transistor, also referred to as the pass switch, tomaintain a constant voltage or constant current

  • AN137

    Rev. 1.3 3

    within the load limits of the circuit. See Figure 3for details.

    Tapered Charger Using the F30x

    Figure 3 illustrates an example buck converterusing the F30x. The pass switch is controlled viathe on-chip 8-bit PWM (Pulse Width Modulator)output of the PCA. When the switch is on, currentwill flow like in Figure 3A. The capacitor ischarged from the input through the inductor. Theinductor is also charged. When the switch isopened (Figure 3B), the inductor will try to main-tain its current flow by inducing a voltage as thecurrent through an inductor cant change instanta-neously. The current then flows through the diodeand the inductor charges the capacitor. Then thecycle repeats itself. On a larger scale, if the dutycycle is decreased (shorter on time), the average

    voltage decreases and vice versa. Therefore, con-trolling the duty cycles allows one to regulate thevoltage or the current to within desired limits.

    Selecting the Buck Converter Inductor

    To size the inductor in the buck converter, one firstassumes a 50 percent duty cycle, as this is wherethe converter operates most efficiently.

    Duty cycle is given by Equation 1, where T is theperiod of the PWM (in our example T = 10.5S).

    Charge Current

    Charge Voltage

    TimeConditioningPhase

    Current regulation Voltage regulation

    Figure 2. Lithium Ion Charge Profile.

    Inductor

    CapacitorPowerSource Battery

    Inductor

    Pass Switch Off

    CapacitorPowerSource Battery

    (A) (B)

    Pass Switch On

    ShottkyDiode

    ShottkyDiode

    Figure 3. Buck Converter.

    DutyCycle tonT

    ---------=

    Equation 1. Duty Cycle.

  • AN137

    4 Rev. 1.3

    With this established, select a PWM switching fre-quency. As Equation 2

    shows, the larger the PWM switching frequency,the smaller (and more cost effective) the inductor.Our example code configures the F30xs 8-bithardware PWM to use the internal master clock of24.5MHz divided by 256 to generate a 95.7kHzswitch rate.

    Now we can calculate the inductors size. Assum-ing Vi, the charging voltage, is 15V, Vsat, the satu-ration voltage, is 0.5V, the desired output voltage,Vo, is 4.2V, and I0MAX, the maximum output cur-rent, is 1500 mA, the inductor should be at least18H. Note that the capacitor in this circuit is simply aripple reducer. The larger it is the better as ripple isinversely proportional to the size of the cap. Formore details on buck converters, refer to the refer-ences listed at the end of this note.

    Li-Ion Battery Charger - SoftwareThe software example that follows demonstrates aLi-Ion battery charger using the C8051F300. TheF300 is designed for high-level languages like Cand includes an 8-bit 8051 based micro-controller,an 8-bit 500 ksps ADC, 8k FLASH, an 8-bit and16-bit PWM, and a 2% accurate oscillator all on-chip. The algorithms discussed are written entirelyin C making them easily portable. Refer to theF300s datasheet for a full description of thedevice.

    Calibration

    To ensure accurate voltage and current measure-ments, the algorithms use a two-point system cali-bration scheme. In this scheme, the user is expectedto apply two known voltages and two known cur-rents, preferable, one point near ground and theother point near full-scale. The algorithm thentakes these two points, calculates a slope and anoffset for both the current and voltage channels,and stores the results in FLASH. All future conver-sions are scaled relative to these slope and offsetcalculations. Note that if an external amplifier isused for the current channel, it will need to be cali-brated with a similar two-point calibration schemeto ensure maximum accuracy.

    Temperature

    To monitor the temperature, the algorithms use theon-chip temperature sensor. The sensor is leftuncalibrated, but still provides a sufficiently accu-rate temperature measurement. For more accuratetemperature measurement, one or two-point tem-perature calibration is required.

    An external temperature sensor can be used ifdesired. The AMUX can to be reconfigured toaccommodate this additional input voltage.

    Current

    The charge-current to the battery cells is monitoredby taking a differential voltage reading across asmall but accurate sense resistor. The current isamplified through the on-chip PGA, digitized bythe on-chip 8-bit ADC, and scaled accordingly viathe slope and offset calibration coefficients. Anexternal gain stage may be necessary if more reso-lution is desired for the current measurement.

    Voltage

    The batterys voltages are divided down and moni-tored via external resistors. Note that this exampleuses the supply voltage as the ADC voltage refer-ence. Any monitored voltage above the referencevoltage must be divided down for accurate moni-

    L Vi Vsat Vo ton2Iomax

    ----------------------------------------------------=

    Equation 2. Inductor Size.

  • AN137

    Rev. 1.3 5

    toring. If a more accurate reference is required, anexternal voltage reference can be used. Adjustmentto the divide resistors must be made accordingly.

    Charging - Phase1

    In phase 1, (for description purposes, we assumethe battery is initially discharged), the F30x regu-lates the batterys current to ILOWCURRENT (typi-cally 1/50 C) until the batterys voltage reachesVMINVOLTBULK. Note that the batterys charge cur-rent is current limited to ILOWCURRENT to ensuresafe initial charge and to minimize battery self-heating. If at any time the temperature increases outof limit, charging is halted.

    Charging - Phase 2

    Once the battery reaches VMINVOLTBULK the char-ger enters phase 2, where the batterys algorithmcontrols the PWM pass switch to ensure the outputvoltage provides a constant charge-current IBULKto the battery (rate or bulk current is usually 1C andis definable in the header file as is ILOWCURRENTand VMINVOLTBULK).

    Charging - Phase 3

    After the battery reaches VTop (typically 4.2 V insingle cell charger), the charger algorithm entersphase 3, where the PWM feeds back and regulatesthe batterys voltage. In phase 3, the battery contin-ues to charge until the batterys charge currentreaches IMINIBULKl, after which, the battery ischarged for an additional 30 minutes and thencharge terminates. Phase 3 typically takes themajority of the charging time.

    Note that in most practical applications, such as aportable PC, the batteries may be in any of the threephases when charging is activated. This doesntreally affect the charger as it simply monitors the

    batterys current condition and starts charging fromthat point.

    ConclusionThe C8051F300s high level of analog integration,small form-factor, integrated FLASH memory, andlow power consumption makes it ideal for flexiblenext generation battery charging applications. Thisapplication note discussed how to use theC8051F30x family in Lithium Ion battery chargerapplications. Example code is provided as well.

    ReferencesMaxim Integrated Product, DC-DC ConverterTutorial.

    Martinez, Carlos and Drori, Yossi and Ciancio,Joe, AN126 Smart Battery Primer, Xicor, Octo-ber 1999.

  • AN137

    6 Rev. 1.3

    Appendix

    Figure 4. 1 Cell Battery Charger Schematic.

  • AN137

    Rev. 1.3 7

    Figure 5. 1 Cell Buck Converter Schematic.

  • AN137

    8 Rev. 1.3

    main()

    Config_F300()

    ErrorDetected

    ?

    BULK_charge()

    Turn off LED0, Error

    Yes

    No

    No

    CalibrateADCforMeasurement()

    Enable Interrupts

    Clear Termination FlagsClear Charge Status Flags

    Yes

    LOWCURRENT_charge()

    No

    Status = BULK?

    Status =LOWCURRENT

    ?

    SW0Pressed?

    ?

    ErrorDetected

    ?

    Infinite Loop

    Yes/No

    Yes

    No

    Yes

    Turn on LED0

    InfiniteLoop

    Yes/No

    Figure 6. main() Flow Chart.

  • AN137

    Rev. 1.3 9

    CalibrateADCforMearurement()

    END

    NoSW0

    Pushed?

    Setup ADC0's AMUX,Throughput, Gain, for nearzero-scale voltage cal point

    Yes

    Acquire 16-bitMeasurement

    Setup ADC0's AMUX,Throughput, Gain, for nearfull-scale voltage cal point

    Calculate Voltage SlopeCoefficient

    Calculate Voltage OffsetCoefficient

    Erase Memory Page0x1A00

    Store Voltage Offset andSlope Coefficients in

    FLASH Memory

    Acquire16-bitMeasurement

    SW0Pushed

    ?

    Setup ADC0's AMUX,Throughput, Gain, for nearzero-scale Current cal point

    Yes

    Acquire 16-bitMeasurement

    Setup ADC0's AMUX,Throughput, Gain, for nearfull-scale Current cal point

    Calculate Current SlopeCoefficient

    Calculate Current OffsetCoefficient

    Store Current Offset andSlope Coefficients in

    FLASH Memory

    Acquire16-bitMeasurement

    No

    Figure 7. CalibrateADCforMeasurement() Flow Chart.

  • AN137

    10 Rev. 1.3

    Monitor_Battery()

    MeasurementType

    ?

    AMUX = Current AMUX = Volt

    AV = AV + ADC0 Turn PWM on

    Stop PWM

    I?

    ADC0 Done?

    AMUX = Volt

    Stop PWM

    AMUX = Temperature

    Start ADC0

    AV = AV/10

    END

    No

    Current Charge Voltage Temperature Battery Voltage

    AV = 0I = 0

    Yes

    No

    Yes

    Calculate Voltage w/Calibration Coefficients

    Calculate Current w/Calibration Coefficients

    Calculate Temperature w/Calibration Coefficients

    TemperatureCurrentVoltage w/ or w/out PWM

    Return Desired Parameter

    Figure 8. Monitor_Battery() Flow Chart.

  • AN137

    Rev. 1.3 11

    Bulk_Charge()

    Start PWM w/ Zero Output

    TWithin Limits

    ?

    Yes

    Status = const_C

    Calculate bulk_finish_time

    Green LED On

    Regulate Battery Current

    Read Charge Voltage

    Change Status fromconst_C to const_V

    V min_Bulk

    ?

    Status =BULK & No

    Error?

    Status =const_c

    ?

    ChargeVoltage Within

    Limits?

    Yes

    No

    No

    ACB D

    Yes

    No

    No

    No

    Yes

    Yes

    Set Appropriate Flags

    Figure 9. Bulk_Charge() Flow Chart (Part 1).

  • AN137

    12 Rev. 1.3

    Status =const_V

    ?

    Yes

    Regulate Voltage()

    Stop PWM& Flag Error

    Stop PWM& Flag Error

    Status = const_CStatus = LOWCURRENT

    Green LED Off

    TimeOverflow

    ?

    Temp.Overflow

    ?

    60 Sec.Over

    ?

    DelayTimeOver

    ?

    Yes

    No

    No

    ACB D

    Yes

    No

    No

    Yes

    END

    Stop PWM

    const_V, NOT Delay & Current

    Below Threshold?

    Calculate bulk_finish_time

    Status = Delay

    No

    No

    Yes

    Yes

    Figure 10. BULKCurrent() Flow Chart (Part 2).

  • AN137

    Rev. 1.3 13

    LOWCURRENT_charge()

    ResetTimeBase()

    Tempwithin Limits

    ?

    ChargeVoltage

    Within Limits?

    V

  • AN137

    14 Rev. 1.3

    Turn_PWM_Off()

    END

    Increment CEX0Counter

    CEX0Counter

  • AN137

    Rev. 1.3 15

    measure()

    END

    i = 0?

    Set accumulator andcounter i variables to zero

    Yes

    accumulator =accumulator + ADC0

    Increment i

    Clear End of ConversionFlag

    ConversionComplete

    ?

    No

    Return 16-bitMeasurement

    No

    Start New Conversion

    Yes

    Figure 13. Measure() Flow Chart.

  • AN137

    16 Rev. 1.3

    Make Duty Cycle Larger

    Voltage