Quote:
Originally Posted by youngWilliam14
ok now i have another problem:
Code:
while (swerve == 0)
{
Tank4 (0 , 2 , 2 , 3 , 4 , 1 , 2 , 1 , 0 , 1 , 0);
swerve = GetRxInput (1 , 5);
}
the variable 'swerve' is set to 0 when i press the lower ch. 5 button. i'm still holding the button down when i get to this part of the code, but it skips the while loop and goes right to trying to turn the wheels back to zero. does anyone know why the loop gets skipped, even though the value of 'swerve' is still 0? the only reason why the program gets to that point is because it's allredy checked to see if the button is being pressed
|
Can you post the code that comes right before this loop? the syntax of the loop looks fine so if it is actually missing the loop the problem is probably occurring before it reaches it. To test this put a printf right before the loop, one right in the loop and one after the loop this will let you know whether the problem is the code not stepping into the loop or if the problem occurs somewhere else.
I still can't read the rest of your code since I don't have EasyC on my laptop but it sounds like you are just driving the motors until you get to a certain number of pulses from the encoder then stopping them. If this is the case you may be able to get (read as will get) better results if you use PID control (or any of many other control algorithms) there is a code paper on here that outlines how to do it, I'll find it and edit this post with a link as soon as I can.
James
http://www.chiefdelphi.com/media/papers/1823 - That is a good reference to get you started on PID control if you have never used it before.