03-20-2008 02:31 AM
03-20-2008 05:49 AM
@Raghunathan wrote:
- The Task then feeds into a 50ms timed loop and inside of the loop I have a AI DAQMx Read set for acquiring 200 samples. / channel. Thus the Timed loop will fire 20 times every second and in each of that instance read 400 samples making it to a total of 20 x 400 = 8000 samples / sec.
03-20-2008 10:41 AM
In short, you've overconstrained yourself by specifying both a fixed DAQ read rate (via the Timed Loop) and a fixed DAQ read quantity (via the # of samples) which don't match up cleanly with your DAQ acquisition rate. 2 options I've used:
1. No Timed Loop. In a regular While loop, call the DAQmx Read function with your fixed # of samples (200? 400? Not clear in your post). By default, DAQmx will always return the oldest data that you have not previously read. Within a few loop cycles, you should catch up to your acq task and find that the DAQmx Read call will actually get stuck waiting for those samples to arrive. This is fine -- the DAQmx driver will yield CPU during this waiting time unlike the old legacy driver. Once you get to this point, your loop rate will generally be constant and stay in sync with your acquisition task. But for sure you'll be dealing with constant chunk sizes of data, which is an important consideration in some apps because you can make special accomodations to overwrite rather than re-allocate memory.
2. Wire -1 to read 'All Available Samples'. Stick with your timed loop to give you your best shot at a constant loop rate. But each time you call DAQmx Read, use the (-1) input value to specify that you want all available samples. This Read call will return immediately with no waiting, but will give you varying quantities of samples from one call to the next. This variable chunk size of data may not be a problem in some apps.
Like Phillip, I often use Queues and/or Notifiers so I can defer things like datalogging, display, and processing so as not to bog down the data acq process. He and I both agreed in that LAVA thread that a set of "lossy queue" or "circular buffer" functions would be a great addition to LabVIEW. Much of the functionality seems to have been worked out inside the DAQmx driver -- we just don't have the ability to do similar things with RAM in our apps.
-Kevin P.
03-20-2008 11:37 AM
03-20-2008 01:37 PM
03-20-2008 09:02 PM
In the DAQmx Read where you set overwrite samples, you may want to use the task and error wires so that it is guarantee to run before the task starts. As of right now, it is a race condition as to whether that node or the task start node executes first. If the task start node happens first, it may or may not be possible to set the "Overwrite Samples". The help file says it depends on the device as to whether this setting can be changed while a task is executing.
I would recommend passing all data to another parallel loop using queues and a producer/consumer design pattern for display and analysis.
In your For loop, you are doing averaging on each row of data, then building that back up into an array where you index out only the 1st row. So the averaging that is being done on 7/8 ths of your array is getting discarded. Why not index out the 0th row first and only average that?
03-20-2008 10:20 PM
03-20-2008 11:49 PM
03-21-2008 12:52 PM
03-21-2008 01:07 PM