Ppid parameter setting method, microcontroller and storage medium
By adjusting the control parameters of the PID algorithm through self-learning error of the spiking neural network, the problem of difficult PID algorithm parameter adjustment is solved, and high-precision and low-cost online parameter optimization is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN H&T INTELLIGENT CONTROL
- Filing Date
- 2026-03-31
- Publication Date
- 2026-06-26
Smart Images

Figure CN122284264A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of control technology, and in particular to a PID parameter tuning method, a microcontroller, and a storage medium. Background Technology
[0002] The PID algorithm is the most widely used control algorithm in home appliances and industrial control. It is often used in systems such as temperature, motion, and power electronics. It generates control signals by performing proportional, integral, and derivative operations on the system error to adjust the controlled object, such as motors, valves, and heaters, so that it reaches the desired state.
[0003] However, the control parameters of the PID algorithm are difficult to adjust, require manual debugging, have a long cycle, are difficult to adapt to dynamically changing systems, and have poor anti-interference ability. Summary of the Invention
[0004] In view of this, this application provides a PID parameter tuning method, a microcontroller, and a storage medium. By learning from errors, the control parameters are adjusted, thereby improving the accuracy of the PID algorithm. Furthermore, parameter tuning is performed online, improving the intelligence of the application system and reducing parameter debugging costs.
[0005] In a first aspect, this application provides a PID parameter tuning method, including: in response to meeting a preset triggering condition, using a spiking neural network to learn the error and determine the control parameters of the PID algorithm so that the PID algorithm meets a preset accuracy.
[0006] In some embodiments, the aforementioned method of adjusting the control parameters of the PID algorithm by employing a spiking neural network to learn the error includes: Obtain the error sequence; The error sequence is input into a spiking neural network for calculation and processing, and the spiking neural network outputs predictive control parameters. The weight parameters of the spiking neural network are adjusted based on the predictive control parameters. The process is repeated until the target control parameters output by the spiking neural network enable the PID algorithm to meet the preset accuracy. The target control parameters are determined to be the control parameters of the PID algorithm.
[0007] In some embodiments, the aforementioned spiking neural network includes a neuron module and a parameter decoding module; wherein, the neuron module is configured to spatially map the error sequence and convert it into an output pulse sequence matrix; the parameter decoding module is configured to decode the output pulse sequence matrix to obtain predictive control parameters.
[0008] In some embodiments, the aforementioned neuron module is configured to encode and transform the error sequence from multiple feature dimensions to obtain an output pulse sequence matrix.
[0009] In some embodiments, the aforementioned plurality of feature dimensions include at least one of the following: error, rate of change of error, integral of error, square of error, target value, and measured value.
[0010] In some embodiments, the aforementioned adjustment of the weight parameters of the spiking neural network based on predictive control parameters includes: The reward trajectory value is determined based on the error sequence and the control quantity output by the PID algorithm based on the predictive control parameters. The weight adjustment value is determined based on the reward trajectory value and the preset learning factor; The weight adjustment values are superimposed on the weight parameters of the spiking neural network to achieve weight parameter adjustment.
[0011] In some embodiments, determining the reward trajectory value based on the error sequence and the control quantity output by the PID algorithm based on predictive control parameters includes: Traverse the error sequence and determine the reward value sequence based on the reward function; The reward value sequence is smoothed to obtain the reward trajectory value.
[0012] In some embodiments, the preset triggering conditions include: the PID algorithm fails to meet the preset accuracy, and / or the learning cycle is reached.
[0013] Thirdly, this application provides a microcontroller, including: At least one processor, and A memory that is communicatively connected to at least one processor, wherein, The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform the PID parameter tuning method as described in the first aspect above.
[0014] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions for causing a computer device to perform the PID parameter tuning method described in the first aspect above.
[0015] The PID parameter tuning method provided in this application, in response to the fulfillment of a preset trigger condition, uses a spiking neural network to learn the error and adjust the control parameters of the PID algorithm so that the PID algorithm meets a preset accuracy. That is, when the preset trigger condition is met, the spiking neural network learns the error generated by the PID algorithm and adjusts the control parameters of the PID algorithm in reverse. In this way, the PID algorithm meets the preset accuracy, thereby improving the accuracy of the PID algorithm. Furthermore, the spiking neural network is lightweight and can be stored in a microcontroller, allowing parameter adjustment to be performed online, improving the intelligence of the application system and reducing parameter tuning costs. Attached Figure Description
[0016] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, which are not intended to limit the embodiments, and elements having the same reference numerals in the drawings are designated as similar elements.
[0017] Figure 1 This is a block diagram of the control process of a PID control system; Figure 2 This is a flowchart illustrating the PID parameter tuning method in an embodiment of this application; Figure 3 This is a schematic diagram of a sub-process of the PID parameter tuning method in an embodiment of this application; Figure 4 This is a schematic diagram of the PID parameter tuning method in the embodiments of this application; Figure 5 This is a schematic diagram of a spiking neural network processing data in an embodiment of this application; Figure 6 This is a schematic diagram of the membrane potential of the updated neuron in an embodiment of this application; Figure 7 This is a schematic diagram of the microcontroller structure in an embodiment of this application. Detailed Implementation
[0018] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0020] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. In addition, the terms "first," "second," and "third" used herein do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.
[0021] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0022] Furthermore, the technical features involved in the various embodiments of this application described below can be combined with each other as long as they do not conflict with each other.
[0023] The PID algorithm is a control algorithm that performs proportional, integral, and derivative calculations in real time based on the error and outputs a control quantity, enabling the controlled object to quickly and stably track the target value. The controlled object can be temperature, speed, position, or voltage, etc.
[0024] Please see Figure 1 , Figure 1 This is a control block diagram for the PID algorithm. The PID algorithm is based on the measured values of the controlled object. With target value Error between Calculate control quantity Based on control quantity Adjust the controlled object so that the measured value of the controlled object Get as close as possible to the target value Among them, control quantity The calculation method is shown in the following formula:
[0025] in, It is the control quantity output by the PID algorithm; It is a measured value With target value The error between; It is the proportional gain coefficient, which determines the response speed of the PID algorithm; It is the integral gain coefficient, used to eliminate steady-state error; It is the differential gain coefficient, used to suppress overshoot and oscillation.
[0026] From the above formula, it can be seen that the control parameters of the PID algorithm ( , , This directly affects control performance. However, adjusting control parameters is difficult, requires manual debugging, has a long cycle, is difficult to adapt to dynamically changing systems, and has poor anti-interference capabilities.
[0027] The inventors of this application are aware of some PID parameter tuning methods, including empirical tuning methods such as ZN tuning and CC tuning. However, these methods only provide engineers with some parameter tuning assistance and still require manual intervention and rely on the engineer's experience.
[0028] The inventors of this application have developed some known PID parameter tuning methods that adjust the PID control parameters based on error and error change rate using fuzzy logic reasoning to achieve adaptive control. While this method achieves adaptive parameter processing by introducing a fuzzy rule base, it still requires expert knowledge for fuzzy rule design.
[0029] Some PID parameter tuning methods known to the inventors of this application combine BP neural networks with PID control. They use a backpropagation neural network and a gradient descent algorithm to train and adjust the network weights, outputting PID control parameters. However, these methods require high computational resources and have long learning cycles, making them difficult to apply and unable to achieve online adjustment.
[0030] To address the aforementioned issues, this application provides a PID parameter tuning method. In response to a preset trigger condition, a spiking neural network (SNN) learns the error and adjusts the control parameters of the PID algorithm to achieve a preset accuracy. Specifically, when the preset trigger condition is met, the SNN learns the error generated by the PID algorithm and reverses it to determine the control parameters. This ensures the PID algorithm meets the preset accuracy, thereby improving its precision. Furthermore, the SNN is lightweight and can be stored in a microcontroller, allowing parameter tuning to be performed online, improving the intelligence of the application system and reducing parameter tuning costs.
[0031] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0032] Please see Figure 2 , Figure 2 This is a flowchart illustrating the PID parameter tuning method in some embodiments of this application. Method S100 includes the following steps: S10: Determine whether the preset trigger conditions are met.
[0033] Understandably, the PID parameter tuning method is executed by the microcontroller. The microcontroller has a built-in PID algorithm and the PID parameter tuning method in this application. When the preset triggering conditions are met, the microcontroller executes the PID parameter tuning method, and the tuned control parameters are used by the PID algorithm to adjust the controlled object.
[0034] In some embodiments, the adjustment accuracy of the PID algorithm is preset. When the microcontroller finds that the PID algorithm does not meet the preset accuracy, the program corresponding to the PID parameter tuning method is started.
[0035] In some embodiments, a learning period is set, and when the microcontroller detects that the learning period has been reached, the program corresponding to the PID parameter tuning method is started.
[0036] In some embodiments, the two situations described above can be combined, with accuracy conditions and periodic conditions monitored simultaneously. When the microcontroller detects that the PID algorithm does not meet the preset accuracy or when the microcontroller detects that the time has reached the learning cycle, the program corresponding to the PID parameter tuning method is started.
[0037] If the preset triggering condition in S10 is met, proceed to step S20.
[0038] S20: Uses a spiking neural network to learn the error and adjusts the control parameters of the PID algorithm.
[0039] Specifically, the microcontroller learns from the error generated by the PID algorithm and updates the control parameters.
[0040] Wherein, the error is in the above formula or Figure 1 In Understandable, error. It can reflect the control accuracy of the PID algorithm. By using a spiking neural network to learn the error, the measured value can be understood. With target value The difference between them, and thus, by adjusting the control parameters based on the difference, can make the control parameters accurate and the measured values... Approaching the target value .
[0041] This allows the PID algorithm to meet the preset accuracy, thereby increasing its precision. Furthermore, the lightweight nature of neural networks, which can be stored in the microcontroller, enables online parameter tuning, improving the intelligence of the application system and reducing parameter adjustment costs.
[0042] In some embodiments, please refer to Figure 3 The aforementioned step S20 specifically includes: S21: Obtain the error sequence.
[0043] Understandably, PID algorithms collect measured values at a fixed frequency. With target value The error was calculated. Therefore, within the time window T, the error sequence can be obtained. The error sequence is the error arranged chronologically within the time window T.
[0044] S22: Input the error sequence into the spiking neural network for calculation and processing, and the spiking neural network outputs predictive control parameters.
[0045] Among them, the Spiking Neural Network (SNN) simulates the information transmission of real neurons through discrete action potentials (pulses). The SNN performs forward inference and feature extraction on the error sequence, outputting predictive control parameters for the PID algorithm. These predictive control parameters include the predicted values mentioned above. , and .
[0046] Since error sequences can reflect the dynamic changes in PID algorithm regulation, they are used as learning data for SNNs. Measurements within the SNN learning time window T... With target value The difference trend between the parameters is more stable and realistic within the time window T, thus improving the accuracy of SNN in judging the PID control state and its anti-interference ability. Furthermore, SNN has strong time series processing advantages; combining it with error sequences can better leverage the advantages of SNN and improve the accuracy of predictive control parameters.
[0047] Understandably, the spiking neural network is pre-configured in the microcontroller, and can be invoked when the microcontroller executes step S22. Compared to the computationally intensive BP neural network, the SNN consumes fewer computational resources and can achieve adaptive adjustment of PID control parameters and online learning in embedded devices. The calculation and processing of the error sequence by the SNN will be introduced below and will not be described in detail here.
[0048] S23: Adjust the weight parameters of the spiking neural network based on the predictive control parameters, return to step S21, and iterate until the target control parameters output by the spiking neural network make the PID algorithm meet the preset accuracy.
[0049] Predictive control parameters can be simulated and applied to PID algorithms to calculate the corresponding measured values. Then, based on the difference between the measured values and the target values under the predictive control parameters, the weight parameters of the spiking neural network are adjusted in reverse to complete one learning cycle.
[0050] Returning to step S21, the error sequence within the next time window T is obtained. Steps S21 to S23 are repeated in this way until the predictive control parameters output by the spiking neural network enable the PID algorithm to meet the preset accuracy, indicating that the measured value is close to the target value and the difference is small, and the loop is exited.
[0051] Understandably, if the predictive control parameters can enable the PID algorithm to meet the preset accuracy, then using these predictive control parameters as target control parameters and providing them to the PID algorithm can improve the accuracy of the PID algorithm.
[0052] S24: Determine the target control parameters as the control parameters for the PID algorithm.
[0053] In other words, the target control parameter is the same as the control parameter of the PID algorithm. The PID algorithm outputs the measured value based on this target control parameter, making the measured value approximate the target value.
[0054] In this embodiment, an error sequence is used to train the SNN online, and the SNN learns the measurement values within the time window T. With target value By continuously iterating and training based on the differences between them, the PID algorithm can output accurate target control parameters. Based on these target control parameters, the PID algorithm can meet the preset accuracy.
[0055] In some embodiments, please refer to Figure 4 The aforementioned spiking neural network includes a neuron module and a parameter decoding module; wherein, the neuron module is configured to perform spatial mapping on the error sequence and convert it into an output pulse sequence matrix; the parameter decoding module is configured to decode the output pulse sequence matrix to obtain the predictive control parameters.
[0056] Understandably, a neuron module comprises multiple neurons or multiple layers of neurons. The error sequence is a numerical vector of length T. The neuron performs feature mapping and pulse coding on the error sequence, converting it into multi-row, multi-column 0 / 1 pulse signals.
[0057] In some embodiments, the aforementioned neuron module is configured to encode and transform the error sequence from multiple feature dimensions to obtain an output pulse sequence matrix.
[0058] In this process, encoding refers to converting the error sequence into a pulse signal, which involves format transformation of the pulse signal. During this process, the neuron module extracts and learns features.
[0059] The neuron module extracts and learns features from multiple feature dimensions, which can comprehensively extract the dynamic features of the PID control system, enrich the information dimensions, and help improve control accuracy and anti-interference ability.
[0060] In some embodiments, the aforementioned plurality of feature dimensions include at least one of the following: error, rate of change of error, integral of error, square of error, target value, and measured value.
[0061] Among them, the error reflects the current deviation, the error change rate reflects the trend of error change, the error integral reflects the historical cumulative error, the error square reflects the degree of error fluctuation, the target value is the control target, and the measured value is the actual operating state of the PID control system.
[0062] Multiple feature dimensions include one or more of the aforementioned feature dimensions. This enables SSN to comprehensively and from multiple perspectives extract dynamic information from the PID control system, understand its actual operation, and thus improve the accuracy and stability of adaptive adjustment of PID control parameters.
[0063] For example, the neurons in the neuron module are LIF neurons. The neuron module includes an input layer, a hidden layer, and an output layer. The input layer includes 6 LIF neurons, the hidden layer includes 12 LIF neurons, and the output layer includes 3 LIF neurons.
[0064] Please see Figure 5 The input layer sequentially performs feature construction, normalization, and Poisson encoding on the error sequence. Feature construction includes building multiple feature dimensions: error, error rate of change, error integral, error squared, target value, and measured value.
[0065] The six LIF neurons in the input layer encode the error, the rate of change of error, the integral of error, the square of error, the target value, and the measured value, respectively. Specifically, through... The function normalizes the input values to the range [-1, 1]. The error, rate of change of error, integral of error, squared error, target value, and measured value are expressed by the following formulas: error: ; Error change rate: ; Error integral: ; Error squared: ; Target value: ; Measured values: .
[0066] Feature vector =[ , , , , , In some embodiments, the input layer will use feature vectors Normalization to [0,1] is achieved using the following formula:
[0067] In some embodiments, the input layer processes the feature vector. Perform Poisson coding to obtain the probability vector. Specifically, Poisson coding can be performed using the following formula:
[0068] in, These are the normalized eigenvectors. It is the maximum probability of distribution. It is the time step. It represents the probability of the current neuron firing a pulse at the current time step.
[0069] The probability vector generates a pulse signal consisting of either 0 or 1, forming an input pulse sequence matrix. A larger probability P results in an output of 1, and a smaller probability P results in an output of 0.
[0070] The input pulse sequence matrix is processed in the hidden layer and the output layer. Please refer to [link / reference]. Figure 6 The process iterates through the time window T, sequentially inputting the pulse sequence matrix components corresponding to each time step in the output pulse sequence matrix into the hidden layer. After processing by the hidden layer, the intermediate pulse sequence matrix components corresponding to each time step are output, and these intermediate pulse sequence matrix components are input into the output layer for further processing. Once the time window T has been traversed, the entire output pulse sequence matrix within the time window T is saved for subsequent learning.
[0071] The process of processing hidden layers is as follows: Figure 6 As shown, the process iterates through all neurons in the hidden layer. For the current neuron, it checks all its input connections and detects whether there is a pulse at the input position of the corresponding output pulse sequence matrix. If a pulse is found, the membrane potential of the current neuron is updated; otherwise, it is skipped and the membrane potential remains unchanged. After all input connections of the current neuron have been traversed, the membrane potential and pulse firing state of the current neuron are updated. When all neurons have been traversed, the hidden layer processing ends, and the intermediate pulse sequence matrix is output.
[0072] Similarly, the processing procedure for the output layer is the same as that for the hidden layer. The difference lies in the number of input neurons (presynaptic neurons) for the hidden layer; and the number of input neurons for the output layer is the same as the number of hidden layers. The intermediate pulse sequence matrix is input into the hidden layer, and then... Figure 6 After the process shown is frequently processed, the aforementioned output pulse sequence matrix is obtained.
[0073] The formula for updating neurons satisfies the dynamic equation of LIF, and the input current is calculated as follows: ,in It is the first in the current neural layer The bias of individual neurons (postsynaptic neurons), It is the first in the current neural layer The input number The weights of each neuron.
[0074] The dynamic equations of LIF neurons are as follows: Synaptic current update:
[0075] Membrane potential update:
[0076] Distribution rules:
[0077] The working process of LIF neurons includes: synaptic currents. Receive input signal And according to the time constant Analog signal attenuation; membrane potential Driven by synaptic current and according to time constant Attenuation; when Reaching the issuance threshold At this time, the neuron fires a pulse, triggering a signal; after firing, the membrane potential resets to its normal value. It enters a non-responsive period.
[0078] The parameter decoding module is configured to decode the output pulse sequence matrix to obtain the predictive control parameters. The module first performs firing probability statistics on the three LIF neurons in the output layer, then performs normalized decoding, and finally performs parameter mapping to obtain the predictive control parameters.
[0079] Among them, the firing probability statistics are as follows: For the three LIF neurons in the output layer, the total number of pulses within the time window T is counted, and the ratio of the total number of pulses to the time window T is used as the normalized firing probability, as shown in the formula:
[0080] in, It is the normalized pulse firing probability of the k-th output neuron within the time window T. It is the total number of pulses fired by the k-th output neuron within the time window T, where T is the total number of steps in the time window.
[0081] Normalized Decoding: Normalized Distribution Probability Perform a linear transformation to map the values from the [0,1] interval to the [-1,1] interval, resulting in the decoded normalized eigenvalues. The formula is as follows:
[0082] in, It is the normalized pulse firing probability of the k-th output neuron within the time window T. It is the normalized feature value of the k-th output neuron within the time window T.
[0083] Parameter mapping: based on control parameters ( , , The actual control scope of ) Perform a linear mapping, as shown in the following formula:
[0084]
[0085]
[0086] in, It is proportional gain The minimum allowable value, It is proportional gain Maximum allowed value, It is the integral gain. The minimum allowable value, It is the integral gain. Maximum allowed value, It is the differential gain The minimum allowable value, It is the maximum allowable value of the differential gain.
[0087] In this way, the neuron module performs spatial mapping on the error sequence, transforming it into an output pulse sequence matrix; the parameter decoding module decodes the output pulse sequence matrix to obtain the predictive control parameters. Thus, the SNN calculates the output predictive control parameters based on the error sequence.
[0088] In some embodiments, step S23 above, "adjusting the weight parameters of the spiking neural network based on the predictive control parameters," specifically includes: S231: Determine the reward trajectory value based on the error sequence and the control quantity output by the PID algorithm based on the predictive control parameters.
[0089] Please refer to it again. Figure 4 The control quantity output by the PID algorithm based on predictive control parameters is Control quantity The error sequence is input into the reward calculation module, and the reward calculation module outputs the reward trajectory value.
[0090] In some embodiments, the aforementioned step S231 includes: traversing the error sequence, determining the reward value sequence based on the reward function, and smoothing the reward value sequence to obtain the reward trajectory value.
[0091] Optionally, the reward function can be expressed using the following formula:
[0092] Among them, the first item As a basic reward, the smaller the control error, the higher the basic reward value; Second item To control the amount of penalty, the coefficient It can avoid excessive control, be used for energy consumption balance, and achieve energy saving; Third item To improve rewards, the coefficient This can encourage the system to actively reduce errors; Fourth item The reward is awarded if the target range (error tolerance zone) is reached. Give The reward is 0 otherwise.
[0093] Understandably, the error sequence includes errors arranged in time sequence. By traversing the error sequence and determining the reward value at each time step based on the reward function described above, a reward value sequence is obtained.
[0094] The reward value sequence is smoothed to obtain the reward trajectory value. In some embodiments, the smoothing process is performed using the following formula:
[0095] in, This is the reward value at the current moment. The reward value from the previous moment. This is the attenuation coefficient.
[0096] Once all reward values in the reward value sequence have been traversed, the reward value obtained at the last moment is the reward trajectory value.
[0097] S232: Determine the weight adjustment value based on the reward trajectory value and the preset learning factor.
[0098] In this embodiment, please refer again Figure 4 The STDP learning module employs the Spike Timing Dependent Plasticity (STDP) algorithm to achieve online adaptive adjustment of weights. The preset learning factors include presynaptic pulse time and postsynaptic pulse time (STDP dual factors).
[0099] Taking the weight update of anterior synaptic neuron i and postsynaptic neuron j as an example, the weight update rule based on STDP is explained: Calculate the difference Δt between the postsynaptic pulse time and the anterior synaptic pulse time; When Δt>0, it indicates that the postsynaptic neuron fires a pulse after the presynaptic neuron, which is positively enhanced. It is believed that the presynaptic neuron causes the postsynaptic neuron to fire a pulse, and the connection between neurons should be strengthened.
[0100] When Δt < 0, it indicates that the postsynaptic neuron fires a pulse before the presynaptic neuron, which is a negative inhibition. It is believed that the presynaptic neuron does not contribute to the postsynaptic neuron, and the connection between neurons should be weakened.
[0101] in, This is the change in the basic weights of STDP. and The coefficient is used to control the strength of the reinforcement. and To simulate the timescale of synaptic plasticity consistent with that of biological neurons, an exponential decay function is used. This ensures that signals from more recent times have a greater impact on neurons, while longer signals do not produce a learning effect, thus preventing memory confusion.
[0102] The weight adjustment value is calculated using the following formula:
[0103] in, The coefficient is the learning rate. As a reward for trajectory value, This is the change in the basic weights of STDP. This is the weight adjustment value.
[0104] S233: The weight adjustment value is superimposed on the weight parameters of the spiking neural network to achieve weight parameter adjustment.
[0105] That is, the weight parameter values of the SNN are added together with the weight adjustment values to obtain new weight parameters, thereby realizing the adjustment of the weight parameters.
[0106] In this embodiment, the STDP algorithm based on reward trajectories is used to adjust the weight parameters of the SNN online, achieving adaptive optimization of the SNN weight parameters. This facilitates rapid convergence of the SNN and the prediction of the target control parameters. Thus, the response speed, steady-state accuracy, and anti-interference robustness of the PID parameter tuning method can be improved.
[0107] This application also provides a microcontroller; please refer to [link / reference]. Figure 7 The microcontroller 300 includes a processor 301 and a memory 302. The processor 301 is connected to the memory 302, for example, the processor 301 can be connected to the memory 302 via a bus.
[0108] Processor 301 is configured to support the microcontroller in executing the steps of the PID parameter tuning method in the above embodiments. Processor 301 may be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof. The aforementioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0109] Memory 302 is used to store program code, etc. Memory 302 may include volatile memory (VM), such as random access memory (RAM); memory 1002 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); memory 302 may also include combinations of the above types of memory.
[0110] In some possible cases, the processor 301 may call the program code to perform the following operations: in response to the satisfaction of a preset trigger condition and self-learning error, adjust the control parameters of the PID algorithm so that the PID algorithm meets a preset accuracy.
[0111] This application also provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the PID parameter tuning method as described in the foregoing embodiments.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for tuning PID parameters, characterized in that, include: In response to the fulfillment of a preset triggering condition, a spiking neural network is used to learn the error and adjust the control parameters of the PID algorithm so that the PID algorithm meets the preset accuracy.
2. The method according to claim 1, characterized in that, The method of using a spiking neural network to learn errors and adjust the control parameters of the PID algorithm includes: Obtain the error sequence; The error sequence is input into the spiking neural network for calculation and processing, and the spiking neural network outputs predictive control parameters. The weight parameters of the spiking neural network are adjusted based on the predictive control parameters. The process then returns to the step of obtaining the error sequence, iterating repeatedly until the target control parameters output by the spiking neural network enable the PID algorithm to meet the preset accuracy. The target control parameter is determined to be the control parameter of the PID algorithm.
3. The method according to claim 2, characterized in that, The spiking neural network includes a neuron module and a parameter decoding module; The neuron module is configured to spatially map the error sequence and convert it into an output pulse sequence matrix. The parameter decoding module is configured to decode the output pulse sequence matrix to obtain the predictive control parameters.
4. The method according to claim 3, characterized in that, The neuron module is configured to encode and transform the error sequence from multiple feature dimensions to obtain the output pulse sequence matrix.
5. The method according to claim 4, characterized in that, The plurality of feature dimensions includes at least one of the following: Error, rate of change of error, integral of error, square of error, target value, and measured value.
6. The method according to claim 2, characterized in that, The step of adjusting the weight parameters of the spiking neural network based on the predictive control parameters includes: The reward trajectory value is determined based on the error sequence and the control quantity output by the PID algorithm based on the predictive control parameters. The weight adjustment value is determined based on the reward trajectory value and the preset learning factor; The weight adjustment value is superimposed on the weight parameters of the spiking neural network to achieve weight parameter adjustment.
7. The method according to claim 6, characterized in that, The step of determining the reward trajectory value based on the error sequence and the control quantity output by the PID algorithm based on the predictive control parameters includes: Traverse the error sequence and determine the reward value sequence based on the reward function; The reward value sequence is smoothed to obtain the reward trajectory value.
8. The method according to claim 1, characterized in that, The preset triggering conditions include: the PID algorithm failing to meet the preset accuracy, and / or reaching the learning cycle.
9. A microcontroller, characterized in that, include: At least one processor, and A memory communicatively connected to the at least one processor, wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer device to perform the method as described in any one of claims 1-8.