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!
Best Answer