Discussion:
How to control whether writting data to the file or not before runs?
(too old to reply)
foolooo
2008-08-06 11:40:09 UTC
Permalink
Hi all,
 
I'm doing multiple channels DO, AO and AI. I want this DAQ programme run continuously at 100K S/s. After I acquire the data I want to write them into a file. But rather than write the whole data block, I would like to write only some of them. A digital wavefrom is generated to determine which part of the data block is to be written, in which high stands for writting and low for not to write. I used a queue to store the acquired data, and I want to do the "filtering" things in the dequeue part so that it won't slow down the acquistion. I think there may be 2 ways to do that, by controlling the enable state of writting fuction or extract a subset of the data block. For the second manner, I need to extract several subsets from a single array (data block), I don't know how to do that. Could any one give me some advice? Or, is there some other way to implement the "segmental writting"? Thank you all.
 
Best wishes
Bo
Hillman
2008-08-06 17:10:14 UTC
Permalink
Hi Bo,
 
I have done and attached an example of data acquisition and analysis using producer/consumer loops. Using queuing no data is lost.
 
However, for your application time may be critical.. so synchronization may need to be considered more.
 
Also, with the example, you may want to do the 'its switch true aka is digital waveform high' test in the consumer loop.
 
Im not sure how you'll keep the timing for the data if (in my example) we only write values when 'x' is true..
 
let me know what you think, and maybe you could attach your code to allow me (and others) to get more involved.
 
Have a great day,


producer&consumer acq.vi:
http://forums.ni.com/attachments/ni/250/42133/1/producer&consumer acq.vi
foolooo
2008-08-07 13:40:11 UTC
Permalink
Hi Hillman,
Thank you for your reply and your code. Sorry I didn't programme the "data selection" part yet, so I cannot show it to you. In your code, you enqueue the data when the switch is on. But since I need to do the DAQ at 100k S/s and I'm afraid the selection in the enqueue part might slow down the acquisition. I prefered to do it in the dequeue loop. I think I didn't describe my question clearly, and the selection is set 'before' we acquire the data. e.g.I set the manner of selection as 00011111000111, which is transmitted from a digital waveform set by the user. And if the data acquired later is ABCDEFGHIJKLMN, then the data written into the file should be DEFGHLMN. So will it be a better way to extract a subset from the data block right before we write it?
Regard,
Bo
Hillman
2008-08-07 16:10:10 UTC
Permalink
Hi Bo,Thanks for replying - I did suggest the filtering may need to be done in the de-queue loop.I have pulled together another example - built on top of the original.It does exactly what you?re talking about in your latest post. i.e.It could take in N samples from your DAQmx task so you keep your 100k S/s rate, queues them.Then in the de-queue part, it goes through sample per sample, and if the digital line (switch) is high it writes them to file (tdms).You may need to consider the amount of memory the buffer (in the queue is using). Also, my only want to write to fill once as writing to file in every loop will take a lot of time (relativity). Therefore, maybe write to an array firstly. Then after all the samples have been filtered, write to file.I hope this makes sense, please post again soon if you wish to discuss this further.Regard,


producer&consumer acq3.vi:
http://forums.ni.com/attachments/ni/250/42166/1/producer&consumer acq3.vi
foolooo
2008-08-12 12:10:13 UTC
Permalink
Hi Hillman,
Thank you for your reply and your code. I'm trying it and I believe this is the right way. Thank you so much.
Best wishes,
Bo
Hillman
2008-08-12 12:10:14 UTC
Permalink
Hi.
Thanks for the reply.. its always nice to hear good feedback.
Good luck with it all.
Have a nice day.
Regards

Loading...