回调:DAQmxRegisterDoneEvent() 和 DAQmxEveryNSamplesEvent 之间的区别
Callbacks: Difference between DAQmxRegisterDoneEvent() and DAQmxEveryNSamplesEvent
试图找出具体调用回调包装器的方式。我们的代码处理 slowTask
和 onTask
。在 slowTask
期间,我处理了以下两行(特定于此问题):
DAQmxCfgSampClkTiming(slowTask, "OnboardClock", GUI_RATE,
DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);
DAQmxRegisterEveryNSamplesEvent(slowTask, DAQmx_Val_Acquired_Into_Buffer, 1,
0, EveryNCallbackWrapper, this);
据我所知,这里每次缓冲区填满一个样本时,都会调用 EveryNCallbackWrapper
。
对于 onTask
,我很难理解回调是如何被调用的。我查阅了 NI 文档,但不太明白。
DAQmxCfgSampClkTiming(onTask, "OnboardClock", ON_RATE, DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps, 100);
DAQmxRegisterDoneEvent(onTask, 0, DoneCallbackWrapper, this);
这个让我更加困惑。我相信只要触发 onTask(使用硬件触发器),DAQ 就会开始在 ON_RATE samples/second 处进行模拟测量并将其数字化,一旦 100 个样本 taken/read 进入 DAQ 缓冲区,DoneCallbackWrapper()
被调用。根据此硬件触发器保持高电平的时间长短,每次 DAQ 读取 100 个样本(触发器为高电平时)都会调用此包装器,或者仅在读取 100 个样本后调用一次回调?
The callback is called only once after 100 samples were read
因为 slowTask
使用 DAQmx_Val_ContSamps
,程序要求进行 无限 (又名连续)采集,其中数据流式传输到主机。使用 EveryNSamples
回调允许程序访问和处理设备发送的最新数据。
因为 onTask
使用 DAQmx_Val_FiniteSamps
,程序要求 单次 采集 100
个样本。使用 Done
事件允许程序访问和处理完整和完整的获取。
在您的评论更新中,程序使用
DAQmxCfgDigEdgeStartTrig(onTask, "/PXI2Slot4/PXI_Trig0", DAQmx_Val_Rising));
为 onTask
配置一个 digital edge start trigger。当该触发线具有上升沿时,onTask
采集开始,捕获 100 个样本,停止并调用回调。
如果程序需要为 /PXI2Slot4/PXI_Trig0
上的 每个 上升沿采集 100 个样本 onTask
,您可以使用 retriggerable property on the NI 63xx series devices that allows the same task to re-run for each trigger event。
更多详细信息在 X Series User Manual:
The AI Start Trigger is also configurable as retriggerable. The timing engine generates the sample and convert clocks for the configured acquisition in response to each pulse on an AI Start Trigger signal.
The timing engine ignores the AI Start Trigger signal while the clock generation is in progress. After the clock generation is finished, the counter waits for another Start Trigger to begin another clock generation. Figure 4-22 shows a retriggerable analog input with three AI channels and four samples per trigger
试图找出具体调用回调包装器的方式。我们的代码处理 slowTask
和 onTask
。在 slowTask
期间,我处理了以下两行(特定于此问题):
DAQmxCfgSampClkTiming(slowTask, "OnboardClock", GUI_RATE,
DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);
DAQmxRegisterEveryNSamplesEvent(slowTask, DAQmx_Val_Acquired_Into_Buffer, 1,
0, EveryNCallbackWrapper, this);
据我所知,这里每次缓冲区填满一个样本时,都会调用 EveryNCallbackWrapper
。
对于 onTask
,我很难理解回调是如何被调用的。我查阅了 NI 文档,但不太明白。
DAQmxCfgSampClkTiming(onTask, "OnboardClock", ON_RATE, DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps, 100);
DAQmxRegisterDoneEvent(onTask, 0, DoneCallbackWrapper, this);
这个让我更加困惑。我相信只要触发 onTask(使用硬件触发器),DAQ 就会开始在 ON_RATE samples/second 处进行模拟测量并将其数字化,一旦 100 个样本 taken/read 进入 DAQ 缓冲区,DoneCallbackWrapper()
被调用。根据此硬件触发器保持高电平的时间长短,每次 DAQ 读取 100 个样本(触发器为高电平时)都会调用此包装器,或者仅在读取 100 个样本后调用一次回调?
The callback is called only once after 100 samples were read
因为 slowTask
使用 DAQmx_Val_ContSamps
,程序要求进行 无限 (又名连续)采集,其中数据流式传输到主机。使用 EveryNSamples
回调允许程序访问和处理设备发送的最新数据。
因为 onTask
使用 DAQmx_Val_FiniteSamps
,程序要求 单次 采集 100
个样本。使用 Done
事件允许程序访问和处理完整和完整的获取。
在您的评论更新中,程序使用
DAQmxCfgDigEdgeStartTrig(onTask, "/PXI2Slot4/PXI_Trig0", DAQmx_Val_Rising));
为 onTask
配置一个 digital edge start trigger。当该触发线具有上升沿时,onTask
采集开始,捕获 100 个样本,停止并调用回调。
如果程序需要为 /PXI2Slot4/PXI_Trig0
上的 每个 上升沿采集 100 个样本 onTask
,您可以使用 retriggerable property on the NI 63xx series devices that allows the same task to re-run for each trigger event。
更多详细信息在 X Series User Manual:
The AI Start Trigger is also configurable as retriggerable. The timing engine generates the sample and convert clocks for the configured acquisition in response to each pulse on an AI Start Trigger signal.
The timing engine ignores the AI Start Trigger signal while the clock generation is in progress. After the clock generation is finished, the counter waits for another Start Trigger to begin another clock generation. Figure 4-22 shows a retriggerable analog input with three AI channels and four samples per trigger