A method, apparatus, medium, device, and terminal for automatic code generation.
By using an automatic code generation method based on a hybrid PWM model, the problems of poor electromagnetic interference suppression effect and complex code implementation in traditional electromagnetic interference suppression strategies are solved. This achieves more efficient electromagnetic interference suppression and simplified code development, reducing hardware debugging costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI UNIV
- Filing Date
- 2023-04-11
- Publication Date
- 2026-06-30
AI Technical Summary
Traditional electromagnetic interference suppression strategies for permanent magnet synchronous motors suffer from limited electromagnetic interference suppression effectiveness and complex and time-consuming code implementation. In particular, random frequency modulation leads to increased torque ripple, and hardware debugging requires writing code, which is also time-consuming.
An automatic code generation method based on a hybrid PWM model is adopted. A vector control model for a permanent magnet synchronous motor is constructed through a hybrid frequency formula. The automatic code generation module automatically generates code files, and the control module communicates with the host computer to achieve graphical display and control. A hybrid frequency modulation strategy is combined to reduce torque ripple.
It achieves more effective electromagnetic interference suppression, simplifies the code development process, improves development efficiency, reduces the difficulty and cost of hardware debugging, and ensures code correctness.
Smart Images

Figure CN116317758B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of motor control technology, and in particular relates to a method, apparatus, medium, device and terminal for automatic code generation. Background Technology
[0002] Currently, wide bandgap devices are developing rapidly. Due to their stronger voltage and current withstand capabilities and high switching speed, motor control systems are gradually shifting from the original Si devices to the current SiC and GaN devices. However, after adopting wide bandgap devices, electromagnetic interference (EMI) problems have become increasingly acute, so EMI has become an issue that cannot be ignored.
[0003] To address this electromagnetic interference (EMI) problem, traditional methods employ Matlab / Simulink simulations to study EMI suppression strategies for permanent magnet synchronous motors (PMSMs). These control strategies often rely on random frequency PWM modulation or periodic frequency modulation. However, while random PWM modulation suppresses EMI, it exacerbates torque ripple. Periodic frequency modulation can produce smoother torque ripple, but its effectiveness in suppressing EMI amplitude concentrated at multiples of the switching frequency is limited. Furthermore, traditional methods typically require physical motor experiments after algorithm simulation verification. Hardware debugging demands strong embedded systems skills and C language proficiency, requiring the programmer to write code, be familiar with the usage of various internal registers of the MCU, and then download the code to the MCU for algorithm implementation. This process is extremely complex and time-consuming. Therefore, a new method for automatic code generation is urgently needed.
[0004] Based on the above analysis, the problems and shortcomings of the existing technology are as follows:
[0005] (1) Traditionally, Matlab / Simulink simulation analysis is used. In the control strategy for suppressing electromagnetic interference of permanent magnet synchronous motor, the periodic frequency modulation strategy has a limited effect on suppressing the amplitude of electromagnetic interference concentrated at multiples of the switching frequency. In order to further suppress electromagnetic interference, random frequency modulation is used, but this will cause the torque pulsation to increase.
[0006] (2) Traditional control strategies usually require physical experiments on motors after completing the simulation verification of the algorithm. However, during hardware debugging, it is necessary to write the code yourself. This implementation process is very complicated and time-consuming. In addition, the code must be correct, otherwise the troubleshooting cycle will be very long. Summary of the Invention
[0007] To address the problems existing in the prior art, the present invention provides a method, apparatus, medium, device and terminal for automatic code generation, and particularly relates to a method, apparatus, medium and terminal for automatic code generation based on a hybrid PWM model design.
[0008] This invention is implemented as follows: a method for automatic code generation, comprising: the system constructing a vector control model of a permanent magnet synchronous motor using a hybrid frequency formula to achieve hybrid modulation of the permanent magnet synchronous motor frequency; automatically generating code files and controlling the frequency through an automatic code generation module; and using a host computer in the control module to achieve graphical display and instruction control of the permanent magnet synchronous motor.
[0009] Furthermore, the automatic code generation implementation method includes the following steps:
[0010] Step 1: Build a vector control model for permanent magnet synchronous motor based on hybrid PWM according to the hybrid frequency formula, and optimize the parameters of the permanent magnet synchronous motor vector control model.
[0011] Step 2: Construct an automatic code generation model and use it to automatically generate code files based on the vector control model of the permanent magnet synchronous motor with mixed frequency PWM.
[0012] Step 3: Load the code file into the control module, the control chip executes the code file, and communicates with the host computer through the communication interface to send the real-time status data of the permanent magnet synchronous motor to the host computer;
[0013] Step four: Receive control commands sent by the host computer to control the permanent magnet synchronous motor. At the same time, the host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
[0014] Furthermore, the mixing frequency formula in step one is:
[0015] f c (t)=f s +[(1-k0)f(t)+k0R]Δf;
[0016] In the formula, f c (t) is the modulated carrier frequency, f s Let R be the center frequency, R be a random number varying between [-1, 1], Δf be the range of carrier frequency variation, f(t) be a sine function with an amplitude of 1, a frequency twice the fundamental frequency of the motor, and a phase of 0, and k0 be a weighting factor.
[0017] When the weighting factor k0 = 0, the mixing frequency becomes periodic frequency modulation;
[0018] When the weighting factor k0 = 1, the mixing frequency becomes random frequency modulation;
[0019] When the weighting factor k0∈(0,1), the mixed frequency becomes mixed frequency modulation.
[0020] Furthermore, the automatic code generation model in step two includes: an ADC sampling module, a Clark transformation module, a Park transformation module, a speed PI controller, a current PI controller, an HFPWM modulation module, an ePWM module, and an SCI serial communication module.
[0021] The ePWM module adjusts the carrier frequency according to a function formula, which is:
[0022]
[0023] In the formula, R is a uniformly distributed random number generated based on the linear congruence method; the function formula adjusts the carrier frequency according to the weighting factor k0.
[0024] Furthermore, when updating the carrier frequency, an interrupt is made at the apex of the triangular wave in ePWM, and the next carrier frequency is updated after entering the interrupt.
[0025] Another object of the present invention is to provide a code automatic generation implementation device that applies the aforementioned code automatic generation method, the code automatic generation implementation device comprising:
[0026] The model building module is used to build a vector control model of permanent magnet synchronous motor based on hybrid PWM according to the hybrid frequency formula, and optimize the parameters of the permanent magnet synchronous motor vector control model.
[0027] The automatic code generation module is used to build an automatic code generation model, which is then used to automatically generate code files based on the vector control model of a permanent magnet synchronous motor with mixed frequency PWM.
[0028] The control module is used to load code files and control the chip to execute the code files. It communicates with the host computer through the communication interface and sends the real-time status data of the permanent magnet synchronous motor to the host computer.
[0029] The data display module is used to receive control commands sent by the host computer to control the permanent magnet synchronous motor. At the same time, the host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
[0030] Furthermore, the control module includes a control chip, a communication interface, a host computer, a permanent magnet synchronous motor, and a servo drive board; the host computer is built from the SCI-HOST module and Dashboard module in Matlab / Simulink, and is used to receive and graphically display the status data of the permanent magnet synchronous motor in real time.
[0031] Another object of the present invention is to provide a computer device, the computer device including a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, causing the processor to perform the steps of the code automatic generation implementation method.
[0032] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the code automatic generation implementation method.
[0033] Another objective of this invention is to provide an information data processing terminal for implementing the aforementioned automatic code generation device.
[0034] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0035] First, the code automatic generation method based on the hybrid PWM model design provided by this invention achieves hybrid frequency modulation through a hybrid frequency formula, solving the problems caused by single frequency modulation. Simultaneously, the code automatic generation module enables automatic generation of code files and convenient frequency control. Finally, the host computer in the control module provides convenient graphical display and command control. Compared to traditional frequency modulation strategies, the method of this invention is more effective and convenient, effectively improving the work efficiency of developers.
[0036] Secondly, the automatic code generation method of the present invention can effectively reduce the severe pulsation caused by a single modulation method in order to suppress electromagnetic interference, and automatically generate code, thereby reducing development difficulty and development cycle and improving work efficiency.
[0037] Third, as supplementary evidence of the inventive step of the claims of this invention, it is also reflected in the following important aspects:
[0038] (1) The expected benefits and commercial value of the technical solution of this invention after transformation are as follows:
[0039] This invention employs an automatic code generation method to implement a hybrid switching frequency modulation strategy. This automatic code generation method can shorten the development cycle while ensuring code correctness. Furthermore, this automatic code generation equipment is significantly cheaper than currently available hardware-in-the-loop testing machines, which typically cost over ten thousand yuan, while the cost of this automatic code generation equipment is less than one thousand yuan.
[0040] (2) The technical solution of this invention fills a technical gap in the industry both domestically and internationally:
[0041] This invention fills the gap in the automatic code generation method for spread spectrum modulation strategies.
[0042] (3) Whether the technical solution of the present invention solves the technical problem that people have long wanted to solve but have never been able to solve successfully:
[0043] This invention avoids the need for developers to write code to implement spread spectrum modulation strategies. After simulation, the effect of the control strategy can be observed simply by configuring the modules in the automatically generated code file. Attached Figure Description
[0044] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart of the code automatic generation implementation method provided in the embodiments of the present invention;
[0046] Figure 2 This is an application flowchart of the code automatic generation implementation method provided in the embodiments of the present invention;
[0047] Figure 3 This is a schematic diagram of the triangular wave switch period update provided in an embodiment of the present invention;
[0048] Figure 4 This is a structural block diagram of a permanent magnet synchronous motor for speed control experiments provided in an embodiment of the present invention;
[0049] Figure 5 This is a schematic diagram of the A-phase two-channel PWM waveform under hybrid frequency modulation provided in an embodiment of the present invention;
[0050] Figure 6 This is a block diagram of the overall structure of the variable frequency speed control system provided in the embodiments of the present invention;
[0051] Figure 7 This is an overcurrent protection circuit diagram provided in an embodiment of the present invention;
[0052] Figure 8A This is a circuit design diagram of the +24V to +5V power supply section provided in an embodiment of the present invention;
[0053] Figure 8B This is a circuit design diagram of the +5V to +6 / -3V power supply section provided in an embodiment of the present invention;
[0054] Figure 8C This is a circuit design diagram of the +3.3V to +1.65V power supply section provided in an embodiment of the present invention;
[0055] Figure 9 This is a driving circuit diagram provided in an embodiment of the present invention;
[0056] Figure 10 This is a software block diagram of the control system provided in an embodiment of the present invention;
[0057] Figure 11 This is the main program flowchart provided in the embodiments of the present invention;
[0058] Figure 12 This is a flowchart of the overcurrent interrupt procedure provided in an embodiment of the present invention;
[0059] Figure 13 This is a flowchart of the timer interrupt program provided in an embodiment of the present invention;
[0060] Figure 14 This is a waveform diagram of the line current during 20Hz operation provided in an embodiment of the present invention;
[0061] Figure 15 This is a current spectrum diagram with a fixed switching frequency of 100kHz provided in an embodiment of the present invention;
[0062] Figure 16 This is a current spectrum diagram of a 100kHz periodic switching frequency with a center frequency provided in an embodiment of the present invention.
[0063] Figure 17 This is a random switching frequency current spectrum diagram with a center frequency of 100kHz provided in an embodiment of the present invention;
[0064] Figure 18 This is a current spectrum diagram of a hybrid switching frequency with a center frequency of 100kHz provided in an embodiment of the present invention;
[0065] Figure 19 This is a comparison diagram of torque waveforms of random switching frequency PWM and hybrid switching frequency PWM provided in the embodiments of the present invention. Detailed Implementation
[0066] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0067] To address the problems existing in the prior art, the present invention provides a method, apparatus, medium, device, and terminal for automatic code generation. The present invention will be described in detail below with reference to the accompanying drawings.
[0068] like Figure 1 As shown, the automatic code generation method provided in this embodiment of the invention includes the following steps:
[0069] S101, using the hybrid frequency formula to construct a vector control model for a permanent magnet synchronous motor to achieve hybrid modulation;
[0070] S102, through the automatic code generation module, realizes automatic generation of code files and frequency control;
[0071] S103 utilizes the host computer in the control module to achieve graphical display and command control of the permanent magnet synchronous motor.
[0072] As a preferred embodiment, the automatic code generation method based on a hybrid PWM model design provided by this invention specifically includes the following steps:
[0073] S1. Based on the hybrid frequency formula, build a vector control model for a permanent magnet synchronous motor based on hybrid PWM and optimize the model parameters;
[0074] S2, Construct an automatic code generation model. The automatic code generation model automatically generates code files based on the vector control model of the permanent magnet synchronous motor with mixed frequency PWM.
[0075] S3 loads the code file into the control module, which includes a control chip, a communication interface, a host computer, a permanent magnet synchronous motor, and a servo drive board. The control chip executes the code file and communicates with the host computer through the communication interface, sending real-time status data of the permanent magnet synchronous motor to the host computer and receiving control commands sent by the host computer to control the permanent magnet synchronous motor. The host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
[0076] The mixing frequency formula provided in this embodiment of the invention includes:
[0077] f c (t)=f s +[(1-k0)f(t)+k0R]Δf
[0078] In the formula, f c (t) is the modulated carrier frequency, f s Let R be the center frequency, R be a random number varying between [-1, 1], Δf be the range of carrier frequency variation, f(t) be a sine function with an amplitude of 1, a frequency of twice the fundamental frequency of the motor, and a phase of 0, and k0 be a weighting factor.
[0079] When the weighting factor k0 = 0, the mixing frequency becomes periodic frequency modulation;
[0080] When the weighting factor k0 = 1, the mixing frequency becomes random frequency modulation;
[0081] When the weighting factor k0∈(0,1), the mixed frequency becomes mixed frequency modulation.
[0082] The automatic code generation model provided in this embodiment of the invention includes:
[0083] The system includes an ADC sampling module, a Clark conversion module, a Park conversion module, a speed PI controller, a current PI controller, an HFPWM modulation module, an ePWM module, and an SCI serial communication module.
[0084] The ePWM module adjusts the carrier frequency according to a function formula, which is:
[0085]
[0086] In the formula, R is a uniformly distributed random number generated based on the linear congruence method; the function formula adjusts the carrier frequency according to the weighting factor k0.
[0087] The carrier frequency update method provided in this embodiment of the invention requires an interrupt at the apex of the triangular wave in ePWM, and the next carrier frequency is updated after entering the interrupt.
[0088] The host computer provided in this embodiment of the invention is built from the SCI-HOST module and Dashboard module in Matlab / Simulink.
[0089] The automatic code generation implementation device provided in this embodiment of the invention includes:
[0090] The software module is used to build a vector control model for a permanent magnet synchronous motor based on hybrid frequency PWM and optimize the model parameters according to the hybrid frequency formula.
[0091] An automatic code generation module is used to automatically generate code files based on a vector control model for a permanent magnet synchronous motor with mixed-frequency PWM.
[0092] The control module is used to load code files. The control module includes a control chip, a communication interface, a host computer, a permanent magnet synchronous motor, and a servo drive board. The control chip executes the code file and communicates with the host computer through the communication interface, sending real-time status data of the permanent magnet synchronous motor to the host computer and receiving control commands sent by the host computer to realize the control of the permanent magnet synchronous motor. The host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
[0093] As a preferred embodiment, such as Figure 1 As shown, the specific application steps of the code automatic generation implementation method based on hybrid PWM model design provided in this embodiment of the invention include:
[0094] The first step is to build a vector control simulation of a permanent magnet synchronous motor based on a hybrid PWM formula in Simulink, and adjust the PI parameters until the simulation results meet expectations. The hybrid frequency formula is:
[0095] f c (t)=f s+[(1-k0)f(t)+k0R]Δf (1)
[0096] In the formula, f c (t) is the modulated carrier frequency, f s Let R be the center frequency, R be a random number varying between [-1, 1], Δf be the range of carrier frequency variation, f(t) be a sine function with an amplitude of 1, a frequency of twice the fundamental frequency of the motor, and a phase of 0, and k0 be a weighting factor.
[0097] When the weighting factor k0 = 0, the mixing frequency becomes periodic frequency modulation;
[0098] When the weighting factor k0 = 1, the mixing frequency becomes random frequency modulation;
[0099] When the weighting factor k0∈(0,1), the mixed frequency becomes a mixed frequency modulation. This mixed frequency modulation method combines random frequency modulation and periodic frequency modulation to improve the random number R. By using the weighting factor, it reduces the severe torque ripple caused by the drastic switching frequency changes caused by traditional random frequency PWM.
[0100] The second step is to build an automatic code generation model, which includes an ADC sampling module, Clark and Park transformation modules, a speed PI controller and a current PI controller, an HFPWM modulation module, an ePWM module, and an SCI serial communication module.
[0101] The HFPWM module and its internal structure are similar to those of traditional fixed-frequency switching modules, including Park coordinate transformation, voltage space vector sector determination, space vector synthesis, and the order of action. The main difference is the triangular carrier wave, which is set in the ePWM module to update the I / O port during hardware implementation.
[0102] The specific method for implementing hybrid frequency PWM using automatic code generation is as follows: In the General tab of the ePWM module, the "Specify timer period via" option is changed to "input port," that is, the timer period is specified by the input port. Here, a function is written to access this interface. The formula of this function is based on equation (2). The random numbers used in this embodiment follow a uniform distribution, and their generation method is based on the linear congruent method, as shown in equation (3). In this embodiment, an interrupt is entered at the apex of the triangular carrier wave. After entering the interrupt, the carrier frequency of the next switching cycle is updated, as shown in equation (3). Figure 2 , Figure 3 As shown.
[0103]
[0104]
[0105] In the formula, R(n+1) and R(n) are the random numbers generated in the (n+1)th and nth iterations, respectively; N s The maximum word length for random numbers is typically 16 or 8, depending on the processor's bit width; P1 and P2 are two prime numbers. The linear congruential method involves only one multiplication and one addition operation, making it suitable for microprocessor processing.
[0106] The third step involves configuring the ADC sampling module based on the actual hardware interface and sensor specifications; configuring the eQEP module to measure motor speed and rotor position angle; and configuring the SCI serial communication sending and receiving module to transmit motor operating parameters to the host computer for real-time display, while simultaneously sending control commands such as speed and position to the chip.
[0107] The fourth step is to construct a host computer file for vector control based on hybrid frequency PWM. Taking this invention as an example, the host computer can send and receive data in real time and display it graphically.
[0108] In another specific embodiment provided by the present invention, such as Figure 4 As shown, after the automatic code generation module and the host computer are constructed through the above steps, a speed control experiment is conducted on the permanent magnet synchronous motor:
[0109] Download the Simulink automated code file described above to the control chip (DSPTMS320F28379D) using a simulator and run it. Simultaneously, run the host computer to implement SCI communication. Power on the servo driver board and use an oscilloscope to check if the switching frequencies of the six PWM signals supplied to the servo driver board are randomly fluctuating. If the frequencies measured on the oscilloscope are randomly fluctuating, the code generation is successful, and hardware debugging can begin. Figure 5 As shown, this is used to check whether the entire model and code generation were completed correctly.
[0110] After the PWM waveform is correct, turn on the bus voltage power supply and run the motor. In the host computer, call up the variable setspeed and set different given speeds. Observe whether the motor can follow the given speed. At the same time, observe the speed waveform and current waveform in real time to obtain the speed dynamic response and steady-state error. If the dynamic response is poor or there is a steady-state error, the experimental effect is poor. Modify the PI parameters in the automatic code model to debug until the experimental effect is satisfactory.
[0111] In this embodiment of the invention, the effect of the hybrid PWM model is verified by conducting speed control experiments on a permanent magnet synchronous motor. After completing simulation verification of other modulation strategies, the ePWM module can still be modified to implement different PWM modulation strategies, but none of these require manually converting various algorithms into C or C++ code, which is simple and convenient and greatly improves the efficiency of experimental verification.
[0112] In another specific embodiment of the present invention, a code automatic generation implementation device based on a hybrid PWM model design is provided, the code automatic generation implementation device specifically comprising:
[0113] The software module is used to build a vector control model for a permanent magnet synchronous motor based on hybrid frequency PWM and optimize the model parameters according to the hybrid frequency formula.
[0114] An automatic code generation module is used to automatically generate code files based on a vector control model for a permanent magnet synchronous motor with mixed-frequency PWM.
[0115] The control module is used to load code files. The control module includes a control chip, a communication interface, a host computer, a permanent magnet synchronous motor, and a servo drive board. The control chip executes the code file and communicates with the host computer through the communication interface, sending real-time status data of the permanent magnet synchronous motor to the host computer and receiving control commands sent by the host computer to realize the control of the permanent magnet synchronous motor. The host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
[0116] Specific limitations regarding the code automatic generation implementation device based on the hybrid PWM model design can be found in the limitations of the code automatic generation implementation method based on the hybrid PWM model design above, and will not be repeated here. Each module in the aforementioned code automatic generation implementation device based on the hybrid PWM model design can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0117] In another specific embodiment of the present invention, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the limitation of the code automatic generation implementation method based on the hybrid PWM model design, which will not be elaborated here.
[0118] In another specific embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the limitation of the code automatic generation method based on the hybrid PWM model design, which will not be elaborated here.
[0119] In another specific embodiment of the present invention, an information data processing terminal is provided, which is used to implement an automatic code generation implementation device based on a hybrid PWM model design.
[0120] Example: Experimental verification of hybrid switching frequency modulation technology for permanent magnet synchronous motors
[0121] 1. Overall structural design of the permanent magnet synchronous motor experimental platform
[0122] The entire control system hardware circuit is divided into two parts: a control board and a power board. The power board includes the main power circuit, power supply circuit, gallium nitride drive circuit, and voltage and current detection circuit. The control board uses the TMS320F28379D evaluation board, which consists of a DSP minimum system, communication circuit, and sampling signal interface circuit. Figure 6 As shown in the diagram, the power supply voltage at each point in the power circuit is mainly obtained from a 24V DC power supply through a power module. The inverter converts the DC bus voltage into an alternating voltage for driving the motor. The microprocessor (DSP) is the core of the entire system. It is responsible for detecting various information, including rotor position signal input control, speed feedback, and system status, accurately outputting motor drive signals, and completing tasks such as speed control and system control.
[0123] 2. Hardware Circuit Design of Experimental Platform
[0124] 2.1 Overcurrent Protection Circuit
[0125] The main function of the overcurrent protection circuit is to prevent damage to components caused by the current in the three-phase stator windings of the permanent magnet motor exceeding the rated operating current of the power switching devices in the bridge inverter. Figure 7 In this example, overcurrent protection for the control system is achieved by determining whether the bus is experiencing overcurrent. A 5V voltage is divided by resistors to generate a 0.56V reference voltage Vref, which is stably tracked by an LM353. A hysteresis comparator is used to compare the voltage output from the current sensor with the reference voltage to determine if an overcurrent has occurred. If an overcurrent is detected, the hysteresis comparator outputs a low level to the enable signal of the driver chip, cutting off the six PWM signals and thus implementing the overcurrent protection function.
[0126] 2.2 Power Supply Circuit
[0127] The power supply in the entire hardware circuit is mainly divided into two parts. The first part is the DC bus voltage, which is obtained after rectification and filtering by an AC voltage regulator. The power supply for the control circuit is obtained from a single 24V DC voltage. The power supply for the GaN driver chip Si8271, the differential receiver chip AM26C32D, and the overcurrent protection section is all +5V. The current sensor is powered by 3.3V, which is divided to 1.65V and used as the bias voltage for the current sensor. The +5V is then converted to +6V / -3V by the power supply chip to drive the GaN. The schematic diagram of the power supply circuit is shown in Figure 8.
[0128] 2.3 Drive Circuit
[0129] The driver circuit for the GaN switching device uses the Si8271 from Silicon Labs. The Si8271 is a single-transistor isolated gate driver with a maximum input-output isolation voltage of 2.5kV, a signal propagation delay of 60ns, and a peak output current of 4A. To prevent floating voltage from causing mis-turn-on of the GaN device, a voltage divider design is used at the control signal input pin to implement a pull-down function. To reduce the peak gate drive current and achieve fast turn-on and turn-off, the gate turn-on drive resistor is set to 10Ω, and the turn-off drive resistor is set to 2Ω. Figure 9 As shown.
[0130] 3. System Software Design
[0131] In designing the software, this experiment focuses on the system's practicality, reliability, and ease of use to ensure the program meets the functional requirements. The controller for this experimental platform is the TMS320F28379D evaluation board, which uses space vector modulation to drive a permanent magnet synchronous motor. The software block diagram is shown below. Figure 10 As shown.
[0132] The TMS320F28379D is a microprocessor specifically designed for low-cost and high-efficiency motor control applications, and has the following key features:
[0133] • Dual-core architecture, with two TMS320C82x 32-bit CPUs, each with a clock speed of 200MHz;
[0134] • Up to four analog-to-digital converters (ADCs) and three 12-bit buffered DAC outputs;
[0135] • 24 enhanced pulse width modulator channels;
[0136] • Three enhanced quadrature encoder pulse modules;
[0137] • The DSP engine enables fast response in the control loop.
[0138] When the motor is running, the PID controller processes the speed error, and its output is used as the q-axis current setpoint. This setpoint then enters the current loop PI controller to complete a series of calculations, including coordinate transformation and SVPWM modulation, to achieve closed-loop control. In this example, the enhanced quadrature encoder pulse module in the TMS320F28379D is used to capture and count the AB phase pulse edges of the encoder output. The Z pulse is used to reset the count. In practice, the motor encoder has 2500 lines, and the motor generates 10,000 pulse edges per revolution. The M-method is used to measure the speed.
[0139] The program mainly includes system and peripheral initialization, timer interrupt routines, and overcurrent protection interrupt routines. The timer interrupt routine mainly includes closed-loop speed regulation, generation of random numbers using the linear congruential method, calculation of the switching period, and finally refreshing the switching period register. Figure 11 , Figure 12 and Figure 13 These are the main program flowchart, the overcurrent protection interrupt program flowchart, and the timer interrupt program flowchart, respectively.
[0140] 4. Analysis of Experimental Results
[0141] 4.1 Permanent Magnet Synchronous Motor Experimental Platform
[0142] This experimental platform uses a 750W three-phase eight-pole permanent magnet synchronous motor as the controlled object and conducts related experiments. The current waveform is analyzed using a four-channel isolated Tektronix oscilloscope TPS2012B and a CYBERTEK current clamp. Comparative experiments were conducted on four modulation methods: fixed switching frequency, periodic switching frequency, random switching frequency, and hybrid switching frequency.
[0143] 4.2 Experimental Results and Analysis of the Influence of Different Frequency Modulation Strategies on Current Spectrum and Torque Ripple
[0144] Figure 14 The current waveform of a permanent magnet synchronous motor under SVPWM modulation at 20Hz with rated load is shown. Figure 15 , Figure 16 , Figure 17 and Figure 18 The output current waveforms are displayed under periodic switching frequency modulation, random switching frequency modulation, and hybrid switching frequency modulation at a fixed switching frequency of 100kHz, a center frequency of 100kHz, and a spread spectrum width of 10% of the center frequency, respectively. Waveform comparison shows that the latter three modulation techniques effectively reduce the power spectral peak. While the periodic switching frequency modulation strategy can suppress noise peaks concentrated at the switching frequency, it is not as effective as the random switching frequency modulation. Figure 19 As can be seen, hybrid switching frequency modulation, compared to random frequency modulation, can not only suppress the peak current power spectrum at the switching frequency and reduce electromagnetic interference, but also reduce torque ripple. Therefore, the hybrid switching frequency modulation technique has superior performance, consistent with the simulation results.
[0145] 5. Summary
[0146] This experiment first analyzes and designs the overall structure of the permanent magnet motor variable frequency speed control experimental platform, and then details the design of the system's hardware circuits and software programs. Related experiments were then conducted on the constructed experimental platform. Comparisons revealed that both random switching frequency modulation techniques can significantly reduce harmonics near the switching frequency, while the hybrid switching frequency modulation technique can distribute harmonic energy more evenly across the entire spectrum and reduces the requirements for random number performance, consistent with simulation results.
[0147] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0148] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for automatically generating an implementation of a code, characterized by, The automatic code generation method includes: the system constructs a vector control model for the permanent magnet synchronous motor using a hybrid frequency formula to achieve hybrid modulation of the permanent magnet synchronous motor frequency; the automatic code generation module realizes the automatic generation of code files and frequency control; and the host computer in the control module realizes graphical display and command control of the permanent magnet synchronous motor. The automatic code generation method includes the following steps: Step 1: Build a vector control model for permanent magnet synchronous motor based on hybrid PWM according to the hybrid frequency formula, and optimize the parameters of the permanent magnet synchronous motor vector control model. Step 2: Construct an automatic code generation model and use it to automatically generate code files based on the vector control model of the permanent magnet synchronous motor with mixed frequency PWM. Step 3: Load the code file into the control module, the control chip executes the code file, and communicates with the host computer through the communication interface to send the real-time status data of the permanent magnet synchronous motor to the host computer; Step 4: Receive control commands sent by the host computer to control the permanent magnet synchronous motor. At the same time, the host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time. The mixing frequency formula in step one is: fc(t)=fs+[(1-k0)f(t)+k0R]Δf; In the formula, fc(t) is the modulated carrier frequency, fs is the center frequency, R is a random number that varies between [-1,1], Δf is the range of carrier frequency variation, f(t) is a sine function with an amplitude of 1, a frequency of 2 times the fundamental frequency of the motor and a phase of 0, and k0 is a weighting factor. When the weighting factor k0 = 0, the mixing frequency becomes periodic frequency modulation; When the weighting factor k0 = 1, the mixing frequency becomes random frequency modulation; When the weighting factor k0∈(0,1), the mixing frequency becomes a mixing frequency modulation; The automatic code generation model in step two includes: an ADC sampling module, a Clark transformation module, a Park transformation module, a speed PI controller, a current PI controller, an HFPWM modulation module, an ePWM module, and an SCI serial communication module; The ePWM module adjusts the carrier frequency according to a function formula, which is: ; In the formula, R is a uniformly distributed random number generated based on the linear congruence method; the function formula adjusts the carrier frequency according to the weighting factor k0.
2. The code automatic generation implementation method according to claim 1, wherein, When updating the carrier frequency, an interrupt is triggered at the apex of the triangular wave in ePWM. After entering the interrupt, the next carrier frequency is updated.
3. A code automatic generation implementation apparatus applying the code automatic generation implementation method according to any one of claims 1 to 2, characterized by The automatic code generation implementation device includes: The model building module is used to build a vector control model of permanent magnet synchronous motor based on hybrid PWM according to the hybrid frequency formula, and optimize the parameters of the permanent magnet synchronous motor vector control model. The automatic code generation module is used to build an automatic code generation model, which is then used to automatically generate code files based on the vector control model of a permanent magnet synchronous motor with mixed frequency PWM. The control module is used to load code files and control the chip to execute the code files. It communicates with the host computer through the communication interface and sends the real-time status data of the permanent magnet synchronous motor to the host computer. The data display module is used to receive control commands sent by the host computer to control the permanent magnet synchronous motor. At the same time, the host computer receives and graphically displays the status data of the permanent magnet synchronous motor in real time.
4. The code automatic generation implementation apparatus according to claim 3, wherein The control module includes a control chip, a communication interface, a host computer, a permanent magnet synchronous motor, and a servo drive board. The host computer is built from the SCI-HOST module and Dashboard module in Matlab / Simulink and is used to receive and graphically display the status data of the permanent magnet synchronous motor in real time.
5. A computer device, comprising: The computer device includes a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the code automatic generation implementation method as described in any one of claims 1 to 2.
6. A computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the code automatic generation implementation method as described in any one of claims 1 to 2.
7. An information data processing terminal, characterized by The information data processing terminal is used to implement the code automatic generation implementation device as described in any one of claims 3 to 4.