otherside Posted June 28, 2003 Posted June 28, 2003 Hey guys, does anyone know a way to measure time with intervall less than 1ms ? I need to measure some signals comming from an input device and the pulses are between 100 us (microseconds) and 2 ms ? thanks Quote
*Experts* Nerseus Posted June 30, 2003 *Experts* Posted June 30, 2003 You'll need to use the performance counters from the Win32 API. Here's some sample code that doesn't do anything, but shows you the functions. You can search Google for more help (search on the function names): [system.Security.SuppressUnmanagedCodeSecurity] [DllImport("kernel32")] private static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency); [system.Security.SuppressUnmanagedCodeSecurity] [DllImport("kernel32")] private static extern bool QueryPerformanceCounter(ref long PerformanceCount); long qwTicksPerSec; // Number of ticks per second. Based on your computer, only set this once long qwTime; // If bUsingQPF returns false, you can't use these - you'll have to use timeGetTime. // I think it's for Win98 or Win95 and earlier (can't remember which versions don't support them) bool bUsingQPF = QueryPerformanceFrequency(ref qwTicksPerSec); QueryPerformanceCounter(ref qwTime); // Use QueryPerformanceCounter to get the current time. Subtract // from previous calls to get the difference. // Use qwTicksPerSec to get how many ticks per second you have. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.