Showing results for 
Search instead for 
Did you mean: 

while loop iteration

Hi Everybody,


I have a USB-5133. Data were acquired for different elapsed time.
I have a problem about while loop iteration number. For example, While the time is 1 s, the iteration is 10.
While the time is 10 s, I expect that the iteration is 100. But it is lower than 100 (for example 80).
That is, the iteration number is not proportional with the time.
I would like they are proportional with each other. What can I do for this?


Thank you for your help.

0 Kudos
Message 1 of 6

An iteration takes as long as the slowest part of the code inside it. Often the slowest part is a wait statement, but if other parts take longer, the while loop will of course be slower. Can you show us some code?


Are you doing inefficient things, such as initializing the DAQ with each iteration?

0 Kudos
Message 2 of 6

Thank you for your reply. In the while loop, I used NI-SCOPE Initiate and Read function. How can data be acquired without the Initiate?



0 Kudos
Message 3 of 6

You need to initialize to read, but only only need to initialize once, to read many times.  Put the the initialize outside of the while loop (happens before executing) put your acquire inside the loop (calls multiple times) then put the close outside of the while loop after the while loop stops executing.

0 Kudos
Message 4 of 6

I tried it. When the initialize function was outside the loop, the read function acquired data once. Data were not renewed for each iteration. If it is possible, could you send me example code.


Thank you.

0 Kudos
Message 5 of 6

@star-123 wrote:

If it is possible, could you send me example code.


Why don't you show us what you did instead.

0 Kudos
Message 6 of 6