Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Queing data and write to file

Hi,

 

I am acquiring data from two channels and continuously displaying them, however I want to write them to a file only when the user specifies. I want the file write to be done in a specific manner, The user specifies a number of samples per second, say 200 and time interval, say 10 s. So what needs to be done is, when the user clicks a collect button the continuous data should be queued (200 samples) and average of that should be written to excel file, so over a period of 10 s we will have 10 values written into the excl.Once this is done user should be given an indication that file write is complete and user can hit the collect button again.

 

Can somebody help me with any ideas?

 

Thank you.

 

0 Kudos
Message 1 of 2
(2,543 Views)

I've got a few ideas on this.  First of all we always recommend keeping a 10:1 ratio of sample rate to samples to read.  So if you are acquiring at 200 s/S, you should acquire 20 samples each run through.

 

In terms of queuing up data, there are several ways to go about doing this.  One way would be to only "queue" data if the user wants to log it.  This data can then be read from the queue and written to a file.  There are definitely other ways to approach this, but I think this is a good start.  This uses what is called a "Producer/Consumer Architecture". Data is acquired in one loop and processed in a second loop.  It is passed between loops using queues.  The idea here is that the data is only queued when the user decides to log data.  Additionally, we check to make sure that we only queue a set amount of data, which corresponds to the acquisition time.  The data is written to a text file in a tab delimited format that can be read in excel.

 

Jon S

Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,524 Views)