View Single Post
  #2   Spotlight this post!  
Unread 14-01-2004, 18:52
josh_johnson josh_johnson is offline
Registered User
#1020 (Indiana Prankmonkeys)
 
Join Date: Nov 2002
Location: Muncie, IN
Posts: 58
josh_johnson is an unknown quantity at this point
Send a message via AIM to josh_johnson Send a message via Yahoo to josh_johnson
Re: New Joysticks...Good or Bad Choice by FIRST?

The easiest way to do this would probably be to add a deadband in programming by changing the output value to the motor to 127 if the joystick is within a certain range of 127. For example, if pwm01 and pwm02 are controlling the robot drive, you could insert the following code in the Process_Data_From_Master_uP function in the user_routines.c function:

int deadband = 20;
//the above value may need to be more or less depending on how sensitive the joysticks are
pwm01 = (abs(pwm01 - 127) <= deadband ? 127 : pwm01);
pwm02 = (abs(pwm02 - 127) <= deadband ? 127 : pwm02);


and add this function to find absolute value to the user_routines.c file as well:

int abs(a) {
return (a < 0 ? -a : a);
}

I have not tested this, but I do believe that it should work.
__________________
5! * (4! - 3! - 1!) / 2!