LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save multiple waveforms to excell spreadsheet

Hi Everyone,

 

So I just got a new project in lab which is to use our new DAQ board(NI USB 6341) to read a voltage from 5 PMTs.  I'm new to labview, and am struggling quite a bit but here's what I've done and would like to accomplish:

 

My example today uses two channels sampled at 1K.

 

1.Interface with the deivice and create a Task to measure from more than one channel. -Complete

-In my example code I have the sampling rate at 1k and N samples at 100.  Eventually I would like to sample at 100Khz. What is an appropriate N samples?

 

2. Generate Labview code that will continuously take data untill I tell it to stop and bring each channel to its own tab delimited column on the write out file.

 

I cannot get step two work correctly.  My understanding was that the DAQ assistant in my example outputs a 1D array of waveforms and that "Export Waveforms to Spreadsheet file" VI would read each element as its own array but I cannot get it to do that.

 

3. Graph in real time the two channels 10 seconds at a time. I.E I want it to continuously have a 10 second window([1,10],[2,11]...[101,111]) etc. so that way I know the current run time for sampling and I can see the current events.   This is a tricky situation because I want each to have their own plot and I haven't found a good way to use the register to append new data without eventually running out of memory.  The other issue is that when I append the data it shows from 0 seconds to my current time, I would like it to show me the waveform in time as discussed above.

 

If I could get some help on either of these two fronts, I would be immensely greatful.  Thank you so much for your help, and for reading this

 

Best,

-Joe

 

PS- Attached is my code.  Give it a run and see what it does to understand things a little better please.

0 Kudos
Message 1 of 8
(3,637 Views)

Oh, and my lab member helped me make the sub-VI.

 

You will probably need this! Smiley Tongue

0 Kudos
Message 2 of 8
(3,633 Views)

The file path control should be outside the while loop and it should be connected to a shift register. After that, the file write had no problems.

 

Perhaps you should be just using a chart. A graph is rewritten with each iteration. If you set the history length of the chart. you can control the number of samples. With your shift register and build array, it will just grow with no bounds.

 

p.s. The subVI you created is just a simplified version of the Append Waveforms on the palette. Why did you create a new one?

0 Kudos
Message 3 of 8
(3,620 Views)

Hi, thank you for your reply.  I must have a had a wiring issue that only sent one waveform before... whoops!  Anyways, this is probably a dumb question consdiering it is my own code but which one is my file path control?  Is that the blue box?  Do I just drag this outside of the loop and wire it back up to fix this?

 

Also I really would like to get it plotted in a similar manner to how I described.  What if, I was able to simultaneously append new data each time but erase it at the same rate?  That way I have a fixed waveform size of ten seconds that gets sent to the graphs.  All I would need to retain is the current iterations "t0" information.  How Might I approach this?

 

Also the sub VI was mainly to reduce clutter on our main VI.

 

Thanks,

 

-Joe

0 Kudos
Message 4 of 8
(3,615 Views)

As I already said, you can use a chart. It's certainly possible to create a fixed length fifo (which is what a chart is doing) so if you want to attempt that, go ahead.

 

Your created subVI is exactly the same size as the built-in append function so I don't understand your comment at all.

0 Kudos
Message 5 of 8
(3,611 Views)

Dennis,

 

I understand now your comment about a chart.  What was not apparent to me is that a chart is more like a plot when I thought you had meant for me to make a table of values.

 

With a bit of searching , I now understand the confusion about the sub-VI.  We were unable to find the "Append Signals" VI untill you had mentioned it.

 

 

I appreciate your patience, thanks.

 

-Joe

0 Kudos
Message 6 of 8
(3,605 Views)

Okay so the charts ended up working out nicely if I wanted to sample at 1kHz and have samples to read=100

 

But If I now up my sampling rate to 100kHz and 25k samples to read for 5 channels I immediately receive the error message:

 

 

"Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem."

 

I guess my first question, would be what is happening that is making the VI crash right away, the DAQ board can handle 500KHz across all channels so that is not the issue, how can I create my VI to handle this amount of data?

0 Kudos
Message 7 of 8
(3,593 Views)

What you have is a typical problem when you are selecting continuous samples and also use a time consuming function such as writing to a text file. With continuous mode, whatever other code you have in the loop must execute faster than the DAQ read iteration. In your case, you are reading 100k samples taken at a 100k/s rate so the the DAQ read needs to occur every secon. The writing of 100k samples would appear to take more than 1 second so when the read actually does occur, it overwrites unread samples and you get the error. You can switch to N Samples, try a binary write to a more efficient file (i.e. TDMS), or putting the file write in a consumer loop.

0 Kudos
Message 8 of 8
(3,583 Views)