converting TriggerFcn in legacy to session based

1 visualización (últimos 30 días)
Juoni Takalo
Juoni Takalo el 4 de Oct. de 2017
Respondida: Jyotish Robin el 10 de Oct. de 2017
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.

Respuestas (1)

Jyotish Robin
Jyotish Robin el 10 de Oct. de 2017
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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by