A real-time motion control method and device based on code generation

Through the real-time motion control method based on code generation, the problems of long development cycle and low efficiency in motion control of permanent magnet synchronous motors are solved, and the automatic model-to-code conversion and system dynamic performance optimization are realized, the debugging process is simplified, and the development is improved. efficiency.

CN117111913BActive Publication Date: 2024-11-12NANJING KAITONG AUTOMATION TECH CO LTD +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202311104536.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2024-11-12
Estimated Expiration
2043-08-30

AI Technical Summary

Technical Problem

In the motion control of permanent magnet synchronous motors, the existing technology requires a lot of code writing, resulting in long development cycles, high labor costs, low efficiency, and high knowledge reserve requirements for technicians, making it difficult to achieve efficient debugging and modeling.

Method used

Using a real-time motion control method based on code generation, a current loop model and a dual closed loop motion control model for current speed are established by obtaining sensor information, and the model runs code is automatically generated, and runs on the DSP board, skipping the process of manually writing controller code. , realize automatic conversion from model to code.

Benefits of technology

It greatly reduces the development cycle and knowledge reserve requirements for technicians, improves development efficiency, optimizes fractional algorithms to improve the dynamic performance of the system, and implements automatic conversion through code generation tools, simplifying the debugging process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117111913B_ABST
    Figure CN117111913B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a real-time motion control method and device based on code generation, and relates to the field of automatic control technology. The present invention comprises: a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power module (5); the present invention adopts Simulink modeling, automatically generates executable controller code through a code generation tool and automatically downloads it to the controller for operation, which has the characteristics of greatly reducing the development cycle and improving development efficiency. The present invention provides a complete set of real-time motion control devices based on code generation, realizes motion control of a permanent magnet synchronous motor through a current-speed dual closed-loop control method, and completes automatic code generation from a model to an executable file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automation control technology, and in particular to a real-time motion control method and device based on code generation. Background Art

[0002] Code generation technology can automatically compile the model built by the user and automatically generate executable C code files. Through code generation technology, developers do not need to master the development programming language or program structure of the target controller, and only need to focus on building the mathematical model of the system. Therefore, by using code generation technology, the knowledge reserve requirements of engineers can be reduced, the development cycle and capital investment can be reduced, and work efficiency can be greatly improved.

[0003] For the motion control of permanent magnet synchronous motors, it is often necessary to establish the motion control model of the motor, such as the current loop model, the current-speed dual closed-loop model, the current-speed-position triple closed-loop model, etc., and perform software simulation by adjusting the control algorithm parameters, observe the control effect, and then conduct actual machine testing. In this process, a large amount of code programs need to be written, so that in the actual research and development process, the work of writing code often takes up the most time of scientific researchers, and the programming process also requires the experience and knowledge reserves of technicians, with high labor costs and low efficiency.

[0004] Therefore, how to apply the code generation solution to the modeling and debugging of motion control of permanent magnet synchronous motors has become an issue that needs to be studied. Summary of the invention

[0005] The embodiments of the present invention provide a real-time motion control method and device based on code generation, which can apply the code generation scheme to the modeling and debugging of the motion control of the permanent magnet synchronous motor, thereby reducing the development cost and the knowledge reserve requirements for technical personnel and improving the project development efficiency.

[0006] To achieve the above object, the embodiments of the present invention adopt the following technical solutions:

[0007] In a first aspect, an embodiment of the present invention provides a method comprising:

[0008] S1. Acquiring sensor information and establishing a current loop model, wherein the sensors deployed in the motor module (4) include: a current sensor and a position sensor, the motor module (4) includes a permanent magnet synchronous motor, and the sensor information includes current information and position information;

[0009] S2. Using the sensor information and the current loop model, establish a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor;

[0010] S3, configuring interface hardware for the current-speed dual closed-loop motion control model, and automatically generating model running code;

[0011] S4, downloading the generated model running code to the DSP board (2) for running.

[0012] In a second aspect, an embodiment of the present invention provides a device comprising: a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power supply module (5);

[0013] The host computer (1) runs MATLAB and establishes a Simulink model (1-1), and the established permanent magnet synchronous motor current-speed dual closed-loop motion control model is imported into the Simulink model (1-1);

[0014] The motion control algorithm of the motor module (4) is written in the host computer (1) by means of Simulink modeling, and after automatically generating codes, it is downloaded to the DSP board (2) for execution, and at the same time, the current-speed dual closed-loop motion control model in the host computer (1) enters a real-time operation state;

[0015] After the host computer (1) and the DSP board (2) establish real-time communication, the model parameters of the current-speed dual closed-loop motion control model running in real time in the host computer (1) are adjusted, and the adjusted parameters are transmitted to the DSP board (2) in real time. After the DSP board (2) receives the adjusted parameters, it obtains the current operation data of the motor module (4) through the signal processing board (3) and feeds it back to the host computer (1);

[0016] The host computer (1) is connected to the DSP board (2) via a UART serial data bus, and the host computer (1) also downloads program codes to the DSP via a JTAG interface;

[0017] The DSP board (2) and the signal processing board (3) are connected by a signal line via a DC3-16P interface;

[0018] The signal processing board (3) and the motor module (4) are connected via a DB9 interface using a signal line, and the signal processing board (3) is connected to the motor module (4) via a terminal wire via a wiring terminal.

[0019] The real-time motion control method and device based on code generation provided in the embodiments of the present invention realize automatic conversion from model to code by utilizing code generation tools, skipping the process of manually writing controller code according to the model, so that developers can realize real-machine debugging without mastering controller programming skills, greatly reducing the development cycle and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 A schematic diagram of the principle of a real-time motion control device based on code generation provided by an embodiment of the present invention;

[0022] Figure 2 A schematic diagram of a current-speed dual closed-loop motion control system provided by an embodiment of the present invention;

[0023] Figure 3 A dynamic structure diagram of a fractional-order PIλ controller provided by an embodiment of the present invention;

[0024] Figure 4 A schematic diagram of the automatic code generation process provided by an embodiment of the present invention.

[0025] Figure 5 A schematic diagram of a method flow chart provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention will be described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention. It can be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "one", "said" and "the" used herein may also include plural forms. It should be further understood that the term "including" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used here may include wireless connection or coupling. The term "and / or" used herein includes any unit and all combinations of one or more associated listed items. It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as generally understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless defined as herein.

[0027] In this embodiment, a permanent magnet synchronous motor motion control device and method based on automatic code generation for model implementation is designed. The device and method can not only reduce development costs and technical personnel's knowledge requirements, but also improve project development efficiency. The control device improves the dynamic performance of the system by optimizing the fractional order algorithm, and realizes automatic conversion from model to executable code through the code generation tool. Specifically, the embodiment of the present invention provides a real-time motion control method based on code generation, such as Figure 5 As shown, including:

[0028] S1. Obtain sensor information and establish a current loop model.

[0029] The sensors deployed in the motor module (4) include: a current sensor and a position sensor, the motor module (4) includes a permanent magnet synchronous motor, and the sensor information includes current information and position information;

[0030] S2. Using the sensor information and the current loop model, establish a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor;

[0031] S3, configuring interface hardware for the current-speed dual closed-loop motion control model, and automatically generating model running code;

[0032] In actual applications, after completing the model configuration, select the interface hardware information to be used in the model settings, such as the serial port baud rate, the communication channel used, the simulator configuration file, etc.

[0033] S4, downloading the generated model running code to the DSP board (2) for running.

[0034] Specifically, the control method is applied to a real-time motion control device based on code generation, the device comprising: a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power supply module (5);

[0035] In this embodiment, the host computer (1) runs MATLAB and establishes a Simulink model (1-1), and the established permanent magnet synchronous motor current speed dual closed-loop motion control model is imported into the Simulink model (1-1). The Simulink model (1-1) also includes a data transmission model.

[0036] The motion control algorithm of the motor module (4) is written in the host computer (1) by means of Simulink modeling, and after automatically generating codes, it is downloaded to the DSP board (2) for execution, and at the same time, the current-speed dual closed-loop motion control model in the host computer (1) enters a real-time operation state;

[0037] After the host computer (1) and the DSP board (2) establish real-time communication, the model parameters of the current-speed dual closed-loop motion control model running in real time in the host computer (1) are adjusted, and the adjusted parameters are transmitted to the DSP board (2) in real time. After receiving the adjusted parameters, the DSP board (2) obtains the current operating data of the motor module (4) through the signal processing board (3), and feeds back to the host computer (1).

[0038] The configured interface hardware includes: a host computer (1) and a DSP board (2) are connected via a UART (Universal Asynchronous Receiver / Transmitter) serial data bus, thereby performing real-time data transmission; the host computer (1) also downloads program codes to the DSP via a JTAG (Joint Test Action Group) interface;

[0039] The DSP board (2) and the signal processing board (3) are connected by a signal line via a DC3-16P (e.g., 2x8 bull-horn socket) interface, thereby transmitting control signals and data;

[0040] The signal processing board (3) and the motor module (4) are connected to each other through a DB9 interface with a signal line to transmit data. The signal processing board (3) is connected to the motor module (4) through a terminal block with a terminal block, thereby driving the motor. Furthermore, the upper computer (1) and the DSP board (2) transmit data through UART. In terms of transmission hardware, a connection is established through a wired serial port. In terms of software, UART transmission is achieved by adding a serial port module to the model and then through the code generated by automatic code. The power supply module (5) provides 3.3V DC and 5V DC power supply to the DSP board (2) through the terminal block, and provides 5V DC power supply and 220V AC power supply to the signal processing board (3) through the terminal block for power driving circuit power supply.

[0041] In this embodiment, in S1, establishing the current loop model includes:

[0042] The three-phase current information (the current information is specifically three-phase current information) and the motor position information of the permanent magnet synchronous motor are read, and Clarke transformation and Park transformation are performed respectively to obtain the current loop model, wherein the three-phase current information is subjected to Clarke transformation to transform the three-phase current coordinates into two-phase current coordinates; the motor position information is subjected to Park transformation to obtain the current in the direction of rotor rotation.

[0043] The main calculation models in the current loop model include: Clarke transformation, Park transformation, inverse Clarke transformation and inverse Park transformation calculation models; when the current loop model is running, it includes: after obtaining the control deviation by subtracting the given value and the actual value of the D-axis and Q-axis currents, the Clarke transformation matrix and the Park transformation matrix are used to perform inverse transformation processing respectively to obtain the inverse Clarke matrix and the inverse Park matrix, and the control target is restored to the three-phase current, so as to drive the motor to run through SVPWM and the power drive circuit.

[0044] The process of performing Clarke transformation includes: establishing the A, B, C three-phase current I of the permanent magnet synchronous motor A ,I B ,I C The coordinates of the α and β phase currents I α ,I β The transformation relationship of the coordinates is:

[0045] Then, according to the transformation relationship, the Clarke transformation matrix is ​​determined as:

[0046] The process of performing Park transformation includes: obtaining the current in the rotor rotation direction of the permanent magnet synchronous motor through Park transformation, including the current I in the D-axis and Q-axis directions d ,I q , where the D axis is parallel to the rotor direction, the Q axis is perpendicular to the rotor direction, and θ is the current rotation angle of the rotor, and Further establish the Park transformation matrix as Generally, I d Set to 0, so that the original need to control three variables can be simplified to control I through Clarke transformation and Park transformation. q Single variable control. After the control algorithm is calculated, the control signal needs to be restored to three-phase current step by step through inverse Clarke transformation and inverse Park transformation, and then the A, B, and C phase voltages are controlled through SVPWM (Space Vector Pulse Width Modulation) technology. Figure 2 As shown, the current loop model is obtained by combining the inverse Clarke transformation matrix, the inverse Park transformation matrix, the SVPWM module and the power drive module.

[0047] Further, in S2, it includes: optimizing the fractional-order speed control algorithm to obtain an improved transfer function G(s), wherein G(s)=C(s)×C'(s)×P(s), C'(s) represents the optimization correction link inserted in series, C'(s)=1+τs, s refers to the integral link, τ represents the time constant, T represents the time constant; K P , K I are proportional gain and integral gain respectively, λ is the fractional integral order, K=1;

[0048] Using the improved transfer function G(s), a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is established, including:

[0049]

[0050] Among them, B and C are two intermediate parameters, which are only used to replace part of the formula content in order to make the formula not too long, so that the formula in the following text is not too complicated and the readability is improved; ω c Indicates the cutoff frequency.

[0051] In this embodiment, S4 includes: after the Simulink model in the host computer (1) is established, the algorithm model and function to be run in the current-speed dual closed-loop motion control model are automatically generated into a DSP running code through a code generation function, and the DSP running code is downloaded from the host computer (1) to the DSP board (2);

[0052] After the DSP board (2) loads and runs the DSP running code, the calculated control signal is output to the signal processing board (3) in the form of a PWM wave;

[0053] The signal processing board (3) processes the received PWM wave and outputs the PWM wave for directly controlling the power device to the power driving circuit of the motor module (4);

[0054] The power drive circuit in the motor module (4) is controlled by the PWM wave and outputs three-phase alternating current to drive the permanent magnet synchronous motor to move; at the same time, the motor module (4) uses the motor operating parameters collected by the sensor as sensor information in real time, and feeds back the sensor information to the DSP board (2) through the signal processing board (3);

[0055] The DSP board (2) inputs the feedback sensor information into the DSP controller, and the DSP controller reads the relevant parameters required by the current-speed dual closed-loop motion control model from the sensor information, and sends the relevant parameters to the designated address of the host computer (1) through UART according to the provisions of the data map, and the Simulink oscilloscope of the host computer (1) displays the relevant parameters by reading the content of the designated address. The Simulink model can adjust some parameters in real time, and the adjusted parameters are sent to the DSP controller in real time through the simulator to update the program content.

[0056] In this embodiment, in S3, the process of automatically generating the model running code includes:

[0057] S301: Since code generation needs to calculate the running time and frequency of each program based on the step size, the solver must first be set to a fixed-step discrete solver, and the fixed step size is set according to actual needs. The end time of the simulation is set to infinite.

[0058] S302: After completing the hardware selection, select the board model in the Hardware Implementation tab of the model parameter setting. The model here is selected according to the model of the DS30P controller. At the same time, according to the selected DS30P controller model, import the target file (Target Configuration) of the corresponding model into the model.

[0059] S303: Complete the hardware peripheral configuration, and perform basic configuration of the peripheral resources to be used in the hardware implementation tab of the model parameter settings, such as setting the overall system clock frequency, the mode of a specific GPIO, the pins and baud rate of the S30CI serial port channel, the frame structure of the serial port communication, etc. At the same time, set whether to automatically download and run the program after compilation. If it is the first generation, you can choose to compile only. After checking the C code automatically generated after compilation and confirming that it is correct, you can choose to compile and run to automatically download the code to DS30P.

[0060] S304: Configure the external mode. Set the channel used by the external mode in the hardware implementation tab of the model parameter setting. Select from the serial port, CAN, and XCP according to the actual situation and specify the serial port number connecting the upper computer and the lower computer to establish real-time external mode communication.

[0061] S305: Import custom code (optional). If it is necessary to import user-written code (such as initialization program, enabling of some chips, etc.), it can be imported into the model through the custom code function in the model settings. The automatic code generator will insert the user-defined code into the corresponding position of the program according to the rules.

[0062] S306: Compile the model and automatically generate code. Use the Build option to compile the model. The automatic code generator will compile and automatically generate C code according to the model and settings. The generated C code can be viewed through Code View, which provides the function of automatically jumping to and highlighting the related C code by clicking on the elements in the model, which is very helpful for debugging.

[0063] S307: Download and run the code. You can modify the Build function in the model configuration to compile, generate and automatically download the code to automatically download the generated C code to the DS30P controller and run it. You can also use the deployment function in the hardware option card to realize automatic download and run of the code.

[0064] This embodiment also provides a real-time motion control device based on code generation, comprising: a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power supply module (5);

[0065] The host computer (1) runs MATLAB and establishes a Simulink model (1-1), and the established permanent magnet synchronous motor current speed dual closed-loop motion control model is imported into the Simulink model (1-1), and the Simulink model (1-1) also includes a data transmission model;

[0066] The motion control algorithm of the motor module (4) is written in the host computer (1) by means of Simulink modeling, and after automatically generating codes, it is downloaded to the DSP board (2) for execution, and at the same time, the current-speed dual closed-loop motion control model in the host computer (1) enters a real-time operation state;

[0067] After the host computer (1) and the DSP board (2) establish real-time communication, the model parameters of the current-speed dual closed-loop motion control model running in real time in the host computer (1) are adjusted, and the adjusted parameters are transmitted to the DSP board (2) in real time. After the DSP board (2) receives the adjusted parameters, it obtains the current operation data of the motor module (4) through the signal processing board (3) and feeds it back to the host computer (1);

[0068] The host computer (1) is connected to the DSP board (2) via a UART serial data bus, and the host computer (1) also downloads program codes to the DSP via a JTAG interface;

[0069] The DSP board (2) and the signal processing board (3) are connected by a signal line via a DC3-16P interface;

[0070] The signal processing board (3) and the motor module (4) are connected via a DB9 interface using a signal line, and the signal processing board (3) is connected to the motor module (4) via a terminal wire via a wiring terminal.

[0071] Specifically, the DSP board (2) includes: a power supply and reset module, a download circuit (2-1), a DSP controller (2-2), a level adjustment circuit (2-3), an ADC (2-4) and an interface module (including RS232, JTAG, DC3-16P bull horn socket, etc.). The download circuit (2-1) uses an emulator to download code through the JTAG interface; wherein, the specific model of the DSP controller is not unique, and can be a DSP C2000 series, C6000 series or other series. Similarly, the form of the ADC (2-4) is not unique, and can be an internal ADC of the DSP controller, or an external ADC, or any software or hardware solution that realizes analog-to-digital conversion. At the same time, the communication interface of the DSP board takes RS232 and DC3-16P as examples, and any other software or hardware solution that can realize the communication between the DSP board and the host computer and the signal processing board can be applied to the solution of this embodiment. However, other code downloading / burning methods based on DSP, such as through serial port, network port, Internet (including wired and wireless), etc., are also within the scope of protection of this patent because they achieve the same function. The level conditioning circuit (2-3) refers to a circuit that realizes the function of converting the output level of the encoder in the signal processing board into the digital input level of the DSP, such as 5V DC to 3.3V DC.

[0072] The signal processing board (3) includes: a PWM output circuit (3-1), a power drive circuit (3-2), an encoder processing circuit (3-3), a current processing circuit (3-4), a power module and an interface circuit (such as DC3-16P, DB9, power terminal, etc.); the PWM output circuit (3-1) is used to process and amplify the SVPWM signal output by the DSP board (2), and output a PWM wave that can directly control the power drive circuit;

[0073] The power drive circuit (3-2) is composed of power devices, is controlled by PWM waves, and is powered by 220V AC. The power drive circuit (3-2) outputs three-phase AC power to drive the permanent magnet synchronous motor to operate;

[0074] The motor module (4) outputs an encoder signal and a two-phase current signal after differential sampling. The two signals are connected to the signal processing board through the DB9 port respectively. The encoder signal is decoded into A, B, Z, U, V, W and other signals through the encoder processing circuit (3-3) and output to the corresponding level conditioning circuit of the DSP board (2). The current signal is converted from a differential signal to a single-ended signal through the current processing circuit (3-4) and output to the analog-to-digital conversion module of the DSP board.

[0075] The motor module (4) at least comprises a rectifier drive circuit, an interface circuit and a protection circuit, a sensor circuit (including voltage and current detection of three-phase windings, etc.), a power module, an encoder module, a controlled motor body, and connections between the modules.

[0076] The power supply module (5) is powered by a common 220V AC mains electricity, and outputs 5V DC and 3.3V DC electricity to supply the control circuit of the DSP board (2) and the signal processing board (3) through a protection circuit, a transformer, a voltage stabilizing module, a voltage conversion module and other circuits. The protected 220V AC electricity is output to the power drive circuit of the signal processing board through a protection circuit and an isolation transformer.

[0077] The host computer (1) also includes: a code generation toolkit (1-2), a data map (1-3) and a Simulink oscilloscope (1-4); the data map (1-3) is used to record the mapping diagram of the storage addresses corresponding to each system variable. In actual applications, the data map specifies the memory address of each system variable. By using the data map, the memory address of the variable can be manually specified, so that Matlab can read the variable by reading the specified memory address to draw charts and apply algorithms; wherein, the code generation toolkit (1-2) can use the function implemented by the free support package based on MATLAB and Simulink software developed by Texas Instruments (TI) in cooperation with Mathworks. It should be pointed out that the model-based automatic code generation function implemented by other software or plug-ins should be regarded as a similar function and is also within the scope of protection of this patent.

[0078] The Simulink oscilloscope (1-4) reads the data and draws it into a waveform graph by accessing the address mapped in the data map (1-3). The data map can be used to access the internal variables of the Simulink model in a programming manner outside Simulink. It should be pointed out that the data map can be drawn by completely manual drawing, automatic drawing by design software, manual drawing with the assistance of software, etc. Any means that can achieve the effect of mapping variables to storage addresses can be applied to the present embodiment.

[0079] Compared with the prior art, the advantage of this embodiment is that, by using the code generation tool, the automatic conversion from model to code is realized, skipping the process of manually writing controller code according to the model, so that developers can realize real machine debugging without mastering controller programming skills, greatly reducing the development cycle and improving development efficiency. At the same time, the optimized fractional order algorithm is used to optimize the limitations of the traditional fractional order, broaden the frequency range of the system, and improve the dynamic performance of the system. By introducing the data map, the user can read the variables during the automatic code generation process, making it more convenient to observe the data.

[0080] For example, in practical applications, this embodiment can also be implemented in the following manners and processes:

[0081] See also Figure 1A real-time motion control device based on code generation comprises a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power supply module (5); the controlled object in this embodiment is a permanent magnet synchronous motor (included in the motor module (4)). The host computer (1) and the DSP board (2) are connected via a UART (Universal Asynchronous Receiver / Transmitter) serial data bus for real-time data transmission, and program code is downloaded to the DSP via a JTAG (Joint Test Action Group) interface. The DSP board (2) and the signal processing board (3) are connected via a DC3-16P (i.e., 2x8 bull-horn socket) interface with a signal line to transmit control signals and data. The signal processing board (3) and the motor module (4) are connected via a DB9 interface with a signal line to transmit data, and via a terminal block with a terminal line to drive the motor. The power module (5) provides 3.3V DC and 5V DC power to the DSP board (2) through the wiring terminals, and provides 5V DC power and 220V AC power to the signal processing board (3) through the wiring terminals for powering the power drive circuit.

[0082] The motion control algorithm of the controlled object is written in the host computer through Simulink modeling. The model automatically generates code and then is downloaded to the DSP for execution. At the same time, the model in the host computer enters the real-time running state, and the host computer establishes real-time communication with the DSP board. Some parameters of the model in the host computer are adjustable during operation and transmitted to the DSP in real time. The DSP feeds back the operating data to the host computer in real time.

[0083] The host computer runs MATLAB and establishes a Simulink model (1-1), wherein the Simulink model includes a permanent magnet synchronous motor current speed dual closed-loop control model and a data transmission model;

[0084] The current-speed dual closed-loop control model of permanent magnet synchronous motor is as follows: Figure 2 As shown, according to Figure 2 Complete the modeling, which includes the following steps:

[0085] S1: Establish a current loop model, and complete Clarke transformation and Park transformation according to the motor A, B, C three-phase current values ​​and motor position information fed back by the current sensor and position sensor included in the motor module (4). The purpose of Clarke transformation is to transform the three-phase current coordinates of A, B, C into the two-phase current coordinates of α and β. Usually, the A phase direction is overlapped with the α direction, and the β direction is placed between the A and B phases to determine the relative position relationship of the two coordinates, and the formula (1) and formula (2) are obtained according to the geometric principle to obtain I α ,I β :

[0086]

[0087] Simplifying it into matrix form gives the Clarke transformation matrix:

[0088]

[0089] Next, the current in the direction of rotor rotation is obtained through Park transformation. Let the D axis be the axis parallel to the rotor direction, the Q axis be the axis perpendicular to the rotor direction, and θ be the angle between the α axis and the D axis, that is, the current rotation angle of the rotor. Similarly, the coordinate transformation formula (4) and formula (5) are obtained through geometric relationships to obtain I d ,I q :

[0090] I d =I α *cos(θ)+I β *sin(θ)#(4)

[0091] I q =-I α *sin(θ)+I β *cos(θ)#(5)

[0092] Simplifying it into matrix form gives the Park transformation matrix:

[0093]

[0094] Generally, I d Set to 0, so that the original need to control three variables can be simplified to control I through Clarke transformation and Park transformation. q Control of a single variable. After the control algorithm is calculated, the control signal needs to be restored to three-phase current step by step through the inverse Clarke transform and the inverse Park transform, and then the A, B, and C phase voltages are controlled through the SVPWM (Space Vector Pulse Width Modulation) technology. By taking the inverse transform of equations (3) and (6), the inverse Clarke transform can be obtained as equation (7), and the inverse Park transform can be obtained as equation (8). This is the end of the current loop modeling.

[0095]

[0096] S2: To determine the current loop input, the motor angle information θ obtained by the position sensor is used to obtain the motor angular velocity value ω by taking its derivative and comparing it with the given angular velocity ω. * By comparing and processing it through the PI algorithm, the input I of the current loop can be obtained. qThe further current loop input refers to the given value I * d ,I * q with I d ,I q The deviation after the difference is made. Propose to optimize the fractional order PI λ The algorithm improves the dynamic performance of the system compared with the traditional PI control. For the speed loop, the controlled object is the link including the current loop control and the PMSM motor. Its equivalent model is shown in equation (9), where K is specified as 1 to not affect the control system gain.

[0097]

[0098] The fractional-order controller C(s) is shown in equation (10), where K P , K I They refer to proportional gain and integral gain respectively, and λ is the fractional integral order.

[0099]

[0100] The parameters are adjusted by the frequency domain design method. Specifically, K is determined according to the phase margin criterion (11), the robustness criterion (12) and the amplitude criterion (13): P , K I , the value of λ.

[0101]

[0102] |G(jω c )|=|C(jω c )P(jω c )|=1#(13)

[0103] Traditional fractional PI λ The frequency range of the speed control algorithm is narrow. For higher cutoff frequencies, there may be no solution according to the above solution principle. Therefore, it is proposed to optimize the fractional-order PI λ The speed control algorithm is implemented by inserting the optimization correction link into the system as shown in equation (14). The overall open-loop transfer function of the system is shown in equation (15). The overall dynamic structure of the system is shown in Figure 3 shown.

[0104] G′(s)=1+τs#(14)

[0105] G(s)=G(s)×C'(s)×P(s)#(15)

[0106] Substituting the improved transfer function G(s) into the phase angle formula (11) yields formula (16).

[0107]

[0108] From formula (16), we can get K I The relationship between λ and is given by equation (17), where

[0109]

[0110] Substituting the improved transfer function G(s) into the robustness criterion formula (12) yields formula (18).

[0111]

[0112] From formula (18), we can get K I The relationship between λ and λ is as follows:

[0113]

[0114] From formula (19), the relationship between τ and B can be obtained as formula (20).

[0115]

[0116] From formula (20), we can see that by selecting an appropriate τ so that C ≥ 0, we can ensure that K I There is a solution, that is, we get equation (21).

[0117]

[0118] According to the amplitude criterion, substituting G(s), C(s), C'(s), and P(s) into equation (13) yields K P , K I The relationship between , λ, and τ is as shown in formula (22).

[0119]

[0120] Combining equations (17), (19), (20) and (22), we can solve K P , K I , λ, τ (the premise is to satisfy C ≥ 0). The modeling of the current-speed dual closed-loop control model of the permanent magnet synchronous motor is now complete.

[0121] The data transmission model building specifically includes the following steps:

[0122] S3: Complete the model configuration and select the interface hardware information to be used in the model settings, such as serial port baud rate, communication channel used, simulator configuration file, etc.

[0123] S4: The data transmission here involves data transmission between the host computer (1) and the DSP board (2) via UART. The transmission hardware is connected through a wired serial port, and the UART transmission is implemented by adding a serial port module to the model and then through the code generated by automatic code. At this point, the data transmission model is completed.

[0124] The code generation toolkit (1-2) refers to the functions implemented using the free support package based on MATLAB and Simulink software developed by Texas Instruments (TI) in cooperation with Mathworks.

[0125] The data map (1-3) refers to the mapping diagram of the storage addresses corresponding to each system variable, which specifies the memory address of each system variable. By using the data map, the memory address of the variable can be manually specified, so that Matlab can read the variable by reading the specified memory address to draw charts and apply algorithms. The Simulink oscilloscope (1-4) reads data and draws a waveform by accessing the address mapped by the data map. The data map can be used to access the internal variables of the Simulink model programmatically outside Simulink.

[0126] The DSP board (2) at least includes a power supply and reset module, a download circuit (2-1), a DSP controller (2-2), a level conditioning circuit (2-3), an ADC (2-4) and an interface module (including RS232, JTAG, DC3-16P bull horn socket, etc.). The specific model of the DSP controller is not unique, and it can be a DSP C2000 series, C6000 series or other series. Similarly, the form of the ADC (2-4) is not unique, and it can be an internal ADC of the DSP controller, or an external ADC, or any software or hardware solution that realizes analog-to-digital conversion. At the same time, the communication interface of the DSP board takes RS232 and DC3-16P as examples, and any other software or hardware solution that can realize the communication between the DSP board and the host computer and the signal processing board is within the protection scope of this patent. The download circuit (2-1) uses an emulator to download code through the JTAG interface. The level conditioning circuit (2-3) refers to a circuit that realizes the function of converting the output level of the encoder in the signal processing board into the digital input level of the DSP, such as 5V DC to 3.3V DC.

[0127] The signal processing board (3) includes a PWM output circuit (3-1), a power drive circuit (3-2), an encoder processing circuit (3-3), a current processing circuit (3-4), a power module and an interface circuit (such as DC3-16P, DB9, power terminals, etc.). The PWM output circuit (3-1) processes and amplifies the SVPWM signal output by the DSP, and outputs a PWM wave that can directly control the power drive circuit. The power drive circuit (3-2) is composed of power devices, controlled by the PWM wave, powered by 220V AC, and outputs a three-phase AC power drive permanent magnet synchronous motor to operate. The motor module (4) outputs an encoder signal and a two-phase current signal after differential sampling. The two signals are connected to the signal processing board through the DB9 port respectively. The encoder signal is decoded into A, B, Z, U, V, W and other signals through the encoder processing circuit (3-3) and output to the corresponding level conditioning circuit of the DSP board; the current signal is converted from a differential signal to a single-ended signal through the current processing circuit (3-4) and output to the analog-to-digital conversion module of the DSP board.

[0128] The motor module (4) at least comprises a rectifier drive circuit, an interface circuit and a protection circuit, a sensor circuit (including voltage and current detection of three-phase windings, etc.), a power module, an encoder module, a controlled motor body, and connections between the modules.

[0129] The power module is powered by a common 220V AC mains electricity, and outputs 5V DC and 3.3V DC power to supply the control circuit of the DSP board (2) and the signal processing board (3) through a protection circuit, a transformer, a voltage regulator module, a voltage conversion module and other circuits. The protected 220V AC power is output to the power drive circuit of the signal processing board through a protection circuit and an isolation transformer.

[0130] After the Simulink model is established, the algorithm and functions to be implemented by the model are automatically generated into DSP running code through the code generation function, and the code is automatically downloaded from the host computer to the DSP, and the DSP end automatically starts running the program. The algorithm performs dual closed-loop control of the current and speed of the permanent magnet synchronous motor according to the above principle. The calculated control signal is output to the signal processing board in the form of PWM wave. The signal processing board conditions the received PWM wave and outputs the PWM wave that can directly control the power device to the power drive circuit. The power drive circuit is controlled by the PWM wave to output three-phase AC power to drive the permanent magnet synchronous motor to move. At the same time, the motor module feeds back the various parameters of the motor operation from the encoder and sensor circuit in real time and sends them to the processing circuit of the signal processing board. The corresponding processing circuit decodes and converts the signal and then outputs it to the DSP board. The DSP board performs level matching conversion and analog-to-digital conversion on the corresponding signal for the DSP controller used, and then inputs the signal into the DSP controller. The DSP controller reads the required parameters in real time to complete the algorithm operation. At the same time, the DSP sends the relevant parameters to the specified address of the host computer through UART according to the provisions of the data map, and the Simulink oscilloscope of the host computer displays the relevant parameters by reading the content of the corresponding address. The Simulink model can adjust some parameters in real time, and the adjusted parameters are sent to the DSP controller through the simulator in real time to update the program content.

[0131] The steps to implement the automatic code generation method based on the motion control model are as follows:

[0132] 1: Since code generation needs to calculate the running time and frequency of each program based on the step size, the solver must first be set to a fixed-step discrete solver. The fixed step size is set according to actual needs. The end time of the simulation is set to infinite.

[0133] 2: After completing the hardware selection, select the board model in the Hardware Implementation tab of the model parameter settings. The model here is selected according to the DSP controller model. At the same time, according to the selected DSP controller model, import the target file (Target Configuration) of the corresponding model into the model.

[0134] 3: Complete the hardware peripheral configuration, and perform basic configuration of the peripheral resources to be used in the hardware implementation tab of the model parameter settings, such as setting the overall system clock frequency, the mode of a specific GPIO, the pins and baud rate of the SCI serial port channel, the frame structure of the serial port communication, etc. At the same time, set whether to automatically download and run the program after compilation. If it is the first generation, you can choose to compile only. After checking the C code automatically generated after compilation and confirming that it is correct, you can choose to compile and run to automatically download the code to the DSP.

[0135] 4: Configure the external mode. Set the channel used by the external mode in the hardware implementation tab of the model parameter settings. Select from the serial port, CAN, and XCP according to the actual situation and specify the serial port number connecting the upper computer and the lower computer to establish real-time external mode communication.

[0136] 5: Import custom code (optional). If it is necessary to import user-written code (such as initialization program, enable of some chips, etc.), you can import it into the model through the custom code function in the model settings. The automatic code generator will insert the user-defined code into the corresponding position of the program according to the rules.

[0137] 6: Compile the model and automatically generate code. Use the Build option to compile the model. The automatic code generator will compile and automatically generate C code based on the model and settings. See the schematic diagram of the automatic code generation process. Figure 4 The generated C code can be viewed through Code View, which provides the function of automatically jumping to and highlighting the related C code by clicking on the elements in the model, which is very helpful for debugging.

[0138] 7: Download and run the code. You can modify the Build function in the model configuration to compile, generate and automatically download the code to automatically download the generated C code to the DSP controller and run it. You can also use the Deploy function in the Hardware tab to automatically download and run the code.

[0139] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The above is only a specific implementation method of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or replacements that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A real-time motion control method based on code generation, characterized in that: include: S1. Acquiring sensor information and establishing a current loop model, wherein the sensors deployed in the motor module (4) include: a current sensor and a position sensor, the motor module (4) includes a permanent magnet synchronous motor, and the sensor information includes current information and position information; S2. Using the sensor information and the current loop model, establish a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor; S3, configuring interface hardware for the current-speed dual closed-loop motion control model, and automatically generating model running code; S4, downloading the generated model running code to the DSP board (2) for running; In S2, it includes: optimizing the fractional-order speed control algorithm to obtain an improved transfer function G(s), wherein G(s)=C(s)×C'(s)×P(s), C'(s) represents the optimization correction link inserted in series, C(s) represents the fractional-order controller, P(s) represents the equivalent model, C'(s)=1+τs, s refers to the integral link, τ represents the time constant, T represents the time constant; K P , K I are proportional gain and integral gain respectively, λ is the fractional integral order, K=1; Using the improved transfer function G(s), a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is established, including: Among them, B and C represent two intermediate parameters, ω c Indicates the cutoff frequency.

2. The method according to claim 1, characterized in that The control method is applied to a real-time motion control device based on code generation, the device comprising: a host computer (1), a DSP board (2), a signal processing board (3), a motor module (4) and a power supply module (5); In S3, the configured interface hardware includes: the host computer (1) is connected to the DSP board (2) via a UART serial data bus, and the host computer (1) also downloads program codes to the DSP via a JTAG interface; The DSP board (2) and the signal processing board (3) are connected by a signal line via a DC3-16P interface; The signal processing board (3) and the motor module (4) are connected via a DB9 interface using a signal line, and the signal processing board (3) is connected to the motor module (4) via a terminal wire via a wiring terminal.

3. The method according to claim 1, characterized in that: In S1, the current loop model is established, including: Reading three-phase current information and motor position information of the permanent magnet synchronous motor, and performing Clarke transformation and Park transformation respectively to obtain the current loop model; The three-phase current information is subjected to Clarke transformation, thereby transforming the three-phase current coordinates into two-phase current coordinates; and the motor position information is subjected to Park transformation, thereby obtaining the current in the rotor rotation direction.

4. The method according to claim 3, characterized in that The main calculation models in the current loop model include: Clarke transformation, Park transformation, inverse Clarke transformation and inverse Park transformation calculation models; The process of running the current loop model includes: subtracting the given value and the actual value of the D-axis and Q-axis current to obtain the control deviation, and then using the Clarke transformation matrix and the Park transformation matrix to perform inverse transformation processing respectively to obtain the inverse Clarke matrix and the inverse Park matrix, and restoring the control target to the three-phase current, thereby driving the motor to operate through SVPWM and the power drive circuit.

5. The method according to claim 4, characterized in that The process of performing Clarke transformation includes: Establish the A, B, C three-phase current I of the permanent magnet synchronous motor A ,I B ,I C The coordinates of the α and β phase currents I α ,I β The transformation relationship of the coordinates is: Then, according to the transformation relationship, the Clarke transformation matrix is ​​determined as: The process of performing Park transformation includes: obtaining the current in the rotor rotation direction of the permanent magnet synchronous motor through Park transformation, including the current I in the D-axis and Q-axis directions d ,I q , where the D axis is parallel to the rotor direction, the Q axis is perpendicular to the rotor direction, θ is the current rotation angle of the rotor, and Further establish the Park transformation matrix as 6. The method according to claim 2, characterized in that The host computer (1) runs MATLAB and establishes a Simulink model (1-1), and the established current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is imported into the Simulink model (1-1); The motion control algorithm of the motor module (4) is written in the host computer (1) by means of Simulink modeling, and after automatically generating codes, it is downloaded to the DSP board (2) for execution, and at the same time, the current-speed dual closed-loop motion control model in the host computer (1) enters a real-time operation state; After the host computer (1) and the DSP board (2) establish real-time communication, the model parameters of the current-speed dual closed-loop motion control model running in real time in the host computer (1) are adjusted, and the adjusted parameters are transmitted to the DSP board (2) in real time. After receiving the adjusted parameters, the DSP board (2) obtains the current operating data of the motor module (4) through the signal processing board (3), and feeds back to the host computer (1).

7. The method according to claim 2, characterized in that: In S4, it includes: After the Simulink model in the host computer (1) is established, the algorithm model and function to be run in the current-speed dual closed-loop motion control model are automatically generated into DSP running code through the code generation function, and the DSP running code is downloaded from the host computer (1) to the DSP board (2); After the DSP board (2) loads and runs the DSP running code, the calculated control signal is output to the signal processing board (3) in the form of a PWM wave; The signal processing board (3) processes the received PWM wave and outputs the PWM wave for directly controlling the power device to the power driving circuit of the motor module (4); The power drive circuit in the motor module (4) is controlled by the PWM wave and outputs three-phase alternating current to drive the permanent magnet synchronous motor to move; at the same time, the motor module (4) uses the motor operating parameters collected by the sensor as sensor information in real time, and feeds back the sensor information to the DSP board (2) through the signal processing board (3); The DSP board (2) inputs the feedback sensor information into the DSP controller, and the DSP controller reads the relevant parameters required by the current-speed dual closed-loop motion control model from the sensor information, and sends the relevant parameters to the designated address of the host computer (1) through UART according to the provisions of the data map. The Simulink oscilloscope of the host computer (1) displays the relevant parameters by reading the content of the designated address.

8. A real-time motion control device based on code generation, characterized in that: include: Host computer (1), DSP board (2), signal processing board (3), motor module (4) and power module (5); The host computer (1) runs MATLAB and establishes a Simulink model (1-1), and the established current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is imported into the Simulink model (1-1); The motion control algorithm of the motor module (4) is written in the host computer (1) by means of Simulink modeling, and after automatically generating codes, it is downloaded to the DSP board (2) for execution, and at the same time, the current-speed dual closed-loop motion control model in the host computer (1) enters a real-time operation state; After the host computer (1) and the DSP board (2) establish real-time communication, the model parameters of the current-speed dual closed-loop motion control model running in real time in the host computer (1) are adjusted, and the adjusted parameters are transmitted to the DSP board (2) in real time. After the DSP board (2) receives the adjusted parameters, it obtains the current operation data of the motor module (4) through the signal processing board (3) and feeds it back to the host computer (1); The host computer (1) is connected to the DSP board (2) via a UART serial data bus, and the host computer (1) also downloads program codes to the DSP via a JTAG interface; The DSP board (2) and the signal processing board (3) are connected by a signal line via a DC3-16P interface; The signal processing board (3) and the motor module (4) are connected with a signal line via a DB9 interface, and the signal processing board (3) is connected with the motor module (4) via a terminal wire via a wiring terminal; Wherein, a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is established, including: The fractional-order speed control algorithm is optimized to obtain the improved transfer function G(s), where G(s) = C(s) × C'(s) × P(s), C'(s) represents the optimization correction link, and C(s) represents the fractional-order controller. P(s) represents the equivalent model, C'(s)=1+τs, s refers to the integral link, τ represents the time constant, T represents the time constant; K P , K I are proportional gain and integral gain respectively, λ is the fractional integral order, K=1; Using the improved transfer function G(s), a current-speed dual closed-loop motion control model of the permanent magnet synchronous motor is established, including: Among them, B and C represent two intermediate parameters, ω c Indicates the cutoff frequency.

9. The device according to claim 8, characterized in that The DSP board (2) comprises: a power supply and reset module, a download circuit (2-1), a DSP controller (2-2), a level adjustment circuit (2-3), an ADC (2-4) and an interface module; the download circuit (2-1) uses an emulator to download codes via a JTAG interface; The signal processing board (3) comprises: a PWM output circuit (3-1), a power driving circuit (3-2), an encoder processing circuit (3-3), a current processing circuit (3-4), a power module and an interface circuit; The PWM output circuit (3-1) is used to process and amplify the SVPWM signal output by the DSP board (2); The power drive circuit (3-2) is composed of power devices, is controlled by PWM waves, and is powered by 220V AC. The power drive circuit (3-2) outputs three-phase AC power to drive the permanent magnet synchronous motor to operate; The motor module (4) outputs an encoder signal and a two-phase current signal after differential sampling. The two signals are connected to the signal processing board through the DB9 port respectively. The encoder signal is decoded by the encoder processing circuit (3-3) and output to the corresponding level conditioning circuit of the DSP board (2); The host computer (1) also includes: a code generation toolkit (1-2), a data map (1-3) and a Simulink oscilloscope (1-4); The data map (1-3) is used to record the mapping diagram of the corresponding storage addresses of each variable in the system; The Simulink oscilloscope (1-4) reads the data and plots it into a waveform graph by accessing the address mapped in the data map (1-3).

Citation Information

Patent Citations

  • Permanent magnet brushless DC motor driver control method

    CN106533303A

  • Permanent magnet synchronous motor servo driver based on double-core MCU (Micro-programmed Control Unit)

    CN106712596A

  • Simulation device for automatic control system of ship oil separator

    CN108806378A

  • Stepping motor control method, device and equipment and storage medium

    CN111049455A

  • Control method and system for current loop prediction of permanent magnet synchronous motor

    CN113726239A