Incremental PID

Incremental PID control does not directly use the error value as input to calculate the control output, but uses the increment of the control amount (i.e. the difference between the previous moment and the current moment) as input.

Incremental discrete PID formula

Uk=Kp[e(k)e(k1)]+Kie(k)+Kd[e(k)2e(k1)+e(k2)]

Difference between positional and incremental PID

positional PID

The positional PID calculates the current deviation value (difference between target value and actual value), integral value (sum of past errors) and differential value (error change rate), and then adds these three parts to obtain the PID output.

incremental PID

The incremental PID calculates the change in the difference between the current error and the last error to obtain the PID output increment.

Code implementation

Incremental PID is speed closed-loop control. Speed closed-loop control is to measure the speed information of the motor according to the number of pulses obtained per unit time, and compare it with the target value to obtain the deviation. Then we control the deviation proportionally, integrally, and differentially to make the deviation approach 0.

Software code

Since the relevant peripheral driver tutorial has been introduced before, it will not be introduced here!

Experimental phenomenon

The Increment_PID.hex file generated by the project compilation is located in the OBJ folder of the Increment_PID project. Find the Increment_PID.hex file corresponding to the project and use the FlyMcu software to download the program into it.

After the program is successfully downloaded: the serial port will print the button status and the currently set encoder increment (corresponding to the motor rotation speed). The button can switch the LED status and control the speed of the motor.

image-20240812145311435