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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Input and Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!