How do I change my trigger commands for a session based interface in the Data Acquisition Toolbox?
古いコメントを表示
I am trying to rewrite my Legacy based code for an analog input device into a Session based code, but it seems as if the Session based commands can not do everything that my Legacy code could. The goal is to change my code from version R2007b so that it will run the same on version R2017a.
Is there a way to convert all of these trigger properties into Session based code even if there isn't a direct corresponding translation?
AI = analoginput(‘nidaq’,'Dev1');
chan = addchannel(AI,0:4);
set(AI,’InputType’,’SingleEnded’);
set(AI,’SampleRate’,5000);
duration = 2.0;
ActualRate = get(AI,’SampleRate’);
set(AI,’SamplespPerTrigger’,ActualRate*duration);
set(AI,’TriggerChannel’,chan(5));
set(AI,’TriggerType’,’Software’);
set(AI,’TriggerCondition’,’Falling’);
set(AI,’TriggerConditionValue’,0.0);
set(AI,’TriggerRepeat’,1);
set(AI,‘TriggerDelay’,-1.2);
start(AI)
while strcmp(AI.Running,’On’)
end
[data,t] = getdata(AI);
delete(AI)
plot(t,data);
I have no trouble converting most of it but the biggest issue is finding a way to set a trigger delay of negative 1.2 seconds. Here is all that I have so far, which may not even be completely correct.
AI = daq.createSession(‘ni’);
chan = addAnalogInputChannel(AI,’Dev1’,0:4,’Voltage’);
chan.TerminalConfig = ‘SingleEnded’;
AI.Rate = 5000;
AI.DurationInSeconds = 2.0;
addTriggerConnection(AI,‘External’,’Dev1/PFI0’,’StartTrigger’);
AI.Connections(1).TriggerCondition = 'FallingEdge';
AI.TriggersPerRun = 2;
Thank you in advance for anyone who can help!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Acquisition Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!