From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loop executes with correct numbers then starts again with random data

HI all,

 

I have written a program and was getting some errors so stepping through debugging it. Ive used a for loop to cut the data going from the peak max working back and finding the data point which is the first point above a given threshold. When i was checking the location values of the peak max i was getting random values and only 5 when i have asked the for loop to execute 20 times and i have at least 30 peaks of data. The same data feeds into other VI's with no issue. So i ran the VI in debug mode. THe via executes 20 times then passes the data on. IT then starts again and runs a further 20 times and passes that on then runs 5 times and passes that on. I am thinking that perhaps the correct values (that come out the first time) are being overwritten when the for loop re executes. I have no idea why this is happening though. I have run a very similar loop that goes from the peak and works forward and I have no issues with that one.

Does anyone have any suggestions please.

 

I have posted the vi plus a screen shot cos i have one of the newer labview versions. THanks

Download All
0 Kudos
Message 1 of 3
(2,017 Views)

You did not attach the subVI

 

You have an input with auto-indexing enabled and a value wired to the N terminal. Do not do both. You should understand that the loop will iterate for a count equal to the lesser of the array size or N count.

0 Kudos
Message 2 of 3
(2,004 Views)

Dennis is correct.The loop is going to execute either the Count Terminal or the FMax array size, whichever is smaller. If changing that doesn't solve the problem, does turning off the Parallel For Loop execution fix it?

0 Kudos
Message 3 of 3
(1,989 Views)