LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop execution time

I would like to know the time taken by a while loop to execute one iteration without a delay. 

 

Thank you

 

 

0 Kudos
Message 1 of 7
(15,449 Views)

Hi teddy_aua,

it depends on the code inside of your while loop. You can use the "Tick Count (ms)" function to measure it. Use one before the loop and one after. Make sure that the second Tick Count will first execute if the while loop is over. Subtract the last value from the first and that's the time in ms. If you get 0 as result, then you should run your loop for more iterations.

 

Mike

Message 2 of 7
(15,445 Views)

I would recommend a globally initialized feedback node. The following code will display the correct ms/iteration, (except at the first iteration).

 

How fast is the loop? If it is a very fast math loop, measuring and displaying the time will slow donw the code, of course.

 

 

Message 3 of 7
(15,418 Views)

Thank you for your reply.

 

I have another question. I have a program that uses one while loop to acquire data from a sensor and another while loop to acquire data from a web cam. Although they should execute independantly, I realized that when both the sensor and the web cam is initiated, the sensor data acquisition stalls. However, seperately, they both run fine. Any advice??

 

 

0 Kudos
Message 4 of 7
(15,371 Views)

Please show us some code.

 

Most likely you have a dataflow issue, creating a data dependency between the two while loops. Make sure that no wires exit one loop and enter the other loop. This would force the second loop to wait until the first loop has finished.

Message 5 of 7
(15,347 Views)

Hello,

 

Thank you for your reply, but there is no data dependancy. There is absolutely no connection between the two while loops. Anyhow, I have attached the code sample.

 

Any help is greatly appreciated.

 

 

0 Kudos
Message 6 of 7
(15,311 Views)

Thank you for your reply. However, I have another problem. I am using a program to stream data from a sensor connected via a USB port. (Configured as COM4) I am also using a USB web cam to capture images as well. I have been trying to acquire data from the two sources at the same time in two different while loops. However, it does not work, and the sensor streaming stalls. I have already tried starting one source before the other. The problam still remains. When seperated, they both work fine. Could this be due to any conflicts being created with the USB ports?

 

Thank you

 

 

0 Kudos
Message 7 of 7
(15,259 Views)