Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the following code cause a timeout when trying to read a finite number of samples from USB-6216?

Solved!
Go to solution

I don't have Measurement Studio, but I'm using the .NET 4 support available with DAQmx.

 

The following code throws a timeout on the ReadMultiSample() call. Can someone please tell me what I'm doing wrong? I'd like to get 40,000 samples with a sample rate of 20 kHz. I've renamed by USB-6216 device to "Meas1" using MAX.

 

[edit] I should point out that I'm using AnalogMultiChannelReader because I intend to be capturing more than one channel once I figure this out.

 

Thanks in advance!

 

            using (Task task = new Task()) {
                task.AIChannels.CreateVoltageChannel("Meas1/ai1", "", AITerminalConfiguration.Differential, -0.2, 0.2, AIVoltageUnits.Volts);
                task.Timing.SampleQuantityMode = SampleQuantityMode.FiniteSamples;
                task.Timing.SampleClockRate = 20000;
                task.Timing.SamplesPerChannel = 40000;
                AnalogMultiChannelReader reader = new AnalogMultiChannelReader(task.Stream);
                task.Start();
                samples = reader.ReadMultiSample(40000); //  <-- Timeout occurs during this call
                task.Stop();
            }

 

0 Kudos
Message 1 of 2
(5,231 Views)
Solution
Accepted by topic author Xooch

I forgot to set the SampleTimingType:

 

task.Timing.SampleTimingType = SampleTimingType.SampleClock;

 

0 Kudos
Message 2 of 2
(5,228 Views)