I am building a two-wheels self-balancing robot and using PID controller to control its speed. The measured value is the encoder signals from the Hall sensors on the back of the DC geared motors. But in my notes, it mentions only to use PI controller, meaning that the Derivative term is set to zero. But i can't understand why? Isn't it better to use a full PID controller to achieve the best results?

I researched online and the best explanation i could find is that for a PI controller which controls the speed, there is a need for faster response so the Derivative term can be omitted. But i am not convinced of this explanation… Maybe someone can offer a better and more complete explanation?

Also, for the angle balancing part, why is the PD controller preferred instead of PI controller and why not use full PID?

## Best Answer

You do already have a D-term when control velocity. It is the differentiation of the position, so no need to do double differentiation - not stable.

^{simulate this circuit – Schematic created using CircuitLab}EDIT:

User DKNguyen has probably found a good reason why PI instead of PID is used: Let' take for exapmle a real servo driver having 62.5us sampling time for current controller, 125us for speed controller and 1ms for position controller. Now, the most straightforward to tune is the current controller. You can compute the Kp, Ti directly from motor resistance and inductance.

The velocity parameters are more tricky, the load and its inertia comes to play here. The algorithm for an integrator can suffer from precision while doing computation. Tiny increments could not be summed in a floating point number. But the real pain is to make a differentiation. In a book it was mentioned that sampling time has to be somewhere from 1/5 to 1/20 of dominant system time for PID controller to work as expected. Thus, high sample rate could spoil the PID, which in servo drive has a fixed sampling time.