PID parameter tuning methods, devices, storage media, and electronic equipment

By combining particle swarm optimization and fuzzy logic, the parameters of the PID controller are dynamically adjusted, solving the problem that conventional PID controllers cannot adapt to systems with time-varying parameters and structures, thus improving control efficiency.

CN116224765BActive Publication Date: 2026-03-13GREE ELECTRIC APPLIANCE INC OF ZHUHAI
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-19
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Conventional PID controllers have fixed parameters Kp, Ki, and Kd, which cannot effectively control systems with time-varying parameters and structures, resulting in low control efficiency.

Method used

By combining particle swarm optimization and fuzzy algorithm, the parameters of the PID controller are dynamically adjusted by obtaining the output current or voltage control error of the converter.

Benefits of technology

It realizes real-time dynamic adjustment of PID controller parameters, improves the control efficiency of time-varying systems with parameters and structure, avoids local optima, and the algorithm is simple and easy to implement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116224765B_ABST
    Figure CN116224765B_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, storage medium, and electronic device for tuning PID parameters. The method includes: acquiring the output current of a converter; calculating the current control error of a PID controller based on the output current and a desired current; inputting the current control error into a particle swarm optimization (PSO) model to output first PID parameters; and configuring the first PID parameters as the PID control parameters of the PID controller. This invention achieves real-time dynamic adjustment of the PID controller's control parameters, solving the technical problem that traditional PID parameters cannot be adjusted in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing, and more specifically, to a method, apparatus, storage medium, and electronic device for tuning PID parameters. Background Technology

[0002] PID (Proportion-Integration-Derivative) controllers are widely used and are common feedback loop components in industrial control applications. They calculate a new input value based on the control deviation e(t) between the actual output value and a given reference value, ensuring the actual output reaches or remains at the reference value. PID control is generally expressed as:

[0003]

[0004] Where e(t) is the system control deviation; Kp, Ki, and Kd are the weights of the system deviation signal and its integral and differential components, respectively. The controller can calculate the control signal and drive the controlled object through such weighting.

[0005] However, the performance of a PID controller often depends on whether the three parameters Kp, Ki, and Kd are reasonable. For conventional PID control, the parameters Kp, Ki, and Kd are usually fixed values ​​that cannot be changed once tuned. Therefore, conventional PID controllers cannot effectively control systems with time-varying parameters and structures.

[0006] There are currently no effective solutions to the aforementioned problems in the relevant technologies. Summary of the Invention

[0007] This invention provides a method, apparatus, storage medium, and electronic device for tuning PID parameters, in order to solve the technical problem in related technologies where PID parameters Kp, Ki, and Kd are fixed, resulting in low control efficiency for systems with time-varying parameters and structures.

[0008] According to one aspect of the embodiments of this application, a method for tuning PID parameters is provided, comprising: obtaining the output current of a converter; calculating the current control error of a PID controller based on the output current and a desired current; inputting the current control error into a particle swarm optimization algorithm model and outputting a first PID parameter; and configuring the first PID parameter as the PID control parameter of the PID controller.

[0009] Optionally, before obtaining the output current of the converter, the method further includes: obtaining the converter voltage control error and the rate of change of the voltage control error; inputting the voltage control error and the rate of change of the voltage control error into a fuzzy algorithm model, and outputting a second PID parameter; configuring the second PID parameter as the control parameter of the PID controller.

[0010] Optionally, obtaining the converter voltage control error and the voltage control error change rate includes: obtaining the output voltage of the converter in the current sampling period; calculating the difference between the output voltage and the desired voltage to obtain the current voltage control error; obtaining the previous voltage control error in the previous sampling period; and calculating the voltage control error change rate by dividing the difference between the current voltage control error and the previous voltage control error by the sampling period.

[0011] Optionally, inputting the voltage control error and the rate of change of the voltage control error into a fuzzy algorithm model to output the second PID parameters includes: performing fuzzy quantization on the voltage control error, the rate of change of the voltage control error, and the PID parameters; determining their respective corresponding fuzzy subsets {VB, B, M, MS, S, VS, ZO} and determining the universe of discourse corresponding to each fuzzy subset, where VB represents super-large, B represents positive large, M represents positive medium, MS represents medium small, S represents positive small, VS represents super-small, and ZO represents zero; calculating the first membership value and corresponding first membership degree of the voltage control error based on the fuzzy subsets and the universe of discourse, and calculating the second membership value and corresponding second membership degree of the rate of change of the voltage control error; obtaining a fuzzy rule table of preset PID parameters; searching the fuzzy rule table to obtain the third membership value and third membership degree of the PID parameters corresponding to the first membership value and the second membership value, where the third membership degree is the product of the first membership degree and the second membership degree; and calculating the second PID parameters by multiplying the third membership value by the third membership degree.

[0012] Optionally, after determining the universe of discourse corresponding to each fuzzy subset, the method further includes: determining the magnitude and sign of the voltage control error and the rate of change of the voltage control error; if the voltage control error is greater than or equal to a first preset value, the rate of change of the voltage control error is greater than or equal to a second preset value, and the voltage control error and the rate of change of the voltage control error have the same sign, then a first contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the first contraction factor is greater than 1; if the voltage control error is greater than or equal to the first preset value, the rate of change of the voltage control error is greater than or equal to the second preset value, and the voltage control error and the rate of change of the voltage control error have opposite signs, then a second contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the second contraction factor is equal to 1; if the voltage control error is less than the first preset value, and the rate of change of the voltage control error is greater than or equal to the second preset value, then a third contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the third contraction factor is greater than 1.

[0013] Optionally, inputting the current control error into the particle swarm optimization (PSO) model and outputting the first PID parameters includes: generating a particle swarm and randomly assigning a value to each particle in the swarm; determining the individual extreme value of each particle and determining the global extreme value of the swarm, wherein the individual extreme value is the best value found by the particle so far, and the global extreme value is the best value found by the entire swarm so far; and iterating the particle values ​​based on the individual extreme value and the global extreme value using the following formula:

[0014] V is (t+1)=V is (t)+c1r 1s (t)(P is (t)-x is (t))+c2r 2s (t)(P gs (t)-x is (t));

[0015] x is (t+1)=x is (t)+V is (t+1);

[0016] Where P is For individual extreme values; P gs V is the global extremum; is x is the velocity vector of the particle; isdenoted as , where i is the particle position; i is the number of particles, i = 1, 2, 3, ..., n; s is the particle dimension, s = 1, 2, 3, ..., s; learning factors c1 and c2 are non-negative constants; r1 and r2 are mutually independent pseudo-random numbers, following a [0, 1] distribution; Vis ∈ [-vmax, vmax], where vmax is a constant; determine if the iteration meets the termination condition; if the iteration meets the termination condition, then the particle position of the last iteration is used as the first PID parameter.

[0017] Optionally, determining the individual extreme value of each particle includes obtaining the individual extreme value of the particle using the following formula:

[0018]

[0019] Here, f(x) is the objective function to be minimized, that is, to minimize the current difference between the output current and the desired current.

[0020] According to another aspect of the embodiments of this application, a PID parameter tuning device is also provided, characterized in that the device includes: a first acquisition module for acquiring the output current of a converter; a first calculation module for calculating the current control error of a PID controller based on the output current and the desired current; a first output module for inputting the current control error into a particle swarm optimization algorithm model and outputting a first PID parameter; and a first configuration module for configuring the first PID parameter as the PID control parameter of the PID controller.

[0021] According to another aspect of the embodiments of this application, a storage medium is also provided, the storage medium including a stored program that executes the above steps when the program is run.

[0022] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the programs stored in the memory.

[0023] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the steps in the above-described method.

[0024] This invention obtains the current control error of a PID controller into a particle swarm optimization (PSO) model, outputs the first PID parameter, and uses the first PID parameter as the PID control parameter of the PID controller. By dynamically adjusting the control parameter of the PID controller in real time through the current control error and the PSO algorithm, the shortcomings of traditional PID parameters that cannot be adjusted in real time are overcome. Furthermore, the PSO algorithm mainly searches for the optimal value using randomly generated numbers, without needing to adjust many parameters. It can also avoid falling into the local minimum value. The algorithm is simple and easy to implement. Attached Figure Description

[0025] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0026] Figure 1 This is a hardware structure block diagram of a computer according to an embodiment of the present invention;

[0027] Figure 2 This is a flowchart of a PID parameter tuning method according to an embodiment of the present invention;

[0028] Figure 3 This is the system topology in the implementation scenario of the present invention;

[0029] Figure 4 This is a circuit diagram showing a boost and buck state in DC-DC mode during the implementation of this invention.

[0030] Figure 5 This is a structural block diagram of a PID parameter tuning device according to an embodiment of the present invention;

[0031] Figure 6 This is a structural diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.

[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0034] Example 1

[0035] The method embodiment provided in Embodiment 1 of this application can be executed on a server, computer, mobile phone, or similar computing device. Taking running on a computer as an example, Figure 1 This is a hardware structure block diagram of a computer according to an embodiment of the present invention. For example... Figure 1 As shown, a computer may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the computer may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the construction of the computer described above. For example, the computer may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0036] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to a PID parameter tuning method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0037] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a computer's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0038] This embodiment provides a method for tuning PID parameters. Figure 2 This is a flowchart of a PID parameter tuning method according to an embodiment of the present invention, as shown below. Figure 2 As shown, the process includes the following steps:

[0039] S1, obtain the output current of the converter;

[0040] One way to obtain the output current is by setting sampling points and then using data acquisition tools or formulas to calculate it at those sampling points.

[0041] In one example, obtaining the output current of the converter includes: obtaining the output voltage of the converter and the circuit load; calculating the output current of the converter based on the output voltage and the circuit load, wherein the quotient of the output voltage divided by the circuit load is the output current.

[0042] S2, the current control error of the PID controller is calculated based on the output current and the desired current;

[0043] The difference between the actual current output value and the expected current value is the current control error of the PID controller.

[0044] S3, input the current control error into the particle swarm algorithm model, and output the first PID parameter;

[0045] Particle Swarm Optimization (PSO) is an evolutionary computational method based on swarm intelligence theory, proposed by Dr. Kennedy and Dr. Eberhart in 1995. Its concept originates from the foraging behavior of groups of birds and other organisms. When solving optimization problems using PSO, a search space is first assumed, in which each bird is considered a "particle" or "agent." Each particle possesses its own attributes during the search process: position and velocity (determining flight direction and distance), and a fitness value determined by an optimization function. Here, position represents a set of solutions, the form of which depends on the problem and can be a one-dimensional or multi-dimensional array; velocity is a crucial parameter used to change position. The fitness function is used to determine the quality of the current position based on this set of solutions. The position and velocity are continuously tuned to reach the optimal solution or a best-to-be-approximate solution. Each iteration is not completely random, but rather uses a better solution as a basis to find the next solution. Each particle remembers its previous best solution during the iteration process. This is the best solution found by the particle itself, called the individual best solution. The solution obtained is then compared with the individual best solutions of all particles.

[0046] In this example, the particle swarm optimization algorithm is used to calculate the PID parameters. By initializing the PID parameters (Kp, Ki, Kd) as a swarm of random particles (random solutions), the optimal solution found by each particle (i.e., the individual extreme value pBest) and the optimal solution found by the entire swarm (i.e., the global extreme value gBest) are tracked and the particles are iteratively updated to find the optimal solution for the PID parameters.

[0047] S4, the first PID parameters are configured as the PID control parameters of the PID controller.

[0048] The first PID parameter calculated by the particle swarm optimization algorithm is used as the PID control parameter of the PID controller to regulate and control the system.

[0049] In this example, the current control error of the PID controller is input into the particle swarm optimization (PSO) model, and the first PID parameter is output. The first PID parameter is used as the PID control parameter of the PID controller. The PID control parameter can be dynamically adjusted in real time through the current control error and the PSO algorithm, which overcomes the shortcomings of traditional PID parameters that cannot be adjusted in real time. Furthermore, the PSO algorithm mainly searches for the optimal value using randomly generated numbers, which does not require adjusting many parameters. At the same time, it can also avoid falling into the local minimum value. The algorithm is simple and easy to implement.

[0050] In one example, prior to obtaining the converter's output current, S1, the method further includes:

[0051] S01, obtain the converter voltage control error and the rate of change of voltage control error;

[0052] Voltage control error is the deviation between the actual output voltage value of the system control and the set voltage value, usually represented by e.

[0053] The rate of change of voltage control error = (voltage control error e2 at the next sampling time - voltage control error e1 at the previous sampling time) / sampling time interval t, i.e. d(e) / d(t), usually represented by ec.

[0054] S02, input the voltage control error and the rate of change of the voltage control error into the fuzzy algorithm model, and output the second PID parameters;

[0055] S03, configure the second PID parameter as the control parameter of the PID controller.

[0056] Fuzzy control is a control method that simulates human judgment and reasoning, originating from fuzzy logic. It transforms common sense and experience into control strategies and is a very important research area within intelligent control. Because it mimics human thinking, it can achieve good control results for some control objects that are difficult to model mathematically or are relatively complex. It is also suitable for solving control objects with time delays, time variations, and nonlinear problems. Compared with traditional control methods, fuzzy control has better robustness.

[0057] This example uses a fuzzy algorithm model to obtain the second PID parameters. It utilizes the fuzzy logic in the fuzzy algorithm and optimizes the PID parameters according to certain fuzzy rules. First, it determines the current control error e and the error change ec. Then, it performs fuzzy inference according to the given fuzzy rules. Finally, it defuzzifies the fuzzy parameters and outputs the PID control parameters, which include Kp, Ki, and Kd.

[0058] In this example, before using the particle swarm optimization algorithm to calculate the PID parameters, the fuzzy algorithm is used to perform preliminary optimization of the PID parameters, making the PID parameter tuning more accurate.

[0059] In one example, obtaining the converter voltage control error and the rate of change of voltage control error, S01, includes:

[0060] S011, obtain the output voltage of the converter in the current sampling period;

[0061] One way to obtain the output voltage is to set a voltage sampling point, and then use a voltage acquisition tool or a formula to calculate the actual output voltage value at the sampling point.

[0062] S012, calculate the difference between the output voltage and the desired voltage to obtain the current voltage control error;

[0063] The desired voltage is a preset voltage reference value. The difference between the actual output voltage and the preset desired voltage is the voltage control error e.

[0064] S013, obtain the voltage control error of the previous sampling cycle;

[0065] One way to obtain the previous voltage control error of the previous sampling period is to first calculate the voltage control error of each sampling period using the difference between the output voltage and the desired voltage, and then store the voltage control error of each sampling period. When calculating the rate of change of voltage control error later, the stored voltage control error of the historical sampling period can be directly called for calculation.

[0066] S014, the voltage control error change rate is calculated by dividing the difference between the current voltage control error and the previous voltage control error by the sampling period.

[0067] The difference between the voltage control error of the current sampling period and the voltage control error of the previous sampling period, divided by the sampling period t, is the rate of change of the current voltage control error.

[0068] This example demonstrates the calculation of converter voltage control error and voltage control error rate of change.

[0069] In one example, the voltage control error and the rate of change of the voltage control error are input into a fuzzy algorithm model, and the output of the second PID parameters includes:

[0070] Fuzzy quantization is performed on voltage control error, voltage control error change rate, and PID parameters to determine their respective fuzzy subsets {VB, B, M, MS, S, VS, ZO} and the universe of discourse corresponding to each fuzzy subset. Here, VB represents super large, B represents positive large, M represents positive medium, MS represents medium small, S represents positive small, VS represents super small, and ZO represents zero.

[0071] In this example, the voltage control error e, the voltage control error change rate ec, and the PID parameters (the PID parameters include three parameters: Kp, Ki, and Kd) are divided into seven fuzzy levels. The fuzzy language includes super-large, positive-large, positive-medium, medium-small, positive-small, super-small, and zero. The corresponding fuzzy subsets are {VB, B, M, MS, S, VS, ZO}.

[0072] Taking the voltage control error *e* as an example, assuming the initial set range of *e*, i.e., the feasible range of *e*, is -240 to 240, this range (-240 to 240) is divided into 8 parts, i.e., 8 universes of discourse. These are -240 to -180, -180 to -120, -120 to -60, -60 to 0, 0 to 60, 60 to 120, 120 to 180, and 180 to 240. Then, -180, -120, -60, 0, 60, 120, and 180 are represented by VS, MS, S, ZO, M, B, and VB, respectively. Similarly, fuzzy quantization can be performed on *ec* and the PID parameters Kp, Ki, and Kd.

[0073] Calculate the first membership value and corresponding first membership degree of the voltage control error based on the fuzzy subset and the universe of discourse, and calculate the second membership value and corresponding second membership degree of the voltage control error change rate.

[0074] For example, when e = 170, e belongs to B and VB, and e has two membership degrees. The percentage of e belonging to B (120) is (180-170) / (180-120) = 1 / 6, and the percentage belonging to VB (180) is (170-120) / (180-120) = 5 / 6. By linearly dividing the range of 120 to 180 that e falls into, the membership degree of e is determined according to the distance of e from B and VB. If e is greater than 180 (VB), the membership degree value is VB and the membership degree is 1, that is, e completely belongs to VB. Similarly, if e is less than -180 (NB), the membership degree value is NB and the membership degree is 1, that is, e completely belongs to NB.

[0075] Similarly, the second membership value and the corresponding second membership degree of the current voltage control error change rate can be calculated based on the fuzzy subset of ec and the corresponding universe of discourse of ec.

[0076] Obtain the fuzzy rule table of preset PID parameters;

[0077] The preset fuzzy rule table for PID parameters includes three fuzzy rule tables: Kp, Ki, and Kd. Each fuzzy rule table for PID parameters defines the membership values ​​of the PID parameters corresponding to the membership values ​​of e and ec, as shown in Table 1 below. Table 1 is a fuzzy rule table for the PID parameter Ki in one embodiment:

[0078]

[0079] The fuzzy rule table is searched to obtain the third membership value and third membership degree of the PID parameters corresponding to the first membership value and the second membership value, wherein the third membership degree is the product of the first membership degree and the second membership degree;

[0080] Assume that according to the above steps, the two membership values ​​of e are B and VB, and the two membership values ​​of ec are VS and MS. Among them, the membership degree of e belonging to B is a (a<1), the membership degree belonging to VB is (1-a), the membership degree of ec belonging to MS is b, and the membership degree belonging to VS is (1-b).

[0081] By searching the fuzzy rule table above, we can see that when e belongs to membership value B and ec belongs to membership value VS (i.e., row e is the intersection of B and column ec is the intersection of VS), the membership value of Kp is ZO, and the corresponding membership value is a*(1-b). Similarly, we can see that the other two membership values ​​of Kp belonging to ZO are a*b (i.e., row e is the intersection of B and column ec is the intersection of MS) ​​and (1-a)*(1-b) (i.e., row e is the intersection of VB and column ec is the intersection of VS). The membership value of Kp belonging to S is (1-a)*b (i.e., row e is the intersection of VB and column ec is the intersection of MS). Therefore, the sum of the membership values ​​of Kp belonging to ZO is a*b + a*(1-b) + (1-a)*(1-b), and the membership value of Kp belonging to S is (1-a)*b.

[0082] The second PID parameter is calculated by multiplying the third membership value by the third membership degree.

[0083] The output value, i.e., the solution of the PID parameters, is calculated by multiplying the membership degree by the corresponding membership value. That is, Kp = (a*b + a*(1-b) + (1-a)*(1-b))*ZO + (1-a)*b*S (Note that ZO and S in this formula are Kp, i.e., the membership degree value of the output value, not the membership degree value of the input value e or ec, which is set according to the fuzzy quantization of the PID parameters).

[0084] Similarly, Ki and Kd in the PID parameters can be calculated, and then Kp, Ki, and Kd can be plugged into the PID control parameters for control.

[0085] It should be noted that the interval range, the domain of discourse, and the values ​​in this example are only examples and can be set according to the specific implementation. This example does not impose any specific restrictions.

[0086] This example demonstrates how to input voltage control error and voltage control error change rate into a fuzzy algorithm model and output PID parameters.

[0087] In one example, after determining the universe of discourse corresponding to each fuzzy subset, the method further includes: determining the magnitude and sign of the voltage control error and the rate of change of the voltage control error; if the voltage control error is greater than or equal to a first preset value, the rate of change of the voltage control error is greater than or equal to a second preset value, and the voltage control error and the rate of change of the voltage control error have the same sign, then a first contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the first contraction factor is greater than 1; if the voltage control error is greater than or equal to the first preset value, the rate of change of the voltage control error is greater than or equal to the second preset value, and the voltage control error and the rate of change of the voltage control error have opposite signs, then a second contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the second contraction factor is equal to 1; if the voltage control error is less than the first preset value, and the rate of change of the voltage control error is greater than or equal to the second preset value, then a third contraction factor is used to adjust the universe of discourse of the voltage control error and the rate of change of the voltage control error, wherein the third contraction factor is greater than 1.

[0088] In this example, an adaptive universe of discourse (UDO) adjustment mechanism is added to the fuzzy PID controller. The adjustment ratio of the UDO is obtained based on the real-time input of the control system (i.e., voltage control error e and voltage control error rate of change ec). The shrinkage factor of the UDO is jointly determined by the error e and the rate of change ec. Let the shrinkage factor be β. If both e and ec are large and have the same sign, it indicates that the actual attitude angle of the control system differs significantly from the target attitude angle, and will continue to deviate from the target attitude angle, causing the error to gradually increase. Therefore, the shrinkage factor is set to a coefficient greater than 1, thereby expanding the output UDO to increase the controller's output. If e and ec are both large and have opposite signs, it means that the actual attitude angle of the control system is significantly different from the target attitude angle, but it is rapidly returning to the vicinity of the target attitude angle. Therefore, the shrinkage factor should be set to a coefficient equal to 1 to keep the universe of discourse unchanged and avoid system oscillations. If e is small and ec is large, it means that the actual attitude angle of the control system is not significantly different from the target attitude angle, but it will gradually deviate from the target attitude angle. Therefore, the shrinkage factor should be set to a coefficient greater than 1 to appropriately expand the output universe of discourse and increase the output of the controller so that the control system does not deviate from the target attitude angle.

[0089] In this example, the scaling factor is determined based on the magnitude and sign of the voltage control error and the rate of change of the voltage control error. Then, the initial basic universe of discourse is multiplied by its corresponding scaling factor to obtain a new universe of discourse. This allows the range of the universe of discourse to be adjusted in real time without changing the basic universe of discourse, making the algorithm iteration faster and more accurate, and the resulting optimized control parameters more effective.

[0090] In one example, the current control error is input into the particle swarm optimization model, and the output of the first PID parameters includes:

[0091] Generate a particle swarm and randomly assign a value to each particle in the particle swarm;

[0092] In this example, the particles are PID parameters Kp, Ki, and Kd. The particle swarm is initialized by randomly assigning values ​​to each particle, including random position and random velocity. The number of particles in the swarm is random, typically between 20 and 40.

[0093] Determine the individual extreme value of each particle and the global extreme value of the particle swarm, wherein the individual extreme value is the best value found by the particle so far, and the global extreme value is the best value found by the entire particle swarm so far.

[0094] Suppose we have a swarm of n particles in an s-dimensional space, where the i-th particle can be represented as an s-dimensional vector x. i =(x i1 ,x i2 ,…,x is ), i = 1, 2, 3, ..., n. The position of each particle is a solution, x i Substituting the values ​​into the objective function yields the fitness value, which is then used to determine the quality of the solution. The velocity vector of the i-th particle is V. i =(V i1 V i2 ,…,V is Assume the best position found by the i-th particle is P. i =(P i1 ,P i2 ,…,P is The optimal position found by the entire particle swarm is P. g =(P g1 ,P g2 ,…,P gs Wherein, the current best position of particle i, i.e., the individual extreme value, is:

[0095]

[0096] f(x) is the objective function to be minimized, that is, to minimize the current difference between the output current and the desired current.

[0097] The particle values ​​are iterated based on the individual extreme value and the global extreme value using the following formula:

[0098] V is (t+1)=V is (t)+c1r 1s (t)(P is(t)-x is (t))+c2r 2s (t)(P gs (t)-x is (t));

[0099] x is (t+1)=x is (t)+V is (t+1);

[0100] Where P is For individual extreme values; P gs V is the global extremum; is x is the velocity vector of the particle; is is the particle position; i is the number of particles, i = 1, 2, 3, ..., n, which can be customized according to the actual situation; s is the particle dimension, representing the spatial dimension of the particle search, i.e., the number of independent variables, s = 1, 2, 3, ..., s, in this example s is 3; learning factors c1 and c2 are non-negative constants; r1 and r2 are mutually independent pseudo-random numbers, following a [0, 1] distribution, increasing the randomness of the search; Vis ∈ [-vmax, vmax], where vmax is a constant;

[0101] Learning factors c1 and c2, also known as acceleration coefficients or acceleration factors, are defined as follows: c1 represents the weight of the particle's next action derived from its own experience, and c2 represents the weight of the particle's next action derived from the experience of other particles. c1 and c2 can be determined based on the situation or experience. Low values ​​cause the particle to hover outside the target area, while high values ​​cause the particle to cross the target area. The recommended value range is [0,4]. Typical values ​​are c1=c2=2, c1=1.6 and c2=1.8, and c1=1.6 and c2=2. Different values ​​are used for different problems. Generally, these two values ​​are adjusted by trial and error within a certain range.

[0102] Determine if the iteration meets the termination condition;

[0103] The termination condition for the iteration can be whether the maximum number of iterations has been reached or whether the global extremum satisfies the minimum bound.

[0104] If the iteration meets the termination condition, the particle position of the last iteration is used as the first PID parameter.

[0105] If the iteration reaches the maximum number of iterations or the global extremum satisfies the minimum limit, the iteration stops, and the particle position of the last iteration is configured as the first PID parameter.

[0106] In this example, the PID parameters are obtained iteratively using a particle swarm optimization algorithm. Initial random positions and velocities are assigned to all particles. Then, the position of each particle is advanced sequentially based on its velocity, the known optimal global position in the problem space, and the particle's known optimal position. As the computation progresses, by exploring and utilizing known advantageous positions in the search space, particles will gather or aggregate around one or more optimal points. Through this embodiment of the invention, the optimal PID parameters for the current situation can be obtained, thereby enabling real-time dynamic adjustment of the PID parameters.

[0107] The following is an explanation of an embodiment of the present invention through an implementation scenario.

[0108] This implementation scenario presents a PID parameter tuning method applied to a bidirectional DC-DC converter. The bidirectional DC-DC converter is a device that enables bidirectional flow of DC power, utilizing power electronics technology to convert DC voltage and current, thus achieving bidirectional energy transmission. Its power can flow not only from the input to the output but also from the output to the input, essentially acting as a high-speed bidirectional channel between two DC systems. Due to the time-varying and nonlinear characteristics of the switching converter in the bidirectional DC-DC converter, conventional PID control cannot be changed once the parameters Kp, Ki, and Kd are tuned. Therefore, conventional PID control is not well-suited for controlling bidirectional DC-DC converters with time-varying parameters and structure. This implementation scenario proposes a dual-loop control strategy for the bidirectional DC-DC converter, employing inner-loop particle swarm control and outer-loop fuzzy PI control to dynamically adjust the PID control parameters.

[0109] Reference Figure 3 , Figure 3 This is the system topology in the implementation scenario of the present invention. Figure 3 In this circuit, S1, S2, S3, and S4 are power switching devices; L is a fractional-order inductor in DC-DC mode; V1 and V2 are voltage sampling signals (Vfbd), Vref is the reference voltage compared with V1 and V2, and Iref is the reference current. This topology enables bidirectional current transmission, so voltage sampling points are set on both sides of the inductor. The corresponding control signals are fed back to different power switching transistors. Each time the control chip determines the operating mode, the selected sampling points are also determined accordingly.

[0110] Reference Figure 4 , Figure 4 This is a circuit diagram showing a boost and buck state in DC-DC mode during an implementation scenario of the present invention. Figure 4-1 Figures 4-2 and 4-3 illustrate the boost and depressurization processes in one direction, respectively. This topology is symmetrical; the boost and depressurization processes in the other direction are similarly illustrated and will be omitted here.

[0111] The control method used in this implementation scenario employs a dual-loop control, where the outer loop is voltage control and the inner loop is current control. The voltage loop uses variable universe of discourse fuzzy PI control, and the current loop uses particle swarm control.

[0112] By controlling the switching transistors to turn on and off via a chip, bidirectional energy transfer can be achieved. Once the energy transfer direction (from left to right or right to left) is determined, the circuit's operating mode (boost or buck) is also determined. There are four possible scenarios, each with different switching times and frequencies for the transistors. The method for determining the operating state is a dual-loop algorithm. First, the output voltage is sampled and compared with the desired voltage (using the outer loop algorithm), resulting in an intermediate variable. This variable is then compared with a desired current (using the inner loop algorithm), finally yielding the PID parameters. Finally, the chip outputs a control signal based on these parameters to control the switching of the transistors.

[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0114] Example 2

[0115] This embodiment also provides a PID parameter tuning device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0116] Figure 5 This is a structural block diagram of a PID parameter tuning device according to an embodiment of the present invention, as shown below. Figure 5 As shown, the device includes: a first acquisition module 100, a first calculation module 200, a first output module 300, and a first configuration module 400, wherein,

[0117] The first acquisition module 100 is used to acquire the output current of the converter;

[0118] The first calculation module 200 is used to calculate the current control error of the PID controller based on the output current and the desired current.

[0119] The first output module 300 is used to input the current control error into the particle swarm algorithm model and output the first PID parameters.

[0120] The first configuration module 400 is used to configure the first PID parameters as the PID control parameters of the PID controller.

[0121] Optionally, the device further includes: a second acquisition module for acquiring the converter voltage control error and the voltage control error change rate; a second output module for inputting the voltage control error and the voltage control error change rate into a fuzzy algorithm model and outputting a second PID parameter; and a second configuration module for configuring the second PID parameter as the control parameter of the PID controller.

[0122] Optionally, the second acquisition module includes: a first acquisition unit for acquiring the output voltage of the converter in the current sampling period; a first calculation unit for calculating the difference between the output voltage and the desired voltage to obtain the current voltage control error; a second acquisition unit for acquiring the previous voltage control error in the previous sampling period; and a second calculation unit for calculating the voltage control error change rate by dividing the difference between the current voltage control error and the previous voltage control error by the sampling period.

[0123] Optionally, the second output module includes: a fuzzy quantization unit, used to perform fuzzy quantization on the voltage control error, the rate of change of the voltage control error, and the PID parameters, to determine their respective corresponding fuzzy subsets {VB, B, M, MS, S, VS, ZO} and to determine the universe of discourse corresponding to each fuzzy subset, wherein VB represents super-large, B represents positive large, M represents positive medium, MS represents medium small, S represents positive small, VS represents super-small, and ZO represents zero; and a third calculation unit, used to calculate the first membership value of the voltage control error and its corresponding value based on the fuzzy subsets and the universe of discourse. The system comprises: a first membership degree, and a second membership degree value and corresponding second membership degree for calculating the voltage control error change rate; a third acquisition unit for acquiring a fuzzy rule table of preset PID parameters; a search unit for searching the fuzzy rule table to obtain the third membership degree value and third membership degree of the PID parameters corresponding to the first membership degree value and the second membership degree value, wherein the third membership degree is the product of the first membership degree and the second membership degree; and a fourth calculation unit for calculating the second PID parameter by multiplying the third membership degree value by the third membership degree.

[0124] Optionally, the second output module further includes: a first determining unit, configured to determine the magnitude and sign of the voltage control error and the rate of change of the voltage control error; a first adjusting unit, configured to adjust the domain of the voltage control error and the rate of change of the voltage control error using a first contraction factor if the voltage control error is greater than or equal to a first preset value, the rate of change of the voltage control error is greater than or equal to a second preset value, and the voltage control error and the rate of change of the voltage control error have the same sign, wherein the first contraction factor is greater than 1; a second adjusting unit, configured to adjust the domain of the voltage control error and the rate of change of the voltage control error using a second contraction factor if the voltage control error is greater than or equal to the first preset value, the rate of change of the voltage control error is greater than or equal to the second preset value, and the voltage control error and the rate of change of the voltage control error have opposite signs, wherein the second contraction factor is equal to 1; and a third adjusting unit, configured to adjust the domain of the voltage control error and the rate of change of the voltage control error using a third contraction factor if the voltage control error is less than the first preset value, and the rate of change of the voltage control error is greater than or equal to the second preset value, wherein the third contraction factor is greater than 1.

[0125] Optionally, the first output module includes: a generation unit, used to generate a particle swarm and randomly assign a value to each particle in the particle swarm; a second determination unit, used to determine the individual extreme value of each particle and the global extreme value of the particle swarm, wherein the individual extreme value is the best value found by the particle so far, and the global extreme value is the best value found by the entire particle swarm so far; and an iteration unit, used to iterate the particle values ​​according to the individual extreme value and the global extreme value using the following formula:

[0126] V is (t+1)=V is (t)+c1r 1s (t)(P is (t)-x is (t))+c2r 2s (t)(P gs (t)-x is (t));

[0127] x is (t+1)=x is (t)+V is (t+1);

[0128] Where P is For individual extreme values; P gs V is the global extremum; is x is the velocity vector of the particle; isdenoted as , where i is the particle position; i is the number of particles, i = 1, 2, 3, ..., n; s is the particle dimension, s = 1, 2, 3, ..., s; learning factors c1 and c2 are non-negative constants; r1 and r2 are mutually independent pseudo-random numbers, following a [0, 1] distribution; Vis ∈ [-vmax, vmax], where vmax is a constant;

[0129] The judgment unit is used to determine whether the iteration meets the termination condition; the configuration unit is used to configure the particle position of the last iteration as the first PID parameter if the iteration meets the termination condition.

[0130] Optionally, the second determining unit includes: a second determining subunit, used to obtain the individual extreme value of the particle using the following formula:

[0131]

[0132] Here, f(x) is the objective function to be minimized, that is, to minimize the current difference between the output current and the desired current.

[0133] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0134] Example 3

[0135] Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0136] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0137] S1, obtain the output current of the converter;

[0138] S2, the current control error of the PID controller is calculated based on the output current and the desired current;

[0139] S3, input the current control error into the particle swarm algorithm model, and output the first PID parameter;

[0140] S4, the first PID parameters are configured as the PID control parameters of the PID controller.

[0141] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0142] Embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0143] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0144] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0145] S1, obtain the output current of the converter;

[0146] S2, the current control error of the PID controller is calculated based on the output current and the desired current;

[0147] S3, input the current control error into the particle swarm algorithm model, and output the first PID parameter;

[0148] S4, the first PID parameters are configured as the PID control parameters of the PID controller.

[0149] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0150] Figure 6 This is a structural diagram of an electronic device according to an embodiment of the present invention, such as... Figure 6 As shown, it includes a processor 61, a communication interface 62, a memory 63, and a communication bus 64. The processor 61, the communication interface 62, and the memory 63 communicate with each other through the communication bus 64. The memory 63 is used to store computer programs, and the processor 61 is used to execute the programs stored in the memory 63.

[0151] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0152] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0153] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0154] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0155] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0156] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0157] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for tuning PID parameters, characterized in that, The method comprises: obtaining an output current of the converter; calculating a current control error of a PID controller according to the output current and a desired current; inputting the current control error into a particle swarm algorithm model to output a first PID parameter; configuring the first PID parameter as a PID control parameter of the PID controller; Before obtaining the output current of the converter, the method further comprises: obtaining a voltage control error and a voltage control error change rate of the converter; inputting the voltage control error and the voltage control error change rate into a fuzzy algorithm model to output a second PID parameter; configuring the second PID parameter as a control parameter of the PID controller; The step of inputting the voltage control error and the voltage control error change rate into the fuzzy algorithm model to output the second PID parameter comprises: fuzzy quantizing the voltage control error, the voltage control error change rate and the PID parameter to determine respective corresponding fuzzy subsets {VB, B, M, MS, S, VS, ZO} and determine respective corresponding domains, wherein VB represents super large, B represents positive large, M represents positive medium, MS represents medium small, S represents positive small, VS represents super small, and ZO represents zero; obtaining the second PID parameter according to the fuzzy subsets and the domains; After determining the domain corresponding to each fuzzy subset, the method further comprises: determining the size and sign of the voltage control error and the voltage control error change rate; if the voltage control error is greater than or equal to a first preset value, the voltage control error change rate is greater than or equal to a second preset value, and the voltage control error and the voltage control error change rate have the same sign, then a first contraction factor is used to adjust the domains of the voltage control error and the voltage control error change rate, wherein the first contraction factor is greater than 1; if the voltage control error is greater than or equal to the first preset value, the voltage control error change rate is greater than or equal to the second preset value, and the voltage control error and the voltage control error change rate have opposite signs, then a second contraction factor is used to adjust the domains of the voltage control error and the voltage control error change rate, wherein the second contraction factor is equal to 1; if the voltage control error is less than the first preset value, the voltage control error change rate is greater than or equal to the second preset value, then a third contraction factor is used to adjust the domains of the voltage control error and the voltage control error change rate, wherein the third contraction factor is greater than 1; multiplying the initial basic domain by the corresponding contraction factor to obtain a new domain.

2. The method of claim 1, wherein, The step of obtaining the voltage control error and the voltage control error change rate comprises: obtaining an output voltage of the converter in a current sampling period; calculating a difference between the output voltage and a desired voltage to obtain a current voltage control error; obtaining a last voltage control error in a last sampling period; calculating a voltage control error change rate according to a difference between the current voltage control error and the last voltage control error and dividing the difference by the sampling period.

3. The method of claim 2, wherein, The step of inputting the voltage control error and the voltage control error change rate into the fuzzy algorithm model to output the second PID parameter comprises: calculating a first membership value and a corresponding first membership of the voltage control error according to the fuzzy subset and the argument domain, and calculating a second membership value and a corresponding second membership of the voltage control error change rate; obtaining a fuzzy rule table of preset PID parameters; searching the fuzzy rule table to obtain a third membership value and a third membership of PID parameters corresponding to the first membership value and the second membership value, wherein the third membership is a product of the first membership and the second membership; multiplying the third membership value by the third membership to obtain the second PID parameters.

4. The method of claim 1, wherein, inputting the current control error into a particle swarm algorithm model to output the first PID parameters, including: generating a particle swarm and randomly assigning values to each particle in the particle swarm; determining an individual extreme value of each particle and determining a global extreme value of the particle swarm, wherein the individual extreme value is an optimal value found by the particle so far, and the global extreme value is an optimal value found by the entire particle swarm so far; iterating the particle value according to the individual extreme value and the global extreme value through the following formula: wherein is a local extremum; is a global extremum; is a velocity vector of a particle; is a position of a particle; i is the number of particles, i = 1, 2, 3, …, n, s is the dimension of a particle, s = 1, 2, 3, …, s; learning factors c1and c2are non-negative constants; r1and r2are mutually independent pseudo-random numbers, obeying [0, 1] distribution; Vis ∈ [-vmax, vmax], vmaxis a constant; determining whether the iteration meets a termination condition; if the iteration meets the termination condition, adopting a particle position of the last iteration as the first PID parameters.

5. The method of claim 4, wherein, determining the individual extreme value of each particle includes: obtaining the individual extreme value of the particle through the following formula: wherein f(x) is a minimized target function, that is, a current difference between an output current and an expected current is minimized.

6. A tuning device of PID parameters, characterized in that, The device is applied to the method of any one of claims 1-5, and the device includes: a first obtaining module configured to obtain an output current of a transformer; a first calculating module configured to calculate a current control error of a PID controller according to the output current and an expected current; a first output module configured to input the current control error into a particle swarm algorithm model to output first PID parameters; a first configuration module configured to configure the first PID parameters as PID control parameters of the PID controller.

7. A storage medium, characterized by The storage medium includes a stored program, wherein the program performs the method of any one of claims 1-5 when running.

8. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein, A processor, a communication interface, and a memory complete communication with each other through a communication bus; wherein: The memory is configured to store a computer program; The processor is configured to perform the method of any one of claims 1-5 by running the program stored in the memory.

Citation Information

Patent Citations

  • Brushless DC motor fuzzy PID control speed regulation system and method

    CN107508506A

  • Particle swarm fuzzy Smith temperature control method based on 3D printing nozzle

    CN111413863A

  • Control method of synchronous phase modifier excitation system based on fuzzy neural network PID control

    CN112799298A

  • Fuzzy self-tuning PID control algorithm for interleaved parallel bidirectional DC / DC converter

    CN113014098A

  • Unmanned life buoy optimal robust control method based on improved particle swarm optimization

    CN114967428A