LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't save data from each loop iteration

Hi folks!

 

I am having some problems saving data from the loop in the attached vi.

 

I am using the vi to adress some multiplexeres and measure the voltage difference from that particular address.

 

However the vi only saves the data from the last iteration. I have confirmed this because I tried going from 1-16 in the loop iteration

one at a time and the values always change, but running for the 16 iterations I always get the same values.

 

Can anyone see what I am doing wrong in the code. Also any advice on the rest of the code Smiley Wink is always welcome since I

am sorta new to LabVIEW.

 

Thank you very much for your help.

 

Cheers! Smiley Happy

0 Kudos
Message 1 of 11
(5,115 Views)

The loop is only set for 1 iteration.  Did you notice that?  Did you expect to see 16 set of data point in 1 file for 16 iteration?  I am just making sure what you are looking for.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 2 of 11
(5,111 Views)

Also, I'm guessing you meant for that to be a 2D array that you indexed one row at a time into your loop, instead of a 15D array:

 

15D.png

 

For more information on indexing data into and out of loops, check out this help document.

0 Kudos
Message 3 of 11
(5,108 Views)

Hi guys.

 

@ jyang72211 : It was saved for 1 iteration because I was still trying some coding. I use all 16 iterations and I get a set of data. The problem is that it only saves the data for the last iteration (the 16th one) and it saves that data to all the 16 sets of data. And I know that because if I run one iteration at a time I get different sets of data than the data I get from running the 16 iterations at once. Hope that was clear.

 

@Darren : I'm using that array to address the multiplexers. Although I didn't quite understand the difference between the two representations...If you could explain further

I would appreciate it.

 

 

Cheers!

0 Kudos
Message 4 of 11
(5,085 Views)

Also, after some tries I found out that using a delay of 10 seconds inside the loop I get all the right measurements.

 

But If I use 1 second I get the worng values again!!

 

Any thoughts???

 

 

Cheers!

0 Kudos
Message 5 of 11
(5,076 Views)

 


@Darren : I'm using that array to address the multiplexers. Although I didn't quite understand the difference between the two representations...If you could explain further

I would appreciate it.


A 1D array is a single row/column. A 2D array is rows and columns, like a spreadsheet page. A 3D array is where the third dimension refers to another page of rows and columns. Like an additional sheet in an Excel workbook. A 15D array ... well, that's getting into superstring theory, and I know this is going to sound disappointing to you, but frankly, your VI is not pushing quarks around or trying to shatter the space-time continuum (thank you for that, by the way). So, stick with the array being a 2D array. Smiley Wink

 

0 Kudos
Message 6 of 11
(5,063 Views)

 

Regarding the 1 sec and 10 sec delay.

I don't know what amount of data must be written in the file but it could happen that the Write To File Vi uses some external functions (e.g. "dll") which use some kind of global variables.

If you start another write before ending the previous one (one write to file could take more than data acquisition from NI Bord) the previous one is cancelled.

 

I'm not sure, it just a taught.

0 Kudos
Message 7 of 11
(5,058 Views)

The Write To File Express VI is configured to save to different files each time.

This means it will save the data from the first iteration in the file with the name you specify, then each subsequent iteration's data will get a separate file with a serialised and/or timestamped name.

 

Could this be your problem?

 

MC

0 Kudos
Message 8 of 11
(5,050 Views)

The main problem I am facing is that the For Loop only records the last data from the 16th iteration and

not the data from all the iterations.

0 Kudos
Message 9 of 11
(5,040 Views)

Drive the Waveform signal out from the loop (using indexing) and write to file after the entire acquisition was done.

I don't see why you have to do it after each iteration and not once at the end.

0 Kudos
Message 10 of 11
(5,037 Views)