Research on SPWM Frequency Converter Based on dsPIC30F4012 with CAN Bus
2026-04-06 06:20:13··#1
Abstract: This paper introduces an SPWM frequency converter based on an IPM module and a motor-specific microprocessor chip, dsPIC30F4012. The converter's output frequency is 0–240Hz, and its carrier frequency is 3.0–12.0kHz. It offers 22 V/F curves and different start-up rates for selection. The software employs various flexible measures to achieve excellent static and dynamic performance and features comprehensive fault protection functions. Keywords: dsPIC30F4012 microprocessor, IPM, CAN, SPWM (Sinusoidal Pulse Width Modulation) 1. Introduction: With the rapid development of power electronics and microcomputer control technologies, traditional electric drives are facing a major transformation, with DC speed regulation gradually being replaced by AC speed regulation. In modern AC speed regulation, frequency conversion speed regulation schemes are increasingly being adopted. Voltage-type sinusoidal pulse width modulation (SPWM) frequency converters have experienced rapid development and widespread application due to their unique technical advantages. The combination of advanced control strategies, high-performance control chips, and intelligent high-speed switching devices has become the mainstream trend in modern AC speed regulation technology. Analog methods are rarely used in SPWM waveform generation. Digital methods offer unparalleled advantages over analog methods in terms of reliability, flexibility, and controllability. Currently, most digital SPWM frequency converters on the market utilize dedicated SPWM chips (such as HEF4752 and SLE480). While this simplifies programming, it increases hardware investment. Therefore, this frequency converter uses Microchip's latest 16-bit microcontroller, the dsPIC30F4012, specifically designed for motors, to construct a digital frequency converter. It generates SPWM drive signals through programming, significantly simplifying the software and hardware required for PWM waveform generation, thus simplifying the system and improving its dynamic and static performance. The main specifications of this frequency converter are as follows: frequency range 0–240Hz, frequency resolution: 0.1Hz, 22 selectable V/f curves, carrier frequency varying between 3.0kHz and 12.0kHz. It also features comprehensive protection functions: DC overvoltage, undervoltage, short circuit, AC overcurrent, and overheat protection. The main circuit adopts an IPM module based on third-generation IGBTs and freewheeling diodes. It features low on-resistance, fast switching speed, low drive power, high operating frequency, high withstand voltage, and large operating current, resulting in excellent overall performance. 2. Inverter Control System:2.1 Introduction to the control chip dsPIC30F4012: The dsPIC30F4012 is a 16-bit microprocessor designed by Microchip specifically for high-speed motor control. It features a 16-bit CPU and a DSP core, with a 16-bit * 16-bit operation taking 8.3ns at a maximum internal clock frequency of 120MHz. It also includes 2048 bytes of register RAM, 48kB of on-chip program space, 1024 bytes of EEPROM, 7 interrupt I/O ports with a total of 21 I/O lines, a full-duplex UART module, a synchronous serial SPI module, an I2C serial communication module, and a CAN serial communication module. It has an on-chip 6-channel A/D converter operating in 10-bit mode, with programmable sampling and holding time, conversion time, threshold detection method, and zero-bias compensation correction. It also includes 5 16-bit timers, 4 capture units, 2 compare/standard pulse width modulation (PWM) modules, and a 6-channel dedicated MCPWM controller for motors. One of the key features of the dsPIC30F4012 is its on-chip MCPWM motor-specific PWM controller. This design greatly simplifies the control software and external hardware required to generate PWM waveforms. Through programming, it can generate independent three-phase, six-channel PWM waveforms with the same frequency and operating mode, and directly output the six PWM signals to the inverter via the RE port. The three phases are complementary and do not overlap. Each pin has a drive current of up to 25mA. To prevent short circuits caused by shoot-through between two power transistors on the same bridge arm, the generator can also be programmed to set the dead-time interlock. When the external clock is 10MHz, after internal 8x multiplication, the system clock is 80MHz. The dead-time range varies depending on the division factor: 1. 1:1: 50ns to 3.15μs; 2. 1:2: 100ns to 6.3μs; 3. 1:4: 200ns to 12.6μs; 4. 1:8: 400ns to 25.2μs. 2.2 System Hardware Structure and Working Principle: Figure 1 shows the internal structure of the inverter. The overall block diagram of this inverter is shown in Figure 1, consisting of a control section and a main circuit section. The main circuit section adopts an AC-DC-AC conversion method. The three-phase power frequency voltage is rectified by a rectifier bridge and then smoothed and filtered by capacitors to obtain a 600V DC voltage, which is then sent to the input terminals P and N of the inverter IPM module PM100CVA120. The IPM module selected in this system is the fourth-generation intelligent power module launched by Mitsubishi Electric. It contains one three-phase H-type inverter bridge with six IGBTs and six fast power diodes, along with their corresponding drive circuits. It also includes overcurrent protection, short-circuit protection, drive power undervoltage protection, overheat protection, and alarm output. It corrects the shortcomings of traditional IGBT-IPM modules, such as the potential breakdown of the IPM when the operating temperature rises rapidly, and the occasional malfunction of the IGBT due to noise caused by parasitic capacitance or parasitic inductance generated by the control circuit. Moreover, it uses far fewer components than traditional IPMs, resulting in improved reliability. The application of this IPM module with integrated IGBT drive circuitry, self-diagnostic functions, and comprehensive protection features makes the system smaller, more reliable, and more intelligent. The system control section consists of a dedicated dsPIC30F4012 microprocessor system (including corresponding software), signal detection circuits, drive and protection circuits, etc., mainly responsible for generating inverter bridge SPWM drive signals, signal detection and fault handling, fault display, control box button detection and logic control, and real-time display of inverter frequency. The dsPIC30F4012 microprocessor is the core of the control system. It receives external information, calculates the three-phase SPWM waveform data in real time according to a predetermined algorithm, and generates three-phase six-channel SPWM signals, outputting them from the RE port. These signals then drive the inverter power switch through the drive circuit to complete the three-phase SPWM inversion. The dsPIC30F4012 microprocessor calculates and looks up the sine function data stored in the on-chip EPROM, multiplies it by the V/f parameter, and sends it to the 6-channel dedicated PWM controller for motors. The waveform generator produces three mutually complementary SPWM signals, which are output through PWM0 to PWM5 terminals and sent to the IPM drive signal input. Seven buttons are used: SET (parameter setting), RUN, STOP, INPUT-F/R (input parameters), MOVE/POINT (changes parameter display mode and changes the flashing bit during parameter setting), UP (increase by 1 and fast increase by 1), and DOWN (decrease by 1). A frequency setting is also included. To ensure safe system operation, the inverter is equipped with multiple protection functions, including overcurrent, overvoltage, overheat, phase loss, short circuit, and overload protection. All protection signals are sent to the FLTA pin of the dsPIC30F4012 via a set of interrupt logic. If any protection function is activated, it will block the output of the 6-channel motor-dedicated PWM controller, prohibiting the generation of three-phase PWM waves, and promptly blocking the IPM drive circuit to protect the IPM and other circuits from damage. Simultaneously, the fault is stored in EEPROM as a code, and its source is displayed on the LED display for maintenance. 3. Control Strategy and Software Design:3.1 Calculation of SPWM Pulse Width This system uses a regular sampling method to generate SPWM waves in software, overcoming the shortcomings of analog component implementation. The regular sampling method is shown in Figure 2. The figure uses median sampling, taking the median point (base point) of the triangular wave as the sampling point. A straight line parallel to the time axis is drawn through the corresponding sine wave point E. The intersection points A and B of this line with the triangular wave are the PWM pulse width, denoted by t2. The following relationship holds: Where Tt is the triangular wave period; M is the modulation index; ω is the angular frequency of the sine wave; and te is the sampling time. The formula for calculating the pulse width of three-phase SPWM is: Where T is the period of the sine wave. When generating SPWM waveforms using a microcomputer, to ensure symmetry of the three-phase SPWM waveforms, the modulation ratio N should be an integer multiple of 3. Considering harmonic elimination, a larger N is better, but the value of N is limited by the switching frequency of the power switching devices and the computer's processing speed. We adopt a segmented synchronous modulation method, with different N values for different frequency bands. The sine function is discretized according to the carrier ratio N and tabulated, and the half-carrier period is also tabulated. The microcomputer calculates the pulse width value using a combination of table lookup and real-time calculation and sends it to the PDCX. 3.2 Calculation of PTPER: Where: fOSC is the crystal oscillator frequency, fPWM is the MCPWM output waveform frequency (carrier frequency), fPWM=Nfsin, fsin is the sine modulation wave frequency. (fsin=1/T, fPWM=1/Tt) 3.3 Software Design: The system software consists of a main program, fault interrupt subroutines, display subroutines, keyboard service program, MCPWM interrupt, A/D sampling interrupt subroutines, etc. The main program mainly completes system initialization, calculates the data to be displayed according to the display mode and sends it out for display, performs keyboard scanning and service processing, and converts the input data code. The fault interrupt subroutine performs self-processing or fault alarm, blocks trigger pulses, trips, etc., depending on the nature of the fault. Figure 3 is the main program flowchart. One of the features of this chip is its comprehensive protection function. As long as the corresponding control command word is written in the PTCON command register, the system can immediately block the pulse when a fault occurs. In the FLTA interrupt service routine, different I/O gates are read to further identify what kind of interrupt has occurred and display it. Figure 4 is the flowchart of the MCPWM interrupt subroutine. 4. System anti-interference measures: Since the frequency converter operates in the harsh industrial environment for a long time, the interference is serious. Therefore, anti-interference measures are essential. This system has taken anti-interference measures in terms of hardware and software. Hardware anti-interference measures: The inverter adopts the IPM module, which has a compact structure. The rectifier circuit is equipped with a filter circuit at the back end to eliminate or reduce noise from the outside. The following measures are taken in the control circuit: (1) A power filter is added at the power input terminal. The power transformer is a shielded transformer, and a 1μF tantalum capacitor is used at the VCC terminal of the CPU to resist power system interference. (2) Process channel anti-interference measures: High-speed optocouplers are used in all input and output ports to cut off the electrical connection between the peripheral analog circuit and the microcontroller digital circuit, and all transmission lines are twisted pair. (3) Circuit board anti-interference measures: When designing the printed circuit board, the digital circuit components and analog circuit components are separated as far as possible in the arrangement of components, and grounding wires are added. The grounding wires form a closed loop, and 0.1μF decoupling capacitors are configured between the positive and negative terminals of the power supply of each integrated chip. Software anti-interference measures: The monitor timer of dsPIC30F4012 is used to implement software anti-interference measures. When the frequency converter causes a software fault due to interference, the control system will automatically reset within less than 16ms. 5. Experimental results: Based on the above scheme, we designed and made a prototype for use on the drive motor of a 22kW injection molding machine. It has been running well for a year, and the technical indicators have met the design requirements. Its current waveform is shown in Figure 5. In summary, the inverter composed of the dsPIC30F4012 microprocessor and IPM is convenient to use, especially with its easy and convenient SPWM signal generation via programming. The dead time can also be controlled within the range of 50ns to 25.2μs through software programming. Multiple V/f curves are available for different users to choose from. Therefore, it has good application prospects.