ROBOTC.net forums
http://robotc.net/forums/

Start/ stop line project. How do i stop a timer???
http://robotc.net/forums/viewtopic.php?f=11&t=8671
Page 1 of 1

Author:  Sheldor [ Fri May 02, 2014 6:40 pm ]
Post subject:  Start/ stop line project. How do i stop a timer???

So i have a start/ stop line project for my class. I have everything good except i can't stop the timer. I have tried a lot of different ideas and am stuck. Is there a way to stop a timer in RobotC? I use Natural language. Even if you told me how to pause the timer for like 5 seconds so i could write down the time on a separate sheet. So far i can clear the timer to begin counting but it will not stop. Any help is gratefully appreciated!

Author:  Coder A [ Fri May 02, 2014 8:58 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

You can't stop a timer. You can, However, write the value of a timer to a variable. The timer will keep counting, but the variable will not, allowing you to write it down or do any other action.

Author:  Sheldor [ Fri May 02, 2014 11:35 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

Coder A wrote:
You can't stop a timer. You can, However, write the value of a timer to a variable. The timer will keep counting, but the variable will not, allowing you to write it down or do any other action.



How do i write a variable?

Author:  Coder A [ Sun May 04, 2014 4:33 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

Try the following:

Code:

int variablefortimer // create an integer to hold the value

// code for starting timer here

// when it is time to stop the timer:

variablefortimer = time1[T1];  // now the value is stored in the variable



Does that help?

Author:  Sheldor [ Mon May 05, 2014 10:35 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

This is what i have so far

Code:

{
    int valTime1, valTime10, valTime100;  // create three integers to read the value of the timer
    untilSonarLessThan (20, dgtl5) ;  // this is when the runner crosses the start line
    ClearTimer (T1);
    turnLEDOn (dgtl1);         // will flash
    wait10Msec(10);
    turnLEDOff(dgtl1);
    untilSonarLessThan(20, dgtl7);  // stops progam after a second when the runner crosses the finish liine
    valTime1 = time1[T1];      //Gets the value of Timer T1 in 1ms increments and stores it in a variable
    valTime10 = time10[T1];    //Gets the value of Timer T1 in 10ms increments and stores it in a variable
    valTime100 = time100[T1];  //Gets the value of Timer T1 in 100ms increments and stores it in a variable
    turnLEDOn(dgtl1);
    wait10Msec(10);
    turnLEDOff(dgtl1);
}



Can you tell me what i am doing wrong if anything. If that is good then how can i access the variable to see my time?

Author:  Coder A [ Tue May 06, 2014 6:38 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

It looks like you are doing everything right. Your "valtime" variables hold information about what time the robot crossed the finish. This is where I become of less help. I don't have a cortex, pic, or other vex product. Mainly, I can just help you with code, not hardware. Anyway, I'll try my best: If you own an lcd display, try printing the variables to it. Or, you could write them to a debug stream. Does that help?

Author:  Sheldor [ Tue May 06, 2014 8:02 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

I think i will write it in the debug stream. The way to view the debug stream is to open the debug stream window right?

Author:  Coder A [ Wed May 07, 2014 4:26 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

I have never used the debug stream :) But that is my guess.

Author:  Sheldor [ Wed May 07, 2014 6:03 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

i got it and it works very well! Thanks man you were very helpful!

Author:  Coder A [ Thu May 15, 2014 3:18 pm ]
Post subject:  Re: Start/ stop line project. How do i stop a timer???

You're welcome. I'm glad I could help!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/