A motor control method, apparatus, device, and storage medium
By acquiring the control correlation parameters of the motor and determining the PID controller parameters using an improved genetic algorithm, the technical problem of poor control accuracy and stability of motors with different structures was solved. Automatic parameter adjustment of the motor was realized, thereby improving the control accuracy and stability of the motor.
Patent Information
- Application Number
- CN202410103774.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2044-01-24
AI Technical Summary
In existing technologies, PID controllers using the same strategy struggle to achieve optimal control for motors with different internal structures, resulting in poor control accuracy and stability. Furthermore, the manual tuning of PID controller parameters in existing technologies leads to poor motor control accuracy and stability.
By acquiring the control correlation parameters of the target motor, the parameters of the PID controller are determined using an improved genetic algorithm. The control strategy is determined based on the transfer function of the target motor, and the PID control function is optimized. By using the control strategy determined based on the transfer function of the target motor and optimizing the PID controller parameters, automatic parameter adjustment of the motor is achieved.
The optimal control strategy for motors with different structures has been achieved, improving the control accuracy and stability of the motors.
Smart Images

Figure CN117914227B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor technology, and in particular to a motor control method, apparatus, device, and storage medium. Background Technology
[0002] Electric motors are widely used in aerospace, medical devices, and other fields. For example, in the medical surgical robot industry, they have become an indispensable part of the robotic arm control system. To ensure stable motor operation and improve motor control accuracy, the method of using a PID controller is widely adopted. The basic principle of a PID controller is to treat the error between the system's input and output as a variable, scale, integrate, and differentiate this variable, and sum the results as the new input to the system, thereby achieving the control of the DC motor.
[0003] For motors with different internal structures, the optimal PID controller structure also differs. Using the same PID controller strategy for all motors makes it difficult to achieve optimal control system performance. Therefore, adjusting the parameters of the PID controller is crucial to the performance of the control system. Traditional methods for determining control strategy parameters involve manually adjusting the PID parameters, which requires specialized knowledge and experience and is difficult to guarantee the optimal solution. Thus, determining the optimal parameters of the motor's PID controller is a pressing technical problem that needs to be solved to achieve precise motor control. Summary of the Invention
[0004] This invention provides a motor control method, apparatus, device, and storage medium to improve the control accuracy of motors.
[0005] According to one aspect of the present invention, a motor control method is provided, comprising:
[0006] Obtain the control-related parameters of the target motor;
[0007] The control correlation parameters are input into the PID controller to obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor;
[0008] The target control motor is controlled based on the output information.
[0009] Optionally, based on the above scheme, the determination of the PID controller includes:
[0010] Determine the transfer function of the target motor, and determine the control strategy based on the transfer function;
[0011] Determine the PID control function based on the control strategy, and determine the parameters to be optimized in the PID control function;
[0012] The target parameter value of the parameter to be optimized is determined based on the improved genetic algorithm, and a PID controller is obtained.
[0013] Optionally, based on the above scheme, the determination of the parameters to be optimized using the improved genetic algorithm includes:
[0014] The following operation is performed iteratively until the iteration termination condition is met, and the parameter value of the parameter to be optimized at the end of the iteration is taken as the target parameter value of the parameter to be optimized:
[0015] The target crossover and mutation parameters for each population are determined based on the population fitness of each population in the previous iteration. The target crossover and mutation parameters include the target crossover rate and / or the target mutation rate.
[0016] The various populations are processed according to the target crossover mutation parameters to obtain the parameter values of the parameters to be optimized in the current iteration;
[0017] The population fitness of each group in the current iteration is determined based on the parameter values of the parameters to be optimized in the current iteration.
[0018] Optionally, based on the above scheme, the iteration termination condition is that the number of iterations meets the set number of iterations and / or the population fitness of each population in the current iteration meets the set fitness threshold.
[0019] Optionally, based on the above scheme, determining the target crossover mutation parameter for each population according to the population fitness of each population in the previous iteration includes:
[0020] For each population, the target crossover mutation parameter of the population is determined based on the relationship between the population fitness and fitness feature value of the population in the previous iteration, wherein the fitness feature value is determined based on the population fitness of each population in the previous iteration.
[0021] Optionally, based on the above scheme, determining the target crossover mutation parameter of the population according to the relationship between the population fitness and fitness feature values of the population in the previous iteration includes:
[0022] When the fitness of the population in the previous iteration is greater than the fitness feature value, the largest crossover mutation parameter among the crossover mutation parameters of each population in the previous iteration is taken as the target crossover mutation parameter.
[0023] When the fitness of the population in the previous iteration is not greater than the fitness feature value, the target crossover mutation parameter is determined based on the largest and smallest crossover mutation parameters among the crossover mutation parameters of each population in the previous iteration and the iteration number of the current iteration.
[0024] Optionally, in addition to the above solutions, the following also applies:
[0025] The target motor is controlled based on the PID controller to obtain control evaluation parameters;
[0026] When the control evaluation parameters do not meet the set parameter requirements, the control strategy is adjusted;
[0027] The adjusted PID controller is determined based on the adjusted control strategy.
[0028] According to another aspect of the present invention, a motor control device is provided, comprising:
[0029] The control association parameter acquisition module is used to acquire the control association parameters of the target controlled motor;
[0030] The PID controller processing module is used to input the control-related parameters into the PID controller and obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor;
[0031] The target control motor control module is used to control the target control motor based on the output information.
[0032] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0033] At least one processor; and
[0034] A memory communicatively connected to the at least one processor; wherein,
[0035] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the motor control method according to any embodiment of the present invention.
[0036] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the motor control method according to any embodiment of the present invention.
[0037] The technical solution of this invention involves acquiring control-related parameters of the target controlled motor; inputting these parameters into a PID controller to obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor; and controlling the target controlled motor based on the output information. This solves the technical problem of poor motor control accuracy and stability caused by manually tuning the PID controller. It achieves automatic determination of PID controller parameters based on the target controlled motor, enabling control of motors with different structures using their optimal control strategies, thus improving the control accuracy and stability of the motor.
[0038] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart illustrating a motor control method provided in Embodiment 1 of the present invention;
[0041] Figure 2 This is a flowchart illustrating a motor control method provided in Embodiment 2 of the present invention;
[0042] Figure 3a This is a flowchart illustrating a PID controller determination method provided in Embodiment 3 of the present invention;
[0043] Figure 3b This is a schematic diagram of the structure of a DC motor provided in Embodiment 3 of the present invention;
[0044] Figure 3c This is a schematic diagram of a control strategy for a DC motor provided in Embodiment 3 of the present invention;
[0045] Figure 3d This is a schematic diagram illustrating the determination of a PID controller according to Embodiment 3 of the present invention;
[0046] Figure 4 This is a schematic diagram of the structure of a motor control device provided in Embodiment 4 of the present invention;
[0047] Figure 5This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Detailed Implementation
[0048] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. 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 should fall within the scope of protection of the present invention.
[0049] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0050] Example 1
[0051] Figure 1 This is a flowchart illustrating a motor control method according to Embodiment 1 of the present invention. This embodiment is applicable to situations where a motor is being controlled. The method can be executed by a motor control device, which can be implemented in hardware and / or software, such as by being configured in an electronic device. Figure 1 As shown, the method includes:
[0052] S110, Obtain the control-related parameters of the target motor.
[0053] In this embodiment, the target control motor can be understood as the motor that needs to be controlled, and can be determined based on the application scenario. For example, if the motor of a surgical robot needs to be controlled, then the target control motor is the motor of the surgical robot. It should be noted that in this embodiment, the type of motor for the target control motor is not limited; the target control motor can be a DC motor or an AC motor. That is, this embodiment can achieve precise control of both DC and AC motors.
[0054] The control correlation parameters for the target controlled motor are the parameters used when controlling the target controlled motor with a PID controller. The basic principle of a PID controller is to treat the error between the system's input and output as a variable, scale, integrate, and differentiate this variable, and then sum them as the new input to the system, thereby achieving the control of the DC motor. Based on this, the control correlation parameters for the target controlled motor can be the error between the motor's input and output.
[0055] S120. Input the control correlation parameters into the PID controller to obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor.
[0056] The control-related parameters are used as input variables for the PID controller, which processes these input variables to obtain output information. Specifically, the PID controller processes the input variables based on the PID control function, performing scaling, integration, and / or differentiation operations. The specific methods for processing the input variables based on the PID control function can be found in existing PID controller processing methods and will not be elaborated further.
[0057] In this embodiment, the technical problem of the PID controller being affected by subjective factors due to manual tuning, which affects the control accuracy, is avoided. The control strategy is determined in advance based on the transfer function of the target motor, and the PID control function of the PID controller is determined based on the control strategy. Then, the parameters in the PID control function are determined, so that the optimal control strategy can be determined for motors with different structures, and then the optimal PID control function can be determined for control.
[0058] The parameters in the PID control function can be determined using existing optimization algorithms, or they can be determined based on improved optimization algorithms; no limitation is made here. Optionally, the optimization algorithm can be a genetic algorithm.
[0059] S130, Control the target motor based on the output information.
[0060] After obtaining the output information of the PID controller based on the control association parameters, the target motor is controlled based on the output information. For example, the output information is used as the input of the target motor to control the target motor to execute the corresponding instruction operation.
[0061] This invention addresses the problem of poor motor control accuracy and stability caused by manually tuning the PID controller. It achieves automatic determination of PID controller parameters based on the target motor, enabling control of motors with different structures using optimal control strategies, thus improving motor control accuracy and stability. The invention also addresses the issue of obtaining control-related parameters for the target motor by acquiring control-related parameters of the target motor; inputting these parameters into a PID controller to obtain the PID controller's output information, whereby the PID controller is determined based on the transfer function of the target motor; and controlling the target motor based on the output information.
[0062] Example 2
[0063] Figure 2 This is a flowchart illustrating a motor control method according to Embodiment 2 of the present invention. This embodiment further optimizes the determination of the PID controller based on the above embodiments. For example... Figure 2 As shown, the method includes:
[0064] S210. Determine the transfer function of the target control motor, and determine the control strategy based on the transfer function.
[0065] Commonly used PID control strategies can be divided into PI control, PD control, and PID control. For DC motors with different internal structures, the optimal PID controller structure also differs. If the same PID controller strategy is used for all motors, it is difficult to obtain optimal control performance. Therefore, the specific control strategy needs to be determined based on the characteristics of the object under study. Based on this, in this embodiment, the optimal control strategy is determined by the motor structure of the target motor. However, it is difficult to form accurate classification rules for motor structures, while the transfer function of the target motor can characterize its structure to a certain extent. Therefore, the transfer function of the target motor can be determined first, and then the control strategy can be determined based on the functional form of the transfer function.
[0066] In one embodiment of the present invention, the corresponding control strategy can be determined based on the order of the transfer function. A pre-constructed correspondence between first-order and second-order transfer functions and the control strategy can be established. Based on this pre-constructed correspondence and the transfer function, the control strategy for the target motor can be determined. For example, when the transfer function is second-order, a PID control strategy can be used; when the transfer function is first-order, a PI control strategy or a PD control strategy can be used.
[0067] The transfer function of the target controlled motor can be determined based on existing transfer function generation methods, and is not restricted here. In one implementation, taking a DC motor as an example, a DC motor typically consists of an electrical network system and a mechanical motion system. The electrical network balance equation of the target controlled motor can be constructed based on the structural characteristics of its electrical network system, and the mechanical balance equation can be constructed based on its mechanical structural characteristics. The transfer function of the target controlled motor can then be obtained based on the electrical network balance equation and the mechanical balance equation.
[0068] S220. Determine the PID control function based on the control strategy, and determine the parameters to be optimized in the PID control function.
[0069] It is understandable that different control strategies correspond to different PID control functions. The corresponding PID control function can be determined based on a given control strategy, and the control parameters in the PID control function can be used as the function to be optimized.
[0070] When the control strategy for the target motor is PID control, the corresponding PID control function can be: Where e(t) is the deviation between the input and output quantities, and k p k i k d If k is a control parameter, then p k i k d These are the parameters to be optimized.
[0071] When the control strategy for the target motor is PI control, its corresponding PID control function can be: Where e(t) is the deviation between the input and output quantities, and k p k i If k is a control parameter, then p k i These are the parameters to be optimized.
[0072] When the control strategy for the target motor is PD control, its corresponding PID control function can be: Where e(t) is the deviation between the input and output quantities, and k p k d If k is a control parameter, then p k d These are the parameters to be optimized.
[0073] S230. Based on the improved genetic algorithm, the target parameter value of the parameter to be optimized is determined, and the PID controller is obtained.
[0074] The adjustment of parameters in the PID control function is crucial for motor control. Genetic algorithms, a series of search algorithms inspired by natural evolutionary theory, mimic the processes of natural selection and reproduction. They can provide high-quality solutions to various problems involving search, optimization, and learning. Furthermore, resembling natural evolution, they can overcome some obstacles encountered by traditional search and optimization algorithms, especially for problems with a large number of parameters and complex mathematical representations. In this embodiment, an improved genetic algorithm is used to determine the target parameter values for the parameters to be optimized. These target parameter values are then fed into the PID control function to obtain the PID controller, making the determination of the target parameter values more accurate.
[0075] In general, the individual individuals in the algorithm can represent the parameters to be optimized, and the optimal solution can be iteratively sought to obtain the target parameter value. This embodiment employs an improved genetic algorithm, using genetic individuals to represent the parameters to be optimized, establishing a corresponding fitness function to characterize the genetic superiority of the population, and selecting genes based on the population fitness to eliminate inferior genes and retain superior ones. Simultaneously, to ensure the globality and diversity of search results and avoid getting trapped in local optima, crossover and mutation are performed on genes in addition to gene selection, ensuring that individuals containing different genes are always generated. This guarantees that the population can escape from local optima in a timely manner, improving the reliability of the algorithm.
[0076] In one embodiment of the present invention, the parameters to be optimized are determined based on an improved genetic algorithm, including:
[0077] The following operation is performed iteratively until the iteration termination condition is met. The value of the parameter to be optimized at the end of the iteration is taken as the target parameter value:
[0078] The target crossover and mutation parameters for each population are determined based on the population fitness of each population in the previous iteration. The target crossover and mutation parameters include the target crossover rate and / or the target mutation rate.
[0079] The various populations are processed according to the target crossover mutation parameters to obtain the parameter values of the parameters to be optimized in the current iteration;
[0080] The population fitness of each group in the current iteration is determined based on the parameter values of the parameters to be optimized in the current iteration.
[0081] Before iteration, the improved genetic algorithm can be initialized. Specifically, the genetic algorithm is used to initially encode the basic three and four, and the population size, iteration number, population dimension, mutation rate and crossover rate of the improved genetic algorithm are set. The steady-state error of the target controlled motor is set as the fitness function, and the fitness function is used as the basis for judging the quality of the parameter optimization results.
[0082] After initialization, the parameters to be optimized are used as individuals in the genetic algorithm population for iteration. During each iteration, the parameter value of the current iteration's parameter to be optimized is substituted into the PID control function to obtain the steady-state error of the target motor under the control of the PID control function. The steady-state error is used as the population fitness. Based on whether the population fitness meets the iteration termination condition, if the iteration termination condition is met, the parameter value of the current iteration's parameter to be optimized is used as the target parameter value. If the iteration termination condition is not met, the crossover rate and mutation rate are determined based on the current iteration's population fitness. Based on the determined crossover rate and mutation rate, the next iteration is executed, and the population genes are selected for crossover and mutation. The above operation is repeated until the iteration termination condition is met, and the parameter value of the parameter to be optimized at the end of the iteration is used as the target parameter value.
[0083] In the aforementioned execution process, gene crossover and mutation are extremely important. Appropriate gene crossover and mutation can not only improve the global search speed for the optimal solution but also prevent the algorithm from getting trapped in local optima. In traditional genetic algorithms, the mutation rate and crossover rate are fixed values. However, in the early stages of genetic iteration, a higher crossover rate and a lower mutation rate help improve the genes of individuals with poor fitness, effectively increasing the algorithm's convergence speed. In the middle stages of genetic iteration, a higher mutation rate helps the algorithm improve its local search ability and escape local optima. In the later stages of genetic iteration, for individuals with strong fitness, a lower crossover rate and mutation rate help preserve individual genes. Based on this, this embodiment of the invention improves the genetic algorithm by using an adaptive crossover rate and mutation rate, adjusting the determination of the crossover rate and mutation rate according to the population fitness to improve the algorithm's performance.
[0084] Optionally, the iteration termination condition is that the number of iterations meets a set number of iterations and / or the population fitness of each group in the current iteration meets a set fitness threshold. The number of iterations can be set; when the number of iterations meets the set number of iterations, the iteration termination condition is determined to be met, and the parameter value of the current iteration is used as the target parameter value. Alternatively, a fitness threshold can be set; when the population fitness of the current iteration meets the set threshold, the iteration termination condition is determined to be met, and the parameter value of the current iteration is used as the target parameter value.
[0085] In some embodiments, determining the target crossover mutation parameter for each population based on the population fitness of each population in the previous iteration includes:
[0086] For each population, the target crossover mutation parameter is determined based on the relationship between the population fitness and fitness feature value of the population in the previous iteration, wherein the fitness feature value is determined based on the population fitness of each population in the previous iteration.
[0087] For the current iteration round, fitness feature values can be determined based on the population fitness of each population in the previous iteration round. These fitness feature values are then used as thresholds. The population fitness of each population in the current iteration round is compared with these thresholds, and the crossover rate and mutation rate of each population are updated based on the relationship between the population fitness and the threshold. For example, assume all populations include population a1, population a2, ..., population a... m The current iteration round is the nth round (n is an integer greater than 1), with any group a d Taking (1 < d < m) as an example, obtain the population fitness p1 of population a1 in the previous iteration (n-1th round), the population fitness p2 of population a2 in the previous iteration, ..., the population fitness p1 of population a1 in the previous iteration. m In the previous iteration, the population fitness p m Then calculate p1, p2, ..., p m Eigenvalues (fitness eigenvalues) p feature , will p feature As a threshold, population a d The population fitness p in the (n-1)th round of the previous iteration d With threshold p feature Compare based on population fitness p d and threshold p feature The comparison results determine population a d Target crossover rate, population a d The target mutation rate can also be determined in the same way described above.
[0088] The fitness feature values can be the mean, median, variance, etc. of the population fitness of various populations in the previous iteration round, and are not limited here.
[0089] Based on the above scheme, the target crossover mutation parameters of the population are determined according to the relationship between the population fitness and fitness eigenvalues of the population in the previous iteration, including:
[0090] When the fitness of the population in the previous iteration is greater than the fitness feature value, the largest crossover mutation parameter among the crossover mutation parameters of each population in the previous iteration is taken as the target crossover mutation parameter.
[0091] When the fitness of the population in the previous iteration is not greater than the fitness feature value, the target crossover mutation parameter is determined based on the largest and smallest crossover mutation parameters among the crossover mutation parameters of each population in the previous iteration and the iteration number of the current iteration.
[0092] In this embodiment, the crossover rate and mutation rate are improved. Optionally, the improved crossover rate is:
[0093]
[0094] In the formula, F is the population fitness, Fchar is the fitness feature value of each population in the previous iteration; n is the current genetic iteration number; nmax is the total number of genetic iterations, pc is the crossover rate in the current iteration, pcmax is the maximum crossover rate of each population in the previous iteration, and pcmin is the minimum crossover rate of each population in the previous iteration.
[0095] The improved mutation rate is:
[0096]
[0097] In the formula, F is the population fitness, Fchar is the fitness characteristic value of each population in the previous iteration; n is the current genetic iteration number; nmax is the total number of genetic iterations, pm is the mutation rate of the current iteration, pmmax is the maximum mutation rate of each population in the previous iteration, and pmmin is the minimum mutation rate of each population in the previous iteration.
[0098] Based on the improved genetic algorithm described above, a set of optimal control parameters under the control strategy of the target motor can be obtained. Substituting these parameters into the PID control function yields the optimal PID controller for the target motor.
[0099] Based on the above scheme, it also includes: controlling the target motor based on a PID controller to obtain control evaluation parameters;
[0100] When the control evaluation parameters do not meet the set parameter requirements, the control strategy should be adjusted.
[0101] The adjusted PID controller is determined based on the adjusted control strategy.
[0102] Due to the optimization of the improved genetic algorithm, the PID controller has a good ability to control steady-state error under the target parameter value. In order to obtain the optimal PID controller, the obtained PID controller can be evaluated to obtain control evaluation parameters. When the control evaluation parameters meet the set parameter requirements, the PID controller is determined to be the optimal controller and is used to control the target motor. When the control evaluation parameters do not meet the set parameter requirements, the PID controller is determined to be not the optimal controller, and the control strategy of the target motor can be adjusted. Based on the adjusted control strategy, the PID control parameters and the parameters to be optimized are re-determined, and the target parameter value of the parameters to be optimized is re-determined using the improved genetic algorithm to obtain the adjusted PID controller. The adjusted PID controller is then re-evaluated until the control evaluation parameters of the PID controller meet the set parameter requirements. The PID controller that meets the set parameter requirements is used as the PID controller for the target motor.
[0103] Parameter thresholds can be set. When the relationship between the control evaluation parameter and the parameter threshold satisfies the set parameter threshold, the control evaluation parameter is determined to meet the set parameter requirements; otherwise, the control evaluation parameter is determined to not meet the set parameter requirements.
[0104] Adjusting the control strategy can involve changing it to another strategy than the current one. For example, if the current PID controller's control strategy is PID control, it can be adjusted to PI or PD control; similarly, if the current PID controller's control strategy is PD control, it can be adjusted to either PID or PI control. After adjusting the control strategy, the corresponding PID control function is adjusted. The PID control functions for each control strategy can be found in the above embodiments and will not be repeated here.
[0105] Optionally, the control evaluation parameters can be transient performance indicators of the system. For example, control evaluation parameters can be one or more of the following: rise time, peak time, maximum overshoot, settling time, and number of oscillations, as long as they can achieve the performance evaluation of the system. Taking maximum overshoot as an example, if the maximum overshoot is greater than the set overshoot threshold, the control evaluation parameter is determined to not meet the set parameter requirements; if the maximum overshoot is not greater than the set overshoot threshold, the control evaluation parameter is determined to meet the set parameter requirements. Similarly, if the control evaluation parameters are time parameters such as rise time, peak time, or settling time, if the corresponding time parameter is less than the set time threshold, the control evaluation parameter is determined to meet the set parameter requirements; if the rise time is not less than the set time threshold, the control evaluation parameter is determined to not meet the set parameter requirements. Likewise, if the control evaluation parameter is the number of oscillations, if the number of oscillations is less than the set number threshold, the control evaluation parameter is determined to meet the set parameter requirements; if the number of oscillations is not less than the set number threshold, the control evaluation parameter is determined to not meet the set parameter requirements.
[0106] When there is only one control evaluation parameter, the PID controller can be determined as the optimal controller as long as the parameter meets the set requirements. When there are multiple control evaluation parameters, it can be set that the PID controller can be determined as the optimal controller only when all parameters meet the set requirements, or a threshold number of parameters can be set. When the parameters above the threshold number meet the set requirements, the PID controller can be determined as the optimal controller. There are no restrictions here, and it can be set according to actual needs.
[0107] By evaluating and adjusting the PID controller, the determined PID controller can achieve precise control of the system.
[0108] S240, Obtain the control association parameters of the target controlled motor.
[0109] S250. Input the control-related parameters into the PID controller to obtain the output information of the PID controller.
[0110] S260, Control the target motor based on the output information.
[0111] This invention, through the determination of the transfer function of the target controlled motor, determines the control strategy based on the transfer function; determines the PID control function based on the control strategy, and determines the parameters to be optimized in the PID control function; and determines the target parameter values of the parameters to be optimized based on an improved genetic algorithm, thereby obtaining the PID controller. This achieves automatic determination of the PID controller parameters based on the target controlled motor, enabling the determination of the optimal PID controller for motors with different structures, thus improving the control accuracy and stability of the motor.
[0112] Example 3
[0113] Figure 3a This is a flowchart illustrating a PID controller determination method according to Embodiment 3 of the present invention. Based on the above embodiments, this embodiment uses a DC motor as an example to exemplify the determination of the PID controller. Figure 3a As shown, this embodiment includes:
[0114] S310. Establish the DC motor transfer function.
[0115] Based on the characteristics of the internal structure of a DC motor, corresponding current equations and motion equations are constructed from the electrical network system and the mechanical motion system, respectively. These equations are then combined, and intermediate variables are discarded to derive the differential equations of voltage and motor speed. Further Laplace transform is then performed to obtain the transfer function of the DC motor. Generally, the transfer function of a DC motor is related to the motor's internal parameters; different internal parameters will result in different orders of transfer functions.
[0116] Specifically, Figure 3b This is a schematic diagram of the structure of a DC motor provided in Embodiment 3 of the present invention; according to Figure 3b Based on the structural characteristics of DC motors, the electrical network balance equations of the shown motor structure can be expressed as follows: In the formula, I a R is the armature current of the motor. a L is the resistance of the electric motor. a E is the inductance of the motor. a The induced electromotive force of the armature winding can be expressed as: E a =K e ω, where K e ω is the electromotive force constant, determined by the structural parameters of the motor, and ω is the angular velocity of the motor.
[0117] Based on the mechanical structure characteristics of a DC motor, the mechanical balance equation can be obtained as follows: In the formula, J a M is the moment of inertia of the motor rotor. a M is the electromagnetic torque of the electric motor. L M is the resistance torque, under no-load conditions. L =0.
[0118] Meanwhile, the torque balance equation can be expressed as: M n =K c I n In the formula, K c It is the electromagnetic torque constant, determined by the structural parameters of the motor.
[0119] Combining the above four equations and eliminating intermediate variables, we obtain the input-output differential equation:
[0120]
[0121] This can be further expressed as:
[0122]
[0123] Setting the initial conditions to zero, and performing a Laplace transform on both sides, the transfer function is obtained as follows:
[0124]
[0125] In the formula, T is the time constant, K is the system gain, and ξ is the damping ratio.
[0126] S320, Initialize the PID control strategy.
[0127] Based on the characteristics of the DC motor transfer function, an initial PID control strategy and corresponding parameters to be optimized are set. The specific control strategy selected varies depending on the order of the DC motor transfer function. For a second-order system, the controller generally adopts a PID control strategy. In practice, since the inductance of the DC motor is small, it can be considered zero, thus transforming the DC motor transfer function into a first-order system. In this case, PI control and PD control can be considered.
[0128] S330. Determine the target parameter value of the parameter to be optimized based on the improved genetic algorithm.
[0129] Figure 3c This is a schematic diagram of a control strategy for a DC motor provided in Embodiment 3 of the present invention, as shown below. Figure 3cAs shown, in the control of a DC motor, the control parameters to be optimized are determined through a PID control strategy, and the parameter values of the control parameters to be optimized are determined through an improved genetic algorithm, thus obtaining the optimal PID controller. Overall, the parameters to be optimized are first extracted from the PID control function corresponding to the PID controller in the S320, and then encoded using a genetic algorithm, with the population size and iteration number set. The steady-state error between the input and output signals is chosen as the fitness function.
[0130] F = x or (t)-x o (t)(t→∞)
[0131] In the formula, x or (t) represents the desired output of the DC motor, x o (t) represents the actual output of the DC motor. For this fitness function, the smaller the fitness function value of the population, the stronger the population's adaptability in the genetic algorithm, and the more likely its genes are to be preserved.
[0132] In this embodiment of the invention, taking PID control as an example, the parameter k to be optimized by the PID controller is... p k i k d As individuals in the genetic algorithm population, the algorithm is first initialized and improved, and then iteratively applied. Specifically, the entire genetic iteration process of the algorithm is as follows:
[0133] (1) Initialize the population size and number of iterations for the genetic algorithm;
[0134] (2) Calculate population fitness;
[0135] (3) Update the crossover rate and mutation rate in gene screening based on the fitness value;
[0136] (4) Select, cross over, and mutate the population genes based on the new crossover rate and mutation rate;
[0137] (5) Determine whether the fitness meets the threshold. If it does, the iteration ends. If it does not, jump to step (2) to continue the iteration.
[0138] After obtaining the target parameter value of the parameter to be optimized based on the above iteration, the target parameter value is substituted into the PID control function to obtain the PID controller.
[0139] S340. Determine the optimal PID controller.
[0140] Figure 3d This is a schematic diagram illustrating the determination of a PID controller according to Embodiment 3 of the present invention, as shown below. Figure 3dAs shown, after determining the PID controller, it is evaluated according to the transient performance requirements of the control system to verify the optimization results of the improved genetic algorithm on the parameters. Specifically, based on the optimization results of the improved genetic algorithm, a set of optimal control parameters (target parameter values) under this control strategy is obtained. These parameters are then substituted into the PID controller to control the DC motor, and appropriate transient performance indicators are selected to verify the control system, ensuring its excellent performance.
[0141] If the transient system performance results are analyzed and the expected system performance requirements are met, the corresponding PID control strategy and control parameters are directly output and applied in practice. If the expected system performance requirements are not met, the PID control strategy of the DC motor is changed, the DC motor is controlled by the new control strategy, and the parameters of the corresponding control strategy are optimized using a genetic algorithm to obtain the corresponding optimal parameters. Then, the system performance is verified again until the requirements are met.
[0142] Optionally, the maximum overshoot M can be utilized. p As an indicator for judging system performance, its formula can be expressed as:
[0143]
[0144] In the formula: t p The time taken for the system to reach its first output peak.
[0145] The technical solution provided by this invention constructs a transfer function based on the structure of a DC motor to determine a control strategy, thereby enabling the acquisition of the optimal control strategy for DC motors with different structures. An improved genetic algorithm is used to determine the target parameter value of the parameter to be optimized, and the PID controller is evaluated, making the determination of the PID controller more accurate, thus enabling precise control of the DC motor.
[0146] Example 4
[0147] Figure 4 This is a schematic diagram of the structure of a motor control device provided in Embodiment 4 of the present invention. Figure 4 As shown, the device includes:
[0148] The control association parameter acquisition module 410 is used to acquire the control association parameters of the target controlled motor.
[0149] The PID controller processing module 420 is used to input control-related parameters into the PID controller and obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor;
[0150] The target control motor control module 430 is used to control the target control motor based on the output information.
[0151] In this embodiment of the invention, the control correlation parameters of the target controlled motor are obtained by the control correlation parameter acquisition module 410; the PID controller processing module 420 inputs the control correlation parameters into the PID controller to obtain the output information of the PID controller, wherein the PID controller is determined based on the transfer function of the target controlled motor; and the target controlled motor control module 430 controls the target controlled motor based on the output information. This solves the technical problem of poor motor control accuracy and stability caused by manually tuning the PID controller, and achieves automatic determination of the PID controller parameters based on the target controlled motor. This allows for the control of motors with different structures using their optimal control strategies, improving the control accuracy and stability of the motor.
[0152] Optionally, based on the above scheme, the device further includes a PID controller determination module, comprising:
[0153] The control strategy determination unit is used to determine the transfer function of the target control motor and determine the control strategy based on the transfer function.
[0154] The parameter determination unit is used to determine the PID control function based on the control strategy and to determine the parameters to be optimized in the PID control function.
[0155] The target parameter value determination unit is used to determine the target parameter values of the parameters to be optimized based on an improved genetic algorithm, thereby obtaining a PID controller.
[0156] Optionally, based on the above scheme, the target parameter value determination unit is specifically used for:
[0157] The following operation is performed iteratively until the iteration termination condition is met. The value of the parameter to be optimized at the end of the iteration is taken as the target parameter value:
[0158] The target crossover and mutation parameters for each population are determined based on the population fitness of each population in the previous iteration. The target crossover and mutation parameters include the target crossover rate and / or the target mutation rate.
[0159] The population is processed according to the target crossover and mutation parameters to obtain the parameter values of the parameters to be optimized in the current iteration;
[0160] The population fitness for the current iteration is determined based on the parameter values of the parameters to be optimized in the current iteration.
[0161] Optionally, based on the above scheme, the iteration termination condition is that the number of iterations meets the set number of iterations and / or the fitness of the population in the current iteration meets the set fitness threshold.
[0162] Optionally, based on the above scheme, the target parameter value determination unit is specifically used for:
[0163] For each population, the target crossover mutation parameter is determined based on the relationship between the population fitness of the previous iteration and the fitness feature values of each population, wherein the fitness feature values are determined based on the population fitness of each population in the previous iteration.
[0164] Optionally, based on the above scheme, the target parameter value determination unit is specifically used for:
[0165] When the fitness of the population in the previous iteration is greater than the mean fitness, the crossover mutation parameter with the largest value among the crossover mutation parameters of each iteration is taken as the target crossover mutation parameter.
[0166] When the fitness of the population in the previous iteration is not greater than the mean fitness, the target crossover parameter is determined based on the largest and smallest crossover parameter among the crossover parameters of each iteration and the number of iterations in the current iteration.
[0167] Optionally, based on the above scheme, the device further includes a PID controller evaluation module, used for:
[0168] The target motor is controlled using a PID controller to obtain control evaluation parameters;
[0169] When the control evaluation parameters do not meet the set parameter requirements, the control strategy should be adjusted.
[0170] The adjusted PID controller is determined based on the adjusted control strategy.
[0171] The motor control device provided in the embodiments of the present invention can execute the motor control method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.
[0172] Example 5
[0173] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers, as well as various motor-controlled devices, such as robots. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0174] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0175] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0176] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as motor control methods.
[0177] In some embodiments, the motor control method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the motor control method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the motor control method by any other suitable means (e.g., by means of firmware).
[0178] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0179] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0180] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0181] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0182] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0183] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0184] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0185] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method of controlling an electric machine, characterized by, The method comprises the following steps: obtaining a control-related parameter of a target control motor; inputting the control-related parameter into a PID controller to obtain output information of the PID controller, wherein the PID controller is determined based on a transfer function of the target control motor; controlling the target control motor based on the output information; wherein the determination of the PID controller comprises: determining the transfer function of the target control motor, and determining a control strategy according to the transfer function; determining a PID control function according to the control strategy, and determining a to-be-optimized parameter in the PID control function; determining a target parameter value of the to-be-optimized parameter based on an improved genetic algorithm to obtain a PID controller; wherein the determination of the to-be-optimized parameter based on the improved genetic algorithm comprises: iteratively performing the following operations until an iteration end condition is met, and taking a parameter value of the to-be-optimized parameter at the end of the iteration as the target parameter value of the to-be-optimized parameter: determining a target crossover and mutation parameter of each population according to a population fitness of each population of the last iteration, the target crossover and mutation parameter comprising a target crossover rate and / or a target mutation rate; processing each population according to the target crossover and mutation parameter to obtain a parameter value of the to-be-optimized parameter in the current iteration; determining a population fitness of each population in the current iteration according to the parameter value of the to-be-optimized parameter in the current iteration.
2. The method of claim 1, wherein, The iteration end condition is that the number of iterations meets a set number of iterations and / or the population fitness of each population in the current iteration meets a set fitness threshold.
3. The method of claim 1, wherein, The determination of the target crossover and mutation parameter of each population according to the population fitness of each population of the last iteration comprises: for each population, determining the target crossover and mutation parameter of the population according to a relationship between the population fitness of the population of the last iteration and a fitness characteristic value, wherein the fitness characteristic value is determined according to the population fitness of each population of the last iteration.
4. The method of claim 3, wherein, The determination of the target crossover and mutation parameter of each population according to the relationship between the population fitness of the population of the last iteration and the fitness characteristic value comprises: when the population fitness of the last iteration is greater than the fitness characteristic value, taking the largest crossover and mutation parameter of each population of the last iteration as the target crossover and mutation parameter; when the population fitness of the last iteration is not greater than the fitness characteristic value, determining the target crossover and mutation parameter according to the largest crossover and mutation parameter, the smallest crossover and mutation parameter of each population of the last iteration, and the number of iterations in the current iteration.
5. The method of claim 1, wherein, The method further comprises the following steps: controlling the target control motor based on the PID controller to obtain a control evaluation parameter; when the control evaluation parameter does not meet a set parameter requirement, adjusting a control strategy; determining an adjusted PID controller according to the adjusted control strategy.
6. An electric motor control device characterized by comprising: The method comprises the following steps: a control-related parameter acquisition module for acquiring a control-related parameter of a target control motor; a PID controller processing module for inputting the control-related parameter into a PID controller to obtain output information of the PID controller, wherein the PID controller is determined based on a transfer function of the target control motor; The target control motor control module is configured to control the target control motor based on the output information. The device further comprises a PID controller determination module, which comprises: a control strategy determination unit configured to determine a transfer function of the target control motor and determine a control strategy based on the transfer function; a to-be-optimized parameter determination unit configured to determine a PID control function based on the control strategy and determine to-be-optimized parameters in the PID control function; a target parameter value determination unit configured to determine target parameter values of the to-be-optimized parameters based on an improved genetic algorithm and obtain a PID controller; The target parameter value determination unit is specifically configured to: iteratively perform the following operations until an iteration end condition is met, and use a parameter value of the to-be-optimized parameter obtained after the iteration as the target parameter value of the to-be-optimized parameter: determine target crossover and mutation parameters of each population according to population fitness of a previous iteration, wherein the target crossover and mutation parameters comprise a target crossover rate and / or a target mutation rate; process the populations according to the target crossover and mutation parameters to obtain a parameter value of the to-be-optimized parameter in a current iteration; determine population fitness of the current iteration according to the parameter value of the to-be-optimized parameter in the current iteration.
7. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the motor control method in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to execute the motor control method in any one of claims 1-5 when executed. The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to execute the motor control method in any one of claims 1-5 when executed.
Citation Information
Patent Citations
Motor driver PID parameter self-tuning method based on improved particle swarm optimization
CN114844403A
PID control parameter setting method and system based on improved genetic algorithm
CN115202191A