View unanswered posts | View active topics It is currently Thu Jul 24, 2014 11:22 am






Reply to topic  [ 10 posts ] 
Start/ stop line project. How do i stop a timer??? 
Author Message
Rookie

Joined: Fri May 02, 2014 6:27 pm
Posts: 5
Post 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!


Fri May 02, 2014 6:40 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Fri May 02, 2014 8:58 pm
Profile
Rookie

Joined: Fri May 02, 2014 6:27 pm
Posts: 5
Post 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?


Fri May 02, 2014 11:35 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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?

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Sun May 04, 2014 4:33 pm
Profile
Rookie

Joined: Fri May 02, 2014 6:27 pm
Posts: 5
Post 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?


Mon May 05, 2014 10:35 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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?

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Tue May 06, 2014 6:38 pm
Profile
Rookie

Joined: Fri May 02, 2014 6:27 pm
Posts: 5
Post 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?


Tue May 06, 2014 8:02 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Start/ stop line project. How do i stop a timer???
I have never used the debug stream :) But that is my guess.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Wed May 07, 2014 4:26 pm
Profile
Rookie

Joined: Fri May 02, 2014 6:27 pm
Posts: 5
Post 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!


Wed May 07, 2014 6:03 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Start/ stop line project. How do i stop a timer???
You're welcome. I'm glad I could help!

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Thu May 15, 2014 3:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.