09-22-2015
01:55 AM
- last edited on
08-12-2024
11:22 AM
by
Content Cleaner
Hi,
From what I understand, Wait ms function will have accumulative error overtime when running many task.
Wait until next ms multiple function may be a better choice because of its consistency in execution.
Instead of using these 2 function,
Any way to go directly to the crystal oscillator in windows os to get the real time clock?
Is this feasible?
Thanks.
09-22-2015 01:59 AM
Hi Adriano,
go directly to the crystal oscillator in windows os to get the real time clock?
Wait and WaitForMultiple are using the internal windows clock…
And that clock isn't "crystal" at all: you have a lot of jitter on that clock!
When you want more accurate timing: either use hardware (like DAQmx cards usually provide) or use a RealTime OS (like provided by cRIO targets)!
09-22-2015 03:32 AM
Hi GerdW,
So other than using hardware to give a real time clock, any other method to implement a
real time from windows os? e,g extract bios clock or something to use within a loop...?
Thanks.
09-22-2015 03:49 AM
You could have a look at something like Tenasys InTime or IntervalZero RTX. I use the former (albeit not as a programmer, just an end user) for motion control and haven't had any problems with it.
If I were doing something mission critical, like writing my own motion controller, I'd go for an embedded RTOS and FPGA system.
09-22-2015 05:28 AM
The short answer is that Windows is NOT a OS that can give any real accuracy when it comes to timing. If you need accurage timing, you need a Real-Time OS or an FPGA. So what exactly are you trying to do?
09-22-2015 05:52 AM
The OP did not ask about loop determinism, they asked about long term execution, so i guess the cumulative error is the problem, not the loop jitter. They asked "Any way to go directly to the crystal oscillator in windows os to get the real time clock?" Yes, there is. The Get Date/Time function returns the value of the OS clock wiich is based on a crystal oscillator. It is not an atomic clock, but has very good long term stability. Of course, if jitter is the problem then go to RT or DAQ clocks, but if it is long term timing and loop jitter is less of a problem then use the Get Date/Time function to give you a Tzero time, then check it periodically and acton the timer when you need to run your process. Yes, you will suffer some jitter, but the long term timing will be far better than any other method including timed loops on windows, and the wait mS multiple. Be careful about changing the OS time while your application is running, results may be unpradictable.
Does this help at all? or have i confused the issue?
Michael.