LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control timing of a loop

I am having trouble executing a while loop at 10Hz (See attached). I have set my "wait till next ms multiple" value to 100, and so would expect my loop to run 10 times per second. However the loop takes 94ms, then 109ms, then 94ms etc....
 
Any ideas?
0 Kudos
Message 1 of 7
(3,172 Views)
There will always be uncertainty in software-based timing due to Windows overhead and the OS sharing applications between the processor. I ran your code and I was consistently getting 99,100, and 101 values somehat better performance. For absolute timing accuracy you need a hardware based solution (counter/timer), LV Realtime, or FPGA.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 2 of 7
(3,152 Views)
I ran it and was dead nuts on 100 everytime (unless I started dragging windows and opening big applications and such).  I am not sure how the guts are different, but maybe using a "Timed Loop" might be more appropriate if the loop rate is that critical. 

Depending on your application, there may be some other method for making your intended action execute at a more consistent rate despite the loop's timing error.  What is it that you want to do at 10Hz?


Message 3 of 7
(3,136 Views)
Thanks for your help everyone.
The 10HZ vi is part of a bigger program I am running that sends out ethernet data to another pc on the network. It's not critical that it goes out bang on every 100ms (99 or 101 would do), but I didn't understand why it should be 94 then 109 etc.
 
Humour me for a second, and explain how I create a timed loop. I am using LabView 6, so maybe that explaind why I've never heard of that!
0 Kudos
Message 4 of 7
(3,107 Views)
I am not a veteren at this, and as such, I do not know which features where added when or what toolboxes they are part of.

When I right-click to bring up a the function menu, inside "Structures" there is an options for "Timed Loop".  It looks like a while loop, but blue and with a little tab on the left of it.  You can reference a timebase in it and it might give you more control over how your loop runs.  If you don't have it, then my idea is of little help.  Perhaps you can experiment with the different between the "Wait (ms)" and "Wait until next Millisecond" blocks and see if one might perform better for you than another.  With software timed applications like yours, other processing threads (other programs running on the computer) can play havoc with LV's priority.  If it is feasible, it might behoove you to try it after a fresh reboot, with as many other applications closed as possible.

Best of luck with your problem, I am sorry I could not be of more help.
Message 5 of 7
(3,093 Views)
Hi Scott,

you're right, LV6 doesn't know about timed loops - they were introduced in LV7. Time to upgrade? 🙂

Please tell us which LabView version you are using every time you start a new thread! More and more people are using the most recent version making it harder to give correct answers for older versions of LabView...

Another point: have you tried to adjust the priority in the execution options of your vi in question? This could help to increase accuracy of the timing.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(3,089 Views)
I think I'll try an upgrade! Smiley Happy
 
Thank you all.
0 Kudos
Message 7 of 7
(3,063 Views)