LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about the Wait Until Next ms Function

Hello,

 

I met a problem when I tried to use wait until next ms function to control the period of the loop.

 

I use Labview2009 now. I wrote a VI to sample the current values at 100Hz and then store the samples in a text file. The currents are sampled once in a loop and then wait for next 10ms to begin the next loop. After 360,000 loops (should be an hour), it will creat a new file to store the new samples in the following an hour.

 

I left the VI runs on CompactRio for the whole weekend. The result I got is shown in the picture below:

20433iEA2ED246D762608B

24 files should be created in one day. While there were only 3 files created in the firest 24 hours ( from Fri 16:00 - Sat 16:00). And after that it worked very well.

 

When I checked the first three files (created from Fri 16:00 - Sat 16:00), I found that it didn't sample at 10Hz. It sampled at the frequency of about 20Hz (sometimes 18Hz, sometimes 19Hz).

 

I am confused by the problem a lot. What may cause it didn't work in the first 24 hours and worked after 24 hours? And How could I fix this problem?

 

Thank you very much!

 

0 Kudos
Message 1 of 13
(4,346 Views)

Without your code, this is a very difficult question to answer...

0 Kudos
Message 2 of 13
(4,332 Views)

You need to show us some code!

 

This cannot happen in a single loop, but can easily happen if you have e.g. stacked loops or sequences containing multiple wait statements.

 

Also have a look at these old threads:

 

Synchronization problems during measurements (using while loop)

accurate timing between events

 

If accurate timing is important, use a timed loop. Your incorrect times are faster, so I don't think there is a problem with the inner code taking too long.

 

0 Kudos
Message 3 of 13
(4,331 Views)

Were you writing these files to a LAN? If so, maintenance on the LAN (typical for weekend) could have presented problems with saving files.

Richard






0 Kudos
Message 4 of 13
(4,314 Views)

Thank you for your reply. Here is my code in attachment.

 

Thank you very much.

0 Kudos
Message 5 of 13
(4,304 Views)

Thank you for your reply. Here is my code in attachment.

 

It works very for creat a new file every 10 minutes. But it fails when I tried to make it to creat a new file every one hour.

 

Thank you very much.

0 Kudos
Message 6 of 13
(4,299 Views)

Thank you for your reply. Here is my code in attachment.

 

It works very for creat a new file every 10 minutes. But it fails when I tried to make it to creat a new file every one hour.

 

Thank you very much.

Download All
0 Kudos
Message 7 of 13
(4,298 Views)

One big problem.  You are obtaining a queue reference on every iteration of your innermost For loop, and never close it.

 

Your queue should be obtained outside of all your loops, and closed after your loops.  Otherwise you will eventually run out of resources.

0 Kudos
Message 8 of 13
(4,280 Views)

You probably have some race conditions. The way you determine the inner while loop termination seems dangerous and not very deterministic.

0 Kudos
Message 9 of 13
(4,275 Views)

Thanks for the reply. When I tried to move the obtain queue function out of the loops, the element data type cannot be matched. The type inside the loop is 1-D array, while the type outside the loop is 2-D array. How can I make them be the same type?

 

Thanks a lot! Smiley Happy

0 Kudos
Message 10 of 13
(4,252 Views)