1 Introduction
Lithium batteries have the advantages of high specific energy and low self-discharge, making them an ideal power source for portable electronic devices. In recent years, with the popularity of high-power and high-capacity portable electronic products such as laptops, PDAs, and cordless phones, the requirements for power systems have also increased. For this reason, it is particularly important to develop lithium battery chargers that are stable, safe, reliable, efficient, and economical.
Based on the comprehensive consideration of the cost, design rate and importance of safe battery charging, this paper designs a single-chip switching power supply lithium battery charger based on ATtiny261 single-chip microcomputer PWM control, which effectively overcomes the shortcomings of general chargers such as overcharging, undercharging and low efficiency, realizes intelligent charging of lithium battery packs, and achieves the expected effect. The solution is flexible in design and can meet the charging needs of various types of lithium batteries, and the integrated flash memory of ATtiny261 makes it easy to debug and upgrade software.
2 Lithium battery charging characteristics
Lithium battery charging requires controlling its charging voltage and limiting its charging current. Lithium batteries usually use a three-stage charging method, namely pre-charging, constant current charging and constant voltage charging. The charging current of lithium batteries should usually be limited to 1C (C is the capacity of the lithium battery), and the single-cell charging voltage is generally 4.2V, otherwise the battery may be permanently damaged due to excessive current.
Pre-charging is mainly to repair over-discharged lithium batteries. If the battery voltage is lower than 3V, pre-charging is necessary, otherwise this stage can be omitted. This is also the most common situation. In the constant current stage, the charger first provides a large constant current to the battery, and the battery voltage rises at the same time. When the battery voltage reaches the saturation voltage, it turns to low-voltage charging. The charging voltage fluctuation should be controlled within 50mV, and the charging current is reduced. When the current gradually decreases to the specified value, the charging process can be ended. Most of the battery's electrical energy flows from the charger to the battery during the constant current and constant voltage stages. As can be seen from the above, the charger is actually a precision power supply, and its current and voltage are limited to the required range.
3 Hardware Circuit Design
The system is mainly composed of three parts in circuit design: single-chip switching power supply, control circuit and protection circuit.
3.1 Monolithic Switching Power Supply
The monolithic switching power supply is responsible for converting electrical energy into the form required for battery charging, and constitutes the main power conversion mode of the charger. Compared with the traditional linear charger with large loss and low efficiency, the monolithic switching power supply composed of TNY268P of Power Integrations Company of the United States has a wide input voltage range (85265VAC), small size, light weight, high efficiency, and has functions such as voltage regulation, current limiting, and overheating protection, which is particularly suitable for forming a charging power supply. Its schematic diagram is shown in Figure 1.
Figure 1 Monolithic switching power supply
The power supply uses a photocoupler feedback circuit with a voltage regulator to achieve a 15V low-voltage DC output. When the output voltage changes, the current of the light-emitting tube through the linear photocoupler PC817 changes accordingly, causing the current flowing out of the EN pin of TNY268P to change, thereby controlling the on-chip power MOSFET to switch on and off, adjust the output voltage, and stabilize the input voltage. For a detailed analysis of the feedback principle, see the pulse width modulation (PWM) control later.
In terms of circuit structure, linear optocoupler PC817 can not only play a feedback role but also an isolation role. The current limiting circuit composed of PNP tube Q2 and resistors R9, R10 and R12 prevents the problem of overcurrent from the source. The slow-start circuit composed of C6 and R11 effectively suppresses the voltage spike generated when the power is powered on. The diode D9 prevents the reverse discharge of the battery pack. In addition, for the entire charging system, when the system loses control due to unexpected circumstances, the 15V DC low voltage provided by the switching power supply also plays a role in limiting its maximum voltage to some extent. [page]
3.2 Control Circuit
The single-chip microcomputer is responsible for controlling the operation of the entire system, including the setting of charging current and voltage values, the detection and adjustment of current and voltage, and the display of charging and discharging status. Compared with the dedicated charging control chip, the single-chip microcomputer control system is not only not restricted by the capacity of the battery pack, but also can achieve more flexible comprehensive control through the coordination of software and hardware, which is also convenient for further subsequent development.
The system control is implemented by Atmel's AVRATtiny261, and the control block diagram is shown in Figure 2. ATtiny261 adopts AVR RISC structure, and most of its instructions execute in only one clock cycle. It can achieve a performance close to 1MIPS/MHZ; 11 channels of 10-bit ADC. And 15 pairs of ADC differential channels with programmable gain, built-in 2.56V reference source with an accuracy of up to 2.5mV, 3 independent PWM generators, and on-chip temperature sensor, which are sufficient to meet the design requirements.
Figure 2 System control structure block diagram
3.2.1 Voluntary testing
The system voltage sampling adopts the precision resistor voltage division method to convert the measured voltage range into 0-2.56V, and then converts it into a digital signal through a 1x differential ADC channel. During the charging process, the measured voltage value is compared with the preset value, and then the PWM duty cycle is adjusted to complete the control and regulation of the charging voltage.
3.2.2 Current Detection
In the measurement of system current, since the ADC differential channel of ATtiny261 is selected, its positive input voltage must be greater than the negative input voltage. Therefore, in the circuit design, the high-precision sampling resistors RsenseB and RsenseA are connected in series in the main current loop, and the two pairs of 32-fold ADC differential channels ADC2-ADC1 and ADC1-ADC0 (see Figure 3) are used to complete the detection of charging and discharging currents respectively. It can be seen that the selection of differential ADC not only ensures the accuracy of current sampling, but also avoids the power loss problem caused by the introduction of differential remote amplifier in the circuit, which well meets the requirements of system performance and power consumption, and fully reflects the advantages of ATtiny261.
Figure 3 Battery protection circuit
3.2.3 Temperature detection
Temperature detection ensures the execution of safe charging steps. The system uses the ATtiny261's humidity sensor and performs temperature detection through ADCI1. The measured voltage is basically linear with temperature, and the accuracy of about lmv/°C can provide sufficient temperature measurement. For higher-precision temperature detection, it can be achieved by writing calibration values in software.
3.2.4 PWM Control
In the design, based on the feedback control of the above voltage regulator tube, the PWM method is introduced in the feedback link to control charging. The basic control idea is to use the PWM port of the microcontroller, without changing the PWM wave cycle, through the feedback of current and voltage, and use software to adjust the PWM duty cycle, so that the current or voltage is carried out according to the predetermined charging process.
After the system enters the charging working state, it is limited by the lithium battery termination charging voltage, and its maximum voltage shall not be higher than 12.7V. Therefore, the voltage regulator Zl in the switching power supply is always in the cut-off state, and the charging process is completely realized by PWM control. Taking constant voltage charging as an example, before adjusting the charging voltage, the microcontroller first quickly reads the charging voltage detection value, and then compares the set voltage value with the actual reading value. If the actual voltage is high, the PWM duty cycle is increased to increase the current 1F of the light-emitting diode of the linear optocoupler PC817, causing the EN pin of TNY268 to be set to a low level, the power MOSFET on the chip is turned off, and the output voltage is reduced. On the contrary, the PWM duty cycle is reduced->IF is reduced->EN pin is high level, the power MOSFET on the chip is turned on, and the output voltage increases. In the pre-charging and constant current charging stages, the current is adjusted by converting the current into voltage through the sampling resistor, so its PWM control adjustment process is completely similar to the constant voltage stage. When charging is finished, PWM continuously outputs a high level with a duty cycle of 1, turning off the on-chip MOSFET of TNY268P and interrupting the power conversion loop, so that charging stops automatically after full charge.
To ensure accurate sampling and avoid ripple interference caused by ADC reading deviation and power supply operating voltage, all sampling points are processed by resistor-capacitor filtering, and digital filtering technology is used in the software PWM adjustment process.
3.2.5 Buttons and Display
The charger's function button response is realized by the external interrupt of ATtiny261, and the LED display can be used to know the battery discharge status and remind the system to terminate. Each state of system charging and discharging corresponds to the corresponding LED display. It can determine whether a battery is loaded and provide battery short circuit protection based on voltage detection, and give an LED alarm signal.
3.3 Protection circuit
Due to the chemical characteristics of lithium batteries, during use, a positive chemical reaction of mutual conversion between electrical energy and chemical energy occurs inside the battery. However, under low conditions, such as overcharging, overdischarging and overcurrent, chemical side reactions will occur inside the battery. The intensification of such side reactions will seriously affect the performance and service life of the lithium battery, and may even cause explosions and lead to safety problems. Therefore, the lithium battery protection circuit is extremely important.
As shown in Figure 3, the circuit is composed of Seiko's multi-cell lithium battery protection chip S8233, which can effectively monitor the battery voltage and loop current, and shut down the discharge circuit under certain conditions by controlling the MOS tube FET-A or FET-B to prevent damage to the battery. Compared with other battery protection chips such as S8254, S8233 can also ensure the charging balance of the lithium battery pack through external MOS tubes FET1, FET1 and FET3, which is an advantage that other similar chips do not have. Through the control of the CTL terminal of the S8233 chip by the single-chip microcomputer, fault protection of the lithium battery can be achieved. [page]
4 Software Design
The system software is written in assembly language and compiled and debugged in the AVR Studio4 environment. The entire system software consists of a charging main program and an interrupt service subroutine. The main program mainly completes the initialization of the system, variables and watchdog timer. The control system realizes the charging function. After the microcontroller completes the initialization, it determines which charging stage to enter according to the battery status, and then completes the PWM adjustment through AD sampling and interrupt response to realize the control of the corresponding stage. The main program flow is shown in Figure 4. In the program, the AD interrupt subroutine is used to change the PWM duty cycle, the timing interrupt subroutine is used to control the maximum charging time, and the external interrupt is used to determine the discharge status of the battery pack.
5 Experimental test results
In the experiment, 750mA constant current was used to charge 3 1500mAh lithium battery packs, and the charging current and voltage test curves are shown in Figure 5. The experimental results show that the lithium battery charger realized by the AC-DC conversion realized by the single-chip switching power supply and the mutual cooperation and control of the ATtiny261 and S8233 protection chip meets the charging requirements of the 3-cell lithium battery pack and achieves a good charging effect.
Figure 5 Battery charging test hotline
6 Conclusion
Due to the good cost performance of AVR ATtiny261, the intelligence and applicability of the product are greatly improved, and the development time is shortened and the development cost is reduced. In addition, the system adopts a comprehensive control software algorithm to meet the needs of lithium batteries of different models and capacities. The machine circuit has high integration, simple structure, reliable performance, economical and light, and has great practical value. In addition, on the basis of the existing function realization of the system, the on-chip and off-chip resources of ATtiny261 are fully utilized, and through its 12C communication function, it can be easily upgraded to an intelligent power management system, which can be directly used in various portable electronic devices.
The author's innovation points: using PWM controlled single-chip switching power supply to achieve charging, greatly improving system efficiency; the software algorithm of comprehensive control based on AVRATtiny261 control core makes system control more flexible and convenient for further upgrading and development.
Previous article:AVR MCU RTOS-AVRX Application
Next article:Application of Wireless Sensor Networks in Intelligent Transportation Systems
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- [TI recommended course] #[High Precision Lab] ADC Series 5: ADC Frequency Domain Indicators#
- Please provide the equation for the LC series resonant circuit plus a rectangular wave, thank you.
- GD32E230C Display Variables
- I would like to ask about the LCD configuration of Imx6ull
- Arduino - 315/433MHz RF Wireless Transceiver Module
- Design of semiconductor laser power supply for intelligent control
- What is the voltage when the voltage is broken from left to right?
- Is there any level conversion chip that can directly convert 24V signal to 5V?
- Analysis of the problem of unstable signal and no output when connected to power on of wireless pressure sensor
- What does this code mean?