Go to Post This is Chief Delphi. We're all crazy here. - Whippet [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2013, 10:16
nickpaterni's Avatar
nickpaterni nickpaterni is offline
Programming Mentor - Java
FRC #0217 (The Thunderchickens)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Mt Clemens, MI
Posts: 16
nickpaterni is an unknown quantity at this point
Ramping up motor tied to a button

Currently, we have a command tied to a button that will activate a motor, but we want to be able to gradually get that motor up to 100%. The code so far looks like:

void RaiseArm::Execute() {
while(Power < 1)
{
arm->TurnOn(Power);
Power += MOTOR_RAMP_UP_AMT;
}

the command is called in OI via a WhileHeld(). Is there a better way to do this?
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2013, 00:30
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Ramping up motor tied to a button

The loop you wrote has no delays. It's going to get to full power almost instantaneously. How long do you want the motor to take to ramp up?

I assume you accidentally forgot to show us the line where Power is set to 0 before starting the loop?
Reply With Quote
  #3   Spotlight this post!  
Unread 17-02-2013, 13:36
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Ramping up motor tied to a button

That makes sense, but as Alan pointed out, the code will run every 20ms, so either don't increment it every pass or make the constant small to take that into account. If you know how fast it should ramp, and you know that happens every 20ms, it should be easy to come up with a constant value.

Also, be sure to reinitialize the value in the initialize() method.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #4   Spotlight this post!  
Unread 17-02-2013, 13:50
nickpaterni's Avatar
nickpaterni nickpaterni is offline
Programming Mentor - Java
FRC #0217 (The Thunderchickens)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Mt Clemens, MI
Posts: 16
nickpaterni is an unknown quantity at this point
Re: Ramping up motor tied to a button

Thanks for the replies, my lead student programmer figured that out after staring at the code for a while, and came to the same conclusion you guys did. It is working with a delay and by resetting the initial value when the button is released. All is working well.

Thanks
Nick
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 14:03.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi