LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to spreadsheet

Solved!
Go to solution

Hello all. I have my Vi attached that does nothing more than feed an output voltage from 1-5, every 3-seconds, unless the stop button is pressed. I don't like the stop button I chose because, if accidentally put in the true state prior to running Vi, it throws up an error I am not sure how to recover from. However, that isn't what my concern is, at the moment. I will try to fix that on my own first. What I am unsure as to do now is how to write a value from each of the case structures onto a spreadsheet. I tried using arrays and store the data from each case structure to a location on the array, without any luck. I have gone through the Core 1 section on arrays to see what I am doing wrong, didn't help me. This has to be much simpler than I am making it. First, am I correct assuming I must first write this to an array, then transfer the data at the end of the Vi cycle, or should I have it write directly to a spreadsheet after each case structure closes? Thank you much.

0 Kudos
Message 1 of 26
(4,016 Views)

I'm not exactly clear on what you're writing in each state. (i.e. are you really writing a spreadsheet or is Write to Text more appropriate?)

Seems like you can accomplish what you want with Write To Spreadsheet and make sure to wire the Append to File input to True instead of false.

 

As always post your attempts and we can correct from there.

 

Message 2 of 26
(4,007 Views)

The Vi will output 1 volt after "initiate" is pressed. It will wait 3 seconds then change to 2 volts, wait 3 seconds then change to 3 volts......until it runs its last one which is 5 volts. After it is done, the output goes back to 0 volts. What I am trying to do is collect the data after each case structure completes. This Vi is for me to learn the NI DAQ device. For now it is just an output voltage however, after I figure this out, I will then add an input voltage as well. But for now, I am just trying to get it to write each voltage from each case structure onto a spreadsheet.

0 Kudos
Message 3 of 26
(3,994 Views)

Seems pretty straightforward.

Go ahead and post what you've got.

I think you'll likely want to use a shift register for the spreadsheet file path.

Seems like you may want to use Build Array prior to using the Write To Spreadsheet.

 

From your description, I would include a Write To Spreadsheet in each case that you want to record data.

Message 4 of 26
(3,987 Views)

This is where I am at.

0 Kudos
Message 5 of 26
(3,982 Views)

OK. So you've set it up so that it will only write the spreadsheet when you exit.

I don't really recommend this approach since you will have to collect all of your results in an array and then perform a single write at the end.

It's unclear how big that array might actually get.

 

If you wire a path into the Write to Spreadsheet function, then you won't be promped for it.

You will also need to wire the data that you intend to write into the Write to Spreadsheet function.

 

In any case, whether you do a write at the end or whether you write during each state, you will need to wire the data that you want to write into the Write To Spreadsheet function. If you're doing this on a state by state basis, you can wire in a 1-D array each time you write. If you're doing a write at the end, you should send in a 2-D array.

Message 6 of 26
(3,968 Views)

I apologize for sounding dumb but I am not sure what you mean, not sure how to do what you are suggesting.

0 Kudos
Message 7 of 26
(3,962 Views)

if you're going to write at the end (i.e. outside of your while loop):

Write At Once Snippet.png

If you're going to write during each case as you generate data (i.e. inside your case structure):

Write During Case in State.png

 

Message 8 of 26
(3,958 Views)

I have tried without much success. I can't seem to get the wiring of the terminals correct even.

0 Kudos
Message 9 of 26
(3,945 Views)

When I run it, nothing is on my spreadsheet. I am not sure how to connect my array to the value that is being output

0 Kudos
Message 10 of 26
(3,929 Views)