The Method Design of Controlling Inverter Bridge Based on PIC Single Chip Microcomputer to Generate SPWM Signal

Source: Date: 2020-11-25

1 Introduction
With the continuous development of information technology and the increasing popularity of computer applications, high-tech equipment has higher and higher requirements for the quality of power supply. Many equipment require the power supply to continue to provide constant frequency, constant voltage, and pure sine wave AC power without turbulence. Discontinuous power supply UPS is used to power these devices. UPS generally adopts sinusoidal pulse width modulation (SPWM) control method to invert direct current into sine wave alternating current. At present, there are generally three ways to generate the SPWM control waveform: 1. It is generated by a discrete component circuit, which is mainly composed of a triangle wave generator, a sine wave generator and a comparator. Discrete components have complex circuits, difficult debugging, high cost, and poor reliability, so they are generally rarely used. 2. It is produced by a dedicated integrated chip, which has powerful functions, high output waveform quality and a wide range of applications. 3. It is realized by single-chip microcomputer. Now many single-chip microcomputers have the function of generating SPWM wave. The use of single-chip microcomputer can make the circuit simple and reliable, and it is also convenient to monitor, display and process other data parameters of the system, which makes the control of the whole system very convenient. This article uses PIC16F73 microcontroller to generate SPWM wave to control the inverter system in UPS power supply.
2 hardware circuit design
The overall hardware block diagram of the system is shown: the AC input from the grid is transformed into a DC voltage after passing through the rectifier filter circuit, which is sent to the power factor correction module (PFC) for power factor correction, and at the same time, the DC voltage is adjusted and boosted to 360V. On the other hand, the 48V DC voltage output by the battery passes through the battery boost circuit to obtain a DC high voltage of 345V. The two DC high voltages are connected in parallel through a diode and supplied to the bridge inverter circuit. In normal operation, the DC obtained from the mains rectification supplies power to the inverter, and when the mains is abnormal, it will automatically switch to battery power supply. After the DC power is inverted by the bridge inverter circuit, it is filtered into 220V, 50Hz pure sine wave AC power and supplied to the load.
The control circuit is designed based on the method of PIC single-chip microcomputer to generate SPWM signal to control the inverter bridge, which is based on the PIC16F73 single-chip microcomputer of MicroChip Company. The PIC microcontroller is a cost-effective embedded controller with a RISC structure. It adopts a Harvard dual-bus structure in which the data bus and the address bus are separated, and it has a high pipeline processing speed.
The PIC16F73 clock frequency is 20MHZ, and the execution cycle of each instruction is 200ns. Since most instructions are executed in one cycle, the speed is quite fast. It contains 192 bytes of RAM, 4K program memory, 5 channels of A/D conversion and 2 channels of PWM wave generator. The peripheral circuit is extremely simple in application and is an ideal single-phase inverter power digital controller.
The single-chip microcomputer generates one SPWM control signal through internal software, and then transforms it into the four drive signals required by the inverter full bridge through the logic gate conversion circuit. After isolation and amplification by the dedicated drive chip TLP250, it is added to the four IGBTs of the inverter full bridge. The gate for driving control.
In order to improve the stability of the output voltage, a voltage feedback closed loop is adopted in this system. After the output voltage is sampled by the resistor divider, the operational amplifier circuit converts the level into a 0~5V voltage signal that the A/D conversion port of the single-chip microcomputer can accept, and sends it to the A/D conversion port of the single-chip microcomputer. During the operation of the software, it will perform A/D conversion at regular intervals to obtain the feedback voltage value and adjust the pulse width of the SPWM signal to ensure the stability of the output voltage.
3 software design
The PIC16F73 microcontroller contains two CCP modules, both of which can be used to generate PWM waves. For the PWM signal, period and pulse width are two essential parameters. The PIC16F73 microcontroller stores the PWM period in the PR2 register, and stores the high level time value of the PWM signal, that is, the pulse width value in the CCPR1L or CCPR2L register. . The internal timer is constantly compared with the values ​​of these two registers during the counting process, and when the set time is reached, the output level changes accordingly, thereby controlling the period and duty cycle of the PWM signal.
The SPWM signal requires the pulse width to change according to the sine law, so the pulse width of each PWM cycle must be changed. The basic idea of ​​generating the SPWM wave by the single-chip microcomputer is to set the PWM cycle value during initialization, and then use the timer to time it. Interrupt to adjust the pulse width, so as to get the SPWM wave whose pulse width changes constantly. But in fact, SPWM frequency is generally very high, the period is very short, it is difficult to complete the pulse width adjustment in each period. In this system, the SPWM cycle is 20KHZ, and the pulse width is set to change every six cycles. The sine wave obtained after filtering the actual output SPWM signal is shown in Figure 6. The waveform is smooth and undistorted, meeting the accuracy requirements.
In the software design, the CCP2 module is used as the PWM output port, and the CCP1 module uses the comparison function, the single-chip clock is 20MHZ, and the timing step is 0.2us. First, establish a sine table. In a complete sine cycle, 64 points are sampled. The ratio of the sine value of the sampling point to the peak value of the sine wave is the duty ratio of the SPWM signal at that point. Then calculate the pulse width value of each point according to the SPWM period, convert it into a timing step, and make a sine table for the CCP1 interrupt subroutine call. The time interval between these 64 points is also converted into timing steps and stored in the CCPR1H and CCPR1L registers. During the program running, the counter TIMER1 is constantly compared with the value of this register. When the set value is reached, CCP1 generates an interrupt and TIMER1 restarts. Timing. The interrupt service subroutine is used to modify the duty cycle of the SPWM signal, as shown in the process.
The main program is an endless loop, waiting for an interrupt to occur. There are three interrupts shared in this program: CCP1 comparison interrupt, used to adjust the SPWM pulse width, the interrupt period is 306us; T0 timer interrupt, the output voltage feedback sampling value A/D conversion is performed at a fixed time interval, and the microcontroller is initialized When the T0 interrupt cycle is set to 153us, after the interrupt is generated, the cycle is changed to 306us; the A/D conversion is based on the PIC microcontroller to generate the SPWM signal to control the inverter bridge. The method design interrupts, the A/D conversion is completed and the interrupt is generated, and the conversion is processed Value, the interrupt period is 20us. After the program starts to run, the CCP1 interrupt occurs first, so that the microcontroller outputs the SPWM wave according to the pulse width value of the sine table. After 153us, the T0 interrupt is generated, A/D conversion is performed, and the T0 interrupt cycle is changed to 306us. After 20us, the conversion is completed and an A/D interrupt is generated. Then CCP1 is interrupted, and the A/D conversion value and sine meter are read to adjust the pulse width. This repeats itself and generates continuous SPWM control signals. The interrupt loop structure is shown in Figure 4.
As shown in the SPWM waveform output from the CCP2 port of the microcontroller, since the frequency is 20KHz and the pulse width is very narrow, only a section of it is intercepted. The process of changing the pulse width from to is not seen, but it can be seen that the pulse width in this waveform is gradually Narrowing, in line with the changing law of SPWM.
After RC filtering, the sine wave shown is obtained. The frequency is 49.6HZ, which is basically consistent with the designed 50HZ. The waveform is smooth and undistorted, which meets the design requirements.
The design of the inverter bridge based on the SPWM signal generated by the PIC microcontroller is designed. In this UPS system, a full-bridge inverter circuit is used. The control method is that two IGBTs on one bridge arm are turned on complementarily, and two of the other bridge arms are turned on Normally open, one normally closed. In the negative half-wave, the two IGBTs switched to the other bridge arm are turned on complementarily, and the original bridge arm becomes one normally open and one normally closed. Therefore, it is necessary to convert one SPWM signal generated by the single-chip microcomputer into four channels to drive four IGBTs respectively. The concrete realization circuit is shown as in Fig. 7.
The SPWM signal and the positive and negative half-wave signals output by the single-chip microcomputer are added to the 12 and 13 pins of U3D respectively based on the method of the PIC microcontroller to generate the SPWM signal to control the inverter bridge. This figure only shows the drive of two IGBTs of the same bridge arm Waveform generating circuit. The generating circuit of the other bridge arm is exactly the same as this circuit, except that an inverting circuit is added before the input positive and negative half-wave signals, so that whether it is a positive half-wave or a negative half-wave, bridge arm 1 and bridge arm 2 of U3D's 11 pins always have one SPWM signal and the other low level. After the subsequent circuit conversion, the bridge arm for the SPWM signal gets two complementary output SPWM waveforms, and the bridge arm for the low level gets a continuous high level and a continuous low level, thus realizing an inverter full bridge Drive.
Since the two IGBTs of the same bridge arm are conducting complementary conduction, the setting of the dead time is indispensable, otherwise the bridge arm through phenomenon may occur, causing the device or the entire electrical damage. R2 and C2 in Figure 7 are used to set the dead time. Through the charging and discharging of the RC circuit, a time delay is designed based on the PIC microcontroller to generate the SPWM signal to control the inverter bridge. SPWM signal waveform. The length of the dead time can be adjusted by changing the size of R and C. The resistance in this circuit is 1000 ohms, and the capacitance is 6.8 nF to get a dead time of 5us.
The four-way drive waveforms of the inverter bridge obtained by circuit conversion are shown in Figure 8. IGBT drive adopts low-level effective. It can be seen from the figure that in the two upper and lower IGBT drive waveforms of the same bridge arm, when the low level of one drive waveform changes to the low level of the other drive waveform, there is a section of both signals. The high level time, that is, the dead time when the two IGBTs are not turned on, prevents the inverter bridge from passing through.
5 Conclusion
The method of using PIC microcontroller to generate SPWM signal to control the inverter bridge introduced in this paper has achieved good experimental results in the application of UPS power supply. At the same time, this method of generating SPWM waves can also be used in other sine wave inverter power supplies.

To

Development strength

Professional and experienced software and hardware

Global channels

Provide customers with cost-effective products and services

Quality Assurance

The professional test guarantee team guarantees the stability

After-sales service

Professional technical service team, 24 hours to provide customers