Go to Post Finding those students and giving them a lift up out of the sea of apathy that is constantly trying to drown them is one of the reasons I am in my profession. - Ben Mitchell [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 13-02-2010, 15:03
frenchie4111 frenchie4111 is offline
Registered User
None #1111
 
Join Date: Jan 2010
Location: Southriver
Posts: 23
frenchie4111 is an unknown quantity at this point
Time in Milliseconds

We are trying to program our robots kicker and we are having a problem with inacurate time delays because we can not get the time in milliseconds.
__________________
[url="http://mylifeisnerdy.co.cc"]My Life Is NerdyURL]

Last edited by frenchie4111 : 13-02-2010 at 15:09. Reason: Also the game.
Reply With Quote
  #2   Spotlight this post!  
Unread 13-02-2010, 15:24
bronxbomber92 bronxbomber92 is offline
Registered User
FRC #1551 (Grapes of Wrath)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Naples
Posts: 75
bronxbomber92 is an unknown quantity at this point
Re: Time in Milliseconds

What are you using currently to get the time?

GetTime() has nanosecond resolution, Timer::GetFPGATimestamp() has microsecond resolution, and the Timer class has microsecond resolution.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2010, 15:28
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Time in Milliseconds

Hmm... Well, I'm sure that there's something buried in the WPILib that can do it for you like using the time() function. But, from a VxWorks perspective, you can issue a:

-> sysClkRateGet()

This will tell you the interrupt rate of the system clock. And, sysClkRateSet(100) would set the interrupt rate to 100 Hz (10 ms clock resolution).

With that, tickGet() will return the current clock tick count with subsequent calls allowing you to measure elapsed time to the resolution of the system clock.

And, taskDelay(1) is a delay of 1 clock tick (10 ms at 100 Hz). You can also create watchdog timers that will attach your code to the system clock interrupt service routine and run it at a specified delay. Again, I'm sure that there's something buried in the WPILib that can provide what you're looking for, but I know VxWorks a lot better than I know the WPILib.

HTH,

Mike
Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2010, 15:30
frenchie4111 frenchie4111 is offline
Registered User
None #1111
 
Join Date: Jan 2010
Location: Southriver
Posts: 23
frenchie4111 is an unknown quantity at this point
Re: Time in Milliseconds

Quote:
Originally Posted by bronxbomber92 View Post
What are you using currently to get the time?

GetTime() has nanosecond resolution, Timer::GetFPGATimestamp() has microsecond resolution, and the Timer class has microsecond resolution.
Oh we were using the time class (time.h). We did not notice the timer class.
__________________
[url="http://mylifeisnerdy.co.cc"]My Life Is NerdyURL]
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2010, 18:47
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Time in Milliseconds

By the way, changing the resolution of the clock using low level VxWorks routines may wreak havoc on the timing of the rest of the system. Obviously you can do so, but do it carefully and test well.

Greg McKaskle
Reply With Quote
  #6   Spotlight this post!  
Unread 13-02-2010, 19:02
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Time in Milliseconds

use Wait(double seconds);
or a Timer
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #7   Spotlight this post!  
Unread 22-02-2010, 05:56
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Time in Milliseconds

BTW, in case you haven't found an optimal solution, I just implemented a GetMsecTime() macro today. The timer object seems a bit heavy to me. This is simple yet functional.
Code:
#define GetMsecTime()           (GetFPGATime()/1000)
Reply With Quote
  #8   Spotlight this post!  
Unread 22-02-2010, 08:47
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Time in Milliseconds

If you want something simple and fast, use the standard C library's ctime (also known as time.h).

the function clock() returns the amount of ticks that have passed since your program started running as a clock_t value. The amount of ticks per second is defined in the macro CLOCKS_PER_SEC. Using this and some simple dimensional analysis, you can easily get how many miliseconds have passed between two clock() calls.
__________________
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Motor for X Milliseconds DWirth NI LabVIEW 2 10-02-2010 07:54
It's that time of year again!! (No, not The Championship event) Tax Time!! Elgin Clock Chit-Chat 4 10-04-2005 10:59
time? roeperJTD06 OCCRA 1 21-11-2003 18:03
time archiver 2000 3 23-06-2002 22:58


All times are GMT -5. The time now is 13:25.

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