Help with PID

Hi, I am planning on creating a line follower robot, and I ran across something called PID, and I am trying to understand this concept and how it can be implemented in a line follower robot.

What I do understand is that this is a control method used to set the current position of something, or current value, to a set point in a short amount of time. Is this correct? Also, I'm assuming this can be used with a line follower robot to move the robot back to it's set point, which would be it centered right above the line.

So, I guess my question(s) is how would you use this control method in your sketch? What code do you need to write to do this? How exactly does it work? What does it do? Do I need a library?(Example code would be awesome)

I really would like to understand this so I could implement it in a line follower robot, and possibly a self-balancing robot.

Any help would be great. :)

Good place to start reading here.

Arduino PID library

First off thanks for the response jremington :)

Ok, so I looked at the links you gave me and I also did a lot of looking around on YouTube, and I had found some helpful videos. I'm somewhat understanding what this control method is all about, but I am still confused...

What I'm confused about currently is basically how the Kp, Ki, and Kd get the values. Like I have seen where people set them to an integer like for example 9, 7, & 6. But what confuses me is how these values make the input equal to the setpoint through an output. So, basically what do these values do and how do they work.

Also, some example code would be great!

You have to choose Kp, Ki and Kd. Google "PID tuning" for some tutorials on how to go about it systematically.

It is very important that you put print statements into your test code, so that you can see whether the values make sense.

If you want help with a line following robot, you will need to post details about the robot and post the code that you are using with it. If you don't have a robot, then it is too early to worry about PID details, as those depend on the robot.