LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Streaming multiple channels directly to CSV USB-6210?

Solved!
Go to solution

I would like to stream up to 16 channels of data to a CSV file. My sample rate will vary from file to file, but I may reach 1KHZ. I understand the disadvantage of using text files rather than TDMS or binary, but I need to be able to read these files later with programs such as Excel (Excel 2007 can do 1 million points).

I have no trouble writing to TDMS files as this seems very straighforward. I am wondering though, would it be more efficient to use TDMS files as the data is being acquired and then after I stop, read the TDMS and convert to CSV or just save directly to CSV? I'm only saying this because I don't know if Labview can stream to a text or CSV file at 1KHZ.

 

The scenario. The user will start acquisition (using the USB-6210) to start reading 16 channels, applying some multipliers to some of the data, then sending to a disk. Don't worry about the size of the file, the operator will be told that if he samples fast he has to limit his total sample time. He has the option of running slower sample rates to acheive longer times.
Bottom line is that I want good time stamped data for all 16 channels. No header information, nothing but raw data start to finish.

 

I've seen several posts where the advice was to use TDMS files. Again, I am not opposed to this, but I need to end up with text files.

 

Jeff

0 Kudos
Message 1 of 8
(4,575 Views)
Solution
Accepted by topic author jeff_scharpf

 LabVIEW can handle this, if you do it correctly.

 

1. If you aren't already, utilize the producer/consumer data design pattern.  It should be a template that shipped with LabVIEW.  This will allow you to take data continuously because your data processing/saving routines take place in a seperate thread.  If saving the data takes longer than reading the data, LabVIEW will just keep the queue size growing with new data and hopefully you won't run out of system memory.

 

2. Write you data in "chunks".  If you expect to write to the disk every data point as soon as it is available then that will probably be very taxing on performance because of the excessive amount of "read/write" header information going to your disk controller and other things.  It is better to save 1000 samples at a time, for instance.  That way you are "hitting" your disk 10 times a second instead of 1000 times a second.

 

3. ASCII files are very large, but I too tend to use them because of their convienance.  If you think about it, one 32-bit value may be "12332.0123" which in ascii is more like 80-bits (1 byte per character, 8 bits per byte, 10 characters is 80 bits which is more than twice the amount if stored as a 32-bit floating point number).  So it makes sense that if you have performance problems (even after applying 1 and 2) that you write to a binary file.  Then you can easily write a program that reads the binary file and writes a text file.

 

4. If your computer has enough memory, you could store everything in memory and save it to a file at the end of data collecting.  You would need to add more checks and stuff if you were writing this LabVIEW application for someone else.

Message 2 of 8
(4,571 Views)

Thanks for the response! I never thought of keeping everything in RAM until the end.

 

Would my math be correct if I estimated 20 bytes (exaggerated) for one reading -- times 16 channels --- times 1 million scans --- is about 320MB of RAM used?

 

I'll have to think about that one..

 

Otherwise I will just do a binary file and when the acquisition is done, just convert it..


Thanks again!

Jeff

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

Hi Jeff,

 

Also if the only reason you are wanting to write to CSV is so that you can also load the data into Excel, I would like to point out that TDMS files can be loaded directly into Excel using the Excel TDM Add-in.  The Add-in installs with many of our software products and can also be downloaded for free from our website here:

 

http://zone.ni.com/devzone/cda/epd/p/id/2944 

 

Hope this helps.

 

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 4 of 8
(4,522 Views)

Whoa that's exactly what I need! 🙂

 

That saves me from having to do ALOT of code!

 

I was struggling to do all kinds of TDMS to CSV conversion.

 

Thanks!

0 Kudos
Message 5 of 8
(4,493 Views)

Can't get it to install. It goes to the "accept license screen", then when I hit next, it gives me the message "No software will be installed". No options, no other message. I am running Office 2007, maybe it's not compatible?

0 Kudos
Message 6 of 8
(4,492 Views)
hmm my mistake it looks like I may already have it installed, found it listed and checked as a COM add on .. now to get it to work lol.. 🙂
0 Kudos
Message 7 of 8
(4,491 Views)

Hi,I am using a USB 6210 device and i want to write the samples to an excel file. I am currently using VB6 for this? is there any example of method which i can use for doing that? Also, is it possible to get a time stamp for the values?

 

Thanks,

 

Bedi

 

0 Kudos
Message 8 of 8
(4,132 Views)