LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to spreadsheet

I have a singal generated within my VI. I want to log the data being generated into a spreadsheet file. How can I output the data so that it uses only 2 columns, one for the x-values and one for the y-values. I need the x-values to be in increments of 1 secs. Can somebody please help me out? Thanks.

Here is my code:
0 Kudos
Message 1 of 9
(3,220 Views)
Change the wait time to 1000 ms.
Use Index Array to get element 0,0 from your 2D array.
Use Get date\time in seconds (from the time palette) and wire the result into To DBL (from the numeric>>conversion palette) to get the number of seconds in LV time format (you can convert this back later).
Use Build Array and wire both numbers in. This builds a 1D array. You can save this. Appending should turn it into a 2D array.
I suggest moving the file write function out of the loop and only saving when you're done (unless there is a specific need to save every second). If you do this, you should have the 1D array auto-indexed when exiting the loop to turn it into a 2D array.

___________________
Try to take over the world!
Message 2 of 9
(3,202 Views)
I tried making the necessary modifications that tst told me to do, but I still cannot limit the ouput to two columns. Can someone please help me out? Thanks

Here is my updated code:
0 Kudos
Message 3 of 9
(3,188 Views)
I guess I wasn't clear enough - You used Index array, but when you use it without wiring it, it only goes down one level, so instead of getting an element, you got the first row. Wire 0 and 0 into it.

___________________
Try to take over the world!
0 Kudos
Message 4 of 9
(3,180 Views)
I have no idea what you mean by wire 0 and 0 into the index array. I just started learning about Labview a couple of weeks ago and so I'm pretty much new to the software. Can you elaborate even further? Thanks
0 Kudos
Message 5 of 9
(3,178 Views)
The Index array is one many built-in VI which change according to what you wire into them. In this case, when you wire a 2D array into the VI, you'll get two additional inputs - one for a row and one for a column. If you wire 0 into both inputs, you'll get element 0,0 and this is what you should do.
Here's some more fun stuff -
If you wire 0 only into the column input, you'll get the entire first column as a 1D array. The same applies for the row (and for any other number).
If you hover over the VI, you will see two arrows on the top and bottom. These mean that you can expand the VI to extract more than one element.
If you expand the VI for a 1D array, the elements will be extracted in order even if you wire nothing in. Try and play with functions. Try wiring things you don't think will work. You will be surprised at the things that do work.

___________________
Try to take over the world!
Message 6 of 9
(3,172 Views)
I tried wiring 0 to the column and 0 to the row. However, I am getting the same constant x-values for the first column. Did I incorrectly wired the the get time/date function to the build array function? Thanks again.
Here is my code:
0 Kudos
Message 7 of 9
(3,166 Views)
I tried subtracting the starting number of seconds with each second that passes by, but for some reason it starts at 2.4sec when I try to ouput the x and y coordinates into excel. Can somebody please explain me what I am doing wrong. Thanks.

Here is my code:
0 Kudos
Message 8 of 9
(3,160 Views)
Nevermind, I finally figured out how to solve the problem. Thanks for all the help, tst
0 Kudos
Message 9 of 9
(3,149 Views)