Out voltage = min_vol + kp*(target degree- current degree)
where min_vol is the voltage below which the chassis will stop turning.
One problem we have is that the drivetrain completely stops turning before reaching the target degree. One “solution” is to increase the min_vol, which however increases the overshooting on the other hand.
what you have right now is not a full PID control loop, it is just a P loop. If you are experiencing overshooting the target, You should add the D term and make a PD loop. You can then tune your kp and kd constants by setting both to 0, then increasing kp until you overshoot, then slowly raise kd until you stop overshooting.
One solution is to make the turn PID exit when the current angle is within a certain value(accuracy of the target). Another solution is to detect the speed and exit when the speed is low.
yes, that is what we do, for example, abs(error) < 0.5. However, as we linearly decrease the voltage based on the P-control, the robot stops completely before reaching target degree - 0.5, and gets stuck in the loop.
If we exit early when detecting 0 speed, it undershoots more than usual. But, we can try. Thanks.
and certainly, it will have the same issue as we are experiencing now. Our main issue is that the min_volt below which the robot does turn depends on the degree to turn and the power level.
I thought P-loop should be good enough for turning PID. We will try adding kd and Ki, tuning Kp and then Kd. Thanks!
Here is this excellent PID animation. You can see in the beginning with only P control they stop between 60% and 80% of the way to the target. Then you can see how adding I and D affects the system.
Just added ki and it works perfectly without too much lag so far. We will further improve by fine tuning kp, kd and ki. Thank you everyone for great suggestions!