LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop

Solved!
Go to solution

Hi,

 

I was trying some tests to see is a while loop can be good to be used in a vi where the time is a really important matter. So I have implemented this simple code to see the duration of iteration of a while loop. Surfing in the net I have already found that because of windows is not a true real time OS, meaning that the priority of the operation can be changed during its execution, the time that each loop takes can greatly change. So recorded in an array all the values of the while loop. Except for the first iteration, which took a time of the order of milliseconds, the others are in order of 10^(-6). I can’t understand way there is such a difference.

 

Thank you for the help!

 

Best Regards,

Zuc

Download All
0 Kudos
Message 1 of 4
(1,018 Views)

Do you get the same result if you run it again a couple of times? A VI compiles before running if it's been changed, so i often see a small 'hiccup' the first time, but not on subsequent runs. Otherwise, a loop requires some setup and memory access so that the 1st loop would be slightly longer is no surprise, but not several millisecs.

 

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 4
(1,013 Views)

Hi Yamaeda,

 

Sorry I have not mentioned that fact: if you have just opened the vi for the first time then the first loop is around 7 ms (but can be also higher), then if you run the vi other times, the first loop duration decreases (0.3-0.2 ms). The same happen if you wait some time (let's say about 15s) between two consequent runs.

 

I have also thought that the cause could be related to the fact that at the very first iteration the shift register brings back a zero value, and it is possible to see that by highlighting the execution, but then I don’t understand why consequents runs reduce this time, since the vi is still loaded in memory and it is always the first loop.

 

I hope to have been clear enough! Thank you for the helpI

 

Best Regards,

Zuc

0 Kudos
Message 3 of 4
(987 Views)
Solution
Accepted by Zuc_Lab

Hi Zuc,

 


@Zuc_Lab wrote:

I don’t understand why consequents runs reduce this time, since the vi is still loaded in memory and it is always the first loop.


You are using an uninitialized shift register!

  • On first run after loading the VI it gives you a ZERO and so you get a large value when subtracting ZERO from "relative seconds".
  • On subsequent runs it gives you the last "relative seconds" value and so you (basically) get the time between the last run and the current start…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 4
(977 Views)