View Single Post
  #3   Spotlight this post!  
Unread 02-03-2006, 03:42
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Motor Ramp Up/Ramp Down Function

you only need like 3 variables in a function: target(the joystick value), output value(the current pwm value), rate(the rate of change).

if((target - output) > rate)
output += rate;
if((output - target) > rate)
output -= rate;
else
output = output;

this is just to explain how to do it.
Make sure all the variable being compared in the if statement are int. Otherwise it will execute for example if it results as (-5 > 4), if they are unsinged variables.

just write a function and you can use it anywhere.