Servo motor control method and device based on PID (Proportion Integration Differentiation) and neural network
By combining neural network, fuzzy control and PID algorithm in the servo motor control system, PID parameters are optimized in real time, and the problem of low control accuracy based on PID algorithm in complex nonlinear systems and variable environments is solved, achieving higher control accuracy and adaptability.
Patent Information
- Application Number
- CN202510435123.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, based on PID algorithm, in a complex nonlinear system of servo motor and a variable working environment, parameter adjustment is difficult, resulting in low control accuracy.
By obtaining the system error of the servo motor in real time, using the target neural network to predict the proportional coefficients, integral coefficients and differential coefficients of the PID algorithm, and fuzzing the prediction results through the fuzzy controller. Finally, the set operating parameters of the servo motor are updated through the PID algorithm to achieve real-time optimization.
The PID algorithm's processing capability for nonlinear systems is improved, the control accuracy and adaptability are enhanced, and the violent fluctuations caused by insufficient model training or burst noise are avoided.
Smart Images

Figure CN120215253A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servo motor control, and in particular, to a servo motor control method, device, computer-readable storage medium, and servo motor control system based on PID and neural network. Background Art
[0002] With the improvement of industrial automation, the control technology of servo motors has become increasingly important. The PID (Proportional-Integral-Derivative) control algorithm is a traditional control method widely used in servo motor control. It achieves precise control of errors by adjusting three parameters: proportional (P), integral (I), and derivative (D).
[0003] However, since traditional PID control is very sensitive to parameter adjustment, it is difficult to achieve satisfactory control effects in some systems with strong nonlinearity, time-variation, and uncertainty. Specifically, due to the requirement of high-precision control of servo motors, and the fact that servo motors are complex nonlinear systems with relatively variable working conditions, there are large errors in traditional PID control due to fixed coefficients. Adjusting parameters according to system changes is difficult to ensure that the parameters change in real time following the working conditions, resulting in little improvement in control performance.
[0004] In summary, in the prior art, when the PID algorithm is applied to the field of servo motor control, there are problems of low accuracy and poor adaptability, and it is difficult to meet the high-precision control requirements of servo motors. Summary of the Invention
[0005] The main purpose of this application is to provide a servo motor control method, device, computer-readable storage medium, and servo motor control system based on PID and neural network, so as to at least solve the problem that in the prior art, in a complex nonlinear system and a variable working environment of a servo motor, parameter adjustment is difficult, resulting in low control accuracy.
[0006] To achieve the above object, according to one aspect of the present application, there is provided a servo motor control method based on PID and neural network, including: obtaining the system error of the servo motor in real time to obtain the first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; predicting the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data through the target neural network to obtain the second target data, and the target neural network is trained according to the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error; performing fuzzy processing on the second target data through a fuzzy controller to obtain the third target data, where the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing; updating the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain the fourth target data, and controlling the operation of the servo motor according to the fourth target data.
[0007] Optionally, before predicting the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data through the BP neural network to obtain the second target data, the method further includes: constructing an alternative neural network based on the BP neural network, and inputting the historical system error into the alternative neural network to obtain the fifth target data; calculating the performance index of the BP neural network according to the fifth target data and the preset adjustment amount: where E(k) is the performance index, Y * (t) is the fifth target data, and Y(t) is the preset adjustment amount; in the case where the performance index is less than or equal to the first threshold, determining the alternative neural network as the target neural network, and in the case where the performance index is greater than the first threshold, updating the alternative neural network according to error backpropagation until the performance index of the alternative neural network is less than or equal to the first threshold.
[0008] Optionally, constructing an alternative neural network based on the BP neural network includes: constructing the input layer of the alternative neural network: where is the output of the input layer, j is the layer number of the input layer, x(1), x(2), x(3) are the model inputs of the current iteration, the system input of the previous iteration, and the system inputs of the previous two iterations; constructing the hidden layer of the alternative neural network: where is the weighted coefficient of the output of the input layer j in the hidden layer i, is the intermediate value of the hidden layer, is the output of the hidden layer, and f is the first activation function; constructing the output layer of the alternative neural network; where is the weighted coefficient of the output of the hidden layer i in the output layer l, is the intermediate value of the output layer, is the output of the hidden layer, and g is the second activation function.
[0009] Optionally, updating the alternative neural network according to error backpropagation includes: updating the weighting coefficients of the output layer according to error backpropagation: where δ is the sensitivity of the weighting coefficient update, η is the learning efficiency, and α is the inertia coefficient. Optionally, performing fuzzy processing on the second target data through a fuzzy controller to obtain third target data, including: obtaining the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm at the current moment to obtain sixth target data; calculating the prediction deviation amount and prediction deviation change rate according to the sixth target data and the third target data; calculating the target membership degree through a preset membership function according to the prediction deviation amount and prediction deviation change rate, and the membership function includes triangular and Gaussian types; calculating the fuzzy output of the proportional coefficient, integral coefficient, and differential coefficient through a preset fuzzy rule according to the target membership degree, and the preset fuzzy rule is used to describe the fuzzy logical relationship between the prediction deviation amount and prediction deviation change rate and the proportional coefficient, integral coefficient, and differential coefficient; performing defuzzification operation on the fuzzy output to obtain the third target data, and the methods of defuzzification operation include the centroid method, area method, and maximum membership degree method.
[0010] Optionally, before controlling the operation of the servo motor according to the fourth target data, the method further includes: constructing a servo motor mathematical model based on the servo motor: where u d and u q are the voltage components in the d-q rotating coordinate system, i d and i q are the current components in the d-q rotating coordinate system, R is the stator resistance, is the magnetic flux generated by the permanent magnet, w is the angular frequency of the d-q rotating coordinate system, i a and i β are the current components of the three-phase current measured in the stationary three-phase coordinate system and converted to the stationary two-phase coordinate system, L d and L q are the inductance components in the d-q rotating coordinate system, and are the magnetic flux components in the d-q rotating coordinate system, T e is the electromagnetic torque, p n is the number of pole pairs.
[0011] Optionally, controlling the operation of the servo motor according to the fourth target data includes: controlling the operation of the servo motor according to the fourth target data and the servo motor mathematical model through the SVPWM method.
[0012] According to another aspect of the present application, a servo motor control device based on PID and neural network is provided. The device includes: a first acquisition unit, configured to acquire the system error of the servo motor in real time to obtain first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; a first calculation unit, configured to predict the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data through a target neural network to obtain second target data, where the target neural network is trained according to historical system errors and a preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to historical system errors; a second calculation unit, configured to perform fuzzy processing on the second target data through a fuzzy controller to obtain third target data, where the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing; a control unit, configured to update the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain fourth target data, and control the operation of the servo motor according to the fourth target data.
[0013] According to still another aspect of the present application, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored program, wherein when the program runs, it controls the device where the computer-readable storage medium is located to execute any one of the methods.
[0014] According to yet another aspect of the present application, a servo motor control system is provided, including: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for any one of the above.
[0015] Applying the technical solution of the present application, in the above servo motor control method based on PID and neural network, first, the system error of the servo motor is obtained in real time to obtain the first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; then, the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm are predicted by the target neural network according to the first target data to obtain the second target data, and the target neural network is trained according to the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error; then, the second target data is subjected to fuzzy processing by the fuzzy controller to obtain the third target data, and the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing; finally, the set operating parameters of the servo motor are updated by the PID algorithm according to the third target data to obtain the fourth target data, and the servo motor is controlled to operate according to the fourth target data. Based on the problem that the traditional PID control method has poor control accuracy for the nonlinear system under the complex working conditions of the servo motor, the present application proposes to learn the mapping relationship between the system error of the servo motor and the PID parameters through the neural network, and based on the mapping of the input-output relationship of the neural network, the PID parameters are adjusted based on the real-time system error of the servo motor, introducing the neural network to improve the processing ability of the PID algorithm for the nonlinear system. At the same time, for the output of the neural network, the present application proposes to further perform fuzzy processing through the fuzzy control algorithm to ensure that the output result is smooth and stable, and avoid violent fluctuations caused by insufficient model training or sudden noise. By combining the neural network, fuzzy control, and PID algorithm, the real-time optimization of the PID algorithm is realized based on the real-time changing error of the servo motor, and the problem that the existing PID-based control algorithm has difficulty in parameter adjustment and low control accuracy in the complex nonlinear system and changing working environment of the servo motor is solved. Description of the Drawings
[0016] Figure 1 The hardware structure block diagram of a mobile terminal showing a servo motor control method based on PID and neural network provided in an embodiment of the present application is shown;
[0017] Figure 2 The flowchart showing a servo motor control method based on PID and neural network provided in an embodiment of the present application is shown;
[0018] Figure 3 The structural schematic diagram of a target neural network provided in an embodiment of the present application is shown;
[0019] Figure 4 The structural block diagram of a servo motor control device based on PID and neural network provided in an embodiment of the present application is shown.
[0020] Among them, the above-mentioned drawings include the following reference numerals:
[0021] 102, processor; 104, memory; 106, transmission device; 108, input / output device. Detailed implementation manners
[0022] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so as to implement the embodiments of the present application described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these process, method, product or device.
[0025] As introduced in the background art, in the prior art, when the PID algorithm is applied to the servo motor control field, there are problems of low accuracy and poor adaptability, and it is difficult to meet the high-precision control requirements of the servo motor. To solve the problem that in the prior art, in a complex non-linear system and a changing working environment of the servo motor based on the PID algorithm, parameter adjustment is difficult, resulting in low control accuracy, the embodiments of the present application provide a servo motor control method, device, computer-readable storage medium, and servo motor control system based on PID and neural network.
[0026] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention.
[0027] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1It is a hardware block diagram of a mobile terminal for a servo motor control method based on PID and neural network according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in Figure 1 ) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Among them, the above mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown in Figure 1 is only schematic and does not limit the structure of the above mobile terminal. For example, the mobile terminal may further include more or fewer components than
[0028] shown in
[0029] or have a different configuration from
[0028] shown.
[0028] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the servo motor control method based on PID and neural network in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely provided with respect to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the above networks include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.
[0029] In this embodiment, a servo motor control method based on PID and neural network running on a mobile terminal, a computer terminal, or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from here.
[0030] Figure 2 is a flowchart of a servo motor control method based on PID and neural network according to an embodiment of the present application. As Figure 2 shown, the method includes the following steps:
[0031] Step S201, obtain the system error of the servo motor in real time to obtain the first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor;
[0032] Specifically, the PID algorithm is a feedback-based control algorithm, that is, by performing proportional, integral, and differential operations on the error (the above system error, which is the difference between the set value and the actual value of the servo motor in this application), the control quantity is obtained to adjust the output of the system.
[0033] It can be understood that proportional control is used to adjust the control quantity proportionally according to the size of the error to achieve a fast response to the system error, but there may be a steady-state error. Integral control integrates the error to eliminate the steady-state error, but due to the increase in computational complexity, the response may become slower. Differential control controls the rate of change of the error to improve the stability and response speed of the system.
[0034] Step S202, predict the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data through the target neural network to obtain the second target data. The target neural network is trained according to the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error;
[0035] Specifically, in this application, it is set to determine the parameters of the PID algorithm with the best adjustment effect based on the system error (the first target data) through the trained target neural network above to achieve precise control. Specifically, by learning the input data to adjust the connection weights between neurons, the mapping from the system error to the parameters of the PID algorithm is realized.
[0036] It can be understood that by optimizing the performance of the neural network through training data, the processing ability of the neural network for the non-linear system of the servo motor can be improved to avoid the problem of poor effect of PID on non-linear systems.
[0037] Step S203, perform fuzzy processing on the second target data through a fuzzy controller to obtain the third target data, where the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing;
[0038] Specifically, since neural networks rely on a large amount of optimization of training data and consume a large amount of computing resources during operation, they have relatively high requirements for the quality of training data. For the servo motor system, there is a situation where insufficient training leads to unstable data. Therefore, in this application, the output result of the neural network (the above-mentioned second target data) is fuzzified, and the complex system is controlled through uncertain and fuzzy information to eliminate the drastic fluctuations caused by noise and other reasons in the model.
[0039] Step S204: Update the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain the fourth target data, and control the operation of the servo motor according to the fourth target data.
[0040] In a specific implementation, the formula of the above PID algorithm is set as follows in this application:
[0041] u(k) - u(k - 1) = k p [e(k) - e(k - 1)] + k i e(k) + k d [e(k) - 2e(k - 1) + e(k - 2)];
[0042] where u(k) is the above-mentioned set operating parameter at time k, e(k) is the system error at time k, and k p , k i , k d are the above-mentioned proportional coefficient, integral coefficient, and differential coefficient.
[0043] Specifically, control can be performed by substituting the corrected above-mentioned proportional coefficient, integral coefficient, and differential coefficient into the above PID algorithm.
[0044] Through this embodiment, first, the system error of the servo motor is obtained in real time to obtain the first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; then, according to the first target data, the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm are predicted by the target neural network to obtain the second target data. The target neural network is trained based on the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error; then, the second target data is fuzzified by the fuzzy controller to obtain the third target data, where the third target data is the fuzzified proportional coefficient, integral coefficient, and differential coefficient; finally, the set operating parameters of the servo motor are updated by the PID algorithm according to the third target data to obtain the fourth target data, and the servo motor is controlled to operate according to the fourth target data. Based on the problem that the traditional PID control method has poor control accuracy for the nonlinear system under the complex working conditions of the servo motor, this application proposes to learn the mapping relationship between the system error of the servo motor and the PID parameters through the neural network, and based on the mapping of the input-output relationship of the neural network, the PID parameters are adjusted based on the real-time system error of the servo motor. The neural network is introduced to improve the processing ability of the PID algorithm for the nonlinear system. At the same time, for the output of the neural network, this application proposes to further perform fuzzy processing through the fuzzy control algorithm to ensure that the output result is smooth and stable, and avoid violent fluctuations caused by insufficient model training or sudden noise. By combining the neural network, fuzzy control, and PID algorithm, the real-time optimization of the PID algorithm is realized based on the real-time change error of the servo motor, and the problem that the parameter adjustment of the existing PID-based control algorithm is difficult and the control accuracy is low in the complex nonlinear system and changing working environment of the servo motor is solved.
[0045] In an optional implementation manner, to ensure that the performance of the model meets the usage requirements, before predicting the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data by the BP neural network to obtain the second target data, the above method further includes:
[0046] Step S301, constructing an alternative neural network based on the BP neural network, and inputting the historical system error into the alternative neural network to obtain the fifth target data;
[0047] Specifically, the alternative neural network is defined based on the structure of the BP neural network, and the input data (the above historical system error) in the pre-prepared training set is used, and then the PID parameters are predicted through the alternative neural network to obtain the above fifth target data.
[0048] Step S302, calculating the performance index of the BP neural network according to the fifth target data and the preset adjustment amount:
[0049]
[0050] Among them, E(k) is the performance index, Y * (t) is the fifth target data, and Y(t) is the preset adjustment amount;
[0051] Specifically, the above formula is the definition of the model performance index function. The performance index of the model is quantified according to the above formula to evaluate whether the model meets the preset usage requirements.
[0052] Step S303: When the performance index is less than or equal to the first threshold, determine the alternative neural network as the target neural network; when the performance index is greater than the first threshold, update the alternative neural network according to error backpropagation until the performance index of the alternative neural network is less than or equal to the first threshold.
[0053] Similarly, based on the quantified performance index, set the above first threshold according to the required precision requirement. Furthermore, when the performance index does not reach the above first threshold, continue to optimize the model; when it reaches the above first threshold, determine that the model can be used.
[0054] It can be understood that the above BP neural network is a feedforward neural network trained according to error backpropagation. Its core lies in continuously learning and correcting the weighting coefficients of each layer through the change of system error to ensure the accuracy of the parameters of the output PID algorithm.
[0055] Through the above embodiments, the model performance in the training process of the model is accurately quantified to avoid unstable output results and large fluctuations caused by insufficient or overtraining of the BP neural network.
[0056] In order to construct the above alternative neural network, in an optional implementation manner, as Figure 3 shown, the above step S301 includes:
[0057] Step S3011: Construct the input layer of the alternative neural network:
[0058]
[0059] Among them, is the output of the input layer, j is the layer number of the input layer, x(1), x(2), x(3) are the model inputs of the current iteration, the system input of the previous iteration, and the system inputs of the previous two iterations;
[0060] Specifically, the above formula is used to define the input layer of the BP neural network. It can be understood that in the neural network structure, the more input layers there are, the more complex the structure becomes. In this application, only three input layers are set, and e(k), e(k - 1), and e(k - 2) are not input, that is, the above x(1), x(2), and x(3).
[0061] Step S3012, construct the hidden layer of the alternative neural network:
[0062]
[0063] Among them, is the weighted coefficient of the output of the j-th input layer in the i-th hidden layer, is the intermediate value of the hidden layer, is the output of the hidden layer, and f is the first activation function;
[0064] Specifically, the above formula is used to define the input variables and output variables of the hidden layer. It can be understood that for the activation function f of the hidden layer, in a specific embodiment, it is as follows:
[0065]
[0066] The above activation function is the Sigmoid function, which has the characteristics of smoothness and easy derivative calculation, and can simplify the calculation of the model.
[0067] Step S3013, construct the output layer of the alternative neural network;
[0068]
[0069] Among them, is the weighted coefficient of the output of the i-th hidden layer in the l-th output layer, is the intermediate value of the output layer, is the output of the hidden layer, and g is the second activation function.
[0070] Specifically, the above formula is used to define the input and output of the output layer. In this application, the output variables are the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm. Therefore, the output layer is defined as three layers, corresponding to the above variables respectively. To ensure that the three parameters of the PID algorithm in the output layer must be positive, the activation function g, in a specific embodiment, the formula is as follows:
[0071]
[0072] In order to optimize the above alternative neural network through backpropagation, in an alternative embodiment, the above step S303 includes:
[0073] Step S3031: Update the weighting coefficients of the output layer according to backpropagation of errors:
[0074]
[0075] Among them, δ is the sensitivity of the weighting coefficient update, η is the learning efficiency, and α is the inertia coefficient.
[0076] Specifically, the BP neural network performs backpropagation according to the error. In this application, the gradient descent method is used for model optimization in the backpropagation, and an inertia term is introduced to ensure the rapid convergence of the above-mentioned alternative neural network.
[0077] In order to ensure the stability of the output result of the neural network, in an optional implementation manner, the above step S203 includes:
[0078] Step S2031: Obtain the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm at the current moment to obtain the sixth target data;
[0079] Step S2032: Calculate the prediction deviation amount and the prediction deviation change rate according to the sixth target data and the third target data;
[0080] Specifically, the inputs of the fuzzy controller are generally the error and the error change rate. Therefore, in this application, it is set to obtain the currently set PID algorithm parameters, and calculate the above error and error change rate by comparing the currently set PID algorithm parameters with the PID algorithm parameters predicted by the BP neural network, so as to obtain the above prediction deviation amount and the prediction deviation change rate.
[0081] Step S2033: Calculate the target membership degree through a preset membership function according to the prediction deviation amount and the prediction deviation change rate. The membership function includes triangular and Gaussian types;
[0082] Step S2034: Calculate the fuzzy outputs of the proportional coefficient, integral coefficient, and differential coefficient through a preset fuzzy rule according to the target membership degree. The preset fuzzy rule is used to describe the fuzzy logical relationship between the prediction deviation amount and the prediction deviation change rate and the proportional coefficient, integral coefficient, and differential coefficient;
[0083] Specifically, input the above prediction deviation amount and the above prediction deviation change rate into the fuzzy controller for fuzzy inference through the membership function and the fuzzy rule. Among them, the membership function usually includes common membership functions such as triangular type and Gaussian type, and the fuzzy rule mainly comes from expert experience and engineering operation experience. A fuzzy quantity, that is, the above fuzzy output, is obtained through fuzzy inference.
[0084] Step S2035: Perform defuzzification operation on the fuzzy output to obtain the third target data. The methods of defuzzification operation include centroid method, area method, and maximum membership degree method.
[0085] Specifically, through methods such as the centroid method, area method, and maximum membership degree method, defuzzification is performed to obtain a clear value, that is, the above-mentioned third target data is obtained.
[0086] It can be understood that the key to defuzzification lies in solving the algorithm design of quantization ladder diagrams such as error and error change rate, and the algorithm design of obtaining the ladder diagram of fuzzy control variables by looking up tables. Through the above embodiments, the fuzzy PID has enhanced control fault tolerance ability, which improves the control accuracy.
[0087] In order to construct a mathematical model of the servo motor for control, in an alternative embodiment, before controlling the operation of the servo motor according to the fourth target data, the method further includes:
[0088] Step S401, constructing a servo motor mathematical model based on the servo motor:
[0089]
[0090] Among them, u d and u q are voltage components in the d-q rotating coordinate system, i d and i q are current components in the d-q rotating coordinate system, R is the stator resistance, is the magnetic flux generated by the permanent magnet, w is the angular frequency of the d-q rotating coordinate system, i a and i β are current components measured in the static three-phase coordinate system of the three-phase current and transformed into the static two-phase coordinate system, L d and L q are inductance components in the d-q rotating coordinate system, and are magnetic flux components in the d-q rotating coordinate system, T e is the electromagnetic torque, p n is the number of pole pairs.
[0091] Specifically, since the servo motor is a complex non-linear system, it is difficult to establish an accurate digital model of the three-phase servo motor. Therefore, this application completes the construction in the rotating coordinate system and sets the following conditions:
[0092] 1) Assume that the current of the three-phase servo motor is a symmetric three-phase sine wave;
[0093] 2) The switching tubes and power components are all ideal components;
[0094] 3) Do not consider the saturation of the iron core;
[0095] 4) Assume that the motor parameters do not change with external factors;
[0096] 5) The stator windings are symmetrically distributed at 120°.
[0097] Furthermore, the mathematical model of the permanent magnet synchronous motor in the above dq rotating coordinate system can be constructed. It can be understood that if Ld = Lq, the electromagnetic torque equation changes from to
[0098] In order to control the operation of the servo motor according to the control quantity output by the PID algorithm, in an optional implementation manner, the above step S204 includes:
[0099] Step S2041, controlling the operation of the servo motor according to the fourth target data and the mathematical model of the servo motor by the SVPWM method.
[0100] Specifically, SVPWM, that is, space vector pulse width modulation, mainly uses the stator flux linkage circle of the servo motor when powered by a three-phase stacked sine wave voltage as a reference standard (in this application, it can be combined with the above mathematical model of the servo motor), that is, a special switching sequence and pulse width size combination of the power device of the three-phase voltage source inverter of the servo motor, so that the servo motor generates an electric angle current waveform with a 120° phase difference in the stator coil, thereby generating a PWM waveform to drive the motor.
[0101] Furthermore, in order to make the motor have better output driving performance, the control method of id = 0 is often adopted in engineering. The current loop adopts the common PI control, and the speed loop and torque loop adopt the control method combining BP neural network and PID to meet the requirements of high control accuracy for speed and torque. Specifically, the rotor position detection is realized by a sliding mode observer. The system generates an adjustable PWM wave through SVPWM to drive the motor to operate, and at the same time, the three-phase voltage in the natural coordinate system output is input into the sliding mode observer after coordinate transformation, and the three-phase current is input into the sliding mode observer after coordinate transformation, and then the position information is output to realize precise control of the motor.
[0102] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0103] The embodiment of the present application also provides a servo motor control device based on PID and neural network. It should be noted that the servo motor control device based on PID and neural network in the embodiment of the present application can be used to execute the servo motor control method based on PID and neural network provided by the embodiment of the present application. The device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that realizes a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0104] The following introduces the servo motor control device based on PID and neural network provided by the embodiment of the present application.
[0105] Figure 4 It is a structural block diagram of a servo motor control device based on PID and neural network according to an embodiment of the present application. As Figure 4 shown, the device includes:
[0106] A first acquisition unit 10, configured to acquire the system error of the servo motor in real time to obtain first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor;
[0107] Specifically, the PID algorithm is a feedback-based control algorithm, that is, by performing proportional, integral, and differential operations on the error (the above system error, which is the difference between the set value and the actual value of the servo motor in the present application), the control quantity is obtained to adjust the output of the system.
[0108] It can be understood that proportional control is used to adjust the control quantity proportionally according to the size of the error to achieve a fast response to the system error, but there may be a steady-state error. Integral control integrates the error to eliminate the steady-state error, but due to the increase in computational complexity, the response may slow down. Differential control controls the rate of change of the error to improve the stability and response speed of the system.
[0109] A first calculation unit 20, configured to predict the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm according to the first target data through a target neural network to obtain second target data, where the target neural network is trained according to historical system errors and a preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to historical system errors;
[0110] Specifically, in this application, the parameters of the PID algorithm with the best adjustment effect are determined based on the system error (the first target data) through the trained target neural network, so as to achieve precise control. Specifically, by learning and adjusting the connection weights between neurons for the input data, the mapping from the system error to the parameters of the PID algorithm is realized.
[0111] It can be understood that by optimizing the performance of the neural network with training data, the processing ability of the neural network for a non-linear system such as a servo motor can be improved, so as to avoid the problem of poor effect of PID on non-linear systems.
[0112] The second calculation unit 30 is used to perform fuzzy processing on the second target data through a fuzzy controller to obtain the third target data, and the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing.
[0113] Specifically, since the neural network depends on a large amount of optimization of training data and occupies a large amount of computing resources during operation, and has high requirements for the quality of training data. For the servo motor system, there is a situation where the training is insufficient and the data is unstable. Therefore, in this application, the output result of the neural network (the above second target data) is subjected to fuzzy processing, and the complex system is controlled through uncertain and fuzzy information to eliminate the violent fluctuations of the model due to reasons such as noise.
[0114] The control unit 40 is used to update the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain the fourth target data, and control the operation of the servo motor according to the fourth target data.
[0115] In a specific implementation, the formula of the above PID algorithm is set as follows in this application:
[0116] u(k)-u(k - 1) = k p [e(k)-e(k - 1)] + k i e(k) + k d [e(k)-2e(k - 1)+e(k - 2)];
[0117] Among them, u(k) is the above set operating parameter at time k, e(k) is the system error at time k, k p , k i , k d are the above proportional coefficient, integral coefficient, and differential coefficient.
[0118] Specifically, control can be performed by substituting the corrected proportional coefficient, integral coefficient, and differential coefficient into the above PID algorithm.
[0119] Through this embodiment, the first acquisition unit acquires the system error of the servo motor in real time to obtain the first target data, where the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; the first calculation unit predicts the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm based on the first target data through the target neural network to obtain the second target data, and the target neural network is trained based on the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error; the second calculation unit performs fuzzy processing on the second target data through the fuzzy controller to obtain the third target data, and the third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing; the control unit updates the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain the fourth target data, and controls the operation of the servo motor according to the fourth target data. Based on the problem that the traditional PID control method has poor control accuracy for the nonlinear system under the complex working conditions of the servo motor, this application proposes to learn the mapping relationship between the system error of the servo motor and the PID parameters through the neural network, and realize the adjustment of the PID parameters based on the real-time system error of the servo motor based on the mapping of the input-output relationship of the neural network. The neural network is introduced to improve the processing ability of the PID algorithm for the nonlinear system. At the same time, for the output of the neural network, this application proposes to further perform fuzzy processing through the fuzzy control algorithm to ensure that the output result is smooth and stable, and avoid violent fluctuations caused by insufficient model training or sudden noise. By combining the neural network, fuzzy control, and PID algorithm, the real-time optimization of the PID algorithm is realized based on the real-time change error of the servo motor, and the problem that the existing PID-based control algorithm has difficulty in parameter adjustment and low control accuracy in the complex nonlinear system and changing working environment of the servo motor is solved.
[0120] In order to ensure that the performance of the model meets the usage requirements, in an optional embodiment, the above device further includes:
[0121] An input unit, configured to build an alternative neural network based on the BP neural network and input the historical system error into the alternative neural network to obtain the fifth target data before predicting the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm based on the first target data through the BP neural network to obtain the second target data;
[0122] Specifically, define the above alternative neural network based on the structure of the BP neural network, input the input data (the above historical system error) in the pre-prepared training set, and then predict the PID parameters through the above alternative neural network to obtain the above fifth target data.
[0123] A third calculation unit, configured to calculate the performance index of the BP neural network according to the fifth target data and the preset adjustment amount:
[0124]
[0125] Among them, E(k) is the performance index, Y * (t) is the fifth target data, and Y(t) is the preset adjustment amount;
[0126] Specifically, the above formula is the definition of the model performance index function. According to the above formula, the performance index of the model is quantified to evaluate whether the model meets the preset usage requirements.
[0127] The training unit is used to determine the alternative neural network as the target neural network when the performance index is less than or equal to the first threshold, and update the alternative neural network according to the error backpropagation when the performance index is greater than the first threshold until the performance index of the alternative neural network is less than or equal to the first threshold.
[0128] Similarly, based on the quantified performance index, the first threshold is set according to the required precision requirement. Furthermore, when the performance index does not reach the first threshold, the model is continuously optimized, and when the first threshold is reached, it is determined that the model can be used.
[0129] It can be understood that the above BP neural network is a feedforward neural network trained according to the error backpropagation. Its core lies in continuously learning and correcting the weighted coefficients of each layer through the change of the system error to ensure the accuracy of the parameters of the output PID algorithm.
[0130] Through the above embodiments, the model performance in the training process of the model is accurately quantified to avoid unstable output results and large fluctuations caused by insufficient or over-training of the BP neural network.
[0131] In order to construct the above alternative neural network, in an alternative implementation, as Figure 3 shown, the above input unit includes:
[0132] The first construction module is used to construct the input layer of the alternative neural network:
[0133]
[0134] Among them, is the output of the input layer, j is the number of layers of the input layer, x(1), x(2), x(3) are the model inputs of the current iteration, the system input of the previous iteration, and the system inputs of the previous two iterations;
[0135] Specifically, the above formula is used to define the input layer of the BP neural network. It can be understood that in the neural network structure, the more input layers there are, the more complex the structure becomes. In this application, only three input layers are set, and e(k), e(k-1), and e(k-2) are not input, that is, the above x(1), x(2), and x(3).
[0136] The second construction module is used to construct the hidden layer of the alternative neural network:
[0137]
[0138]
[0139] Among them, is the weighted coefficient of the output of the j-th input layer in the i-th hidden layer, is the intermediate value of the hidden layer, is the output of the hidden layer, and f is the first activation function;
[0140] Specifically, the above formula is used to define the input variables and output variables of the hidden layer. It can be understood that for the activation function f of the hidden layer, in a specific embodiment, it is as follows:
[0141]
[0142] The above activation function is the Sigmoid function, which has the characteristics of being smooth and easy to differentiate, and can simplify the calculation of the model.
[0143] The third construction module is used to construct the output layer of the alternative neural network;
[0144]
[0145] Among them, is the weighted coefficient of the output of the i-th hidden layer in the l-th output layer, is the intermediate value of the output layer, is the output of the hidden layer, and g is the second activation function.
[0146] Specifically, the above formula is used to define the input and output of the output layer. In this application, the output variables are the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm. Therefore, the output layer is defined as three layers, corresponding to the above variables respectively. To ensure that the three parameters of the PID algorithm in the output layer must be positive, the above activation function g, in a specific embodiment, the formula is as follows:
[0147]
[0148] In order to optimize the above alternative neural network through backpropagation, in an alternative embodiment, the above training module includes:
[0149] A training module for updating the weighting coefficients of the output layer according to backpropagation of errors:
[0150]
[0151] where δ is the sensitivity of the weighting coefficient update, η is the learning efficiency, and α is the inertia coefficient.
[0152] Specifically, the BP neural network performs backpropagation according to the error. In this application, the gradient descent method is used for model optimization in the backpropagation, and an inertia term is introduced to ensure the rapid convergence of the above-mentioned alternative neural network.
[0153] In order to ensure the stability of the output result of the neural network, in an optional implementation manner, the above-mentioned second calculation unit includes:
[0154] A first acquisition module for acquiring the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm at the current moment to obtain the sixth target data;
[0155] A first calculation module for calculating the prediction deviation amount and the prediction deviation change rate according to the sixth target data and the third target data;
[0156] Specifically, the inputs of the fuzzy controller are generally the error and the error change rate. Therefore, in this application, the PID algorithm parameters set currently are acquired, and the above-mentioned error and error change rate are calculated by comparing the currently set PID algorithm parameters with the PID algorithm parameters predicted by the BP neural network, so as to obtain the above-mentioned prediction deviation amount and the prediction deviation change rate.
[0157] A second calculation module for calculating the target membership degree through a preset membership function according to the prediction deviation amount and the prediction deviation change rate, and the membership function includes triangular and Gaussian types;
[0158] A third calculation module for calculating the fuzzy outputs of the proportional coefficient, integral coefficient, and differential coefficient through a preset fuzzy rule according to the target membership degree, and the preset fuzzy rule is used to describe the fuzzy logical relationship between the prediction deviation amount and the prediction deviation change rate and the proportional coefficient, integral coefficient, and differential coefficient;
[0159] Specifically, the above-mentioned prediction deviation amount and the above-mentioned prediction deviation change rate are input into the fuzzy controller for fuzzy inference through the membership function and the fuzzy rule. Among them, the membership function usually includes common membership functions such as triangular and Gaussian types, and the fuzzy rule mainly comes from expert experience and engineering operation experience. A fuzzy quantity, that is, the above-mentioned fuzzy output, is obtained through fuzzy inference.
[0160] A processing module for performing defuzzification operation on the fuzzy output to obtain the third target data, and the methods of defuzzification operation include the centroid method, the area method, and the maximum membership degree method.
[0161] Specifically, through methods such as the centroid method, area method, and maximum membership degree method, defuzzification is performed to obtain a clear value, that is, the above-mentioned third target data is obtained.
[0162] It can be understood that the key to defuzzification lies in solving the algorithm design of the quantization ladder diagram of the error and the error change rate, etc., and the algorithm design of obtaining the ladder diagram of the fuzzy control variable by looking up the table. Through the above embodiments, the fuzzy PID has enhanced control fault tolerance ability, which improves the control accuracy.
[0163] In order to construct the mathematical model of the servo motor for control, in an alternative embodiment, the above device further includes:
[0164] A construction unit, configured to construct a servo motor mathematical model based on the servo motor before controlling the operation of the servo motor according to the fourth target data:
[0165]
[0166] Wherein, u d and u q are the voltage components in the d-q rotating coordinate system, i d and i q are the current components in the d-q rotating coordinate system, R is the stator resistance, is the magnetic flux generated by the permanent magnet, w is the angular frequency of the d-q rotating coordinate system, i a and i β are the current components of the three-phase current measured in the stationary three-phase coordinate system and converted to the stationary two-phase coordinate system, L d and L q are the inductance components in the d-q rotating coordinate system, and are the magnetic flux components in the d-q rotating coordinate system, T e is the electromagnetic torque, p n is the number of pole pairs.
[0167] Specifically, since the servo motor is a complex non-linear system, it is difficult to establish an accurate digital model of the three-phase servo motor. Therefore, this application completes the construction in the rotating coordinate system and sets the following conditions:
[0168] 1) Assume that the current of the three-phase servo motor is a symmetric three-phase sine wave;
[0169] 2) The switching tubes and power components are all ideal components;
[0170] 3) Do not consider the saturation of the iron core;
[0171] 4) Assume that the motor parameters do not change with the change of external factors;
[0172] 5) The stator windings are symmetrically distributed at 120°.
[0173] Furthermore, to construct the mathematical model of the permanent magnet synchronous motor in the above dq rotating coordinate system, it can be understood that if Ld = Lq, the electromagnetic torque equation changes from to
[0174] In order to control the operation of the servo motor according to the control quantity output by the PID algorithm, in an optional implementation manner, the above control unit includes:
[0175] A control module, configured to control the operation of the servo motor according to the fourth target data and the mathematical model of the servo motor by means of SVPWM.
[0176] Specifically, SVPWM, that is, space vector pulse width modulation, mainly uses the stator magnetic flux circle of the servo motor when powered by a three-phase stacked sine wave voltage as a reference standard (in this application, it can be combined with the above mathematical model of the servo motor), that is, a special combination of the switching sequence and pulse width size of the power device of the three-phase voltage source inverter of the servo motor, so that the servo motor generates a three-phase current waveform with an electrical angle difference of 120° in the stator coil, thereby generating a PWM waveform to drive the motor.
[0177] Furthermore, in order to enable the motor to have relatively good output driving performance, the control method of id = 0 is often adopted in engineering. The current loop adopts the common PI control, and the speed loop and torque loop adopt the control method combining BP neural network and PID to meet the requirements of high control accuracy for speed and torque. Specifically, the rotor position detection is realized by a sliding mode observer. The system generates an adjustable PWM wave through SVPWM to drive the motor to operate, and at the same time, the three-phase voltage in the natural coordinate system output is input into the sliding mode observer after coordinate transformation, and the three-phase current is input into the sliding mode observer after coordinate transformation, and then the position information is output to achieve precise control of the motor.
[0178] The above servo motor control device based on PID and neural network includes a processor and a memory. The above first acquisition unit, first calculation unit, second calculation unit, control unit, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions. The above modules are all located in the same processor; or, the above modules are respectively located in different processors in any combination form.
[0179] The processor contains a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set, and the accuracy of servo motor control can be improved by adjusting the kernel parameters.
[0180] The memory may include non-permanent memory in the form of computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0181] An embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, it controls the device where the computer-readable storage medium is located to execute the servo motor control method based on PID and neural network.
[0182] An embodiment of the present invention provides a processor for running a program, and when the program runs, it executes the servo motor control method based on PID and neural network.
[0183] An embodiment of the present invention provides a communication system, which includes a primary communication domain, a secondary communication domain processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements at least the steps of the servo motor control method based on PID and neural network.
[0184] The present application also provides a computer program product, which is adapted to execute a program initialized with at least the steps of the servo motor control method based on PID and neural network when executed on a data processing device.
[0185] Obviously, those skilled in the art should understand that the various modules or steps of the present invention described above can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. Thus, the present invention is not limited to any specific combination of hardware and software.
[0186] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0187] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to produce a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices produce means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0188] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0189] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0190] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0191] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.
[0192] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0193] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0194] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0195] 1) The servo motor control method based on PID and neural network in this application first obtains the system error of the servo motor in real time to obtain the first target data. The system error is the error between the set operating parameters and the actual operating parameters of the servo motor. Then, the target neural network predicts the proportional coefficient, integral coefficient, and differential coefficient of the PID algorithm based on the first target data to obtain the second target data. The target neural network is trained based on the historical system error and the preset adjustment amount. The preset adjustment amount is the proportional coefficient, integral coefficient, and differential coefficient adjusted according to the historical system error. After that, the fuzzy controller performs fuzzy processing on the second target data to obtain the third target data. The third target data is the proportional coefficient, integral coefficient, and differential coefficient after fuzzy processing. Finally, the PID algorithm updates the set operating parameters of the servo motor based on the third target data to obtain the fourth target data, and controls the operation of the servo motor according to the fourth target data. For the problem that the traditional PID control method has poor control accuracy for nonlinear systems under the complex working conditions of servo motors, this application proposes to learn the mapping relationship between the system error of the servo motor and the PID parameters through a neural network, and realize the adjustment of the PID parameters based on the real-time system error of the servo motor through the mapping of the input-output relationship of the neural network. Introducing a neural network improves the processing ability of the PID algorithm for nonlinear systems. At the same time, for the output of the neural network, this application proposes to further perform fuzzy processing through a fuzzy control algorithm to ensure that the output result is smooth and stable, and avoid violent fluctuations caused by insufficient model training or sudden noise. By combining neural network, fuzzy control, and PID algorithm, the real-time optimization of the PID algorithm is realized based on the real-time change error of the servo motor, and the problem that the existing PID-based control algorithm has difficulty in parameter adjustment and low control accuracy in the complex nonlinear system and changing working environment of the servo motor is solved.
[0196] 2) The servo motor control device based on PID and neural network of the present application, the first acquisition unit acquires the system error of the servo motor in real time to obtain the first target data, and the system error is the error between the set operating parameters and the actual operating parameters of the servo motor; the first calculation unit predicts the proportional coefficient, integral coefficient and differential coefficient of the PID algorithm according to the first target data through the target neural network to obtain the second target data, and the target neural network is trained according to the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, integral coefficient and differential coefficient adjusted according to the historical system error; the second calculation unit performs fuzzy processing on the second target data through the fuzzy controller to obtain the third target data, and the third target data is the proportional coefficient, integral coefficient and differential coefficient after fuzzy processing; the control unit updates the set operating parameters of the servo motor according to the third target data through the PID algorithm to obtain the fourth target data, and controls the operation of the servo motor according to the fourth target data. Aiming at the problem that the control accuracy of the traditional PID control method for the nonlinear system under the complex working conditions of the servo motor is poor, the present application proposes to learn the mapping relationship between the system error of the servo motor and the PID parameters through the neural network, and realize the adjustment of the PID parameters based on the real-time system error of the servo motor based on the mapping of the input-output relationship of the neural network. The neural network is introduced to improve the processing ability of the PID algorithm for the nonlinear system. At the same time, for the output of the neural network, the present application proposes to further perform fuzzy processing through the fuzzy control algorithm to ensure that the output result is smooth and stable, and avoid violent fluctuations caused by insufficient model training or sudden noise. By combining the neural network, fuzzy control and PID algorithm, the real-time optimization of the PID algorithm is realized based on the real-time change error of the servo motor, and the problem that the parameter adjustment of the PID-based control algorithm in the prior art is difficult and the control accuracy is low in the complex nonlinear system and variable working environment of the servo motor is solved.
[0197] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A servo motor control method based on PID and neural network, characterized in that: include: Acquire a system error of the servo motor in real time to obtain first target data, wherein the system error is an error between a set operating parameter and an actual operating parameter of the servo motor; The second target data is obtained by predicting the proportional coefficient, the integral coefficient and the differential coefficient of the PID algorithm according to the first target data through a target neural network, wherein the target neural network is trained according to the historical system error and the preset adjustment amount, and the preset adjustment amount is the proportional coefficient, the integral coefficient and the differential coefficient adjusted according to the historical system error; Performing fuzzy processing on the second target data through a fuzzy controller to obtain third target data, wherein the third target data is the proportional coefficient, the integral coefficient and the differential coefficient after the fuzzy processing; The set operating parameters of the servo motor are updated according to the third target data through the PID algorithm to obtain fourth target data, and the operation of the servo motor is controlled according to the fourth target data.
2. The method according to claim 1, characterized in that Before obtaining the second target data by predicting the proportional coefficient, the integral coefficient and the differential coefficient of the PID algorithm according to the first target data through the BP neural network, the method further includes: Constructing an alternative neural network based on the BP neural network, and inputting the historical system error into the alternative neural network to obtain fifth target data; The performance index of the BP neural network is calculated according to the fifth target data and the preset adjustment amount: Wherein, E(k) is the performance index, Y * (t) is the fifth target data, and Y(t) is the preset adjustment amount; When the performance indicator is less than or equal to a first threshold, the candidate neural network is determined as the target neural network; when the performance indicator is greater than the first threshold, the candidate neural network is updated according to error back propagation until the performance indicator of the candidate neural network is less than or equal to the first threshold.
3. The method according to claim 2, characterized in that Construct alternative neural networks based on BP neural network, including: Construct the input layer of the candidate neural network: in, is the output of the input layer, j is the number of layers of the input layer, x(1), x(2), x(3) are the model input of the current iteration, the system input of the previous iteration, and the system input of the previous two iterations; Construct the hidden layer of the candidate neural network: in, is the weighted coefficient of the output of input layer j in hidden layer i, is the middle value of the hidden layer, is the output of the hidden layer, and f is the first activation function; constructing an output layer of the candidate neural network; in, is the weighted coefficient of the output of hidden layer i in the output layer l, is the intermediate value of the output layer, is the output of the hidden layer, and g is the second activation function.
4. The method according to claim 3, characterized in that: Updating the candidate neural network according to error back propagation includes: Update the weight coefficients of the output layer according to the error back propagation: Among them, δ is the sensitivity of updating the weighted coefficient, η is the learning efficiency, and α is the inertia coefficient.
5. The method according to claim 1, characterized in that: The fuzzy processing is performed on the second target data by a fuzzy controller to obtain third target data, including: Acquire the proportional coefficient, the integral coefficient and the differential coefficient of the PID algorithm at the current moment to obtain sixth target data; Calculate the predicted deviation amount and the predicted deviation change rate according to the sixth target data and the third target data; Calculating a target membership by using a preset membership function according to the predicted deviation amount and the predicted deviation change rate, wherein the membership function includes a triangular type and a Gaussian type; Calculating the fuzzy outputs of the proportional coefficient, the integral coefficient and the differential coefficient according to the target membership by using a preset fuzzy rule, wherein the preset fuzzy rule is used to describe the fuzzy logic relationship between the predicted deviation amount and the predicted deviation change rate and the proportional coefficient, the integral coefficient and the differential coefficient; A defuzzification operation is performed on the fuzzy output to obtain the third target data, and the defuzzification operation method includes a centroid method, an area method and a maximum membership method.
6. The method according to claim 1, characterized in that Before controlling the servo motor to operate according to the fourth target data, the method further includes: Construct a servo motor mathematical model based on the servo motor: Among them, u d and u q is the voltage component in the dq rotating coordinate system, i d and i q is the current component in the dq rotating coordinate system, R is the stator resistance, is the flux generated by the permanent magnet, w is the angular frequency of the dq rotating coordinate system, i a and i β is the current component of the three-phase current measured in the stationary three-phase coordinate system and converted to the stationary two-phase coordinate system, L d and L q is the inductance component in the dq rotating coordinate system, and is the magnetic flux component in the dq rotating coordinate system, T e is the electromagnetic torque, p n is the pole pair number.
7. The method according to claim 6, characterized in that Controlling the servo motor to operate according to the fourth target data includes: The operation of the servo motor is controlled according to the fourth target data and the servo motor mathematical model by using the SVPWM method.
8. A servo motor control device based on PID and neural network, characterized in that: The device comprises: A first acquisition unit is used to acquire a system error of the servo motor in real time to obtain first target data, wherein the system error is an error between a set operating parameter and an actual operating parameter of the servo motor; a first calculation unit, configured to predict a proportional coefficient, an integral coefficient, and a differential coefficient of a PID algorithm according to the first target data through a target neural network to obtain second target data, wherein the target neural network is trained according to a historical system error and a preset adjustment amount, and the preset adjustment amount is the proportional coefficient, the integral coefficient, and the differential coefficient adjusted according to the historical system error; a second calculation unit, configured to perform fuzzy processing on the second target data through a fuzzy controller to obtain third target data, wherein the third target data is the proportional coefficient, the integral coefficient and the differential coefficient after the fuzzy processing; A control unit is used to update the set operating parameters of the servo motor according to the third target data through the PID algorithm, obtain fourth target data, and control the operation of the servo motor according to the fourth target data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 7.
10. A servo motor control system, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of claims 1 to 7.
Citation Information
Cited By
Intelligent servo control method of glass edge grinding machine guided by causal priori
CN121348966A