Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong timing in Multi Channel Acquisition USB-6210 using DAQmx

Hi,

 

Im trying to test the USB-6210 for multi channel acquisition using DAQmx but ther is something strange about the time the device takes to collect data for  single channel acuisition to multi channel acquisition: it comes out to be same!

 

For example in the following code I add single channel with sample per channel = 25000 and sample clock rate = 250000.

 

 

void startDataRead()
        {
noOfSamplesToCapture = 250000;
// Create a new task myTask = new NationalInstruments.DAQmx.Task(); // Create a virtual channels myTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "Ch1Sensor", AITerminalConfiguration.Rse, Convert.ToDouble(-10), Convert.ToDouble(10), AIVoltageUnits.Volts); // Configure the timing parameters myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(250000), SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, noOfSamplesToCapture); // Verify the Task myTask.Control(TaskAction.Verify); runningTask = myTask; analogInReader = new AnalogMultiChannelReader(myTask.Stream); analogCallback = new AsyncCallback(AnalogInCallback); // Use SynchronizeCallbacks to specify that the object // marshals callbacks across threads appropriately. analogInReader.SynchronizeCallbacks = true; analogInReader.BeginReadWaveform(Convert.ToInt32(noOfSamplesToCapture), analogCallback, myTask); testTimer.Start(); } private void AnalogInCallback(IAsyncResult ar) { testTimer.Stop(); try { if (runningTask != null && runningTask == ar.AsyncState) { data = analogInReader.EndReadWaveform(ar); System.Diagnostics.Debug.WriteLine(testTimer.ElapsedMilliseconds); testTimer.Restart(); analogInReader.BeginMemoryOptimizedReadWaveform(noOfSamplesToCapture, analogCallback, myTask, data); } } catch (Exception) { throw; } }

 

I measure the time between callbacks and it comes out to be almost 1 second. Okay thats logical, it takes 1 second to collect 250000 samples for 1 channel at 250000kHz rate.

 

But when I add 5 channels as follows:

 

void startDataRead()
        {
            noOfSamplesToCapture = 250000;
            
            // Create a new task
            myTask = new NationalInstruments.DAQmx.Task();

            // Create a virtual channels            
            myTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "Ch1Sensor",
                AITerminalConfiguration.Rse, Convert.ToDouble(-10),
                Convert.ToDouble(10), AIVoltageUnits.Volts);
           
            myTask.AIChannels.CreateVoltageChannel("Dev1/ai1", "Ch2Sensor",
                AITerminalConfiguration.Rse, Convert.ToDouble(-10),
                Convert.ToDouble(10), AIVoltageUnits.Volts);

            myTask.AIChannels.CreateVoltageChannel("Dev1/ai2", "Ch3Sensor",
                AITerminalConfiguration.Rse, Convert.ToDouble(-10),
                Convert.ToDouble(10), AIVoltageUnits.Volts);

            myTask.AIChannels.CreateVoltageChannel("Dev1/ai3", "Ch4Sensor",
                AITerminalConfiguration.Rse, Convert.ToDouble(-10),
                Convert.ToDouble(10), AIVoltageUnits.Volts);

            myTask.AIChannels.CreateVoltageChannel("Dev1/ai4", "Ch5Sensor",
                AITerminalConfiguration.Rse, Convert.ToDouble(-10),
                Convert.ToDouble(10), AIVoltageUnits.Volts);

            // Configure the timing parameters
            myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(250000),
                SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, noOfSamplesToCapture);

            // Verify the Task
            myTask.Control(TaskAction.Verify);

            runningTask = myTask;
            analogInReader = new AnalogMultiChannelReader(myTask.Stream);
            analogCallback = new AsyncCallback(AnalogInCallback);
            
            // Use SynchronizeCallbacks to specify that the object 
            // marshals callbacks across threads appropriately.
            analogInReader.SynchronizeCallbacks = true;
            analogInReader.BeginReadWaveform(Convert.ToInt32(noOfSamplesToCapture),
            analogCallback, myTask);

            testTimer.Start();
            
        }

        private void AnalogInCallback(IAsyncResult ar)
        {
            testTimer.Stop();
            try
            {
                if (runningTask != null && runningTask == ar.AsyncState)
                {
                    data = analogInReader.EndReadWaveform(ar);
                    System.Diagnostics.Debug.WriteLine(testTimer.ElapsedMilliseconds);
                    testTimer.Restart();
                    analogInReader.BeginMemoryOptimizedReadWaveform(noOfSamplesToCapture,
                        analogCallback, myTask, data);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

Still the time between each callback comes out to be 1 second. And as I check the 'data' variable in each callback. it contains valid data of 250000 samples for each channel everytime.

 

I expected it to take 5 seconds between each callback in order to collect 250000 samples of each channel.  Please help me out here. What am I doing wrong?

 

Thanks.

 

Regards,

 

Zeeshan

 

0 Kudos
Message 1 of 2
(4,355 Views)

Everything is correct. 1 clock - all channels. Rate is specified in samples/s, not samples/ch/s

 

Ideally the board should collect samples on all channels simultaneously on every clock tick. If there are N ADCs on the board (simultaneous sampling type), each ADC samples at the same time.

USB-6210 has one ADC with multiplexer - it switches much faster than acquisition clock.

Some ADCs have hold curcuit to keep voltage until it is processed by ADC.

0 Kudos
Message 2 of 2
(4,283 Views)