Friday

Building With Legos, III: Line Follower Part 2

Next two classes were spent modifying our line follower to get smoother motion. We learned two new ways of control: proportional and derivative.
                Proportional control required our vehicle to change its speed according to how far off it was from the line.  This was done by having an optimal light value determined experimentally for the line we wanted the vehicle to follow. Then the difference between this optimal value and the current light reading of the sensor would be taken to get our “error”. This error would be multiplied by a “gain”, a value we used to adjust how much we wanted our speed to change, basically a factor. Then we added or subtracted, based on which wheel it was, this value to the base power of our wheels. This is how we proportionally controlled the speed. The end result produced differences in the speeds of the two wheels, which controlled the size of the sweeps. The goal was to get a critically damped system where the vehicle’s acceleration is right and requires a few oscillations to reach the goal value.
                Next, we wrote the code using mathematical signs on LabView and started adjusting it. We first had a power of 25 percent, edge light value of 34 and gain of 1. We found that 25 was too fast for turning angles and 20 worked better. We also decided on a gain of 3 after trying 1 through 4. This gave us smaller sweeps instead of the jerky motion we observed. We also found that the light values were very sensitive and 35 worked better as the edge value. Our robot worked pretty with this new program. However, we didn’t feel like the proportionality made such a great difference for our little line follower. Lyn suggested we try the white table with the black tape. We had been using the yellow masking tape on the grey floor. This didn’t provide as great a difference between tape and ground as the table and electrical tape did. We had already observed that even a difference of one means a lot to the robot in terms of following the line and a greater difference would make it much easier for the vehicle to function smoothly. Thus, we agreed to move to the table and modify our program to work there. Our new gain was 0.8, our power 17 and edge light value 39. This produced a great line follower that stayed on the line (and the table) as long as we watched. We were really proud of our little guy. Sure, it had some problems. For example, it only functioned on the outside due to our wheel programming choices. Its sweeps also allowed it turn only so many degrees. However, it worked well within its limits and we were happy with it.
Our code for the proportionally controlled line follower
                Up next was another sophistication: derivative control. Using derivative control, we could get our vehicle to move faster without getting large errors. We did this by adding a shift register to our program. We then took the difference between our previous and current errors using the shift register and adjusted our vehicle’s power based on this difference. This constituted a closed-loop system because we were using feedback from the system to adjust it. Before we applied these principles we learned to our line followers, we built a small light arm that stayed at the same angle as an exercise. We attached alight sensor to a rod and the rod to a motor. We programmed it so that no matter in which direction you push it, it will come back to the level where the light value is 40. Here is the program:
Light arm's code
Light follower from the back
                Then we started to use these new ideas on our line follower. Now it was to follow a light at the back of another vehicle. We modified our car so it had a light sensor in the front of it and a small light at the back. The location of both of these was up to us, which made it a variable among groups. So we paired up with another group to get a reading of the light value of what we thought as a good distance from their back. This turned out to be 30. We added a derivative control to our light arm program (we hadn’t had time to do so, it was just a closed loop) and changed the light value to 30. When we tried out the program outside on the carpet, our vehicle had trouble following. We came back in and tinkered with it a little. Turning of the light of the sensor seemed to solve the problem.  Our robot ended up working very well, functioning as a part of even a group of three.



Light-follower's code
 

No comments:

Post a Comment