pid tuning for line following robot

Hi guys, I was doing a project for line following robot and I was wondering how to get the optimal coefficients of PID controller?
So is there any way to measure the overall line position error or ocscillation rather than just by observing?

shenjiawei008:
Hi guys, I was doing a project for line following robot and I was wondering how to get the optimal coefficients of PID controller?
So is there any way to measure the overall line position error or ocscillation rather than just by observing?

Well that all depends on what you mean by optimal. (ex Low % overshoot, fast settling time, low steady state error) There is a lot that can go into “optimal” and you generally need to know your system dynamics.

Assuming that you just want something that looks good and doesn’t do crazy things I usually do the following.

Set all coefficients to zero

Turn up the P coef until you get the response speed you desire
Then turn up the D coef to smooth it out a little bit (D should almost never be bigger than P (20%? don’t quote me on that number)
Finally bump up your I a bit to remove steady state error.

With regards to measuring overall line position error I would assume that you are already doing that as the error is what should be fed into your PID controller.

Hope that helps some.