View unanswered posts | View active topics It is currently Mon Jul 28, 2014 10:41 pm






Reply to topic  [ 9 posts ] 
1.40: use of Timer / Timing 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 1.40: use of Timer / Timing
hi to all,
I don't get how the timer has to be used.
I need functions
Code:
reset timer(0)
start timer(0)
get timer(0) (milli seconds)
stop timer (0)

reset timer(1)
start timer(1)
get timer(1) (milli seconds)
stop timer (1)

... a.s.o.


the help, as usual, won't help... :evil:

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Aug 08, 2008 2:39 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post Re: 1.40: use of Timer / Timing
Does this help?

http://www.robotc.net/teachingmindstorm ... timers.pdf

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Fri Aug 08, 2008 3:49 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 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
Code:
int GetTimer(int timer);
int this_time, that_time;
ResetTimer(1);
StartTimer(1);
this_time=GetTimer(1);
StopTimer(1);
// do sth. special not depending from the timer;
StartTimer(1);
that_time=GetTimer(1);
ResetTimer(1);

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Aug 08, 2008 4:00 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post Re: 1.40: use of Timer / Timing
You have 4 timers: T1, T2, T3, and T4

To start and clear the timer you use:

Code:
ClearTimer[T1];


To "read" in 1 millisecond values use time1[T1]. time10[T1] will return it in 10 millisecond values.

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Fri Aug 08, 2008 4:03 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 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... :?:

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Aug 08, 2008 4:10 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 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
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: 1.40: use of Timer / Timing
hello,
thx, with nSysTime it's now working!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Aug 09, 2008 4:41 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 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?

Code:
int StartTime, myTime;
StartTime=nSysTime;
while (true)
{
  mytime=nSysTime-StartTime;
}

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Aug 09, 2008 5:06 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 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.