| Author |
Message |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 1.40: use of Timer / Timing
hi to all, I don't get how the timer has to be used. I need functions the help, as usual, won't help... 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Fri Aug 08, 2008 2:39 pm |
|
 |
|
vnguyen
Site Admin
Joined: Wed Jan 24, 2007 10:44 am Posts: 421 Location: Pittsburgh, PA
|
 Re: 1.40: use of Timer / Timing
_________________Vu Nguyen Software Training Development Team | WebmasterNeed more support? Use the ROBOTC Ticketing systemRobotc.net| Robomatter Store | Robotics Academy
|
| Fri Aug 08, 2008 3:49 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: 1.40: use of Timer / Timing
thx, but actually unfortunately not. I see how to reset (clear) , but I don't see how to stop in between or how to read. I don't understand T1 , time(T1): what is this? That is really not understandable. there should be a
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Fri Aug 08, 2008 4:00 pm |
|
 |
|
vnguyen
Site Admin
Joined: Wed Jan 24, 2007 10:44 am Posts: 421 Location: Pittsburgh, PA
|
 Re: 1.40: use of Timer / Timing
You have 4 timers: T1, T2, T3, and T4 To start and clear the timer you use: To "read" in 1 millisecond values use time1[T1]. time10[T1] will return it in 10 millisecond values.
_________________Vu Nguyen Software Training Development Team | WebmasterNeed more support? Use the ROBOTC Ticketing systemRobotc.net| Robomatter Store | Robotics Academy
|
| Fri Aug 08, 2008 4:03 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: 1.40: use of Timer / Timing
aaah. so T1=0, T2=1, T3=2, T4=3 ? and this_time=time1[T1] means this_time=GetTimer(T1)=GetTimer(0) (result in milli seconds ?) ok, then there's only a intermediate stop missing, and a new start command afterwards... 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Fri Aug 08, 2008 4:10 pm |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
 Re: 1.40: use of Timer / Timing
There is no "pause" command. Only restart. In other OS that I have worked with I have never seen a "pause timer" command.
If you want other functionality you can "build" it yourself using the "nSysTime" variable which is essentially a 1-msec "clock". You can compare current time against whatever value you have saved to determine the time difference.
|
| Sat Aug 09, 2008 4:16 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: 1.40: use of Timer / Timing
hello, thx, with nSysTime it's now working!
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Sat Aug 09, 2008 4:41 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: 1.40: use of Timer / Timing
sorry, just 1 more question: if I use nSysTime for timing, and the program keeps running for a longer time (maybe 2 hours), won't there be an overflow some time?
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Sat Aug 09, 2008 5:06 am |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
 Re: 1.40: use of Timer / Timing
Yes. You will eventually get overflow. In about 25 days!
'nSysTime" is a signed 32-bit value that is reset to zero when NXT is powered up. We only want positive values so there's 31-bits. This overflow in 24.7days.
You can also use "nPgmTime" which is a similar 32-bit counter that is reset every time a program is run. It also stops incrementing when a program is suspended by the ROBOTC debugger which is (or can be) convenient when debugging programs.
|
| Sun Aug 10, 2008 1:24 am |
|
|