Thread: PWM Speed
View Single Post
  #2   Spotlight this post!  
Unread 18-02-2008, 15:14
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: PWM Speed

You would probably want to scale the precision of whatever control mechanism or joystick you are using to get the full scale of motion, so this should graph that to the new maximum:

Code:
long answer; //Must be long to hold precise values
if (p1_x > 127){ //Or whatever joystick
answer = p1_x * 200 / 255;
pwm02 = (unsigned char)answer; //Cast this to the proper type
} else {
pwm02 = p1_x;
}