accurate timer

  • Thread starter =?ISO-8859-1?Q?Stephan_W=F6rmke?=
  • Start date
?

=?ISO-8859-1?Q?Stephan_W=F6rmke?=

Hi!

In one of our experiments we are using piezo electric transducers to
move a stage. So far a feedback loop was implemented using the real-time
system from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and
resolution of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.

Thanks for any comments!

Stephan
 
K

Karl Heinz Buchegger

Stephan said:
Hi!

In one of our experiments we are using piezo electric transducers to
move a stage. So far a feedback loop was implemented using the real-time
system from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and
resolution of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.

Thanks for any comments!

Standard C++, the only topic in this newsgroup, has no idea
what a timer is. So your best bet is to ask in a newsgroup
which discusses Windows programming.
 
M

Moonlit

Hi,

Stephan Wörmke said:
Hi!

In one of our experiments we are using piezo electric transducers to move
a stage. So far a feedback loop was implemented using the real-time system
from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and resolution
of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.

timeGetTime
in mmsystem.h

possibly in combination with WaitForSingleObject( handle, time );


Regards, Ron AF Greve
 
J

Jack Klein

Hi!

In one of our experiments we are using piezo electric transducers to
move a stage. So far a feedback loop was implemented using the real-time
system from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and
resolution of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.

Thanks for any comments!

Stephan

First, questions of this type should be asked in newsgroups like
or They are really
inappropriate to a group like this because C++ is a platform and
hardware independent language and does not define timers, or
transducers for that matter.

As a practical matter, however, I will tell you that no standard
version of Windows will guarantee anything near 1 ms timing accuracy.
Or even 10 ms. I have my doubts about whether versions like CE or the
ones with 'embedded' in their names will either.
 
I

Ioannis Vranos

Stephan said:
Hi!

In one of our experiments we are using piezo electric transducers to
move a stage. So far a feedback loop was implemented using the real-time
system from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and
resolution of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.


Ask in microsoft.public.dotnet.languages.vc .If it doesn't appear in
your news server use the public MS one:

msnews.microsoft.com
 
M

Matt Hurd

Stephan Wörmke said:
Hi!

In one of our experiments we are using piezo electric transducers to
move a stage. So far a feedback loop was implemented using the real-time
system from venturcom. We now would like to use timers instead.

Is there any good way to implement timers with an accuracy and
resolution of 1ms or better?

Our software runs on windows and is written with Visual Studio 2003 .NET
running on Windows XP.

This isn't really the forum for it, but I sympathise with your
frustration at not having an accurate timer in Standard C++.

The high resolution timers on windows may be enough for you: see
http://msdn.microsoft.com/library/d...ce/TimerFunctions/QueryPerformanceCounter.asp
However there are many issues with the use of this particular api.

Or break it down into simple embedded asm in your C++ using the CPU's
cycle counter for your MSVC:

__int64 measure()
{
volatile ULARGE_INTEGER ts;
_asm
{
cpuid
rdtsc
mov ts.HighPart,edx
mov ts.LowPart,eax
}
return ts.QuadPart;
}

A similar approach works for GCC and Intel uPs.

But this is inherently dangerous, as cpu speed changes,
multiprocessors, counter wrapping and it is a long way from Standard
C++.

The ACE toolkit has a cross platform hi-res timer that uses these
tricks, but support some other platforms as well, such as Solaris, but
it too is susceptible to similar issues on ia32.

You may findsome clever people who have combined the cpu counter, or
other timers, with the real time clock to make accurate api's that
deal in real wall time by extrapolating from clock points.

Also, remember that measuring accurately to a millisecond might not
help you much as a general OS context switch, including windows, may
be greater than this. If it is a real time requirement then you
should be thinking about a RTOS. RTAI is a reasonable free one.

Perhaps you now get the idea of why it is not straightforward to wrap
this into Standard C++ nicely ;-)

Hope this helps,

Matt Hurd
www.hurd.com.au
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top