Thread: Timer class
View Single Post
  #2   Spotlight this post!  
Unread 13-09-2011, 00:16
TofuRama TofuRama is offline
01000110 01010010 01000011
AKA: Matt
FRC #2484 (Team Implosion)
Team Role: Programmer
 
Join Date: Apr 2011
Rookie Year: 2009
Location: Woods Cross Utah
Posts: 17
TofuRama is an unknown quantity at this point
Re: Timer class

I've made this mistake myself a few times. What's happening is that it's only checking to see if it should stop if and only if button 11 is pressed, which isn't what you want. Another problem you're running into is that the timer isn't resetting after it completes it's cycle, meaning it will only stop once and that's it. Below is the new tele-op code:

Code:
void OperatorControl(void)
{
//this makes sure we're getting a good value from the timer
      time->Start();
      time->Reset();

      While(IsOperatorControl())
      {
            GetWatchdog().Feed();

//insert any other code you want ran during tele-op mode here

            if (ArmStick.GetRawButton(11) && time->Get() >= 60) 
            {
                  time->Reset();
                  Carriage_motor->Set(1.0);
            }
            if (time->Get() >= 60)
            {
                 Carriage_motor->Set(0.0);
            }
      }
}
One thing that you'll notice is the second part I added to the first "if" statement. All this will do is make sure that the robot doesn't reset it's timer until after it's completed it's first cycle. Of course, you can remove it if you want.

I hope this helps!
Reply With Quote