NI DAQ: Detect change in Digital Input in background? and, what is ChangeDetectionEvent in NI DAQ Matlab?

3 次查看(过去 30 天)
Hi, I am trying to monitor a Digital Channel in the background. This channel is configured as input:
DA = daq.getDevices;
s = daq.createSession('ni');
ch = s.addDigitalChannel('Dev2','Port0/Line0','InputOnly');
This input is at random time and I need to be able to read it in my software as soon as it happens, with a maximum delay of 500 ms. I am unable to find a way to detect it in background as DAQ sessions in Matlab only supports 'DataAvailable', 'DataRequired' and 'ErrorOccurred' type of events in addlistener for DAQ, none of which are useful if I want to detect a change in a Digital Input line. Is there a way I can do this in background?
I tried multiple ways and stumbled upon 'ChangeDetectionEventChangeDetectionEvent', this is supported by my NI DAQ device and when I look for terminals I can see it is available in Matlab:
DA = daq.getDevices;
DA.Terminals
ans =
39×1 cell array
{'Dev2/PFI0' }
{'Dev2/PFI1' }
% Many other terminals in between
{'Dev2/ChangeDetectionEvent' }
% Many other terminals afterwards
{'Dev2/FrequencyOutput' }
{'Dev2/100kHzTimebase' }
I looked it up and it is exactly what I need, according to the documentation available on NI website "Change detection can quickly identify changes in digital port state, and allows port monitoring without polling in a software loop. It also removes redundant data, and registers for the entire port. Change detection is useful for monitoring lines that change at irregular intervals". However, when I look for any kind of documentation for this on Matlab or Matlab Answers or on Google I found nothing. Is there a way I can access this terminal so that I can be notified about the change in my Digital Input channel in background?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Input and Output 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by