Does the D in PID slow down the motors?

Since error is always decreasing, that means the derivative is always negative.

Does this mean the D term in PID slows down the motors?

Indeed, the derivative acts kind of like a “limiter”. If your robot is going too fast, (dError / dt) will be greater in magnitude, which helps reduce the output power. Conversely, if your robot is going too slow, derivative will be low and proportional + integral can take over and speed up the robot.

Not quite, if you are going backwards, the derivative will be positive. It is more accurate to say that the sign of derivative is opposite to the direction of motion.

An important cavaet is that while D acts to slow the robot down, it does it with a goal of letting your system reach its desired state faster.

If you just programmed P control only, to reach the desired state and come to a controlled stop afterwards would require a much lower P gain than to reach it with a well tuned D gain. Look at below gif, the current P gain is oscillating like crazy, uncontrollable. The D gain lets the P gain be that large AND controllable without any real loss of speed.

PID_Compensation_Animated
source PID controller - Wikipedia

19 Likes

Following up on the excellent animation linked by @tabor473:

P (proportional) power corresponds to how aggressive you want to be in reaching your target.

I (integral) learns how much motor power is needed just to overcome energy losses due to friction or the force of gravity.

D (derivative = velocity) corresponds to how much kinetic energy there is in your moving robot, thus indicating when to start cutting motor power in order to avoid overshooting the target.

6 Likes

Love the visual representation of how to tune a PID and what one observes while tuning it!

2 Likes

This video might also help understand the effect of each variable:

8 Likes