ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Read and Write to Multiple Files Using Producer/Consumer Architecture

Hi all,

 

I have a problem when I acquired data by DAQmx and then write them into multiple files. Previously I put the format into file in the reading while loop, it is a main lag for the program execution. Later I decided to use the producer/consumer architecture. I searched the forum and then found the link: http://decibel.ni.com/content/docs/DOC-2431  .The only difference with the example is that I have more channels and more files to write. So I just simply add more channels and more files output in the consumer loop. But sometimes the below error occurred:

error.PNG

Also, after using the producer/consumer architecture, I could not feel the improvement in program execution, for example, when I increase the sampling rate or decrease the numbers per channel, the error 200279 still occurs. Is there some misuse of the architecture in my code and how to correct that? The attachment is my trial vi and its subvis. Thank you very much

 

Best,

Tian, Hongxiang

0 Kudos
Message 1 of 4
(3,942 Views)

You'd be better off if you divided your consumer loop in two so that each consumer loop handles one queue and one file.

 

You also have a problem with your format into file.  You are taking a waveform datatype and coercing it into a double.  So you are actually only writing one value out of the waveform on every iteration.

 

Also, the array to cluster, then unbundler cluster combination in the producer loop is awkward.  You should be just using "Index array" on the 1-D array of waveforms coming out of your DAQmx Read.  It is resizable so you can get all 4 waveforms in one function.

 

Also, make sure you wire up the error output on your second dequeue function.  That is why you are getting the popup error dialog.  Put error indicators on both of those wires so you can see when the error occurs without otherwise interrupting your program.  I don't know what is causing your error 1.

Message 2 of 4
(3,933 Views)

Thank you very much for your reply.

 

I divided the consumer into two parts and it worked. And I also replaced my stupid 'array to cluster' then "unbundled" with the "index array", I used that weird thing just because I even don't know the index array is capable of doing this. After add another indicator, it seems the error 1 problem is also solved. Now my main problem is how to correctly write the data into .txt files. Actually I was always wondering why the format into files only record the last data in each iteration, now I understand.Smiley Happy Could you please tell me how to write the waveform into the .txt file? Because later I want to process the data by Matlab, the txt file is easier to deal with. Thank you again.

 

Best,

Hongxiang

0 Kudos
Message 3 of 4
(3,925 Views)

What you can do is use the Unbundle Waveform Components (in the Waveform tablet) to break out the Y array of data.  I would wire that into a Write Spreadsheet File function (File I/O palette) so that it automatically formats the data with linefeeds in between.

Message 4 of 4
(3,911 Views)