ATEVK527

Manufacturer Part NumberATEVK527
DescriptionKIT EVAL PWM AVR USB 4 SERIES
ManufacturerAtmel
SeriesAVR®
ATEVK527 datasheet
 

Specifications of ATEVK527

Main PurposePower Management, Battery ChargerEmbeddedYes, MCU, 8-Bit
Utilized Ic / PartATmega16U4, ATmega32U4Primary Attributes1 Cell- Li-Ion
Secondary AttributesGraphical User Interface, USB InterfaceLead Free Status / RoHS StatusLead free / RoHS Compliant
1
Page 1
2
Page 2
3
Page 3
4
Page 4
5
Page 5
6
Page 6
7
Page 7
8
Page 8
9
Page 9
10
Page 10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Page 1/35

Download datasheet (731Kb)Embed
Next
AVR146: Lithium-Ion Battery Charging via USB
with ATmega16/32U4
Features
• Fully Functional Design for Charging Lithium-Ion Batteries
• High Accuracy Measurement with 10-bit A/D Converter
• Modular “C” Source Code
• Easily Adjustable Battery and Charge Parameters
• Analog Inputs for Reading Battery ID and Temperature
• USB CDC class for user interface
1 Introduction
This application note is based on the ATmega16/32U4 and focuses on how to use
the EVK527 evaluation kit to charge Lithium-Ion (Li-Ion) batteries using USB
connection as power supply.
The USB CDC class offers an easy interface to display charge parameters.
This application note is derived from:
AVR458: Charging Lithium-Ion Batteries with ATAVRBC100
The firmware is written entirely in C language (using IAR
Workbench) and is easy to port to other AVR
Systems Embedded
®
microcontrollers.
®
8-bit
Microcontrollers
Application Note
Rev. 7801A-AVR-06/08

ATEVK527 Summary of contents

  • Page 1

    AVR146: Lithium-Ion Battery Charging via USB with ATmega16/32U4 Features • Fully Functional Design for Charging Lithium-Ion Batteries • High Accuracy Measurement with 10-bit A/D Converter • Modular “C” Source Code • Easily Adjustable Battery and Charge Parameters • Analog Inputs ...

  • Page 2

    Description AVR146 2 This document describes an application running on the EVK527 evaluation kit. The EVK527 is dedicated to ATmega16/32U4. The USB offers a 5V power supply on the VBUS pin. The available current range is from 100mA to ...

  • Page 3

    Displaying Charging Parameters on the PC 7801A-AVR-06/08 Figure 2-2. Device Manager Window. The application performs a continuous update of parameters displayed on the PC battery is detected and identified, the charger is not started. The State of ...

  • Page 4

    Theory of Operation 3.1 Li-Ion Battery Technology 3.1.1 Safety AVR146 4 Battery charging is made possible by a reversible chemical reaction that restores energy in a chemical system. Depending on the chemicals used, the battery will have certain characteristics. ...

  • Page 5

    Charging Li-Ion Batteries 3.2.1 Safety 3.2.2 Priming & Charge Intervals 7801A-AVR-06/08 The electronic protection circuit works as follows: • A solid-state switch is opened if the charge voltage of any cell reaches a given threshold. • A fuse cuts ...

  • Page 6

    Charge Stages AVR146 6 Lithium-Ion battery charge follows three stages: 1. Prequalification current: Charging of a Li-Ion battery starts with a test of battery voltage. If the voltage is under a defined threshold (PREQUAL_VOLTAGE), the charge starts with a ...

  • Page 7

    VARTA™ battery 3.3.1 Typical Charge Characteristics 3.3.2 Typical Battery Characteristics 7801A-AVR-06/08 Battery specifications should always be verified from manufacturer’s data sheets. Below is a summary of typical lithium-ion battery charge characteristics. Actual parameters may vary. Table 3-1. Typical Charge ...

  • Page 8

    Electrical pinout 3.4 VBUS Supply Voltage AVR146 8 This application uses a particular type of lithium-ion batteries and all configurations presented here are based on manufacturer’s data. Other lithium-ion batteries may naturally be used but ...

  • Page 9

    EVK527 Revision 3.6 Buck converter 7801A-AVR-06/08 • Self-Power Self powered functions can draw up to 100mA from VBUS and the rest from another source. The current to power the EVK527 and to charge the battery comes from VBUS. The ...

  • Page 10

    PWM frequency AVR146 10 The PWM speed for the PWM is programmed to the maximum (64MHz). The source clock is the PLL output (96MHz) used both by USB and PWM. A postscaler offers a 1.5 division for the PLL ...

  • Page 11

    Battery Charger Software 4.1 Scheduler 4.2 List of files 7801A-AVR-06/08 A scheduler is implemented to call indefinitely defined tasks. Before starting this infinite loop, init functions are called. There are three tasks. Each task is called after the end ...

  • Page 12

    Table 4-2. Project files for battery module (see IAR EW workspace file ) AVR146 12 File Type cdc_task.c C source code cdc_task.h Header file main.c C source code main.h Header file uart_lib.c C source code uart_lib.h Header file uart_usb_lib.c C ...

  • Page 13

    Overview 4.4 State Machine 7801A-AVR-06/08 File Type statefunc.c C source code statefunc.h Header file The firmware integrates all functions required to charge a lithium-ion battery. Table 4-3. Memory requirements of firmware (IAR without optimization) Build option Memory CODE (Flash) ...

  • Page 14

    Initialize() 4.4.2 BatteryControl() AVR146 14 Label Related Function PREQUAL Charge() PREQUAL_CTRL Charge() SLEEP Sleep() CCURRENT Charge() CCURRENT_CTRL Charge() CVOLTAGE Charge() CVOLTAGE_CTRL Charge() ENDCHARGE Charge() DISCHARGE Discharge() ERROR Error() State functions are described in the following sections. The initialisation function ...

  • Page 15

    Charge() 7801A-AVR-06/08 Figure 4-4. Flow chart of battery control function The charge function contains the charging algorithm divided into stages. For this application, it has four stages: • Prequalification - during which the battery is charged with a constant ...

  • Page 16

    Figure 4-5. Flow chart of the charge state function AVR146 16 What is the current ST_PREQUAL ST_CCURRENT Set charge current to the Set charge current to the defined prequalification battery's maximum current. current. (BattData.MaxCurrent) (BAT_CURRENT_PREQUAL) Set ST_CCURRENT as the Set ...

  • Page 17

    Discharge() 4.4.5 Sleep() 7801A-AVR-06/08 Figure 4-6. End of charge state function. ST_PREQUAL_CTRL ST_CCURRENT_CTRL Call ConstantCurrent() Call ConstantCurrent() Return next state to batt_task(). This function has not been implemented. The application enters sleep mode when all batteries have been fully ...

  • Page 18

    Error() 4.5 Charging Control Functions 4.5.1 Constant Current/Voltage AVR146 18 Program flow is diverted here when an error has occurred. Program execution will exit the error handler when all sources of error have been cleared. The program flow is ...

  • Page 19

    Figure 5-3. Flow chart for ConstantCurrent() ConstantCurrent() Wait for ADC conversions to complete. Charging of battery inhibited? YES Drop PWM output to zero. NO Stop timers. Were we stopped by Master MCU YES earlier? Remove flag that Master MCU ...

  • Page 20

    Charge Halt Determination AVR146 20 Charge halt is determined by HaltNow(). This function is called by ConstantCurrent() and ConstantVoltage() every time they loop, to decide if a stage of charging is done. With the variable HaltParameters the user can ...

  • Page 21

    Figure 5-4. Flow chart for HaltNow() part 1. AVR146 21 ...

  • Page 22

    Figure 5-5. Flow chart for HaltNow() part 2 AVR146 22 7801A-AVR-06/08 ...

  • Page 23

    Figure 5-6. Flow chart for HaltNow() part 3 2 Halt on timeout? YES Charging timer run out AVR146 YES Set Halt flag. Flag battery as worn YES out? Stop PWM output. Disable battery and flag it ...

  • Page 24

    Other Functions 4.6.1 A/D Conversion AVR146 24 Figure 5-7. Flow chart for HaltNow() part 4 3 Battery temperature YES too cold or hot? Set Halt flag. NO Flag a battery temperature error and set ST_ERROR as next state. BatteryCheck() ...

  • Page 25

    Implementation 4.7.1 Configuration 7801A-AVR-06/08 Figure 5-8. Flow chart of ADC interrupt service routine 0b100011 0b001001 3/ Save NTC reading Set next MUX = 0b100100 1/ Format and save IBAT Update averaged IBAT Update ADC flag Set next MUX = ...

  • Page 26

    Table 5-1. Battery-related compile-time constants (see source file battery.h) AVR146 26 Label Description In case unmatched batteries are to be charged, this constant CELL_VOLTAGE_SAFETY is subtracted from CELL_VOLTAGE_MAX for every extra cell in the battery, ie. BAT_CELL_NUMBER – 1. CELL_VOLTAGE_MAX ...

  • Page 27

    Compilation Section Tab Target General Options System C/C++ Language Compiler Output Linker Extra Options 4.7.3 Programming 7801A-AVR-06/08 Both IAR and GCC project are available. The GCC project can use an external makefile (see Makefile in \gcc\default) or use the ...

  • Page 28

    ... CDC key pressed application removal. The HWB button is used to start the sending of data to the HyperTerminal. After the download of software with AVR Studio, the ATmega16/32U4 bootloader is erased download is needed by using FLIP (ATMEL ISP), a download of bootloader software (with AVR Studio) is needed. AVR146 ...

  • Page 29

    EVK527 Rev1.0.0 Schematics 7801A-AVR-06/08 Figure 6-1. Page 1/5 (Schematics Rev3.0.0 corresponds to Board Rev1.0.0) AVR146 29 ...

  • Page 30

    Figure 6-2. Page 2/5 AVR146 30 7801A-AVR-06/08 ...

  • Page 31

    Figure 6-3. Page 3/5 AVR146 31 ...

  • Page 32

    Figure 6-4. Page 4/5 AVR146 32 7801A-AVR-06/08 ...

  • Page 33

    Figure 6-5. Page 5/5 AVR146 33 ...

  • Page 34

    ... Retrieved April 3, 2007, from Battery University: http://www.batteryuniversity.com/partone-12.htm 4. “VARTA™ EasyPack” datasheet: 550mAh http://www2.varta- microbattery.com/en/mb_data/documents/promotion_varta_easypack/688819.pdf 750mAh http://www2.varta- microbattery.com/en/mb_data/documents/promotion_varta_easypack/688820.pdf 1000mAh http://www2.varta- microbattery.com/en/mb_data/documents/promotion_varta_easypack/688821.pdf 2000mAh http://www2.varta- microbattery.com/en/mb_data/documents/promotion_varta_easypack/688822.pdf 5. “ATmega32U4”. Available from Atmel web site: http://www.atmel.com/products/avr/ 7801A-AVR-06/08 ...

  • Page 35

    ... BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’ ...