In the Analog Output Generator Toolbox, how do I trigger the analog output with a external digital signal ?

7 次查看(过去 30 天)
Hi,
I use the NI-USB 6211 to output a DC voltage signal in ao channel which is triggered by an external TTL signal, imported by PFI0.
I use the function addtrigger to enable the external trigger mode. However, the external trigger signal cannot trig the output. I wonder how to config it ?
The codes are listed below:
d = daq("ni");
addoutput(d,"Dev1","ao0","Voltage");
addtrigger(d, "Digital", "StartTrigger", "External", "Dev1/PFI0");
write(d,OutputVol); % OutputVol is the Output DC Voltage
Additionally, I tried another way to realize the triggering the output, the codes are :
s=daq.createSession('ni');
ch=s.addAnalogOutputChannel('Dev1',0,'Voltage');
s.addTriggerConnection('External','Dev1/PFI0','StartTrigger')
output=1; % for example
s.queueOutputData(output);
s.startForeground();
It is effective, but the speed, executing from Line 4 to Line 6, is much slower than the method using the first method. How to accelerate it? And what is the difference between the two methods?
Thanks a lot.
  1 个评论
Sakari Vekki
Sakari Vekki 2022-9-7
编辑:Sakari Vekki 2022-9-7
I had similar issues trying to trigger output signal with external trigger (using NI-USB 6216). Code below seems to do the trick in my matlab app.
app.speedOutput =daq("ni");
addoutput(app.speedOutput,"Dev1","ao0","Voltage");
% % With this configuration writing Dev1/PFI0 high will output preloaded data
addtrigger(app.speedOutput,"Digital","StartTrigger","External","Dev1/PFI0");
%% Preload output values
preload(app.speedOutput,output);
start(app.speedOutput);
%% app.speedOutput will wait for PFI0 to go high before writing preloaded values
So instead of using 'write', try to preload the data and use 'start' command. Output signal and incoming trigger are perfectly synchronized this way.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simultaneous and Synchronized Operations 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by