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

14 ビュー (過去 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 Center および File ExchangeSimultaneous 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