1. The x and y directions are calculated separately, and the velocity error (target speed 0)
(for integral) 2. The cumulative error, the cumulative error need limiter (after infinite cumulative error will cause the overflow, cause error integral element, such as the number of symbols, output mutation)
3. The calculation of PID
The output error=p * error_sum + d + I * * (the error - error_old);
4. Output limiter (prevent output more than PWM regulating range)
5. Save the current error
Error_old=error
Program