I made a normal linefollower robot using 5 sensors. I want to learn how to apply PID. I have QTR-8RC and Adafruit Motor Shield.
Read up a bit on how PID works -- there are lots of tutorials on the web.
Then study the many posted examples that use PID in line following robots.
While the balancing bot is't a line following bot it has the same principals. You are just balancing the edge of the line instead.
- Suggestion is to have the sensor follow the edge of the line 50% white 50% black and have the setpoint at that analog value.
- Set the sample rate at somewhere around 100 times a second (10ms) setting this too high will hinder integral and derivative calculations.
- Since we know what our setpoint is and what our output is when following a straight line, we know that Integral factor can be zero and get good control.
- When centered on the lines edge and the line is straight the motors (Left and Right) will be the same speed.
- Proportional control will be the major control factor, any offset from setpoint you will want to cause a differential in the motors to turn the bot back to setpoint. input * Kp = output
- Derivative will cause a "kick" in the correct direction to occur giving a boost to the proportional control start off with the derivative at zero until your proportional is holding to the line correctly
- What does the sensor read when on white and what does the sensor read when on black?
- What is the minimum PWM power setting to the motors to get the bot to move?
- What is the max PWM power setting you wish to control the bot at?