From the basic principle of PID control, we know that the introduction of differential signals can improve the dynamic characteristics of the system, but there is also a problem, that is, it is easy to introduce high frequency interference and especially show the deficiency of differential term when the deviation disturbance is abrupt. In order to solve this problem, low-pass filtering is introduced to solve this problem.

**1****、The basic idea of incomplete differential**

The differential term has the risk of introducing high frequency interference, but if the low-pass filter is added to the control algorithm, the performance of the system can be improved. One way is to add a first order low pass filter to the PID algorithm. This is called incomplete differential, and its structure is as follows:

Or in another form:

Here we consider the first form of structure. In this case, the differential formula can be expressed as follows:

Among them, the value of alpha is between 0 and 1, and the filtering constant and sampling period are determined. Based on this, we can get incremental formula for incomplete differential by increasing it.

Or expressed as:

These two expressions are equivalent, and the second representations are closer to our incremental differential PID algorithm, which is easy to understand. It is also more consistent with positional representation, so we choose second representations.

**2****、Algorithm implementation**

After previous analysis and formula deduction, it is quite easy for us to achieve incomplete differentiation. To facilitate understanding, we keep the ratio and integral as the basic format, and only use incomplete differential algorithm to the differential part.

**（****1****）Positional type****PID****Algorithm implementation**

The location PID implementation process is different from the previous one, and the difference is the need to increase the previous Ud value. First, the structure of the PID object is defined:

1 /*Definition of structure and public*/ 2 3 typedef struct 4 5 { 6 7 float setpoint; //Set value 8 9 float proportiongain; //Ratio coefficient 10 11 float integralgain; //Integral coefficient 12 13 float derivativegain; //Differential coefficient 14 15 float lasterror; //First beat deviation 16 17 float lastdev; //The value of the differential term at the first beat 18 19 float alpha; //Incomplete differential coefficient 20 21 float result; //Output value 22 23 float integral;//Integral value 24 25 }PID;

Next, the PID controller is implemented.

1 void PIDRegulation(PID *vPID, float processValue) 2 3 { 4 5 float thisError; 6 7 float thisDev; 8 9 thisError=vPID->setpoint-processValue; 10 11 vPID->integral+=thisError; 12 13 thisDev= vPID->derivativegain*(1- vPID-> alpha)*(thisError-vPID->lasterror)+ vPID-> alpha* vPID-> lastdev; 14 15 16 17 vPID->result=vPID->proportiongain*thisError+vPID->integralgain*vPID->integral+ thisDev; 18 19 vPID->lasterror=thisError; 20 21 vPID->lastdev = thisDev; 22 23 }

This has realized a position type PID controller with the simplest incomplete differential. Of course, it does not consider any interference conditions, only the computer language of the mathematical formula.

**（****2****）Incremental type****PID****Algorithm implementation**

The realization of incremental PID controller is based on the incremental formula. First, the structure of the PID object is defined:

1 /*Definition of structure and public*/ 2 3 typedef struct 4 5 { 6 7 float setpoint; //Set value 8 9 float proportiongain; //Ratio coefficient 10 11 float integralgain; //Integral coefficient 12 13 float derivativegain; //Differential coefficient 14 15 float lasterror; //First beat deviation 16 17 float preerror; //First two beat deviations 18 19 float lastdeltadev; //The increment of the differential term at the first beat 20 21 float alpha; //Incomplete differential coefficient 22 23 float deadband; //dead zone 24 25 float result; //Output value 26 27 }PID;

Next, the PID controller is implemented.

1 void PIDRegulation(PID *vPID, float processValue) 2 3 { 4 5 float thisError; 6 7 float increment; 8 9 float deltaDev; 10 11 float pError,dError,iError; 12 13 14 15 thisError=vPID->setpoint-processValue; //Get the deviation value 16 17 pError=thisError-vPID->lasterror; 18 19 iError=thisError; 20 21 dError=thisError-2*(vPID->lasterror)+vPID->preerror; 22 23 24 25 deltaDev= vPID->derivativegain*(1- vPID-> alpha)*dError+ vPID-> alpha* vPID-> lastdeltadev; 26 27 increment=vPID->proportiongain*pError+vPID->integralgain*iError+ deltaDev; //Incremental calculation 28 29 30 31 vPID->preerror=vPID->lasterror; //The storage deviation is used for the next operation 32 33 vPID->lasterror=thisError; 34 35 vPID-> lastdeltadev = deltaDev; 36 37 vPID->result+=increment; 38 39 }

This is the simplest incremental incomplete differential PID controller, and does not consider any interference conditions, only the computer language of the mathematical formula.

**3****、summary**

In the incomplete differential mode, low pass filtering is used in differential links, and the differential term is effectively improved. The value of alpha is the number of 0~1. The two limit value, at 0, is actually the ordinary differential link without filtering; and when 1, there is no differential action. So the value of alpha to the incomplete differentialThe effect is very important, generally determined according to the characteristics of the controlled object.

**Welcome to:**

### Similar Posts:

- Eight note of PID controller development: implementation of PID controller with dead zone
- Eight note of PID controller development: implementation of PID controller with dead zone
- PID control algorithm
- PID learning essays
- PID learning essays
- Python artificial intelligence – three big math difficulties!
- Test of correlation coefficient
- Four axis PID thinking arrangement
- Four axis PID thinking arrangement
- 1stOpt (application Collection)