Proportional-Integral-Derivative (PID):
Here are the equations illustrating PID control:
- power ∝ error
- error = goal - reality
- power = error * Kp
Power of the device is proportional to the error. Kp is the proportional gain constant. While setting the gain constant, if the value is too big, the device will overshoot; if the value is too small, the device will undershoot.
Straight-Proportional:
Using proportional control, Jennifer and I coded our SciBorg to move in a straight line by calculating the difference of speeds between the two motors. We used that to scale the speed the wheel 1 to line up with wheel 2, therefore moving in a straight line.
We tested our Sciborg on three different surfaces - lab floor, carpet, ramp.
On the right, the SciBorg goes straight on the lab floor.
On the left, we lined the SciBorg to a line outside the engineering lab right before the entrance/exit to the science center. This allowed us to know for sure that our SciBorg was moving straight.
Despite the SciBorg going straight on the other two surfaces, every time it went up the ramp, it veered off to the left. Jennifer and I believe the ramp is tilted.
The results using proportional control is very similar to bang bang control when testing our SciBorg to move in a straight line.
Reminder: In straight-bang-bang, we coded the two motors to move at different speeds depending on the different conditions. The conditions were based on how fast each motor was moving.
10-Feet-Proportional:

Using proportional control, we coded our SciBorg to move 10 feet using the same distance (wheel revolutions and 12643 from the motor encoder reading) calculated in our 10 feet task.
Using the equation for PID, we created a constant Kp. Only the position of one wheel is needed to tell whether the SciBorg has moved 10 feet. Therefore, if the position of wheel 1 was not at 12643, the speed of the motor would continue moving, but would scale itself using the PID equation. The motors would move slower and slower as it reached its finish line. We gave the wheels an initial speed of 110 to ensure the SciBorg would move.
Jennifer and I examined the SciBorg moving the supposed 10 feet, but every time our SciBorg would stop about 6 inches short. We created a nudge function for the car to slowly inch up to the finish line. Our SciBorg stopped right on the line.
Note: Without realizing, our SciBorg was low on battery so it was not moving in as straight line a as it would with new batteries.
Ultrasonic-Sensor-Proportional:
We used proportional control to code our SciBorg to follow an object - a sheet a Delrin - at different speeds depending on the distance the SciBorg was away from the object. There are four different speeds - fast, medium, slow, stop.
Again, we set up a gain constant to be proportional to the speed of the SciBorg. If the SciBorg was far from the object, it would move at a fast pace, but if the SciBorg was close to the object, it would move at a slower pace, eventually close enough with a low enough power to stop moving.
Again, we set up a gain constant to be proportional to the speed of the SciBorg. If the SciBorg was far from the object, it would move at a fast pace, but if the SciBorg was close to the object, it would move at a slower pace, eventually close enough with a low enough power to stop moving.
Using proportional control, the SciBorg transitions to different speeds much smoother as opposed to bang bang control.
Line-Following-Proportional:
Lastly, Jennifer and I coded our SciBorg to follow the white line using PID control. Like in line-following-bang-bang, we set the light sensor value to react to the edge of the white line in order to follow that rather than the entire white line.
Both wheels are set to adjust to different speeds based on what the light sensor reading is, but both wheels are set to move in opposite directions in order for the SciBorg to turn and adjust.
Both wheels are set to adjust to different speeds based on what the light sensor reading is, but both wheels are set to move in opposite directions in order for the SciBorg to turn and adjust.
With proportional control, the SciBorg moves a lot smoother while not only going in a straight line but also while making turns. This makes the SciBorg look a lot more natural while in motion.
In real life, if a car was using bang bang, turns would be sudden but using PID, turns would be smooth like we experience these days in safe driving.
PID control is much more effective and reliable than bang bang control. With PID control, machines are able to perform at ease without two simple commands - on and off. PID allows the object to calculate an error and use the error to continuously make adjustment changes.
In real life, if a car was using bang bang, turns would be sudden but using PID, turns would be smooth like we experience these days in safe driving.
Reflections:
Although learning how PID and the equation took some time and frustration, once we understood the equation and how it works, it made it much simpler to complete the rest of the tasks at a much faster rate as it all has to do with setting up an equation.PID control is much more effective and reliable than bang bang control. With PID control, machines are able to perform at ease without two simple commands - on and off. PID allows the object to calculate an error and use the error to continuously make adjustment changes.
Haha we had the same problem with the ramp! It must be tilted. I really liked your explanation of PID, at the top, it was very clear and concise and really set a good starting point for your post. I also liked your analysis of when PID vs bang-bang control was appropriate.
ReplyDeleteOne slight comment/more of a question: I can't seem to get your videos to play. What browser are you using? I tried Safari and Chrome, but neither worked for me - maybe I'm doing something wrong?