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

16 views (last 30 days)
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 Comment
Sakari Vekki
Sakari Vekki on 7 Sep 2022
Edited: Sakari Vekki on 7 Sep 2022
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.

Sign in to comment.

Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!