View Single Post
  #12   Spotlight this post!  
Unread 03-12-2006, 22:38
Noah Kleinberg Noah Kleinberg is offline
Registered User
FRC #0395 (2TrainRobotics)
Team Role: Driver
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 196
Noah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to behold
Send a message via AIM to Noah Kleinberg
Re: Motor Ramp Up/Ramp Down Function

Here's how I'd do it:

Code:
//In user_routines.h, just an example value
#define ramp_speed 3 

//In user_routines.c
if(pwm01 > (p1_y+ramp_speed))
{
     pwm01 += ramp_speed;
}
else if (pwm01 < (p1_y-ramp_speed))
{
     pwm01 -= ramp_speed;
}
else
{
     pwm01 = p1_y;
}
(replacing p1_y with the value you ultimately want the pwm to have, and pwm01 with the actual port connected to the motor)
(similar to what was posted earlier I believe)

Although it might seem too simple this should work fine; taking into account the rate of change seems unnecessary to me because the ramping should/will only have a difference when the rate of change is large.

Last edited by Noah Kleinberg : 03-12-2006 at 22:45.