Triggering MATLAB Script Externally Using NI-USB 6008
이전 댓글 표시
I'm currently trying to make a flash detector using MATLAB and a NI-USB 6008. When my sensor detects a flash I want it to trigger MATLAB to run a script as quickly as possible. Currently I am able to do this at around 100Hz using inputSingleScan within a loop. The 6008 however is capable of sampling at 10kHz, which is closer to what my application requires.
Does anyone have any ideas on how to speed this up? I'm currently using an analog input, I was thinking if I switched to the digital counter I could run it in trigger mode, but all I can get it to do is log the voltage data. Is there any way to get it to run a function instead of logging the data?
Here is sample code for reference:
s = daq.createSession('ni');
s.addAnalogInputChannel('Dev1','ai0','voltage')
s.Rate = 10000;
while 1
tic;
if inputSingleScan(s) > 0.05
disp(' ')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%%%%%%%%%% TRIGGERED!!!!! %%%%%%%%%%%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
break
end
toc
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!