Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI-6122 and simultaneous sampling

We are using PCI-6122 to read two channels simultaneously at 500 kHz. The task is configured as follows:
long samplingRate = 500000;
long bufferSize = 10 * samplingRate;
DAQmxCfgSampClkTiming(taskHandle,"", samplingRate, DAQmx_Val_Rising,DAQmx_Val_ContSamps, bufferSize));
long amountOfSamples = 2 * samplingRate;
DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer, amountOfSamples, 0, &onSamplesRead, this));

I thought that the callback would be called every second because 500 kHz at the same time for two channels. Instead the callback is called every 2 seconds. Why is this?
0 Kudos
Message 1 of 3
(2,844 Views)
Ok, I reply (partly) to my own question. I got the total number of samples that was read in the callback by using:
int read = 0;
DAQmxReadAnalogF64(taskHandle,nSamples,10.0,DAQmx_Val_GroupByChannel, data.get(), bufferSize, &read, NULL)

The read contained 500 000 and this was confusing me. Now I noticed that the variable contains the amount of samples read per _channel_ not by per task that I thought. So now I get the correct amount of samples per second.

But this still does not explain why following call:

DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, 500000, 0, &onSamplesRead, this)

causes the callback to be called every second. I would expect it to be called every 0.5 seconds as there is 1 million samples per second (two simultaneous sampling channels at 500 kHz)?

Does the nSamples parameter in DAQmxRegisterEveryNSamplesEvent mean that the callback is called after nSamples have been read for each channel in task? If so, the documentation should be fixed because it says:

nSamples uInt32 The number of samples after which each event should occur.
0 Kudos
Message 2 of 3
(2,839 Views)
SamiL,
 
Typically in the DAQmx API, a sample is defined by one reading from each of the channels in your task.  You can think of this in terms of what your device is doing.  You configure a rate for the sample clock.  Each time that clock pulses, all of the channels in your task are read.  The idea of a sample in the DAQmx API is essentially all of the data which is acquired as a result of one pulse of the sample clock.  This same concept is applied to the every N sample event.
 
Hope this helps,
Dan
0 Kudos
Message 3 of 3
(2,826 Views)