About dsp28335 phase-shifted full-bridge fuzzy adaptive PID control algorithm
[Copy link]
In order to get rid of the mutual influence of various factors in the classic PID algorithm, the proportional, integral and differential effects can be represented by proportional factor P, integral factor I and differential factor D respectively, which are not related to each other and do not affect each other. The calculation formula is as follows:
△u(n)=P*[e(n)―e(n-1)]+1/I*e(n)*Kii+D*[e(n)―2*e(n-1)+e(n-2)]
Where:
P, I and D are proportional factor, integral factor and differential factor respectively, Ki is the integral action intensity factor Where: A is the deviation limit. That is, when the absolute value of the deviation |e| is close to A to A/2, the integral action gradually increases from 0.2 to 100%.
When the deviation |e|>A, the integral does not fully work. Compared with the classic PID algorithm, the effects of the proportional factor P, integral factor I and differential factor D are similar to those of the proportional coefficient Kp, integral time Ti and differential time Td. The larger the P value, the stronger the proportional effect, and the smaller the P value, the weaker the proportional effect; the smaller the I value, the stronger the integral effect, and the larger the I value, the weaker the integral effect; the larger the D value, the stronger the differential effect, and the smaller the D value, the weaker the differential effect. However, there are obvious differences: ⑴ The proportional factor P, integral factor I and differential factor D are similar to the proportional factor Kp, integral time Ti and differential time Td. The larger the P value, the stronger the proportional effect, and the smaller the P value, the weaker the proportional effect; the smaller the I value, the stronger the integral effect, and the smaller the D value, the weaker the differential effect.
⑵ The values of the integral factor I and the differential factor D are very different from the integral time Ti and the differential time Td, and cannot be set based on experience;
⑶ The integral action intensity factor Kii is related to the deviation and has fuzzy adaptive ability, which can automatically adjust the strength of the integral action according to the size of the deviation. Establish fuzzy control rules based on the size and nature of the deviation. When the deviation is large or large, enhance the control action to eliminate the deviation as soon as possible; when the deviation is small, reduce the control action to reduce the fluctuation caused by measurement error.
Set △T1= Range*1.0%
Set △T2= Range*0.25%
When the deviation |e| is between △T1 and A and |e|>A, calculate according to the formula. When the deviation |e| is between △T1 and △T2, increase the effects of P and I, weaken the effect of D, and make
the following corrections to the PID parameters:
P'=P*(1+(|e|-△T2)/(△T1-△T2)*c1)
I'=I*(1-(|e|-△T2)/(△T1-△T2)*c2)
D'= D*(1-(|e|- △T2)/(△T1- △T2)*c3)
Use the new P', I' and D' to replace P, I and D in the formula calculation.
The coefficients c1, c2 and c3 are related to the number of times the deviation |e| is between △T1 and △T2, and the range is 0.05~0.50. When the deviation |e| is between 0 and △T2, the adjustment effects are weakened and the PID parameters are modified as follows:
P'=P*(1+(|e|-△T2)/△T2*0.20)
I'=I*(1-(|e|-△T2)/△T2*0.10)
D'= D*(1+(|e|-△T2)/△T2*0.20)
When the deviation |e| oscillates between 0 and △T1, the P, I, and D parameters are automatically modified within the range of ±0.25 according to the oscillation characteristics.
Its control process. First, according to the initial values of proportional factor P, integral factor I and differential factor D, set the deviation limits △T1, △T2 and A, assume that the set value is r, the measured value is y, initialize e(n-1)=0, e(n-2)=0, and then calculate the deviation e(n)=rn-yn. According to the size of the deviation e(n), use the formula to automatically calculate Kii and adjust the values of P, I and D to calculate the PID output. If the sampling period is reached, enter the next cycle to recalculate.
The specific implementation in the program is as follows:
Fuzzy_pid.E0 = V_Set - V_Now;
if( Fuzzy_pid.E0<= Fuzzy_pid.A /2)
Fuzzy_pid.Kii = 1;
else
Fuzzy_pid.Kii = 1-0.8*(2*fabss(Fuzzy_pid.E0)-Fuzzy_pid.A)/Fuzzy_pid.A;
if(Fuzzy_pid.E0 >=Fuzzy_pid.T2&&Fuzzy_pid.E0 <=Fuzzy_pid.T1 )
{
Fuzzy_pid.P1 = Fuzzy_pid.P*(1+(fabss(Fuzzy_pid.E0)-Fuzzy_pid.T2)/
(Fuzzy_pid.T1-Fuzzy_pid. T2)*Fuzzy_pid.C1);
Fuzzy_pid.I1 = Fuzzy_pid.I*(1-(fabss(Fuzzy_pid.E0)-Fuzzy_pid.T2)/
(Fuzzy_pid.T1-Fuzzy_pid.T2)*Fuzzy_pid.C2);
Fuzzy_pid.D1 = Fuzzy_pid.D*(1- (fabss(Fuzzy_pid.E0)-Fuzzy_pid.T2)/
(Fuzzy_pid.T1-Fuzzy_pid.T2)*Fuzzy_pid.C3);
Fuzzy_pid.P = Fuzzy_pid.P1;
Fuzzy_pid.I = Fuzzy_pid.I1;
Fuzzy_pid.D = Fuzzy_pid.D1;
}
Fuzzy_pid.SUM+=
Fuzzy_pid.P*(Fuzzy_pid.E0-Fuzzy_pid.E1)+
1/Fuzzy_pid.I*Fuzzy_pid.E0*Fuzzy_pid.Kii+
Fuzzy_pid.D*(Fuzzy_pid.E0-2*Fuzzy_pid.E1+Fuzzy_pid.E2) ;
|