Showing results for 
Search instead for 
Did you mean: 

for loop iteration problem

Go to solution



I have built this vi to log data from two air velocity sensors and the analog signals that drive two actuators.My problem is: Whatever number of iterations I set at the second frame, the same number of iterations will occur at the third frame. At the example below I initially set the loop to run for 20 seconds and the second loop to run for 3 minutes. When I run the program both loops ryn for 20 seconds. Any hints?



for loop

0 Kudos
Message 1 of 5
Accepted by topic author Ioannis86
It is because of the array output from the first loop. A for loop iterates to the smaller of the N count or array size. You simply need to right click on the output and select disable indexing. No need to create an array of filenames.

p.s. Get rid of the sequence structure. It is unnecessary.
0 Kudos
Message 2 of 5

Thanks, it works! I tried to run it also having removed the sequence but some things, such as the message output after data have been collected, pop up as soon as I press start. I have to do a bit of reading about order of execution. Thanks again.

0 Kudos
Message 3 of 5

You have a lot of duplicate code, for example the two FOR loops only seem to differ by a few inputs. Using a state machine architecture, you should be able to use a single instance of the inner code (at the same time eliminating the local variables).

Use one while loop, one instance of the inner code and switch state according to the iteration. Start out with five states (write header|steady state|step up|show message|idle) and go from there. Have a look at the design templates.

0 Kudos
Message 4 of 5

Hello altenbach and thank you for your advice! I will try this, it is definitely going to be useful for the one I'm logging data from numerous sensors!


0 Kudos
Message 5 of 5