I'm having some trouble updating some old NI interfacing code (for a PCI-6115) to the new session based interface in 2011b.
Here's the basic idea: I'd like to run my DAQ board like an oscilloscope, so I set it to passively scan, wait until my signal passes some threshold value, and then record a sample for X length of time (or NUMBEROFSAMPLES number of samples).
Here's my code %Initial routines for creating the daq session and initializing the channels (device = daq.createSession('ni'), etc.) % thresh = 2; % 2V threshhold value
device.NotifyWhenDataAvailableExceeds = NUMBEROFSAMPLES;
lh = device.addlistener('DataAvailable', @(src, event) stopwhenpassthresh(src, event, thresh));
device.IsContinuous = true;
function stopwhenpassthresh(src, event, thresh)
if any(event.Data > thresh)
Some questions that I have: - How do I pull event.Data and event.TimeStamps out from the stopwhenpassthresh function into something I can process? - If it was at all possible, I'd like to be able to tell my code that when we pass the threshhold value, it should take one extra run of data (and then I can lop off the extra data afterwards). It'd also be nice if I could get a bit more control over the pre-trigger data as well.
Thank you for your help, Paul