Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

writing continuous 1D wfm to one column per channel in .tdms file?

Solved!
Go to solution

Hi guys,

 

I use the daq 6361 to write ecg samples continuously to the analog input. Everytime the analog Comparison event occurs at a specific threshold a counter waits for a specific low time and then writes a pulse to an digital output to trigger a another device. To check if the pulse is in the right place I routed it to a second analog input. Now I want to save the data for postprocessing in an excel file in the end.

 

The problem I stumbled over is that the loop only reads 100 samples because of the 'samples per channel' and just those last 100 samples were stored in the tdms file. Or with a shift register every next set of 100 samples was written in the two next columns. How can I overcome this problem to store the whole data in one column per channel?

 

If I have a single Waveform there is no problem to transfer it through the loop. But as soon as I have two analog inputs I have to define the read VI as an Analog 1D Wfm NChan NSamp and get a 1D Waveform. I have no idea how to transfer it through the loop to save the ecg samples and the trigger pulse samples in a file. 

 

Thanks a lot for your help and have a nice weekend!

 

(Code is attached, to simulate it I attach a file with a sine wave)

 

 

Download All
0 Kudos
Message 1 of 3
(895 Views)
Solution
Accepted by topic author skittlesgiraffe

The solution you want is not the one you should use.  It's not considered a good practice to accumulate data indefinitely inside a loop and then dump it all at once into a file after the loop.  Here's a brief outline of 3 better alternatives:

 

1. Use DAQmx Logging to let DAQmx stream to TDMS in the background for you.  See the shipping examples for continuous analog input to see how easily this can be done.  If desired, after you stop the task you could convert the TDMS file contents into a different format.

 

2. Use the file primitives rather than the Express VI.  Open a file before starting the loop, write to it inside the loop using the file refnum, then close it after completing the loop.  By itself, this is the worst of the 3 options.

 

3. Use the Producer Consumer pattern to make a parallel file writing loop that's structured like #2 above.  Use a Queue or a "Stream Channel" to deliver data from your data acq loop to the file writing loop.

 

All 3 alternatives will write data to the file incrementally as the acquisition runs instead of accumulating it and writing all at once.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 3
(879 Views)

Dear Kevin,

 

thank you so much for your help and your advice. It works right now and I finally understand how to use queues properly.

 

Have a nice day!

 

0 Kudos
Message 3 of 3
(837 Views)