In power electronic devices such as UPS, control methods are the core technology. Early control methods made the output rectangular waves with high harmonic content and difficult filtering. SPWM technology has overcome these shortcomings. There are many methods for generating SPWM at present, which are summarized as follows.
1) Using discrete components, analog and digital hybrid circuits are used to generate SPWM waves. This method has complex circuits, difficult to implement and not easy to improve;
2) The SPWM wave is generated by directly connecting the SA828 series of SPWM dedicated chips to the microprocessor. SA828 generates SPWM waves by regular sampling method, which has relatively large harmonics and cannot achieve closed-loop control;
3) Using CPLD (complex programmable logic device) design to realize digital SPWM generator;
4) Based on single-chip microcomputer to realize SPWM, this method has a simple and reliable control circuit, uses software to generate SPWM waves, reduces the requirements for hardware, and has low cost and little external interference.
Today, the application of single-chip microcomputers has developed from relying solely on 51 series single-chip microcomputers to other single-chip microcomputers, especially the development and application of embedded PIC single-chip microcomputers are more extensive. PIC microcontrollers contain peripheral function modules (CCP) with PWM functions. Using this module, it is easier to implement SPWM through software and has a faster execution speed. This paper adopts a combination of software and hardware design, uses the area equivalent method, and implements SPWM control of the experimental inverter system based on the PIC microcontroller.
1 Area equivalent SPWM control algorithm
There are currently four main control algorithms for generating SPWM waves.
1) Natural sampling method;
2) Symmetric regular sampling method;
3) Asymmetric regular sampling method;
4) Area equivalent method.
After theoretical analysis, it is known that the natural sampling method and the area equivalent method have smaller harmonics than the regular sampling method and have stronger harmonic suppression capabilities. Because there is no large space in the PIC microcontroller to realize online operations, the natural sampling method is not conducive to software implementation. The experimental system in this paper uses the area equivalent method to realize SPWM control, and its principle is shown in Figure 1.
Figure 1 SPWM area equivalent algorithm
Based on the principle that the area of the sine wave block S1 is equal to the pulse area S2, the positive half cycle of the sine wave is divided into N equal parts, and the width of each equal part is π/N radians. The area equivalent method is used to calculate N different pulse width values in half a cycle, and the generated pulse width series is stored in the ROM of the PIC microcontroller in the form of a list for program call.
The basic formula for pulse width generation is
: Where M is the modulation index;
N is the carrier ratio, that is, the number of pulses in half a cycle. In the experiment, N is 64;
k is 0-63.
The actual pulse width calculated by formula (1) is converted into a timing step and then a 64-value sine table is generated and stored in the ROM of the PIC for call. The generated SPWM pulse width table is a table of 64 values from narrow to wide and then from wide to narrow.
2 Hardware and software combined The test system
is based on two peripheral function modules (CCP) inside the PIC microcontroller. Using the PWM function of the module, the software controls the output of two SPWM waveforms. Then, these two SPWM waves are transformed into four channels using the complementary conduction principle, and after isolation and amplification, they drive the IGBT inverter to achieve output control.
2.1 Hardware Design
The experimental hardware system is shown in Figure 2. The mid-range series of PIC microcontrollers are selected. The main features of this series of microcontrollers are:
1) High-performance RISC CPU;
2) Except for the program branch instruction which is two cycles, the rest are single-cycle instructions, and there are only 35 single-word instructions;
3) 8K×14 FLASH program memory, 368×8 data memory (RAM) bytes;
4) Strong interrupt capability, reaching 14 interrupt sources;
5) Rich peripheral function modules, including 2 16-bit register CCP modules with PWM function;
6) Contains 3 timers, among which timer 2 (TMR2) related to the PWM function has an 8-bit period register, and has an 8-bit prescaler and postscaler.
Figure 2 The inverter part of the hardware test system
uses the self-shutoff device IGBT to realize single-phase full-bridge inverter. IGBT is a fully controlled power electronic device. Its control stage is an insulated gate field effect transistor and its output stage is a two-stage power transistor. Therefore, it has the advantages of both and overcomes the disadvantages of both. It has a relatively high switching frequency, low driving power, small output voltage ripple of the power converter it constitutes, and simple circuit. It is the power device with the most application prospects today. [page]
2.2 Software Design
2.2.1 Settings of PIC microcontroller
In the test, the frequency of SPWM is set to 20 kHz, and an external 20 MHz crystal signal is connected. The instruction cycle, that is, the timing step, is calculated to be 0.2uS. The PWM function of the CCP peripheral function module of the PIC microcontroller mainly relies on the setting of the relevant register values, and timer 2 (TMR2) is used as the time base of PWM. The settings of the relevant registers are as follows.
1) Setting of SPWM cycle is set by register PR2. (PWM) cycle = (PR2+1) × 4 × Tosc × (TMR2) pre-division
(4)
In the experiment, Tosc is 20 MHz. To improve the resolution, TMR2 pre-division is set to 1:1. Thus, PR2 = 0XF9 is calculated.
2) Setting of control register T2CON of timer TMR2.
Because the SPWM frequency is high and the cycle is short, it is difficult to adjust the pulse width in each cycle. Therefore, the post-division is set to 1:3 in this register. In this way, the pulse width value is changed once after outputting three SPWM waves with the same pulse width.
3) Setting of control registers CCP1CON and CCP2CON of two CCP modules. The setting of control registers of two CCP modules is similar. The CCP module is selected to act on the PWM function mode, that is, bit3:0 = 11 XX.
4) The pulse width value written into the CCPR1L pulse width write register is transferred to CCPR1H at the beginning of the next TMR2 cycle. The PWM pulse width is changed by reading the pulse width value of CCPR1H.
5) Register TRISC corresponds to the input and output settings of CCP1 and CCP2, and should be set to output form, that is, bit2:1 of TRISC=00.
2.2.2 Implementation process of SPWM waveform generation
The software controls the PIC microcontroller to generate SPWM waveform. First, write the previously set register value into the relevant register. When the PWM function of the PIC is turned on, TMR2 starts counting from 0, and the CCP module pin outputs a high level.
- When TMR2≥CCPR1L, the PWM function pin starts to output a low level.
- When TMR2≥PR2, TMR2=0, restart another cycle counting, and the PWM function pin starts to output a high level. At the same time, the interrupt flag bit of TMR2 is set high by the system, that is, TMR2IF=1, and the interrupt service program is executed.
Because the post-division frequency of TMR2 is set to 1:3 in the experiment, the program will only execute the interrupt service program after 3 PR2 cycles. Look up the pulse width table in the interrupt service program and write the next pulse width value into register CCPR1L. The pulse width of the PWM output in the next cycle is the pulse width value just written into CCPR1L, that is, the change of the pulse width is realized in the interrupt program. The interrupt program flow is shown in Figure 3.
Figure 3 Interrupt service program flow chart
The flag F is used in the program to realize the conversion of SPWM output in CCP1 and CCP2. When F=1, CCP1 outputs PWM waveform and CCP2 sets the output to 0 level; when F=0, CCP2 outputs PWM waveform and CCP1 sets the output to 0 level.
3 Experimental results and analysis
The SPWM wave generated by the PIC microcontroller can be measured by an oscilloscope. Since the SPWM frequency is 20kHz and the program sets every three pulse widths to be equal, the complete change process of the pulse width from the minimum to the maximum cannot be clearly seen on the oscilloscope. A section of the SPWM waveform output by the CCP1 pin of the PIC microcontroller is shown in Figure 4. The pulse width in this section of the waveform gradually changes from narrow to wide, which conforms to the change law of SPWM.
Figure 4 A section of the SPWM waveform
In the experiment, two CCP modules of the PIC microcontroller generate two SPWM waves. These two SPWM waves are converted into four and then driven by the IGBT of the inverter system through isolation. The two SPWM waveforms generated correspond to the positive and negative half waves of the sine wave respectively. The two SPWM complementary waveforms of the complete cycle are shown in Figure 5.
Figure 5 Two-way complementary SPWM wave
test system The sine wave obtained by load operation when the DC voltage is 30V is shown in Figure 6. It can be seen that the period is 19.9ms, which meets the power frequency requirements.
Figure 6 The load sine wave
test system is a single-phase full-bridge inverter system. This working mode has an obvious frequency doubling effect. The frequency doubling effect is beneficial to filtering, and can also reduce the switching frequency of the device and reduce switching losses. Because this test system uses the area equivalent method, it has a stronger harmonic suppression ability than the regular sampling method. After harmonic analysis, there is basically no even harmonic at low voltage, and the amplitude of the contained odd harmonics is small, which can meet the harmonic requirements of the UPS inverter system.
4 Conclusion
The SPWM control technology based on PIC microcontroller introduced in this paper combines software and hardware technologies well. In view of the disadvantage of large harmonics in the regular sampling method, the harmonics are well suppressed by using the area equivalent method. This paper gives a specific hardware test system and software design. After analyzing the waveform of the test results, it is shown that this method has small output harmonics and has strong practical value in UPS inverter systems that require high output waveform quality. Nowadays, PIC microcontrollers are more and more widely used, and power electronics technology is developing more and more rapidly. This control technology combining software and hardware also has a large development space in many other application fields.
Previous article:Intelligent inverter power control system based on PIC microcontroller
Next article:Wireless remote control fan design
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- On the first day back to work, the company CEO wants to fire me? Can I get N+1 compensation?
- Hard disk control and encryption based on FPGA
- Causes of color difference between different batches of LCDs
- Is there no one in the forum?
- What exactly are S parameters?
- Can the current direction of a MOS tube be reversed? How much current can a body diode carry?
- EEWORLD University ---- TI Battery Management In-depth Analysis Series
- Introduction to FPGA CLB LUT to implement logic functions
- Is the IoT card a data card? What is the difference between it and a mobile phone data card?
- Introduction to 10G Ethernet Test Solution