LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop duration accuracy

Hi,
 
I'm using LabVIEW 8.0.1, and i'm having problem getting For or While loop running at exactly 100ms duration. The loops never seem to run exactly 100ms, always differ by a little. If i change the duration to 500ms, it becomes fine, but anything less then 500ms duration per step has problem with constant duration. I have attached an example, any help will be really appreciated
 
Thank You
0 Kudos
Message 1 of 5
(3,324 Views)
Try a timed loop like in the picture.

If you need exactly some time duration, you're going to have to use a real-time OS and not something like windows, mac, or linux.
0 Kudos
Message 2 of 5
(3,318 Views)
This is normal for a VI running on a multipurpose OS. There are other things running, fighting for CPU.
 
You will get better results using a timed loop. It is designed to keep time much better and also notifies you if the timing is off.
 
In addition, you should use "wait next ms multiple" so the timing errors don't accumulate (you might need to discard the first time because it will be random, or add another wait before the loop).
 
Lets' assume your loop contains code that takes 40ms to execute. With "wait next ms multiple", the loop with run roughly every 100ms. With a plain wait(ms) the loop can take anywhere between 100 and 140ms, depending on the order things execute.
 
Another analogy:
"Wait next ms multiple":  Do something.every time the minute hand on the clock is at 12.
"Wait(ms): .... do something, wait one hour. do something, wait one hour, .... (the repetition depends on the time to complete the task).
 
(If your timing needs to be perfect, you need to use LabVIEW RT)
0 Kudos
Message 3 of 5
(3,310 Views)
What is a real-time OS like? is it easy to switch over from windows? I have absolutely no knowledge about that field, is it possible to direct me to some resources related to this area?
 
I reconstructed that VI you posted, it worked nicely, but when I changed the "Tick Count (ms)" function to a "Get Date/Time in Seconds" and the error still exists, is there any reason why?
 
Thanks a lot for the help
0 Kudos
Message 4 of 5
(3,305 Views)

Took me a bit to understand the concept of "wait next ms multiple", that explaination should be in the help file =P Thanks a lot

I am using the version of LabVIEW provided by the university of auckland, New Zealand. So I think it's the LabVIEW development professional package if i'm not mistaken. Is LabVIEW RT included in the original LabVIEW package?

Thanks a lot for the help

0 Kudos
Message 5 of 5
(3,304 Views)