LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

collect data after a 2 loop

Hi all, sorry if the question will be too trivial...but I have engaged into a problem 🙂

I am collecting data currents measurement coming from a while loop inside a for loop.

The acquisition looks good.

I can then acquire data in a array format outside the loops enabling the auto-index.

 

The problem is that with the "write on spreadsheet file" I get an array of data in which each column report the data acquired 

during a loop cycle, while I need a single column only of the all the data....

 

What is the mistake?

Thank you for your patience....

G

 

0 Kudos
Message 1 of 13
(4,052 Views)

Please post some code so we can look at it.

 

We can't just guess what the problem is.

0 Kudos
Message 2 of 13
(4,047 Views)

aa.png

 

Just reshape the 2d array


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 13
(4,046 Views)

Hello Ravens, hello Jeff,

thank you for your replies. I have post the code .vi

In the code I have already done the reshape as suggested by Jeff.

I have tried and the solution works well, thank you!

Nevertheless I am not sure that the code I have written is the best to

save data.

Currently the array saves only the column of the current, that is the y column

and I have not done yet the x column of the times, but I don't know

how to do this.

 

Thank you for all you can suggest to me

G.

0 Kudos
Message 4 of 13
(4,024 Views)

Right now you don't have any time data.  You are just saving a 1-D array of doubles.

 

You need to build an array of times to go with the array of doubles you are creating.  Build an array of the current time and the data point into a 1-D array.  Then autoindex that at the For loop into a 2-D array.

 

(There is something awkward about your While Loop in a For Loop.  You are collecting data on every while loop iteration once per second into a 1-D array until an amount of time has passed.  Then passing that out.  Then repeating the Loop and creating a 2-D array out of your 1-D arrays. I'm not sure what your current 2-D array is supposed to represent.)

0 Kudos
Message 5 of 13
(4,013 Views)

Thank you again Ravens.

About the awkward thing in the Loops, I thougt that every data in loop is passed on the array every cyle.

I have not idea about another solution. I have tried to make some acquisition and, often it looks good but, truly, sometimes fails.

if you can address me toward other ways I can try! 🙂 this is my first labview program and I can start again from scratch.

 

Thank you, G.

 

 

 

(There is something awkward about your While Loop in a For Loop.  You are collecting data on every while loop iteration once per second into a 1-D array until an amount of time has passed.  Then passing that out.  Then repeating the Loop and creating a 2-D array out of your 1-D arrays. I'm not sure what your current 2-D array is supposed to represent.)

0 Kudos
Message 6 of 13
(4,000 Views)

I'd do something more like this.

 

Take the present time in seconds and build it into a 1-D array with your data value and store that in a shift register in the inner loop.  Continue building on them as the outer loop iterates using a shift register.  Then pass that data to the 2-D array input of the Write to Spreadsheet File function.

 

(With proper wiring, the stacked sequence structure is unnecessary.)

0 Kudos
Message 7 of 13
(3,996 Views)

Wow, thank you very much Ravens. 

Your code is clearly better!

I have tried to make an acquisition and it works well.

I have only problemns on the output file yet: I have seen that it consists of a number of columns (each for every loop cylce) and the time column reports the same value in every cell. Maybe there could be a problem in the transferring data in/out of the loop?

 

Thank you again for your help. G.

 

PS. Just a question: I have noted that you deleted the wire to the N of the for-loop...but it continue to work properly 🙂 that it is making a number of for-loops equal to the size of the array: how is it possilbe? 

0 Kudos
Message 8 of 13
(3,976 Views)

Wow, thank you very much Ravens. 

Your code is clearly better!

I have tried to make an acquisition and it works well.

I have only problemns on the output file yet: I have seen that it consists of a number of columns (each for every loop cylce) and the time column reports the same value in every cell. Maybe there could be a problem in the transferring data in/out of the loop?

 

Thank you again for your help. G.

 

PS. Just a question: I have noted that you deleted the wire to the N of the for-loop...but it continue to work properly 🙂 that it is making a number of for-loops equal to the size of the array: how is it possilbe? 

0 Kudos
Message 9 of 13
(3,976 Views)

Autoindexing tunnels.  The For loop runs the number of times necessary for the number of elements in the array. Explicitly measuring the size of the array and wiring in the N terminal is redundant.

 

What does your time data look like?  The value that comes out is the number of seconds since the epoch, which is something like Jan 1, 1904 midnight GMT.  So the raw number is something like over 3.4 billion seconds.  By going into the Write to Spreadsheet function, it might be truncating the data.

 

You may want to manually convert the data to strings inside the loop.  Convert the time data to a string and convert the data you are collecting to a string using whatever format code is necessary to preserve the information.  Build them into a string array, and pass that 2-D string data out to the Write to Spreadsheet File function.

0 Kudos
Message 10 of 13
(3,973 Views)