Design and implementation of intelligent charger based on PIC microcontroller

Publisher:EtherealGazeLatest update time:2012-05-26 Source: 电源在线网 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

Lead-acid batteries are the main type of large-capacity batteries at present. They have low manufacturing costs, large capacity, low prices, and a wide range of applications. There are two basic charging methods for lead-acid batteries: constant voltage charging and constant current charging. If only one method, such as the constant current method, is used, the capacity will easily decrease and the battery will be scrapped prematurely due to the unchanged charging current in the later stage of charging. If the constant voltage method is used alone, the current is too large at the beginning of charging, which may cause the electrode active material to fall off, and the current is too small in the later stage, resulting in long-term undercharging, which affects the service life of the battery [1]. Therefore, most chargers use a multi-stage charging method that combines the two methods. In recent years, the three-stage charging method of constant current, constant voltage, and constant voltage floating charge has gradually been accepted.

At present, the three-stage charging method mainly adopts the analog control scheme. Although it has the advantages of good real-time performance and high bandwidth, its hardware circuit is complex and the control is not flexible. To this end, this paper designs a digitally controlled charger, which uses a single-chip microcomputer as the core of the control loop, and controls the output voltage and output current through real-time sampling of voltage and current, realizing a three-stage charging strategy, which can intelligently and flexibly control the charging of the battery, improve the utilization efficiency of the battery, and help to improve the service life and performance of the battery.

2 Charger power structure

The overall design block diagram of the system is shown in Figure 1. It mainly consists of three parts: the first part is the switching power supply part, which adopts a flyback DC/DC converter; the second part is the voltage and current sampling circuit; the third part is the PWM output of the microcontroller core, which then drives the flyback circuit through the drive circuit.

1.JPG

Figure 1 Overall design block diagram of charger circuit

The system consists of a voltage sampling circuit and a current sampling circuit to sample the voltage and current in real time, and send the sampled voltage and current to RA0 and RA1 of the microcontroller respectively. The sampled voltage and current are converted into numerical values ​​through the A/D conversion module inside the microcontroller, and then corresponding operations are performed according to the written software. The corresponding duty cycle is obtained by the PWM module, and then the duty cycle is sent to the drive circuit by RC2 to drive the switch tube of the flyback circuit, so that the corresponding voltage or current is obtained at the output end to charge the lead-acid battery.

3 Digital Control Circuit Structure

The digital control circuit monitors and controls the corresponding working process of the charger by acquiring and outputting the corresponding signals, so that it can work adaptively. However, the output of the main circuit is an analog signal, but the microcontroller can process a digital signal. Therefore, before processing the signal, the analog signal must be converted into a digital signal through an analog-to-digital converter (ADC). Assuming that the ADC word length is N, the analog-to-digital conversion accuracy is 1/2N. The larger N is, the higher the accuracy is, but the more expensive it is. The time resolution and analog-to-digital conversion accuracy of the digital controller PWM unit determine the accuracy of the charger's output voltage, output current, and output power. In order to meet the accuracy requirements and reduce costs at the same time, it is necessary to select an ADC and PWM digital controller with appropriate bits.

After the ADC converter is selected, the PWM bit number needs to be selected. If the PWM bit number is too small, the output voltage will fluctuate around a certain voltage value, causing a limit cycle phenomenon. The output voltage will periodically jitter, which will affect the sampled data and ultimately the processing accuracy of the entire system. Therefore, the higher the PWM unit resolution, the better.

The PWM bit number N and frequency fPWM satisfy the following formula: 2.JPG . In the formula, fclk represents the clock frequency of the microcontroller. PR2 is the microcontroller PWM period register. The higher the fPWM, the smaller the value stored in PR2. If the value stored in PR2 is M, the maximum resolution is the frequency division value f/M. It can be seen that the higher the frequency is, the better it is. Too high a frequency will reduce the PWM resolution. The relationship between the frequency and resolution of the PWM output is shown in Table 1.

Table 1 Relationship between PWM frequency and resolution (fclk=40MHz)

QQ screenshot 20120518141801.JPG

In order to ensure a high enough resolution and ensure that the output voltage ripple is less affected by the PWM resolution than the output filter capacitor, this design uses 10-bit PWM. [page]

At the same time, taking into account other needs, the specific requirements of this system for the digital controller mainly include: (1) built-in ADC module, at least 2 ADC channels, and an accuracy of more than 10 bits; (2) at least 1 built-in PWM unit, and PWM accuracy of more than 10 bits; (3) at least two timers; (4) interrupt priority setting; (5) at least 5 I/O ports; (6) price less than RMB 50.

Taking all the above factors into consideration, we choose PIC18F2620 from Microchip as the digital control chip. The main performance of PIC18F2620 includes: 10 10-bit ADC channels; the maximum external clock frequency can reach 40M; 1024 bytes of data EEPROM for storing variable data; low-power enhanced design that can extend battery life, power consumption in sleep mode is only 100nA, etc. Its performance meets the system requirements.

4 System Software Design

4.1 Main program design

Three-stage charging, constant current charging at the beginning, constant voltage charging in the middle, and floating charging at the end. This charging method reduces the amount of gas discharged during charging, charges more thoroughly, and prolongs the battery life. The charging current and charging voltage change curves of the three-stage charging method are shown in Figure 2.

QQ screenshot 20120518141815.JPG

Figure 2 Three-stage charging characteristics

According to the principle of three-stage charging, draw the main program flow chart of the system, as shown in Figure 3. (Where Um is the maximum voltage upper limit of the battery, Ubat is the constant voltage charging threshold, and Ibat is the constant current charging threshold, and its value is generally 1/10 of the battery capacity.)

The main program of the single-chip microcomputer system is mainly used for A/D sampling initialization, PWM initialization, timing and interrupt system, and timer initial value setting. It then continuously detects the voltage and current of the charger and performs three-stage adaptive charging.

There are a few things you need to pay attention to in the program.

(1) Because it is necessary to sample two variables, voltage and current, at this time, according to the characteristics of the sampling unit of PIC18F2620, the channel can be changed by directly changing the A/D control register ADCON0.2~3 bits, which is fast and takes less time.

(2) The interrupt system is the key part of the program. Since the sampling unit cannot work all the time, it will not only waste the computing power of the microcontroller, but also affect the work of other parts, making the system inefficient. In order to make the microcontroller work more efficiently, the system adopts a timed interrupt working mode: using the TMR0 timer for timing, and entering the interrupt after a fixed period of time. At present, the microcontrollers on the market generally have interrupt priorities. For example, the PIC18F2620 used in the system has 2 priorities, and different priority operations can be performed by setting different interrupt vectors. The corresponding high-priority interrupt service subroutine resets TMR0, loads the corresponding initial value, and enters the next timing state. The low-priority interrupt service subroutine resets the A/D module enable bit, reads and stores the A/D conversion results, and then determines the corresponding voltage and current sampling value stage, and finally modifies the duty cycle through the corresponding PI adjustment of each stage.

QQ screenshot 20120518141845.JPG

Figure 3 Main program flow chart [page]

4.2 Sampling subroutine

The voltage and current signals after sampling and processing inevitably have noise and interference caused by the system. In order to accurately measure and control, these noise and interference must be filtered out. In addition to filtering on the hardware circuit, software filtering or digital filtering can also be used. There are many commonly used digital filtering methods. This system uses the average method: sorting after multiple sampling, and then removing the maximum and minimum values ​​to calculate the average value, which improves the sampling accuracy.

4.3 PI subroutine

In order to eliminate the influence of integral saturation, this system adopts an incremental PI control algorithm and utilizes the method of weakening when encountering limits.

The PI algorithm that weakens the integral when encountering a limit actually stops increasing the integral term and only performs the operation of weakening the integral term once the control variable enters the saturation range [5]. The PI program flow chart is shown in Figure 4.

QQ screenshot 20120518141930.JPG

Figure 4 PI control algorithm flow chart

5 Experimental results and analysis

The above method was used to make a prototype to charge the YTX7A-BS/12V-7AH lead-acid battery.

The main circuit parameters are as follows: input voltage Uin=24V, circuit operating frequency f=50kHz, EI33 magnetic core, primary inductance Lp=212μH, secondary inductance Ls=112μH, switch tube IRF840, output capacitor 1000μF/25V electrolytic capacitor.

FIG5 is a curve diagram of the charging change of the lead-acid battery by the prototype, wherein the horizontal axis is the charging time, the left Y axis is the battery voltage, and the right Y axis is the charging current.

QQ screenshot 20120518141944.JPG

Figure 5 Battery charging curve

As shown in Figure 5, according to the program design requirements, in the initial stage of charging, the charger first performs constant current charging, and the battery current is maintained at about 0.7A. Thereafter, when the battery voltage exceeds the constant voltage charging threshold of 14.4V, it switches to constant voltage charging, the charging voltage is maintained at 14.4V, and the charging current continues to decrease. At the same time, the charging current is continuously detected by RA1. When the charging current drops below 0.1A, it indicates that the battery is fully charged. At this time, in order to supplement the self-discharge of the battery, it switches to floating charging, and the charging voltage is maintained at 13.7V. According to the above results, the three-stage adaptive digital control scheme for lead-acid batteries proposed in this paper is effective, and the charger can select the corresponding charging mode (constant current, constant voltage charging and floating charging) for charging according to the actual state of the battery.

6 Conclusion

Compared with the traditional analog-controlled lead-acid battery charger, the digital-controlled charger greatly improves the flexibility, reliability, and stability of the control system. With the continuous improvement of control schemes and functional integration and the gradual reduction of microcontroller prices, digital-controlled chargers using microcontrollers will become an important research direction in the future.

References

[1] Hu Hengsheng, Wang Hui, Zhao Xucheng, Lv Ruiqiang. Analysis and discussion of battery charging methods [J]. Power Technology Application, 2009, 12 (8): 1-4.

[2] Chen Jian. Power Electronics: Power Electronics Conversion and Control Technology[M]. Beijing: Higher Education Press, 2004.

[3] Meng Jianhui, Liu Wensheng. Analysis and comparison of DCM and CCM modes of flyback converter [J]. Communications Power Technology, 2010, 27 (6): 33-38.

[4] Tong Shibai, Hua Chengying. Fundamentals of Analog Electronics Technology[M]. Beijing: Higher Education Press, 2001.

[5] Cook,B. New Developments and Future Trends in High-Efficiency Lighting. IEEEngineering Science and Education Journal, 2000,9:207-217.

Reference address:Design and implementation of intelligent charger based on PIC microcontroller

Previous article:Rail Ultrasonic Flaw Detection System Based on TMS320C6201
Next article:Microcontroller entry design: a simple and fun heart rate meter

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号