Summary:
We have a system controlling a NI-PCIe 6363 Device via the NI-DAQmx library (see NIDAQmx.h, nidaqmx.lib). I have successfully programmed the device for digital and analog I/O. At this time, we have a single analog input that we are trying to control with a variety of combined (sampling rate and number of samples).
Question:
What are the valid combinations of {sampling rate, number of samples} given the following Setup?
Setup:
Here is the abstract C++ code configuration:
// internal clock is 10 MHz
int32 read = 0;
float64 dSamplingConvRate = 2000000.0; // 2M Hz
// set of parameters that does work
float64 SamplingRate = 200000.0; // 200K Hz
uInt32 nSamples = 100000; // 100K
DAQmxCfgSampClkTiming(m_TaskHandle,
NULL,
SamplingRate,
DAQmx_Val_Rising,
sDAQmx_Val_ContSamps,
nSamples);
DAQmxSetAIConvRate(m_TaskHandle, dSamplingConvRate);
DAQmxSetSampTimingType(m_TaskHandle, DAQmx_Val_SampClk);
DAQmxSetStartTrigType(m_TaskHandle, DAQmx_Val_DigEdge);
DAQmxSetDigEdgeStartTrigSrc(m_TaskHandle, "/Dev1/PFI10");
DAQmxSetDigEdgeStartTrigEdge(m_TaskHandle, DAQmx_Val_Rising);
DAQmxSetStartTrigDelay(m_TaskHandle, 0.0);
DAQmxSetStartTrigDelayUnits(m_TaskHandle, DAQmx_Val_Seconds);
next, we setup a callback:
DAQmxRegisterEveryNSamplesEvent(m_TaskHandle, DAQmx_Val_Acquired_Into_Buffer, 1, 0, EveryNCallback, this);
inside the callback, our code reads the data:
DAQmxReadAnalogF64(m_TaskHandle,
nSamples,
10.0,
dataLayout,
pBuffer,
nSamples,
&read,
NULL);
Discussion:
This setup uses a waveform on "/Dev1/PFI10" where a square wave cycles every second. In this design, the leading edge of the assigned trigger pulse kicks-off the data collection (via DAQmxSetDigEdgeStartTrigSrc). The above abstract code snippet (key parameters are shown to illustrate the setup) works well. The system runs continuously until we stop data collection using API calls to stop the DAQ under our software control. This pattern configured the API to internally transfer the data into our client buffer using the DAQmx thread (the eventOptions flag was set to 0, so the callback function is called in a DAQmx thread) as opposed to the alternative method of using a separate thread via DAQmx_Val_SynchronousEventCallbacks. Once we've read the data using DAQmxReadAnalogF64, we return, everything works fine. This setup is stable and runs without error continuously for many days. The goal is to change the readout frequency by changing the number of samples read at a constant ADC rate. The internal clock is 10MHz.
Question:
What are the valid combinations of {sampling rate, number of samples} given this setup?
For example, trying the following setup does not work, the registered callback is never called.
float64 SamplingRate = 180000.0; // 180K Hz
uInt32 nSamples = 60000; // 60K
But, the following setup combinations do work.
float64 SamplingRate = 200000.0; // 200K Hz
uInt32 nSamples = 200000; // 200K
float64 SamplingRate = 200000
uInt32 nSamples = 100000
float64 SamplingRate = 150000
uInt32 nSamples = 50000
float64 SamplingRate = 200000
uInt32 nSamples = 50000
float64 SamplingRate = 125000
uInt32 nSamples = 25000