converting TriggerFcn in legacy to session based

3 ビュー (過去 30 日間)
Juoni Takalo
Juoni Takalo 2017 年 10 月 4 日
回答済み: Jyotish Robin 2017 年 10 月 10 日
I was looking my older code with legacy data acquisition toolbox. I decide to convert, that code to session base and I simultaneously could change Matlab to new 64 bit version. I came across problem, that in legacy code I used TriggerFcn for detecting, when external trigger happened. I looked around session based help, but could not find the similar solution. The problem is, that the program simultaneously uses analog input, analog output and draws to the screen. All this is triggered by external trigger pulse.

回答 (1 件)

Jyotish Robin
Jyotish Robin 2017 年 10 月 10 日
Hi Juoni!
Currently in DAQ Session, there is no equivalent functionality to StopFcn and TriggerFcn in DAQ Legacy in the session based interface.
As you may be knowing TriggerFcn specify callback function to execute when trigger occurs.
One possible approach to achieve a similar effect with Session is to use a MATLAB property event listener for a corresponding predefined session property. http://www.mathworks.com/help/matlab/ref/handle.addlistener.html
For a trigger event, create a listener for the 'IsWaitingForExternalTrigger' session property.
lh1 = s.addlistener('IsWaitingForExternalTrigger', 'PostSet', @trigCallback);
Please see attachment trigCallback.m for an usage example.
Unlike DAQ Legacy, these events are property event listeners, and these callbacks might execute multiple times because of the internal session object operation.
Thanks,
Jyotish

Community Treasure Hunt

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

Start Hunting!

Translated by