View Single Post
  #4   Spotlight this post!  
Unread 11-11-2009, 22:53
jamie_1930's Avatar
jamie_1930 jamie_1930 is offline
Registered User
FRC #2228 (Cougartech)
Team Role: Student
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Rush-Henrietta
Posts: 371
jamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to behold
Re: [FTC]: Spin Motor Wind Down: Programming

Quote:
Originally Posted by l0jec View Post
jamie_1930, while your approach is indeed simple, I do not believe it would ramp down the speed over a long enough period of time. I would suggest you refactor your strategy into a separate task which could employ a wait statement inside of a loop until the speed reaches zero. This would allow you to properly slow down the speed over the course of several seconds. Also, I imagine you would likely want to employ the same approach to ramping up speed.

This is assuming you are not actually trying to control the speed of launcher motors interactively with an analog stick... which I would also not recommend as it would be very difficult to shoot any distance consistently other than full speed and you still run the risk of stopping the motors hard.
This was the main concern I had with implementing that code although this should work fine. Just make x (x = iterations ; creates the needed pause) the right number. (here it's 1000 just for the sake of example)

if(joystick1.joy_y1 == 0 && motorspeed > 0)
{
x = x + 1;
if(x=1000){x = 0; motorspeed = motorspeed - 1;}
motor[shooter] = motorspeed;

}

if(joystick1.joy_y1 != 0){motor[shooter] = ((joystick1.joy_y1 * 100) / 127);}

or if your using a button

if(joy1Btn(1) == 0 && motorspeed > 0)
{
x = x + 1;
if(x=1000){x = 0; motorspeed = motorspeed - 1;}
motor[shooter] = motorspeed;

}

if(joy1Btn(1) ==1){motor[shooter] = 100;}

that should work much better
Reply With Quote