Triggering MATLAB Script Externally Using NI-USB 6008
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simultaneous and Synchronized Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!