LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting data to excel having multiple channel analog input on NI USB 6009 device

Here are some questions and some guesses on my part:

  • What is MyVoltageTask_0?  This sounds like a Task that MAX makes (which is an excellent place for someone getting started with DAQmx to begin!).  However, it looks like you want to take two channels, Channel 0 and Channel 1, and may even have programmed this into the Task.  [Suggestion -- put a Text Box on your Block Diagram that says "MyVoltageTask_0 uses AI0 and AI1, sampling Continuously at 1KHz for 1000 samples" -- or whatever the details are].  If this is true, then you should just "Start Task", have a single Task that (as you have done) takes NChan NSamp and returns the data as a 1D array of Waveform (since you have 2 channels, you'll get an array of 2 Waveforms).  You've just saved half your Block Diagram!
  • There is no point to a For Loop with 1 wired to the Loop Count.  You don't need the Shift Register since there is only the one array to contend with.
  • If you are taking data continuously, there is no sense in putting the time on each data point.  A Waveform gives you T0, the starting time (which is usually irrelevant) and dt, the sampling interval (which should be rock-solid fixed, and can be written once in seconds (e.g. 0.001, if sampling at 1KHz) and is good for the whole data file.  Note that this will also simplify your data file.
  • When using loops to build arrays (which you do not need to do here, see above), you should learn to use the AutoIndexing tunnel, which removes the need for an internal Build Array and a Shift Register in the loop.  Simplifies the code and makes what you are doing more "obvious", even without documentation.
  • If you are writing to a Delimited Spreadsheet, there is no need to convert the data to text, as it will accept arrays of Dbl.

Even following these suggestions, you still are probably not going to get the File Structure you want (in part because I failed to consider how you want to combine multiple samplings).  So here are some more questions:

  • Let's say that you sample 2 channels continuously at 1KHz, taking 1000 samples at a time.  Let's also say you sample for an hour, or 3600 seconds.
  • Thinking only about the 3.6 million samples from the 2 channels (and ignoring time for the moment), how do you want this arranged?  Two rows of 3.6 million comma-separated values?
  • If you do use the "Dbl" form of Write Delimited Spreadsheet, pay attention to the Format specifier -- by default, it uses 3 digits of precision.
  • If you want dt written, we might need to "get creative" ...

Bob Schor

0 Kudos
Message 11 of 12
(685 Views)

Thank you for the feedback. I have attached a program similar to what you suggested below. The only thing is if I do not use the delimited spreadsheet, my data time from the waveform is off when I convert the kHz to seconds where I just collected data for a minute and the time in the spreadsheet (after converting it) was not equaling out. I will attach the data too.  Do you know why that is different? Or am I missing a basic concept?

 

I really like your textbox suggestion because I was outputting data as N sample with sample reading of 1000 at 1 kHz rate using the program I attached earlier. I do not want to have the data every second (every 30 seconds or minute would be ideal). Additionally, I really do not need the change in time (dt) but would prefer time in one column and data for each channel in a separate column. Do you know how I would need to do this?  You are correct the delimited spreadsheet in the code I am attaching does not provide the data in proper format. 

 

Thank you again!

 

 

Download All
0 Kudos
Message 12 of 12
(678 Views)