Last Friday we introduced the idea of proportional control--control proportionate to the magnitude of error (error defined as the actual value subtracted from the target value), as opposed to bang-bang control (all the way on or off). We began by modifying the distance-sensing program to power the motors proportionately to the amount of error from the ideal distance (a reading of 15, about a foot away from the sensor).
"Snow White" the Cyborg:
The grey and white sensor at the front is the light sensor; the small, black cylinder is the ultrasonic sensor; the large clear/white box next to the ultrasonic sensor is the display.
The modified distance-sensing program:
The most difficult part of this exercise was figuring out how to deal with the intermittent negative sign from the sensor, which changed based on whether an object were closer or farther than a foot away from the sensor. After much thinking, we eventually realized that we should use another if-then-else statement to be sure that the error was always positive. We found that a gain of 20 made our robot smoothly change directions and stop at the exact "15" distance.
After enjoying some exciting success with this project, we next attempted to apply proportional control to our line-following program. At first things seemed to be working, but the robot soon began to turn around in helpless circles, unable to find the line accurately. We weren't sure if the problem were actually in the program, since we realized that the robot was no longer able to move in a straight line--the motor seemed to be listing.
Our original light-following program (left "forever" loop):
Top "forever" loop, 80% and 40% blocks, and right green columns: our attempts at applying proportional control to the line-following program:
We tried to change the power of the motors in this program according to the error and gain (being sure to keep error positive, so the power level would be positive), while keeping the ratios of power of one wheel to the next approximately the same as in the bang-bang control for the two types of motion (bearing right or spinning slowly). To do this, we introduced the blocks "80%" and "40%", which were meant to keep the wheels spinning with independent power and direction appropriately so the robot would bear right or spin to the left (without this step, we thought the robot would simply move in a straight line with different power based on the light sensor's reading). We also changed the gain depending on whether the sensor was fully off or fully on the line, to keep the motor values for each motion approximately constant regardless of where the sensor was (a strategy that worked well in bang-bang control).
After realizing there were some problems with the motor (the robot was having trouble bearing right, even when we returned to our previously-functional program in bang-bang control), we began a class exercise to reset one wheel to a particular degree of rotation. The idea was that we would set some angle (say, 42 degrees), then displace the wheel, then run the program and have the wheel move back to its initial angle. My partner and I managed to get a bang-bang control version of this to work, but the proportional control has not yet been realized.
Bang-bang wheel reset:
By the end of this class, everyone was a little annoyed with proportional control, as it seems to vastly complicate a previously-functional program. Its obvious necessity in higher levels of design (i.e., anything with a real motor) makes me excited to actually learn how to write these sorts of programs--I look forward to continuing my experiments to tackle this challenge!





No comments:
Post a Comment