View Single Post
  #4   Spotlight this post!  
Unread 06-08-2006, 10:52
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,790
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Vex Encoder Code

Your function definitions cannot be placed inside another function such as Process_Data_From_Local_IO(), so that's why you saw all those errors when you tried it. The function definitions can actually go in any file you like (even your own new file). Declaring your functions is like setting up a library of stuff you can call on to do. It's where and how you call them that's important.

Your description of the robot's behavior sounds clear enough. You're right that you have to call your polling function StartRightEncoder() from within Process_Data_From_Local_IO() to get the faster polling during regular user driving. So concentrate on fixing the odd pulsing you're seeing.

Offhand I'd say odd pulsing like that is the symptom of a variable overflow. pwm04=255 while GetRightTick() returns values of 0 to 179, then I assume you set pwm04=127 somewhere else. Because of momentum the robot continues to roll forward (or the wheels continue to spin) even though the motors are off. The momentum means you still get encoder counts, so rtick continues to get bigger and bigger. If rtick is declared as an unsigned char, for instance, then when the count tries to increase to 256, rtick will suddenly wrap around to be 0 again and your code will set pwm04=255. Hence, pulsing motors. The same thing will occur eventually with larger variable types as well, e.g., a signed int would buy you 91 feet of travel.

Your variable rtick needs to be a pretty large variable type. Large enough to hold the distances you're planning to cover. What type are all your variables?
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 06-08-2006 at 14:59.
Reply With Quote