Detailed explanation of PID control algorithm

1 Introduction

PID is the English abbreviation of Proportional (proportional), Integral (integral) and Differential (differential). As the name suggests, the PID control algorithm is an automatic control algorithm that combines proportional, integral and differential links. It is the most mature and widely used control algorithm in continuous systems. This control algorithm appeared in the 1930s and 1940s. It is suitable for occasions when the model of the controlled object is not clear. Actual operation experience and theoretical analysis show that when using this control law to control many industrial processes, satisfactory results can be obtained. The essence of PID control is to perform operations according to the functional relationship of proportion, integral, and differential according to the deviation value of the input signal, and the operation results are used to control the output.

Through the introduction of this paragraph, it is still difficult for people who have not studied the PID algorithm to understand what the PID algorithm can do? What kind of control effect can it exert? Some examples will be introduced below to explain in detail the role and control effect of understanding PID control. After understanding PID, we will deduce the PID algorithm in detail.

2. Switching control

2.1. Brief description of switch quantity

Now we have a task that requires controlling a heater to maintain the temperature of a pot of water at 50degrees. You should think it's simple. When the water temperature is less than 50 degrees, just turn on the heater and let it heat the water. If the water temperature is greater than 50 degrees, turn off the heater and stop heating the water. Isn't that enough? Yes, when there are no high accuracy requirements for the controlled variable (the controlled variable here is water temperature), it is indeed possible to use a switch such as turning on or off to control the controlled object.

2.2. Disadvantages of switching quantity

But what if the control object is a car? At the same time, if I want the car's speed to remain at 50km/h, can I still use switch control? For such questions, we can imagine that if the car's cruise control computer measures the vehicle speed at a certain time 45km/h. Because it was lower 50km/hthan the target speed, it immediately asked the engine to accelerate. As a result, the engine received a 100% full throttle command, and the car accelerated sharply 60km/h. At this time, because the speed is higher than , 50km/hthe computer issues a command to brake again! The ride experience obtained using such a control method is extremely poor. The end result of letting passengers use such a system is, of course, angry passengers.

Therefore, in most situations, it is too simple to use a switch value to control a physical quantity. Because the microcontroller and sensor are not infinitely fast, acquisition control requires time (when the sensor detects that the temperature has increased, the actual temperature is already much higher than the target temperature, and when the sensor detects that the temperature decreases, the actual temperature is already much lower than the target temperature) So there is a perceptual lag. And the controlled object has inertia. For example, if you unplug a heater, its residual heat (that is, the existence of thermal inertia) will still cause the water temperature to continue to rise for a period of time, so most of the time it cannot maintain a stable state.

2.3. Continuous control

Compared with the shortage of switching quantity, at this time, an algorithm is required that can quickly bring the physical quantity that needs to be controlled to near the target value. At the same time, it can foresee the changing trend of this quantity. It can eliminate some factors such as heat dissipation and resistance. Static errors caused by factors such as (for example, the heating speed is equal to the cooling speed. Even if there is a temperature difference, continuing to heat with constant power will not increase the temperature). As a result, mathematicians at that time invented this enduring algorithm, which is the PID control algorithm.

3. PID control

3.1. Control principle

The PID parameter is its name, so as the name suggests, the PID algorithm has three parameters, namely P (proportional), I (integral), and D (differential). In practical applications, these three parameters are generally defined as Kp (proportional). Ki (integral), Kd (differential). These three parameters correspond to different regulatory effects. Note: Although PID has three parameters, it allows us to use only one of them, or only two of them, or all three parameters can be used at the same time to form a control system.

3.1.1 Kp proportional adjustment

p in Kp is proportion, that is, proportional control. The control effect is the most obvious and the principle is the simplest. For example, the controlled variable here is water temperature. As a controlled variable, water temperature has the current temperature value and the target temperature value we expect.
When the difference between the current temperature value and the target temperature value is not large, let the heater heat gently .
If for some reason the temperature drops a lot, turn the heater on a little harder .
If the current temperature is much lower than the target temperature, turn on the heater at full power to bring the water temperature to near the target temperature as soon as possible.

This is the proportional control function of P. Compared with the switching control method, it is obviously more elegant. The larger P is, the more radical the adjustment effect is, and the smaller P is, the more conservative the adjustment effect is. With insufficient control of the P link, the system cannot reach stability, and the water temperature still hangs around 50 degrees.

3.1.2 Kd differential adjustment

Please add image description
d in Kd is differential, that is, differential control. As mentioned before, stability cannot be achieved using only the proportional control system, and the temperature still fluctuates. This is similar to a weight hanging on a spring. When the spring and weight are in a balanced position, pull the spring hard and then let go. At this point it will vibrate. Because the resistance is very small, it can continue to oscillate for a long time before regaining its equilibrium position.
But if the spring and weight are immersed in water, also when the spring and weight are in the equilibrium position, pull hard on the spring and then let go. In this case, it only takes a short time for the spring and weight to return to the equilibrium position due to the resistance of the water.

So we need a control effect to make the change speed of the controlled physical quantity tend to 0, which is similar to the damping effect of water on the spring mentioned above. Because, as the closer to the target, the control effect of P becomes smaller. The closer you get to the target, the gentler the action of P. However, there are many internal or external factors that cause the control volume to swing in a small range.

Therefore, the function of D in PID is to make the speed of the physical quantity tend to 0. Whenever the controlled quantity shakes, D will exert force in the opposite direction and try its best to brake the change (jitter). The larger D, the stronger the braking (damping) force in the opposite direction.

In fact, with proportional and differential control, the entire system can be stable. In this case, why is integral control needed? Let me continue with this question.

3.1.3 Ki integral adjustment

i in Ki is integral, that is, integral control. As mentioned earlier, with proportional and differential control, the entire system can be stable. Now, if the heating device that only uses proportional and differential control is brought to a very cold place to boil water, the water needs to be boiled to 50 degrees. Okay, now,
under the action of P proportion control, the water temperature will slowly increase. It was not until the water temperature rose to 45 degrees that a problem was discovered. The water temperature could not rise any higher and stayed at 45 degrees. Why is this? Now let’s analyze this problem together, and the results are as follows.

Because the water temperature has reached 45 degrees, Brother P thinks like this: I am very close to the target, I just need to heat it slightly. But the weather is too cold, and the speed of water dissipation is equal to the speed of gentle heating controlled by P. At this time, Brother D thought this way: heating and heat dissipation are equal, the temperature does not fluctuate, and I don’t seem to need to adjust. As a result, the water temperature stays at 45 degrees forever and cannot continue to rise to 50 degrees.

According to common sense, we all know that for the same heating rate and heat dissipation rate ( this is the steady-state error, the steady-state error occurs when the system transitions from a steady state to a new steady state, or when the system is disturbed and rebalanced. deviation ), but in order to continue to increase the temperature, the heating power should be further increased ( eliminating the steady-state error ). But this will encounter another problem. This problem is how much power should be increased?

Scientists have already thought about this problem and set an integral amount. As long as the deviation exists, the deviation will be continuously integrated (accumulated) and reflected in the adjustment intensity.
In this way, even if there is not much difference between 45 degrees and 50 degrees, the time will change as time goes by. As long as the target temperature has not been reached, the integral will continue to increase. At this time, the control system will slowly realize that the target temperature has not been reached and it is time to increase the power.
After reaching the target temperature, assuming that the temperature does not fluctuate, the integrated value will not change (because the integration of 0 continues, the result will still be 0). At this time, the heating power is still equal to the cooling power, but the temperature is steadily at 50 degrees.

The larger the I value, the larger the coefficient multiplied during integration, and the more obvious the integration effect. Therefore, the role of I is to reduce the error under static conditions and make the controlled physical quantity as close as possible to our set target value. I need to pay attention to one issue when using it: the points limit needs to be set. Because when heating is just started, the current temperature must be quite different from our set temperature value. If the integral limit is not set, the integral will be too large, and ultimately the system will be difficult to control.

3.2 PID step response curve

The working methods and principles of the three types of PID adjustments have been explained before. Now let’s observe the adjustment response effects of the three types of adjustments.
Please add image description

4. Application scenarios

From the above introduction, we can know that PID can play its role in situations where a controlled physical quantity needs to be stably controlled, such as maintaining balance, stabilizing temperature, stabilizing speed, etc. Typical applications include attitude control of rockets, aiming control of ship artillery, cruise control of cars, engine speed control, steering of autonomous vehicles, hover control of drones, camera stabilizers, camera gimbals, and liquids in industry. Bit control and so on.

5. Derivation of PID formula

Before this, we have analyzed the principle of PID control in detail and have a certain understanding of PID control theory, so let's specifically analyze the derivation and discretization of PID mathematical expressions.

5.1 Control system definition

In the control system, the control deviation e refers to the result of comparing the set value w with the actual output value y, that is,

e = w − y e = w-y e=wy

The so-called PID regulator is a type of regulator that forms the control quantity according to the linear combination of the proportion (P), integral (I), and differential (D) operations of the deviation e, as shown in the figure below.
Please add image description
As mentioned earlier, in practical applications, the structure of the PID regulator can be flexibly changed according to the characteristics and control requirements of the controlled object, and some of the links are taken to form the control law to form various controllers. For example, a proportional (P) regulator, a proportional-integral regulator (PI), or a proportional-derivative regulator (PD).

5.2 Analysis of various types of regulators

5.2.1 Proportional regulator

The control law of the proportional regulator is

u = K e + u 0 u=Ke+u_{0}u=When+u0

KK in the expressionK is the proportion coefficient (i.e. Kp in the figure),u 0 u0u 0 is the benchmark of the control quantity, that is,e = 0 e=0e=Control function at 0 (such as the initial opening of the valve, reference electrical signal, etc.). The advantages of proportional control are that it is simple (it is the simplest regulator), but it is fast and can adjust the deviationeee makes an immediate response. Once the deviation occurs, the regulator takes effect immediately to make the controlled quantity change in the direction of reducing the deviation.
The control effect of the proportional regulator depends on the proportional coefficientKKK K K The larger K is, the stronger the effect of the regulator is, which is beneficial to reducing the static difference of the system. For control objects with self-balancing properties, it is difficult for the proportional regulator to eliminate the system static error. In addition, the proportional coefficientKKK cannot be increased infinitely. WhenKKWhen the K value is too large, the dynamic performance of the system will deteriorate, causing oscillation of the control system, and in severe cases, the system will be out of control.

5.2.2 Proportional integral regulator

On the basis of the proportional regulator, an integral link is added to form a proportional-integral regulator (PI) whose control law is:

u = K ( e + 1 T i ∫ 0 t e d t ) + u 0 u=K(e+\frac{1}{T_{i}}\int_0^t e dt)+u_{0} u=K(e+Ti10tedt)+u0

In the expression T i T_{i}Tiis called the integration time, subscript iii means integral. The integral link in the PI regulator has a cumulative effect on the deviation. As long as the deviationeeIf e is not zero, it will affect the control quantity through cumulative effect and reduce the deviation. Until the deviation reaches zero, the control effect will no longer change and the system will reach a steady state. Therefore, the addition of the integral link helps eliminate the static error of the system.
Integration timeT i T_{i}TiThe smaller it is, the stronger the integration link is. Integration time T i T_{i}TiThe larger it is, the weaker the integration link is. This is beneficial to reducing the overshoot of the system and improving the stability of the system, but the process of eliminating the static error of the system will be slower.
Integration time T i T_{i}TiThe selection can be based on the characteristics of the controlled object. For controlled objects such as pipeline pressure and flow rate with little hysteresis, a smaller integration time T i T_{i} can be selected.Ti, for objects with strong hysteresis such as temperature, the optional area is larger T i T_{i}Ti

5.2.3 Proportional-integral-derivative regulator

By adding a differential link on the basis of the proportional integral regulator, a proportional integral differential regulator (PID) is formed. The control law is:

u = K ( e + 1 T i ∫ 0 t e d t + T d d e d t ) + u 0 u=K(e+\frac{1}{T_{i}}\int_0^t e dt+T_{d}\frac{de}{dt})+u_{0} u=K(e+Ti10tedt+Tddtof e)+u0

T d T_{d} in the expressionTdis called differential time, subscript ddd refers to differential, and the output of the added differential link is

u = K ( 0 + 0 + T d d e d t ) + 0 u=K(0+0+T_{d}\frac{de}{dt})+0 u=K(0+0+Tddtof e)+0

i.e. ud = KT ddedt i.e. u_{d}=KT_{d}\frac{de}{dt}Immediately _d=KTddtof e

The differential link can respond promptly to any changes in the deviation and produce a control effect to adjust the output of the system and prevent changes in the deviation. The faster the deviation changes, the differential link output ud u_{d}udThe larger the value, the greater the feedback correction amount.
The differential effect helps to reduce system overshoot, overcome system oscillation, and stabilize the system. The differential link speeds up the system action and reduces the adjustment time, thus improving the system dynamic performance.

6. Digitization of PID algorithm

The digital computer control system is essentially a sampling control system. It can only calculate measurements based on the deviation value at the sampling time. Therefore, we need to discretize the formula of the proportional integral differential regulator and replace the differential equation of the continuous system with a digital difference equation.

This typical example is the digital oscilloscope that is widely used today. For a digital oscilloscope, it cannot directly quantify analog signals. So if you need to quantify an analog signal such as a sine wave, how does a digital oscilloscope do it? The digital oscilloscope can collect a voltage value on the sine wave signal at a certain time through the analog-to-digital converter (ADC). Then when the sampling is continued at a certain time at a certain rate, a series of sampling points can be obtained. These sampling points That is, a set of voltage values ​​that constitute a sine wave signal. Convert these voltage values ​​into screen coordinates, and connect these coordinates using line segments to obtain an image close to the sine wave signal. Therefore, as long as the sampling rate is higher (the sampling rate tends to (near infinity), the closer the obtained image is to the true continuity. This is the idea of ​​limit and differential in mathematics .
Please add image description

6.1 Digitization

In the control system, it is assumed that the computer every time Δt ΔtΔt collects the control signal once and sends the control signal once to the actuator of the controlled object, Δt ΔtΔtWe generally useTTT represents, called the sampling period.
Suppose at the sampling timet = i ⋅ Δ t = i ⋅ T ( i is the sampling number, i = 0 , 1 , 2 , 3 , . . . , n ) t=i·Δt=i·T (i is the sampling number ,i=0,1,2,3,...,n)t=iΔt=iT ( i is the sampling sequence number ,i=0,1,2,3,...,n ) , here the sampling numberiii is the number of sampling, sampling periodTTT is the time each sampling lasts (takes), sot = i ⋅ Δ t = i ⋅ T t=i·Δt=i·Tt=iΔt=iT is to add up the time of each sample to get the total duration from the beginning to the present, which is similar to integrating time.
The deviation value ise ( i T ) e(iT)e ( i T ),简记为e ( i ) e(i)e ( i )no noe i , refers to the deviation value of the current time (sampling sequence number x period = current time).
The control quantity isu ( i T ) u(iT)u ( i T )简记为u ( i ) u(i)u ( i ) oruiuiu i , that is, we get the following

e i = e ( i ) = e ( i T ) , u i = u ( i ) = u ( i T ) e_{i} = e(i)=e(iT), u_{i} = u(i)=u(iT) ei=e ( i )=e(iT),ui=u(i)=u(iT)

When the sampling period TTWhen T is small enough, numerical calculation methods can be used to infinitely approximate the integral and differential terms of PID, and the following approximation can be obtained

Points part

∫ 0 t e d t ≈ ∑ j = 0 i e ( j ) ⋅ Δ t \int_0^t e dt \approx \sum_{j=0}^i e(j) · Δt 0tedtj=0ie ( j ) Δt

即 ≈ ∑ j = 0 i e ( j ) ⋅ T 即 \approx \sum_{j=0}^i e(j) · T Right nowj=0ie ( j ) T

即 ≈ T ⋅ ∑ j = 0 i e ( j ) 即 \approx T·\sum_{j=0}^i e(j) Right nowTj=0ie ( j )

即 ≈ T ⋅ ∑ j = 0 i e j 即 \approx T·\sum_{j=0}^i e_{j} Right nowTj=0iej

Differential part

d e ( t ) d t ≈ Δ e Δ t \frac{de(t)}{dt} \approx \frac{Δe}{Δt} dtd e ( t )ΔtΔe _

即 ≈ e ( i ) − e ( i − 1 ) Δ t 即 \approx \frac{e(i)-e(i-1)}{Δt} Right nowΔte ( i )e ( i1)

即 ≈ e ( i ) − e ( i − 1 ) T 即 \approx \frac{e(i)-e(i-1)}{T} Right nowTe ( i )e ( i1)

即 ≈ e i − e i − 1 T 即 \approx \frac{e_{i}-e_{i-1}}{T} Right nowTeiei1

So when the sampling period TTWhen T is small enough, the controlled process is very close to the continuous control process. This situation is called quasi.

6.2 Positional PID

Now we substitute the expressions of the integral and differential parts that have been digitized in the previous point into the expression below, replacing the integral and differential parts of the expression below

u = K ( e + 1 T i ∫ 0 t e d t + T d d e d t ) + u 0 u=K(e+\frac{1}{T_{i}}\int_0^t e dt+T_{d}\frac{de}{dt})+u_{0} u=K(e+Ti10tedt+Tddtof e)+u0

First replace the expression of the integral part as follows

u i = K ( e i + 1 T i ⋅ T ⋅ ∑ j = 0 i e j + T d d e d t ) + u 0 u_{i}=K(e_{i}+\frac{1}{T_{i}}·T·\sum_{j=0}^i e_{j}+T_{d}\frac{de}{dt})+u_{0} ui=K(ei+Ti1Tj=0iej+Tddtof e)+u0

Then replace the expression in the differential part as follows

u i = K ( e i + 1 T i ⋅ T ⋅ ∑ j = 0 i e j + T d ⋅ e i − e i − 1 T ) + u 0 u_{i}=K(e_{i}+\frac{1}{T_{i}}·T·\sum_{j=0}^i e_{j}+T_{d}·\frac{e_{i}-e_{i-1}}{T})+u_{0} ui=K(ei+Ti1Tj=0iej+TdTeiei1)+u0

Finally, sort it out and get

u i = K [ e i + T T i ⋅ ∑ j = 0 i e j + T d T ⋅ ( e i − e i − 1 ) ] + u 0 u_{i}=K[e_{i}+\frac{T}{T_{i}}·\sum_{j=0}^i e_{j}+\frac{T_{d}}{T}·(e_{i}-e_{i-1})]+u_{0} ui=K[ei+TiTj=0iej+TTd(eiei1)]+u0

Since the output value of the expression ui u_{i}uiCorresponds one-to-one with the position of the actuator (such as valve opening), so this formula is usually called the digital position PID control formula.
In the control system, if the actuator uses a regulating valve, the control quantity corresponds to the valve opening, which represents the position of the actuator. At this time, the controller should use a digital position PID control algorithm.

6.3 Incremental PID

What is incremental PID? From the previous derivation, we know that the positional PID controller can output a specific size of control quantity to control the opening and closing angle of the valve. For example, the output of 30 degrees controls the valve to open 30 degrees, and the output of 0 degrees controls the valve to close. This control quantity is called absolute control. quantity. The concept opposite to absolute control volume is relative control volume. The so-called relative control volume means that the control value output by PID is a relative value. For example, the output of 30 degrees controls the valve to open 30 degrees, and the output of -30 degrees controls the valve to close, so the relative value is The amount of change from the previous value. Based on the idea of ​​relative values, incremental PID can be derived from positional PID.

According to the previous positional PID derivation, it can be seen that ui u_{i}uiis (note T i T_{i}Tisubscript iii refers to the integral, not the sampling index)

u i = K [ e i + T T i ⋅ ∑ j = 0 i e j + T d T ⋅ ( e i − e i − 1 ) ] + u 0 u_{i}=K[e_{i}+\frac{T}{T_{i}}·\sum_{j=0}^i e_{j}+\frac{T_{d}}{T}·(e_{i}-e_{i-1})]+u_{0} ui=K[ei+TiTj=0iej+TTd(eiei1)]+u0

Root ui u_{i}uiKachiui − 1 u_{i-1}ui1is (note T i T_{i}Tisubscript iii refers to the integral, not the sampling index, and does not participate in the operation)

u i − 1 = K [ e i − 1 + T T i ⋅ ∑ j = 0 i − 1 e j + T d T ⋅ ( e i − 1 − e i − 2 ) ] + u 0 u_{i-1}=K[e_{i-1}+\frac{T}{T_{i}}·\sum_{j=0}^{i-1} e_{j}+\frac{T_{d}}{T}·(e_{i-1}-e_{i-2})]+u_{0} ui1=K[ei1+TiTj=0i1ej+TTd(ei1ei2)]+u0

Shojo style ui u_{i}uisum ui − 1 u_{i-1}ui1Substitute the expression below

Δ ui = ui − ui − 1 Δu_{i}=u_{i}-u_{i-1}Δ ui=uiui1

Available

Δ u i = K [ e i + T T i ⋅ ∑ j = 0 i e j + T d T ⋅ ( e i − e i − 1 ) ] + u 0 − K [ e i − 1 + T T i ⋅ ∑ j = 0 i − 1 e j + T d T ⋅ ( e i − 1 − e i − 2 ) ] + u 0 Δu_{i}=K[e_{i}+\frac{T}{T_{i}}·\sum_{j=0}^i e_{j}+\frac{T_{d}}{T}·(e_{i}-e_{i-1})]+u_{0} - K[e_{i-1}+\frac{T}{T_{i}}·\sum_{j=0}^{i-1} e_{j}+\frac{T_{d}}{T}·(e_{i-1}-e_{i-2})]+u_{0} Δ ui=K[ei+TiTj=0iej+TTd(eiei1)]+u0K[ei1+TiTj=0i1ej+TTd(ei1ei2)]+u0

The summation part is subtracted and the remaining TT iei \frac{T}{T_{i}}e_{i}TiTei

Δ u i = K [ e i − e i − 1 + T T i e i + T d T ( e i − 2 e i − 1 + e i − 2 ) ] Δu_{i}=K[e_{i}-e_{i-1}+\frac{T}{T_{i}}e_{i}+\frac{T_{d}}{T}(e_{i}-2e_{i-1}+e_{i-2})] Δ ui=K[eiei1+TiTei+TTd(ei2e _i1+ei2)]

Will KKExpand K to each term, we get

Δ ui = K ei − K ei − 1 + KTT iei + KT d T ( ei − 2 ei − 1 + ei − 2 ) Δu_{i}=Ke_{i}-Ke_{i-1}+K\frac{ T}{T_{i}}e_{i}+K\frac{T_{d}}{T}(e_{i}-2e_{i-1}+e_{i-2})Δ ui=K eiK ei1+KTiTei+KTTd(ei2e _i1+ei2)

Expand again

Δ u i = K e i − K e i − 1 + K T T i e i + K T d T e i − 2 K T d T e i − 1 + K T d T e i − 2 Δu_{i}=Ke_{i}-Ke_{i-1}+K\frac{T}{T_{i}}e_{i}+K\frac{T_{d}}{T}e_{i}-2K\frac{T_{d}}{T}e_{i-1}+K\frac{T_{d}}{T}e_{i-2} Δ ui=K eiK ei1+KTiTei+KTTdei2K _TTdei1+KTTdei2

Merge similar items again

Δ u i = ( K + K T T i + K T d T ) e i + ( − K − 2 K T d T ) e i − 1 + ( K T d T ) e i − 2 Δu_{i}=(K+K\frac{T}{T_{i}}+K\frac{T_{d}}{T})e_{i}+(-K-2K\frac{T_{d}}{T})e_{i-1}+(K\frac{T_{d}}{T})e_{i-2} Δ ui=(K+KTiT+KTTd)ei+(K2K _TTd)ei1+(KTTd)ei2

Will KKK is put outside the expression, and we get

Δ u i = K ( 1 + T T i + T d T ) e i + K ( − 1 − 2 T d T ) e i − 1 + K ( T d T ) e i − 2 Δu_{i}=K(1+\frac{T}{T_{i}}+\frac{T_{d}}{T})e_{i}+K(-1-2\frac{T_{d}}{T})e_{i-1}+K(\frac{T_{d}}{T})e_{i-2} Δ ui=K(1+TiT+TTd)ei+K(12TTd)ei1+K(TTd)ei2

Order again

d 0 = K ( 1 + T T i + T d T ) , d 1 = − K ( 1 + 2 T d T ) , d 2 = K ( T d T ) d_{0}=K(1+\frac{T}{T_{i}}+\frac{T_{d}}{T}), d_{1}=-K(1+2\frac{T_{d}}{T}), d_{2}=K(\frac{T_{d}}{T}) d0=K(1+TiT+TTd),d1=K(1+2TTd),d2=K(TTd)

So use d 0 , d 1 , d 2 d_{0},d_{1},d_{2}d0,d1,d2Δ ui Δ_{i}Δ uisimplified to

Δ ui = d 0 ei + d 1 ei − 1 + d 2 ei − 2 Δu_{i}=d_{0}e_{i}+d_{1}e_{i-1}+d_{2}e_{i -2}Δ ui=d0ei+d1ei1+d2ei2

The incremental algorithm only needs to maintain the deviation values ​​of the three moments before the current moment. The incremental PID algorithm has certain advantages compared with the positional PID algorithm. The calculation of each output of the positional algorithm uses the accumulated value of past deviations.

∑ j = 0 i e j \sum_{j=0}^i e_{j} j=0iej

It is easy to produce large accumulated errors, while the incremental algorithm only needs to calculate the increment. When there is a calculation error or insufficient accuracy, it will have less impact on the calculation of the control quantity.

7. Summary

Through the previous derivation process, we have a detailed understanding of the derivation and discretization of PID, but here we still need to think about two issues.

Question 1 : Why is the integration time T i T_{i} in the PID algorithm formula?Tiand differential time T d T_{d}TdOne in the denominator and one in the numerator?
Please add image description
There is mainly a dimensional consideration.

The integral part is the proportional gain multiplied by the error, then multiplied by the time unit divided by the integration time constant, so the integration time constant T i T_{i}TiPut in the denominator and the time unit that the integral needs to be multiplied by to cancel, so that the dimension of the sub-integral is still the proportional gain times the error. (For example, for speed vvv times timettt gets the distancesss , the dimension at this time changes from speed to distance. At this time, the integration timeT i T_{i}Tiplaced into the denominator, it will end up with time ttt cancels out, and the final dimension is still speed. )

The same is true for the differential part. Multiply the proportional gain by the error, then multiply by the differential time constant, divide by the time unit, put the differential time T in the numerator, and offset it by the time unit by which the differential needs to be divided. The dimension of the differential is still the proportional gain divided by to error.

As for the proportional gain K p K_{p}KpThe dimension is determined by the physical relationship and mathematical model between error and output.

Question 2 : Why in the derivation of the discretization of the PID integral part, the error e ( j ) e(j)e ( j ) also needs to be multiplied by the sampling periodΔ t ΔtΔt is accumulated again?

This is because the essence of integral is to calculate the area and finely divide the complete area of ​​an irregular shape into several lengths ( yyy- axis value) is different, the width (sampling timeΔt ΔtΔt ) the same rectangle, and then accumulate the areas of these rectangles to finally obtain the complete area of ​​the irregular shape, such as the instantaneous velocity vvv versus timettt is integrated, and the distancesss , the size of the area after integration corresponds to the distance of the journey, as shown in the figure below.

Please add image description
So in order to make the error e ( j ) e(j)The cumulative effect of e ( j ) approaching the integral must be multiplied byΔ t ΔtΔt

Question 3 : TT in PID discretization derivation expressionT T i T_{i} Ti T d T_{d} TdThe difference?

Both are used to describe time, but they are completely different, TTT represents the sampling timeΔt ΔtΔ t,而T i T_{i}Ti T d T_{d} TdIt is a to-be-determined constant, which is used to adjust the stability of the system so that the system can be adjusted according to different application scenarios.

Guess you like

Origin blog.csdn.net/jf_52001760/article/details/129424139