We put our newly-learned information into practice with two small projects. The first was to use a proportional controller and full closed loop system to create a hovering light sensor beam that would always hover at a certain, set distance from a white piece of paper on the table. The idea was that, no matter how one manipulated the hover arm (pushing it up or down, or even moving the paper up or down) the arm would adjust itself and return to its set distance above the paper.
We decided that a light value of 40 would be our goal hover-height, and wrote this program:
Our closed-loop proportional controller! (At this stage, without a derivative) |
Movie:
If we had added a derivative, this would have become our new equation: m = Kp(40-l) + KdΔE
m = motor speed
Kp = gain of proportional controller
Kd = gain of derivative
l = light sensor value
ΔE = change in error
We would have had two gains to experiment with, instead of just one—the gain of the proportional controller and the gain of the derivative. We didn't have time to add a derivative control to the hover arm before moving on, but we made our first one in the next mini-project!
Mini-Project number two brought us back to our line following robots. Our challenge was to revamp our vehicles so that instead of following a line, they would be able to follow a small light on the robot in front of them. Ideally, each robot would speed up if it was too far away, slow down to maintain a constant speed when it reached optimal following distance, and back up if it found itself too close to the light sensor in front of it.
We did not need to make many changes to our light arm program, but we did finally add a derivative! We also changed the optimal light value from 40 to 30, our robot's light reading at what we determined was an appropriate distance from the car in front of it.
Initial program . . . |
And with added derivative! |
We updated our line follower so that the light sensor would be able to sense light in front of it, instead of from the ground, and added a small light on the back so that other cars would be able to follow it.
Revamped robot! |
Rear view! |
We took our robot outside for a trial run, and found that it had trouble following the lights on other robots. We went back to our program and switched the LED aspect of our light sensor off, and that seemed to solve the problem! This was our equation: KpE + KdΔE. We found that with the added derivative controller, we could make the gain higher and our robot would reach its goal more quickly, but without as many oscillations!
Here are two movies our our robot in action:
Follow the leader success! (Our robot is in the back)
And again:
Our robot (in the center) misbehaves slightly at the end of this clip (it got overwhelmed), but it successfully moved forward in a line of three! In the first clip, it accelerated when it was too far away, maintained a constant speed at the optimal distance, and backed up when it was too close . . . success!