View Single Post
  #15   Spotlight this post!  
Unread 18-01-2007, 13:25
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Slow down teh motors!

Quote:
Originally Posted by Alan Anderson View Post
Joey probably has it right. The pwm values are unsigned char, and it's likely that the compiler isn't accounting for the possibility of underflow when subtracting 127. If your joystick puts out 125, the result wraps around to 254, which gets divided down to 127 and shifted back up to 254 by the final addition. Forward control on the joystick will work okay, but the slightest backward movement will cause the robot to go full speed forward. Using 1-stick control, barely moving the joystick to either side will make it circle madly in the opposite direction.

Adding the cast to (int) will force the compiler to deal properly with the signed values, and everything should be okay.
Thanks for the support. I seem to remember smashing a mentor into the tool cabinet a couple years back because any input value less than 127 would send the output to 0, and thus sent the robot into full reverse as soon as I touched the joystick. I'm pretty sure that was the quick-and-dirty way of fixing it. Good luck, brennerator.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_