Go to Post Just so you don't spend too much time on non-clues ... now you can all go back to the real one! :D - Libby K [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 12-09-2011, 17:03
krudeboy51's Avatar
krudeboy51 krudeboy51 is offline
Only Programmer
AKA: kory
FRC #0369 (369)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: brooklyn
Posts: 151
krudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of light
Send a message via AIM to krudeboy51
Red face Timer class

Hi, I have a problem, I use wait to time the motors on our robot, but then we ran into a problem where we would lose control of the robot untill it has finished the wait sequence. I have tried putting "myRobot->Drive(leftstick, rightstick)" in the function but we still would lose control. So I heard that I can use the Timer.h class to substitute for wait, I have tried this code on our bench top set up on a different cRio but it would jus run the motor non stop, when I disable it then enable, the motor starts running again. Can someone help me please?

Code:
class RobotDemo : public SimpleRobot

Timer *time;

public:

time->Reset():

Tele-op:

if (ArmStick.GetRawButton(11))
{
      time->Start();
      Carriage_motor->Set(1.0);
      if (time->Get() >= 60)
      {
         Carriage_motor->Set(0.0);
      }
}
Reply With Quote
  #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
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 17:51.

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