On Friday, we continued our work on proportional control by trying to combine our straight driving with our conga line program.
First, we tried to make both components of the program proportional. We continued to have one independent wheel and one dependent wheel for the straight driving, while having the "base speed," i.e. the speed of the independent wheel, depend proportionally on input from the ultrasonic sensor. To do this, we needed two error variables: "error" being the error in the ultrasonic sensor, and "wheelerr" being the error in wheel counts. We also needed a new variable "speed" which is the power of the independent wheel based on the distance from the object.
We also learned how to create a new block, called "valid," which outputs the value it is given unless the value is negative, in which case it outputs 0. This is useful for values given to "set power" because the power will be 100 if it is given a negative number, when we actually want the power to be 0.
This, however, didn't work; we had the issue of, when going backward, only one wheel -- the independent wheel -- would spin, and, when returning forward, the dependent wheel would "catch up" with it.
![]() |
This program had the problem of driving backwards. We changed "set wheelerr" to a plus sign because the two wheels had opposite signs for their counts. |
Thinking this was a problem with our proportional control, we created a version that used bang-bang control for the back-and-forth motion while remaining proportional for the straight driving. This had the same problem, and we found out that it was a sign error in the power when going backwards, which was confusing us because count A increased going forward, while count C decreased going forward. We also swapped the dependent wheel's motor from C to B so that both wheels' counts increased in the forward direction. Then, we set the error to be counta-countb, but, when going backwards, the error was seThis worked!
![]() |
Bang-bang control for the back-and-forth motion. The sign error was solved by making the error negative whenever the car was going backwards. |
We applied the sign fix to our proportional code, and it was also successful!
![]() |
Proportional control for both the back-and-forth and straight-driving motions. |
No comments:
Post a Comment