|
Re: Help with Speed control using Cortex and US Digital Encoders
In C and most languages I know of, the while() operator looks for a value equal to 0 or not equal to 0. A comparison operation (this == that) results in a 0 if they do not equal, or a 1 if they do equal, so that is one possibility. Another is an equate operation (this = that), which sets this to the value of that, and if the process does not fail (which it won't unless you have a memory error) the result is 1, thus the while loop runs and you get angry trying to debug. So, a while(1) is the shortest syntax to make a while loop that always runs.
If both wheels are going the same speed, you will drive in a straight line. That is why you speed-control both sides separately, so they both go the same speed even if there are differences mechanically.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor
"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
|