Method and device for controlling an electric machine
By using parameter identification and the LQR algorithm to calculate the optimal control law for the motor, the problem of manual parameter adjustment in motor control is solved, thus improving control effect and performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AUBO (BEIJING) ROBOTICS TECH CO LTD
- Filing Date
- 2022-07-22
- Publication Date
- 2026-07-14
AI Technical Summary
Existing motor control methods require manual parameter adjustment, and there is room for improvement in control performance.
By establishing a transfer function model of the motor current loop through parameter identification, and using the LQR algorithm to calculate the optimal control law, the optimal control law of the motor can be obtained directly without manual parameter tuning.
It enables motor control without manual parameter adjustment, improving control effectiveness and performance.
Smart Images

Figure CN117478000B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor technology, specifically to a motor control method and a motor control device. Background Technology
[0002] Currently, the mainstream motor control method is based on PID (Proportion Integration Differential) three-loop control. FOC (Field Oriented Control) is also commonly used for vector voltage control. In addition, there are hysteresis control, fractional PID, adaptive PID, and PID with feedforward, among other three-loop control methods.
[0003] However, PID-based three-loop control requires manual parameter tuning, cannot apply arbitrary parameters to any motor, and still has significant room for performance improvement. Summary of the Invention
[0004] To address the problem of requiring manual parameter adjustment in related technologies, this invention proposes the following technical solution.
[0005] A first aspect of the present invention provides a method for controlling a motor, comprising: determining the parameters of the motor and establishing a transfer function model of the motor current loop based on the parameters; obtaining a discrete state-space model of the motor current loop based on the transfer function model; calculating the optimal control law of the motor in the discrete state space using the LQR (linear quadratic regulator) algorithm; and controlling the motor according to the optimal control law.
[0006] In addition, the motor control method according to the above embodiments of the present invention may also have the following additional technical features.
[0007] According to one embodiment of the present invention, determining the parameters of the motor includes: performing parameter identification on the motor to obtain the parameters of the motor.
[0008] According to an embodiment of the present invention, the transfer function model is as follows:
[0009]
[0010] Among them, T V K is the equivalent time constant of the inverter. V R is the voltage output proportional coefficient of the inverter, L is the inductance of the motor, and R is the voltage output proportional coefficient of the inverter. S The resistance of the motor is given.
[0011] According to an embodiment of the present invention, obtaining a discrete state-space model of the motor current loop based on the transfer function model includes: discretizing the transfer function model to obtain a discrete transfer function model; and converting the discrete transfer function model into a discrete state-space model.
[0012] According to one embodiment of the present invention, discretizing the transfer function model includes: discretizing the transfer function model using a zero-order hold.
[0013] According to an embodiment of the present invention, the discrete transfer function model is as follows:
[0014]
[0015] The discrete state-space model is as follows:
[0016] x t+1 =Ax t +Bu t
[0017]
[0018]
[0019] Where, x t+1 For {x t The current state variable at time t+1 in}, x t For {x t The current state variable at time t in {x} t Let u be the time series of the system's output current. t For {u t The voltage control quantity at time t in}, {u t Let} be the time series of voltage control quantity, A and B be coefficient matrices, c be an element in matrix A, and d be an element in matrix B.
[0020] According to one embodiment of the present invention, the optimal control law of the motor is calculated in the discrete state space using the LQR algorithm, including: establishing the following cost function:
[0021]
[0022] Where J is the cost function, x is the actual output current, and x d Let u be the desired output current and u be the input voltage. T Let Q be the transpose of u, Q be the state weight matrix of the LQR algorithm, and R be the control weight matrix of the LQR algorithm. d ) T Indicates (xx) dThe transpose of the cost function is obtained; the Riccati equation is constructed based on the cost function; the Riccati equation is solved by dynamic programming to obtain the optimal control law of the motor corresponding to the minimum value of the cost function.
[0023] According to one embodiment of the present invention, the Riccati equation is:
[0024] P ss =Q+A T P ss AA T P ss B(R+B T P ss B) -1 B T P ss A
[0025] q ss =(A+BK) ss ) T q ss -Qx d
[0026] K ss =-(R+B) T P ss B) -1 B T P ss A
[0027] Among them, A T Let B be the transpose of matrix A. T Let P be the transpose of matrix B. SS q SS K SS The solution to the Riccati equation is: The optimal control law is:
[0028] u t =k1(cx t +du t-1 )+k2x d
[0029]
[0030]
[0031] g t =-(R+B) T P ss B) -1 B T q ss
[0032] Among them, u t-1For {u t In the context of the optimal control law, k1 and k2 are the voltage control quantities at time t-1, and g is the voltage control quantity at time t-1. t This is an intermediate quantity.
[0033] According to one embodiment of the present invention, before controlling the motor according to the optimal control law, the method further includes: optimizing the optimal control law to obtain an optimized optimal control law; wherein, optimizing the optimal control law includes: controlling the motor to perform a step response in the current loop, and using the constant of the optimal control law as the independent variable, iterating according to the following formula to perform maximum gradient descent on the cost function until the final iterative value of the constant of the optimal control law is obtained:
[0034]
[0035]
[0036] Where, k 1,t+1 Let k1 be the value at time t+1, and k 2,t+1 Let k2 be the value at time t+1, and k 1,t Let k1 be the value at time t, and k 2,t Let k2 be the value at time t, and α be the learning rate;
[0037] The optimized optimal control law is as follows:
[0038] u t =k 1,ss (cx t +du t-1 )+k 2,ss x d
[0039] Where, k 1,ss Let k1 be the final iteration value, and k be the final iteration value. 2,ss This is the final iteration value of k2.
[0040] A second aspect of the present invention provides a motor control device, comprising: an establishment module for determining the parameters of the motor and establishing a transfer function model of the motor current loop based on the parameters; a determination module for obtaining a discrete state space model number of the motor current loop based on the transfer function model; a calculation module for calculating the optimal control law of the motor in the discrete state space using the LQR algorithm; and a control module for controlling the motor according to the optimal control law.
[0041] The technical solution of this invention, based on the transfer function model of the motor current loop, obtains the optimal control law of the motor through the LQR algorithm. It can control the motor without the need for manual parameter tuning and can achieve better control effect and better control performance. Attached Figure Description
[0042] Figure 1 This is a flowchart of a motor control method according to an embodiment of the present invention.
[0043] Figure 2 This is a block diagram of a motor control device according to an embodiment of the present invention. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] Figure 1 This is a flowchart of a motor control method according to an embodiment of the present invention.
[0046] like Figure 1 As shown, the control method of the motor includes the following steps S1 to S4.
[0047] S1. Determine the parameters of the motor and establish the transfer function model of the motor current loop based on the parameters.
[0048] Specifically, by working together with a host computer and a servo computer, the parameters of the motor can be identified, thereby obtaining parameters such as the motor's resistance, inductance, and flux linkage. Based on these parameters, the following state equations for the motor current loop can be established:
[0049]
[0050] Where p is the differential operator, i d i q R represents the current along the d-axis and q-axis. s L is the resistance of the motor. d L q P represents the inductance along the d-axis and q-axis. n ω is the number of pole pairs of the motor. r Let i be the mechanical angular velocity of the motor. d i q These represent the voltages along the d-axis and q-axis.
[0051] Based on this state equation and the control object of the motor current loop, a transfer function model of the motor current loop can be established.
[0052] The motor in this embodiment of the invention may be a permanent magnet synchronous motor.
[0053] S2, the discrete state-space model of the motor current loop is obtained based on the transfer function model.
[0054] Specifically, the discrete state-space model of the motor current loop can be obtained by sequentially discretizing and transforming the transfer function model.
[0055] S3 calculates the optimal control law of the motor in the discrete state space using the LQR algorithm.
[0056] The optimal control law can be understood as the voltage control law of a motor that can achieve the goal of the current loop (i.e., make the actual output current of the motor follow the desired output current as quickly as possible with the smallest possible voltage control quantity).
[0057] Specifically, a cost function can be established, and the optimal control law can be calculated in the discrete state space using a discrete-time LQR (linear quadratic regulator) under the given cost function, so as to obtain the optimal control law of the motor, such as the relationship between the actual output current of the motor at a certain moment and the voltage control quantity at that moment.
[0058] S4 controls the motor according to the optimal control law.
[0059] As described above, this embodiment of the invention, after establishing the post-transfer function model, transforms it into a discrete state-space model, then calculates the optimal control law for the motor using the LQR algorithm, and finally controls the motor according to the optimal control law. This allows for the deriving of the optimal control law in a functional sense. Compared to PID-based three-loop control, it eliminates the need for manual parameter tuning and achieves better control performance.
[0060] The motor control method of this invention can obtain the optimal control law of the motor through the LQR algorithm based on the transfer function model of the motor current loop. It can achieve motor control without manual parameter tuning and can achieve better control effect and better control performance.
[0061] In one embodiment of the present invention, determining the parameters of the motor may include: performing parameter identification on the motor to obtain the parameters of the motor, which may include the inductance and resistance of the motor.
[0062] In one embodiment of the present invention, the transfer function model is as follows:
[0063]
[0064] Among them, T VK is the equivalent time constant of the inverter. V This is the voltage output proportional coefficient of the inverter, L is the inductance of the motor, and R is the voltage output proportional coefficient. S The resistance of the motor.
[0065] Specifically, the motor current loop control objects include the first-order inertial element of the motor (e.g., a permanent magnet synchronous motor) and the first-order inertial element of the inverter. When using i d =0 vector control method, when ignoring the influence of back EMF and ignoring the delay of current feedback loop, assuming the feedback proportional coefficient is 1, the controlled object of current loop can be simplified to the series connection of two first-order inertial loops in formula (2).
[0066] In this transfer function model, T V K can be defined in the program. V It is only related to the design of the control circuit. Therefore, the inductance and resistance of the motor can be obtained by using the parameter identification method, and the transfer function model in formula (2) can be established.
[0067] In one embodiment of the present invention, obtaining a discrete state-space model of the motor current loop based on the transfer function model may include: discretizing the transfer function model to obtain a discrete transfer function model; and converting the discrete transfer function model into a discrete state-space model.
[0068] Furthermore, discretizing the transfer function model can include discretizing the transfer function model using a zero-order hold.
[0069] The discrete transfer function model is as follows:
[0070]
[0071] Specifically, the zero-order hold method can be used to discretize the transfer function model, resulting in the discrete transfer function model in equation (3). Assume:
[0072]
[0073] The discrete transfer function model can be further transformed into the following discrete state-space model:
[0074] x t+1 =Ax t +Bu t (5)
[0075] Where, x t+1 For {x t The current state variable at time t+1 in}, x t For {x t The current state variable at time t in {x} tLet u be the time series of the system's output current. t For {u t The voltage control quantity at time t in}, {u t} represents the time series of voltage control quantities. A and B are coefficient matrices, c is an element in matrix A, and d is an element in matrix B.
[0076] Then, the optimal control law of the motor is calculated in the discrete state space using the LQR algorithm.
[0077] In one example of the present invention, calculating the optimal control law of the motor in the discrete state space using the LQR algorithm may include: establishing the following cost function:
[0078]
[0079] Where J is the cost function, x is the actual output current, and x d Let u be the desired output current and u be the input voltage. T Let Q be the transpose of u, Q be the state weight matrix of the LQR algorithm, and R be the control weight matrix of the LQR algorithm. d ) T Indicates (xx) d The transpose of the cost function is obtained; the Riccati equation is constructed based on the cost function; the Riccati equation is solved by dynamic programming to obtain the optimal control law of the motor when the cost function is minimized.
[0080] Furthermore, the Riccati equation is:
[0081] P ss =Q+A T P ss AA T P ss B(R+B T P ss B) -1 B T P ss A
[0082] q ss =(A+BK) ss ) T q ss -Qx d
[0083] K ss =-(R+B) T P ss B) -1 B T P ss A
[0084] Among them, A T Let B be the transpose of matrix A. T Let P be the transpose of matrix B. SS q SS K SS This is a solution to the Riccati equation.
[0085] Specifically, the cost function shows that the control objective is to make the actual output current x follow the desired output current x as quickly as possible while keeping the input voltage u as small as possible. d This aligns with the motor current loop control objective. Next, the discrete-time LQR problem can be solved using dynamic programming, specifically by solving the Riccati equations. The resulting optimal control law is:
[0086]
[0087] Among them, g t =-(R+B) T P ss B) -1 B T q ss g t This is an intermediate quantity.
[0088] Will Substituting the above optimal control law (7), the optimal control law can be simplified into the following form, which is easier to program:
[0089] u t =k1(cx t +du t-1 )+k2x d (8)
[0090]
[0091]
[0092] Among them, u t-1 For {u t In the equation, k1 and k2 are the voltage control quantities at time t-1, where k1 and k2 are constants of the optimal control law.
[0093] After obtaining two constants k1 and k2, the actual output current x of the motor at the current time t is... t The actual voltage u at the previous moment t-1 and the expected output current x d Given the given information, the voltage control quantity u at the current time t can be obtained according to the optimal control law (8). t Using this voltage control quantity to control the motor provides better control performance.
[0094] It should be noted that due to the influence of noise in the real environment, the actual solved control law will deviate slightly from the optimal control law. Therefore, optimization methods can be used to further optimize the optimal control law.
[0095] In one embodiment of the present invention, before controlling the motor according to the optimal control law, the method further includes: optimizing the optimal control law to obtain an optimized optimal control law.
[0096] Furthermore, optimizing the optimal control law may include: controlling the motor to perform a step response in the current loop, and using the constant of the optimal control law as the independent variable, iterating according to the following formula to perform maximum gradient descent on the cost function until the final iterative value of the constant of the optimal control law is obtained:
[0097]
[0098]
[0099] Where, k 1,t+1 Let k1 be the value at time t+1, and k 2,t+1 Let k2 be the value at time t+1, and k 1,t Let k1 be the value at time t, and k 2,t Let k2 be the value at time t, and α be the learning rate, which is usually set to 0.001.
[0100] The optimized optimal control law is:
[0101] u t =k 1,ss (cx t +du t-1 )+k 2,ss x d (11)
[0102] Where, k 1,ss Let k1 be the final iteration value, and k be the final iteration value. 2,ss This is the final iteration value of k2.
[0103] Specifically, the host computer sends control parameters k1 and k2 to the server, which then performs on-machine verification. During verification, the host computer and server work together to perform maximum gradient descent on the control parameters k1 and k2, further optimizing the control law's performance on the actual machine.
[0104] In actual operation, the motor is controlled to perform a step response experiment of the current loop. At the same time, k1 and k2 are used as independent variables to perform maximum gradient descent on the cost function over a period of time, that is, to iterate according to formula (11). After the iteration is completed, the final iteration result of k1 and k2 is recorded as k 1,ss ,k 2,ssThus, the optimized optimal control law is obtained.
[0105] Then, by controlling the motor according to the optimized optimal control law, better control results can be achieved.
[0106] In summary, the embodiments of the present invention, based on parameter identification and discrete-time LQR algorithm, can derive the optimal control law in a functional sense. Compared with PID-based three-loop control, it does not require manual parameter tuning and can achieve better control effect and better control performance.
[0107] Corresponding to the motor control method in the above embodiments, the present invention also proposes a motor control device.
[0108] Figure 2 This is a block diagram of a motor control device according to an embodiment of the present invention.
[0109] like Figure 2 As shown, the control device for the motor includes: a setup module 10, a determination module 20, a calculation module 30, and a control module 40.
[0110] The module 10 is used to determine the parameters of the motor and establish a transfer function model of the motor current loop based on the parameters; the module 20 is used to obtain the number of discrete state space models of the motor current loop based on the transfer function model; the module 30 is used to calculate the optimal control law of the motor in the discrete state space using the LQR algorithm; and the module 40 is used to control the motor according to the optimal control law.
[0111] It should be noted that the specific implementation method and implementation principle of the motor control device can be found in the specific implementation method of the motor control method described above. To avoid redundancy, they will not be described in detail here.
[0112] The motor control device of this invention obtains the optimal control law of the motor through the LQR algorithm based on the transfer function model of the motor current loop. It can control the motor without manual parameter tuning and achieve better control effect and performance.
[0113] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. "A plurality of" means two or more, unless otherwise explicitly specified.
[0114] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0115] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0116] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0117] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments. Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0118] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for controlling an electric motor, characterized in that, include: Determine the parameters of the motor, and establish a transfer function model of the motor current loop based on the parameters; The discrete state-space model of the motor current loop is obtained based on the transfer function model. The optimal control law for the motor is calculated in the discrete state space using the LQR algorithm. The motor is controlled according to the optimal control law. The transfer function model is as follows: Among them, T V K is the equivalent time constant of the inverter. V R is the voltage output proportional coefficient of the inverter, L is the inductance of the motor, and R is the voltage output proportional coefficient of the inverter. S Let be the resistance of the motor. Obtaining the discrete state-space model of the motor current loop based on the transfer function model includes: discretizing the transfer function model to obtain a discrete transfer function model; and converting the discrete transfer function model into a discrete state-space model. The discrete transfer function model is as follows: The discrete state-space model is as follows: Where, x t+1 For {x t The current state variable at time t+1 in}, x t For {x t The current state variable at time t in {x} t Let u be the time series of the system's output current. t For {u t The voltage control quantity at time t in}, {u t Let} be the time series of the voltage control quantity, A and B be coefficient matrices, c be an element of matrix A, and d be an element of matrix B. The optimal control law for the motor is calculated in the discrete state space using the LQR algorithm, including: Establish the following cost function: Where J is the cost function, x is the actual output current, and x d Let u be the desired output current and u be the input voltage. Let be the transpose of u, Q be the state weight matrix of the LQR algorithm, and R be the control weight matrix of the LQR algorithm. express The transpose of the matrix; Construct the Riccati equation based on the cost function; The Riccati equation is solved using dynamic programming to obtain the optimal control law for the motor that minimizes the cost function. The optimal control law is: Among them, u t-1 For {u t In the context of the optimal control law, k1 and k2 are the voltage control quantities at time t-1, and g is the voltage control quantity at time t-1. t P is an intermediate quantity. SS q SS K SS is the solution to the Riccati equation.
2. The motor control method according to claim 1, characterized in that, Determining the parameters of the motor includes: The parameters of the motor are identified.
3. The motor control method according to claim 1, characterized in that, Discretizing the transfer function model includes: The transfer function model is discretized using a zero-order hold.
4. The motor control method according to claim 3, characterized in that, The Riccati equation is: in, Let A be the transpose of matrix A. Let be the transpose of matrix B.
5. The motor control method according to claim 4, characterized in that, Before controlling the motor according to the optimal control law, the method further includes: The optimal control law is then optimized to obtain an optimized optimal control law. Optimizing the optimal control law includes: The motor is controlled to perform a step response in the current loop, and the constant of the optimal control law is used as the independent variable. The following formula is used to iterate the cost function using maximum gradient descent until the final iterative value of the constant of the optimal control law is obtained: in, Let k1 be the value at time t+1. Let k2 be the value at time t+1. Let k1 be the value at time t. Let k2 be the value at time t. The learning rate; The optimized optimal control law is as follows: in, This is the final iteration value of k1. This is the final iteration value of k2.
6. A motor control device for implementing the motor control method according to any one of claims 1-5, characterized in that, include: A module is established to determine the parameters of the motor and to establish a transfer function model of the motor current loop based on the parameters; The determination module is used to obtain the number of discrete state-space models of the motor current loop based on the transfer function model; The calculation module is used to calculate the optimal control law of the motor in the discrete state space using the LQR algorithm; The control module is used to control the motor according to the optimal control law.