View Single Post
  #7   Spotlight this post!  
Unread 09-11-2007, 14:15
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,276
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: programing the vex optical shaft encoder

Quote:
Originally Posted by youngWilliam14 View Post
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.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)

Last edited by JamesBrown : 09-11-2007 at 14:20. Reason: Found the white paper