06-13-2006 03:08 AM
06-13-2006 12:26 PM
Wim -
DirectX has a clock with resolution of 100 nanoseconds. The IReferenceClock interface exposes the reference clock functionality of DirectX.
It's described in the Win32 SDK. It's a base class (CBaseReferenceClock), so you wouldn't be able to use it from C, you'd have to use C++ I would think.
As you said, if you're not doing anything else with your system, why not do a busy wait? You could Sleep() or Delay() a few times a second to allow the system to process other threads, and do a busy wait the rest of the time.
Yup, the down side of a busy wait scheme, among other things, is that it's processor speed dependent. Getting it calibrated / tuned is a hassle.
You could also use a dedicated high priority or real time priority thread to do the writing, this would minimize the time the OS lets other threads run.
I don't think you're going to find any OS service with a time resolution of under a millisecond in WIn32 except for the maybe the media-related timers (e.g. DirectX).
Menchar
06-13-2006 01:24 PM
Wim,
Look up the following functions in the windows SDK.
QueryPerformanceCounter
QueryPerformanceFrequency
To implement a delay use QueryPerformanceCounter to get the start time. Then QueryPerformanceFrequency to get the number of clock ticks per second. Calculate how many clock ticks you want to wait and use QueryPerformanceCounter in a loop to calculate your delta. Once the time interval specified has been reached jump out.
Garth
06-13-2006 01:42 PM
06-13-2006 05:20 PM
06-14-2006 02:01 AM
Hello guys,
Thanks for your fast replies, it's really appreciated.
Unfortunately I don't have mucht time to spend on this issue, so I guess the USB to I2C convertor might be the best solution. Leaving out the Delays works fine on my PC, but I don'tknow if it will work on all systems...
Thanks,
Wim
06-14-2006 09:58 AM
Happy to help Wim. Sometimes the "easy" or "cheap" solution is neither. In a case like this, I would much rather spend the $100 to $250 to buy the hardware than expend a couple of days trying to get it to work on a parallel port. Especially since my labor for two days costs my employer a lot more than the price of the adapter.
06-15-2006 03:39 PM
GarthE -
How do you do any arithmetic with the __int64 data type?
Or is there a way to do arithmetic on the LARGE_INTEGER values? I tried assigning the LARGE_INTEGER.QuadPart to an __int64 variable (the assigment appears to work just fine) but when I try to subtract two __int64 types I get a GPF.
Thanks,
Menchar
06-15-2006 04:04 PM
06-15-2006 05:55 PM
GarthE -
I get a GPF (general protection fault) when I try to subtract the QuadParts of the two values, the same as when I try to subtract any two __int64 values.
Or when I do any arithmetic on __int64 values for that matter. All that I can seem to do is assignment and printing of __int64s. Expressions with __int64 data types compile and build just fine in CVI, without error, but then fault at runtime.
Seems like a compiler issue to me.
Do you know that the code you posted will compile and execute in CVI?
Menchar