简体   繁体   English

回调:DAQmxRegisterDoneEvent()和DAQmxEveryNSamplesEvent之间的区别

[英]Callbacks: Difference between DAQmxRegisterDoneEvent() and DAQmxEveryNSamplesEvent

Trying to figure out how callback wrappers are called specifically. 试图弄清楚如何专门调用回调包装器。 Our code deals with a slowTask and an onTask . 我们的代码处理了slowTaskonTask During a slowTask , I deal with the following two lines (specific to this question): slowTask期间,我处理以下两行(特定于此问题):

DAQmxCfgSampClkTiming(slowTask, "OnboardClock", GUI_RATE,
      DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);
DAQmxRegisterEveryNSamplesEvent(slowTask, DAQmx_Val_Acquired_Into_Buffer, 1,
      0, EveryNCallbackWrapper, this);

I understand that here, everytime the buffer fills up with one sample, EveryNCallbackWrapper will be called. 我知道在这里,每当缓冲区填充一个样本时,就会调用EveryNCallbackWrapper

For an onTask , I have a hardtime understanding how the callback gets called. 对于onTask ,我onTask理解回调如何被调用。 I consulted the NI documentation but couldn't quite get it. 我查阅了NI文档,但听不懂。

DAQmxCfgSampClkTiming(onTask, "OnboardClock", ON_RATE, DAQmx_Val_Rising,
     DAQmx_Val_FiniteSamps, 100);
DAQmxRegisterDoneEvent(onTask, 0, DoneCallbackWrapper, this);

This one boggles my mind a bit more. 这个让我更加困惑。 I believe that whenever onTask is triggered (with a hardware trigger), the DAQ starts taking and digitizing analog measurements at ON_RATE samples/second and once 100 samples are taken/read into the DAQs buffer, the DoneCallbackWrapper() is called. 我相信只要触发onTask(使用硬件触发器),DAQ就会以ON_RATE采样/秒的速率开始对模拟测量值进行数字化处理,一旦将100个采样采样/读入DAQs缓冲区,就会调用DoneCallbackWrapper() Depending on how long this hardware trigger stays high, this wrapper will be called every time the DAQ reads 100 samples (while trigger is high) OR will the callback be called only once after 100 samples were read? 取决于此硬件触发信号保持高电平的时间,每次DAQ读取100个样本(触发器为高电平)时,将调用此包装器?或者在读取100个样本之后,仅调用一次回调?

The callback is called only once after 100 samples were read 读取100个样本后,仅调用一次回调

Because slowTask uses DAQmx_Val_ContSamps , the program asks for an infinite (aka continuous) acquisition where data is streamed to the host. 由于slowTask使用DAQmx_Val_ContSamps ,因此该程序要求进行无限 (也称为连续)采集,并将数据流式传输到主机。 Using the EveryNSamples callback allows the program to access and process the newest data that was sent by the device. 使用EveryNSamples回调使程序可以访问和处理设备发送的最新数据。

Because onTask uses DAQmx_Val_FiniteSamps , the program asks for a single acquisition of 100 samples. 因为onTask使用DAQmx_Val_FiniteSamps ,所以该程序要求单次采集100样本。 Using the Done event allows the program to access and process the complete and full acquisition. 使用“ Done事件,程序可以访问和处理完整的采集和完整的采集。

In your comment update, the program uses 在您的评论更新中,程序使用

DAQmxCfgDigEdgeStartTrig(onTask, "/PXI2Slot4/PXI_Trig0", DAQmx_Val_Rising));

to configure a digital edge start trigger for onTask . onTask配置数字边沿启动触发器 When that trigger line has a rising edge, the onTask acquisition begins, captures 100 samples, stops, and invokes the callback. 当该触发线具有上升沿时, onTask采集开始,捕获100个样本,停止并调用回调。

If the program needs to acquire 100 samples for onTask for every rising edge on /PXI2Slot4/PXI_Trig0 , you can use the retriggerable property on the NI 63xx series devices that allows the same task to re-run for each trigger event . 如果程序需要在/PXI2Slot4/PXI_Trig0 每个上升沿为onTask采集100个样本, onTask可以使用NI 63xx系列设备上的可重触发属性 ,该属性允许针对每个触发事件重新运行同一任务。

More details are in the X Series User Manual : 更多详细信息在X系列用户手册中

The AI Start Trigger is also configurable as retriggerable. AI启动触发器也可配置为可重新触发。 The timing engine generates the sample and convert clocks for the configured acquisition in response to each pulse on an AI Start Trigger signal. 定时引擎响应于AI Start Trigger信号上的每个脉冲,生成样本并转换时钟以进行配置的采集。

The timing engine ignores the AI Start Trigger signal while the clock generation is in progress. 在时钟生成过程中,定时引擎会忽略AI Start Trigger信号。 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 图4-22显示了一个可重触发的模拟输入,每个输入具有三个AI通道和四个采样

可触发的模拟输入信号的图示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM