PID control

hi guys,

I’m looking for educational purposes a simple exercise to test a PID control. I would like to utilize this project of a robot light seeker:

Do you have any suggestion how to include a PID control in robot light seeker?

PID control reference:

Do you have any suggestion how to include a PID control in robot light seeker?

  1. You could make a sort of radar that tracks the direction light source, with a pid it moves more gently .

  2. Make a system that poors sugar from a reservoir into a cup and that has to stop at 100 grams. Without PID it is easy to overshoot.

  3. a light dimmer that slowly adapts from low to high intensity and back

Very very insightful and useful project suggestions! In the first phase i was thinking to use the PID to control the two motors velocity because at the moment in the code there in only a ON/OFF control on the motor.

could you suggest link with some PID programmig code examples?

in a PID control there are 3 costants: Kp, Kd, Ki.

how to tune the PID constants? random?

many thanks in advance!

check - -

Another fun project that can utilize PID control and give good visual feedback of the effect of different constants is a line following robot, which can be made mostly from the same components as a light seeker.

where could i find a simple tutorial step-by-step of the line follower robot?

I'm not sure but I'm sure you could find something on google.

The basic idea is that you have some kind of mobile robot base, which can be pretty much exactly what they have in that instructable you linked to.

Then instead of, or in addition to, the photo-resistor (light dependent resistor) "antennas" used in that instructable you can put an array of photo-resistor sensors pointing at the ground under the front of the robot along with some LEDs. The LEDs shine on the floor and the sensors pick up the reflected light which varies with color of the floor. This setup is well capable of picking up electrical tape or something similar on a light colored floor or masking tape on a dark floor. An array like this is simple to build or you can just purchase something like, which is similar but uses infrared and photo-transistors instead of visible light and photo-resistors

Since you have an array of sensors, or several sensors in a line, you can figure out how far off of center the robot is over the line, which you can then use as the error term for your PID loop.

Sorry I don't know of any great references but they are probably out there. Its really not much more complicated than that light follower, just a few more sensors and there is no real reason you couldn't use the one robot base for both. Oh, and the code would look very similar for both scenarios as well I imagine.

Its fun with the line follower because you can see how changes in the proportional response make things sluggish or oscillate around the line, and how the derivative can help damp oscillations and whatnot but you will see the same type of thing with a light-follower as they really are very similar behaviors.

Many many thanks for the very helpful hints.

I found a very interesting tutorial, in particular for the code the chapter “Developing PID algorithm”, page 16: