Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously Sample Tasks

Hi,
 
I have a NI-SCXI-1600 USB DAQ with some analog inputs, but I think the question is independent from the HW.
 
I want to sample a set of channels continuously (some hours) at 1000Hz and take the mean for every 50 values, so that I have a effective sample rate of 20Hz per channel. Therefor I set the "DAQmx Sample Clock" to the corresponding inputs and start reading in a infinite loop.
The Problem: I do not want to set the "DAQmx Read" control "Num of Samples ..." to "-1" because I can not guarantee that I get equidistant values (the mean is not taken over the same portion of data).
So I set this input to "50", to disbelieve that the "DAQmx Read" blockade and waits until 50 samples are ready (with 1000Hz sample rate should be ervery 50ms one set ready).  To know from experience, that windows xp is not a realtime system, this approach is cool, because the device and the driver buffers the samples (for me it is important that I don't miss data)
BUT: "DAQmx Read" does NOT blockade and wait. The loop is executed as fast as possible and I get more values as I measure (if I slow down the loop e.g. 20ms I get 40Hz data)
 
How should I solve this? Where is my fault?
 
thx
 
M.Tiedje
 
0 Kudos
Message 1 of 4
(2,289 Views)
Are you using labview? You can easily multithread this program place each read task in its own thread, if the processing is fast enough you can process the data in its own loop, or you can use queues to send the data packets to a asynchronous processing loop.  This is a multiple producer one consumer architecture where each producer runs at 20 Hz hardware timed (use the timeout to grab the samples at the desired rate) and send the data to a consumer (data analysis loop) for processing and display.  I would packet the data a a cluster with a id number signifying the source (daqTask) and the data as a 1d vector of data.  The processor can the grab the data as it arrives and process it is (with 1000Hz) near real time depending on your CPU/system loads.  Since each task/data acquisition unit gets its own thread, this design is extensible.  Again the driver will buffer the data and prevent data from being lost.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 4
(2,284 Views)
If you set the "Number of Samples per Channel" Input to the DAQmx Read VI to 50, it will wait until it has 50 samples to return.  If you are sampling at 1000Hz, then it will be approximately 50ms.  Check out the attached VI.  If I understood your post, then it should do pretty much what you are trying to accomplish.  I added a couple things to check the timing.  Run it with 1000Hz as the sample rate, and 50 as the number of samples to read.  Let it run for a little bit, press the stop button, and take a look at the Average Loop Time control.  You should see that it is fairly close to 50.  If you find other results, post back with your findings and we can investigate further.  Happy Holidays 🙂
-Alan A.
Message 3 of 4
(2,283 Views)
Thank you for your quick reply.
 
I found the misstake: I was some kind of race condition between the "DAQmxRead" and my datalogger. While "DAQmx read" waits for new data my logger , which was in the same loop (connected with "i" and "Tick Count" and a array of strings of values from "mean" for loop). After I shift the result thru the loop, it works 🙂
Strange, because there must be a signal on all wires to act so.
 
M.Tiedje
 
 
 
0 Kudos
Message 4 of 4
(2,272 Views)