Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. NiMH Battery Charger Reference Design Designer Reference Manual M68HC08 Microcontrollers DRM051/D Rev. 1, 10/2003 MOTOROLA.COM/SEMICONDUCTORS For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... NiMH Battery Charger Reference Design Designer Reference Manual — Rev 1 By: Roger Fan Application Engineering Microcontroller Division Hong Kong To provide the most up-to-date information, the revision of our documents on the World Wide Web will be the most current. Your printed copy may be an earlier revision. To verify you have the latest information available, refer to: http://motorola.com/semiconductors The following revision history table summarizes changes contained in this document. Motorola and the Stylized M Logo are registered trademarks of Motorola, Inc. DigitalDNA is a trademark of Motorola, Inc. This product incorporates SuperFlash® technology licensed from SST. DRM051 — Rev 1 © Motorola, Inc., 2003 Designer Reference Manual MOTOROLA 3 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — DRM051 Freescale Semiconductor, Inc... Revision History Section Page 2 12 Description of Change Figure 2-1: Minor changes to ADC channels for consistency Designer Reference Manual DRM051 — Rev 1 4 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — DRM051 Table of Contents Freescale Semiconductor, Inc... Section 1. System Overview 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 1.2 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 1.3 MC68HRC908JK3E Features. . . . . . . . . . . . . . . . . . . . . . . . . . .8 1.4 Charging Characteristic of NiMH Battery Cell. . . . . . . . . . . . . . .8 Section 2. Hardware and Firmware 2.1 Hardware Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 Firmware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3 Firmware Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Section 3. Solution 3.1 Test Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.2 Extra Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.3 Further Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.4 Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 DRM051 — Rev 1 Designer Reference Manual MOTOROLA 5 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. Designer Reference Manual DRM051 — Rev 1 6 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. System Overview Introduction Designer Reference Manual — DRM051 Section 1. System Overview Freescale Semiconductor, Inc... 1.1 Introduction This manual describes a reference design for a NiMH battery charger that uses the Motorola MC68H(R)C908JK3E MCU. For full specification of MC68H(R)C908JK3E, please refer to the data sheet, Motorola order number MC68HC908JL3/D. RD68CH908NBCSW contains software files for this design and is available from the motorola website: http://motorola.com/sps. 1.2 Overview MC68H(R)C908JK3E is a member of Motorola HC08 Family of microcontrollers (MCUs). The MC68H(R)C908JK3E includes a 10-channel Analog-to-Digital Converter (ADC) and a 2-channel Timer Module which can be programmed to generate PWM signals. This feature makes this MCU suitable for applications such as a NiMH or NiCd battery charger. The MC68H(R)C908JK3E is available in several packages. In this reference design, the low-cost NiMH battery charger demonstrated uses the 20-pin SOIC package. The main features of this low-cost NiMH battery charger reference design include: • • • Capable of fast charging two in-series NiMH batteries with charging current approximately 1 A Implements fast, trickle, and maintenance charging modes Safety protection terminates charging when: • • – Battery is fully charged by -ve dV, zero dV/dt and dT/dt. – Maximum charging-time is achieved – Battery’s temperature, voltage, or current is out of range Auto detection of battery insertion Supports in-circuit programming DRM051 — Rev 1 MOTOROLA Designer Reference Manual System Overview For More Information On This Product, Go to: www.freescale.com 7 Freescale Semiconductor, Inc. System Overview Freescale Semiconductor, Inc... 1.3 MC68HRC908JK3E Features MC68HRC908JK3E is a 20-pin MCU which has 4096 bytes of user FLASH memory. The FLASH memory can be on-chip, in-application programmed without special programming voltage. By use of the internal charge pump of the MCU, the FLASH memory can be read, programmed, and erased from a single external supply. MC68HRC908JK3E has128 bytes RAM, a 10-channel, 8-bit ADC. The RC oscillator helps to reduce the system cost of the application by eliminating the expensive external crystal oscillation circuit. It has one 16-bit timer module with two timer channels which can be configured to generate PWM signals. Most of the I/O pins are multiplex together with the ADC channels, KBI, and TIM. This gives users great flexibility for their application. All of these features make MC68HRC908JK3E suitable for small applications like a battery charger. 1.4 Charging Characteristic of NiMH Battery Cell Figure 1-1 illustrates the charging characteristic of a NiMH cell with charging current applied. When charging a NiMH battery, the battery’s cell voltage will rise rapidly to reach 1.3 V or 1.4 V depending on the charging current. So for a NiMH battery, if the battery voltage is below 1.0 V before charging, we should apply a small charging current for a few minutes to test whether the battery is good or faulty. This is for safety purposes only. If the battery is good, then we can start fast charging process. When the battery is fully charged, the battery voltage will stop rising and it may level off or drop slightly. In this case, we can apply the –ve dv or zero dv method to check and cut off the charging power when the battery is fully charged. During charging, the NiMH battery cell will start getting warm. Continuing to charge the battery when it is near fully charged will make its temperature rise much quicker. We can also make use of this characteristic to tell that the battery is fully charged. Designer Reference Manual 8 DRM051 — Rev 1 System Overview For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Overview Charging Characteristic of NiMH Battery Cell Fully Charged Checkpoint dV/dt = 0, max. dT/dt Cell Voltage is measured WHILE charge current is applied 1.6 45 dV/dt = 0 1C 0.5C 1.5 40 0.1C Freescale Semiconductor, Inc... Cell Voltage[V] 1.4 35 1C max. dT/dt 1.3 Cell Temp. [o C] 0.5C 30 0.1C 1.2 1.1 25 0 20 40 60 80 100 120 140 20 160 Capacity Input [%] Figure 1-1. Charging Characteristics of NiMH Cell DRM051 — Rev 1 MOTOROLA Designer Reference Manual System Overview For More Information On This Product, Go to: www.freescale.com 9 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Overview ² Designer Reference Manual 10 DRM051 — Rev 1 System Overview For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware and Firmware Hardware Descriptions Designer Reference Manual — DRM051 Section 2. Hardware and Firmware Please refer to the detailed schematics at 3.3.3 Schematics. Current Source 5V 1A(d.c.) NiMH Battery PNP TR Vb 3 PWM Voltage Regulator +5V TCH0 VDD ADC0 Vdd Vdd Charge Status LED1 LED2 HRC908JK3 Freescale Semiconductor, Inc... 2.1 Hardware Descriptions 2 Vt ADC1 T ADC2 Vi 1 RST VSS Reset Button 0V Figure 2-1. NiMH Battery Charger Block Diagram 2.1.1 Power Supply to the MCU The power supply input to the charger is a regulated 5 V, 1 A at P1. TL431 is used in this reference design to act as a voltage regulator. It serves two purposes: • to provide accurate power to the microcontroller with Vdd = 4 V • to provide reference voltage for the ADC module with 1% in accuracy DRM051 — Rev 1 MOTOROLA Designer Reference Manual Hardware and Firmware For More Information On This Product, Go to: www.freescale.com 11 Freescale Semiconductor, Inc. Hardware and Firmware 2.1.2 Charging Control Pin 19 of the MCU is the TCH0 which is configured as a PWM output. The PWM output signal will control the on/off of charging power to the battery, and thus controls the charging current and voltage. Q2, D1, L1, and C8 form the bulk regulator, which provides a smoother charging power source to the battery being charged. Freescale Semiconductor, Inc... 2.1.3 Sensing Circuit Three ADC channels (ADC0, ADC1, and ADC2) of the MCU are used in this reference design for checking the battery's voltage, current, and temperature. Charging current is determined at the B- of J1 by AD2. When the battery is being charged, charging current will flow through the detection resistors R18 and R29. A voltage drop will appear on the resistors R18 and R29. R18 and R29 are 1 Ω, 1% resistors. They are in parallel and give an equivalent value of 0.5 Ω. With a charge current of 1 A, the voltage at B- will be 500 mV. The voltage of the battery can be determined directly at the B+ terminal of J1. When the battery is being charging, current will flow through the R18 and R19. Therefore it is required to subtract the voltage across on these two resistors. That is, subtract the voltage at B- to obtain the actual battery voltage at its terminals. An NTC is connected between terminals T of J1 and ground. The battery's temperature can be determined by detecting the voltage at the terminal T of J1 with the help of the NTC. 2.1.4 Charging Status PTD2 and PTD3 are used to control the on/off of the two LEDs which indicate the status of the charger during charging. (Please refer to Table 2-1). Both of them are set as output port. When output high, it will turn off the LED. When output low, it will turn on the LED. Designer Reference Manual 12 DRM051 — Rev 1 Hardware and Firmware For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware and Firmware Hardware Descriptions Freescale Semiconductor, Inc... Table 2-1. Charging Status Red LED Green LED Charge in Progress On Off Battery is Fully Charged Off On Battery is Not Connected Off Off Fault Condition Occurred Flashing Flashing 2.1.5 In-Circuit Programming J3 contains the signals for the MCU 68HRC908JK3E to enter monitor mode for ICP. The ICP requires connecting J3 to the MON08 cable of Cyclone programmer (see Figure 2-2). The signals from the J3 are Vdd, Vss, Vtst and OSC1, and PA0. Entering monitor mode also requires that PTB1 is pulled low, and PTB2 and PTB3 must be pulled up. This requirement is fulfilled with the carefully designed charger hardware. When in-circuit programming, the jumper J4 must be opened to disconnect the filter cap, 0.1 µF at PTB0/AD0 to avoid distortion of the data signal caused by the capacitor’s loading. The programming software is PROG08SZ.exe from P&E. Select Class V for Target Hardware Type. Select baud rate 9600 bps. The ICP supports erasing, programming, and verifying the firmware in the MCU. DRM051 — Rev 1 MOTOROLA Designer Reference Manual Hardware and Firmware For More Information On This Product, Go to: www.freescale.com 13 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Hardware and Firmware Figure 2-2. In-Circuit-Programming of the JK3E Charger 2.2 Firmware Description 2.2.1 Battery Inserted Detection When the charger is powered up, the charger-control software will enable the PWM output, and it will gradually charge up the cap E8. Before any battery is inserted, the B+ voltage read by the AD0 will be near or equal to its full scale. Whenever a battery is inserted, the B+ voltage will fall immediately to the value equal to the battery’s voltage. Therefore, the battery insertion or removal can be checked by the microcontroller by sensing the variation of B+ points’ voltage of the battery. (Please refer to 3.3.3 Schematics). When battery insertion is detected, the firmware will go on to check the inserted battery's terminal voltage and temperature. If they fall in the Designer Reference Manual 14 DRM051 — Rev 1 Hardware and Firmware For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware and Firmware Firmware Description valid range, then proceed to charging mode. Table 2-2 compares the battery voltage to the charger status. Table 2-2. Battery Voltage and Charger Status Freescale Semiconductor, Inc... Battery Voltage Charger Status Vbat < 1.0 V Not charging, bad battery, flashing LEDs Vbat > 2.8 V Battery full, no charging, green LED on 1.0 V < Vbat < 2.0 V Trickle charge, red LED on 2.0 V <Vbat < 2.8 V Fast charge, red LED on Vtemp < 0 °C Not charging, flashing LEDs Vtemp > 45 °C Not charging, flashing LEDs I_charge > 1.5 A Over current, stop charging, flashing LEDs 2.2.2 Trickle Charge If the battery voltage is <2.0 V but >1.0 V, then go to trickle charge. The current for the trickle charge is set to 0.1C which equals to the 10% of the battery's rate capacity. The maximum charge time is 10 minutes. If within 10 minutes time, the battery voltage can be charged above 2.0 V, then the battery is good and the charger can be switched to fast charging mode. If the voltage does not rise up to 2.0 V after 10 minutes trickling charge, the charger will signify that the battery is bad and stop the charging process. 2.2.3 Fast Charge In fast charging mode, a constant current of 1 A is applied to the battery. A maximum charging time is set for the fast charging mode to prevent over charging. Fast charging mode is actually a constant current charging mode and the charger system is in closed-loop control. The firmware continuously checks the charging current by sensing the voltage at the current-determining resistors (R13, R14) and adjusts the duty of PWM DRM051 — Rev 1 MOTOROLA Designer Reference Manual Hardware and Firmware For More Information On This Product, Go to: www.freescale.com 15 Freescale Semiconductor, Inc. Hardware and Firmware output from the MCU accordingly. The battery's voltage is checked frequently during the charging process. Whenever the zero dV or –ve dV condition is detected, the battery is announced fully charged. In the meantime, if the MCU determined that the battery’s temperature gradient is becoming steep and the battery’s voltage is over 1.4 V, the battery is also announced fully charged. Freescale Semiconductor, Inc... Since the charging current and the battery’s terminal voltage must be measured with the charging current applied, the transistors Q1 and Q2 (which are controlled by the PWM output pin of the MCU) must be turned on when the measurement takes place. This can be implemented by the firmware described below. The timer overflow interrupt is enabled for the MCU and a flag will be set to indicate the timer overflow has occurred. This flag will be cleared after the ADC conversion. The PWM output is a part of the mechanism of the timer overflow. Immediately after the timer overflow, the PWM is output high to turn on Q1. Then Q2 turns on to charge the battery. When a measurement is required, the firmware will enable the corresponding ADC channel, clear this flag, and then wait until the flag is set again. After the flag is set, the MCU will start the ADC conversion to get the conversion data. This conversion data, either voltage or current, is the data with the charging current applied. It is required to determine whether the battery is fully charged. The flag will be cleared after the ADC conversion. Designer Reference Manual 16 DRM051 — Rev 1 Hardware and Firmware For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware and Firmware Firmware Description Freescale Semiconductor, Inc... Charging Current Table; Rsense = 0.5 Ohm, VrefH = 4.0V. I (mA) 1200 1000 800 500 200 Isense (mV) 600 500 400 250 100 Hex $26 $20 $19 $10 $06 Bat Voltage (V) Hex 1 $40 Battery Voltage Table; refH = 4.0V 1.8 2 2.4 2.6 2.8 3 $73 $80 $99 $A6 $B3 $C0 100 50 $03 3.2 $CC Battery Temperature Table; refH = 4.0V, R pull-up =10K (1%) T (degC) 50 45 40 25 10 0 R NTC (K) 3.63 4.4 5.356 10 19/85 32.33 Tsense (V) 1.17 1.34 1.53 2.2 2.92 3.36 Tsense(Hex) $4A $55 $61 $8C $BA $D6 3.4 $D9 3.6 E6 -5 42.81 3.57 $E3 2.2.4 Maintenance Charge When the battery is fully charged and not removed, the maintenance charge mode is applied. Maintenance charge will applied a 0.01C charging current to the battery continuously until the battery is removed or the battery voltage is low enough for a fast charge to take place. 2.2.5 Safety Protection During charging (either trickle or fast charge mode), anytime the battery's voltage, current, or temperature is determined to be out of range, the charger will shut off the charging power. DRM051 — Rev 1 MOTOROLA Designer Reference Manual Hardware and Firmware For More Information On This Product, Go to: www.freescale.com 17 Freescale Semiconductor, Inc. Hardware and Firmware 2.3 Firmware Files Firmware is complied under CASM08Z.EXE ver 3.16 from P&E Microcomputer System, Inc. Table 2-3 summarizes the functions of each firmware files: Freescale Semiconductor, Inc... Table 2-3. Files Functions Files Functions JK3ECHGRDEMO.asm Charger main program MC68HC908JL3.equ Registers and memory definitions file JK3ECHGR_INC.asm Subroutines file Designer Reference Manual 18 DRM051 — Rev 1 Hardware and Firmware For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Solution Test Description Designer Reference Manual — DRM051 Section 3. Solution Freescale Semiconductor, Inc... 3.1 Test Description The solution was tested with two 1.2 V NiMH battery cells using a +5 V power supply (HP6236B). 3.2 Extra Features There is a useful subroutine included in the file JK3ECHGR_INC.asm. It is DSRL_OUT which is a serial RS-232 data transmit routine. It uses PTB7 as the data line to serial out the data. The baud rate is 19200 bps when the RC oscillation frequency is trimmed at bus frequency of 2.4576 MHz. The data line is output to a standard RS-232 interface circuit that connected to the COM port of a PC. This routine is helpful in project development because the developer can monitor the battery charging status and has the charging parameters such as voltage, temperature, and current for analysis. Since RC oscillation is used, some fine tuning might need on the bit delay routines if the bus frequency cannot be tuned to exactly to 2.4576 MHz bus frequency. When calling this routine, the interrupt mask bit is set to avoid interrupt, and the mask interrupt bit will be clear before leave this subroutine. When software development is completed, calling this sub-routine is not necessary, and it should be removed from the main program. 3.3 Further Information 3.3.1 Related Documents MC68HRC908JK3E Technical Data DRM051 — Rev 1 MOTOROLA Designer Reference Manual Solution For More Information On This Product, Go to: www.freescale.com 19 Freescale Semiconductor, Inc. Solution 3.3.2 Notes on Schematic and Layout The current schematic and layout show an identical set of charging paths for another set of NiMH batteries. This is for user reference if implementing a charger that can charge four NiMH cells (i.e. 2 x 2 x1.2V). Freescale Semiconductor, Inc... 3.3.3 Schematics Figure 3-1. JK3 NiMH Battery Charger — MCU Section Designer Reference Manual 20 DRM051 — Rev 1 Solution For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Solution Further Information Figure 3-2. JK3 Battery Charger — Control Section DRM051 — Rev 1 MOTOROLA Designer Reference Manual Solution For More Information On This Product, Go to: www.freescale.com 21 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Solution Designer Reference Manual 22 DRM051 — Rev 1 Solution For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. HOW TO REACH US: USA/EUROPE/LOCATIONS NOT LISTED: Motorola Literature Distribution; P.O. Box 5405, Denver, Colorado 80217 1-303-675-2140 or 1-800-441-2447 JAPAN: Motorola Japan Ltd.; SPS, Technical Information Center, 3-20-1, Minami-Azabu Minato-ku, Tokyo 106-8573 Japan 81-3-3440-3569 Freescale Semiconductor, Inc... ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd.; Silicon Harbour Centre, 2 Dai King Street, Tai Po Industrial Estate, Tai Po, N.T., Hong Kong 852-26668334 Information in this document is provided solely to enable system and software implementers to use Motorola products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. TECHNICAL INFORMATION CENTER: Motorola reserves the right to make changes without further notice to any products 1-800-521-6274 herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Motorola assume any HOME PAGE: http://motorola.com/semiconductors liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Motorola does not convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Motorola product could create a situation where personal injury or death may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the design or manufacture of the part. Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2003 DRM051/D Rev. 1 For More Information On This Product, Go to: www.freescale.com