How to use NI counter card in "Buffered event counting mode" with Matlab session based interface?

4 views (last 30 days)
Hi, I am using a NI 6602 counter/timing card, and I don't know how to use the "Buffered event counting" & "Buffered period measurement" modes of this card with Matlab.
The communication with the card is fine that I can use commands such as "daq.Session.inputSingleScan" & "daq.session.resetCounters". However, these commands seem to get data with "interrupt request" and would be slower than "direct memory access" achieved with "Buffered event counting" mentioned above. (I would like to acquire counts per microsecond from the card)
Any suggestion on how to do this? or is there a way to do it with Matlab Legacy based interface commands?
  2 Comments
Eyal weinberger
Eyal weinberger on 19 Nov 2014
Hi Jet, I asked a similar question recently, see below. Have you had any luck with using the PCI-6602 with matlab?
I am using the code below to measure the number of TTL pulses (=photon counts) per second in a single photon counter. I am using the NI PCI-6602 counter + board and matlab data aquisition tool box. I tested the code with a 20 MHz square wave from a function generator as input. When I use pause(t) (between the two inputSingleScan commands ) with t > a few seconds, the result I get is reasonable (up to 0.5% error), however, when t~0.01 sec. (which is the acquisition time I expect in my experiment) I get fluctuating results with 10-25 % error.
Is there a more accurate way to get the counter data , preferably without adding an external function generator as a clock , but perhaps with? Any code examples would be very welcome. Thanks!!
s = daq.createSession('ni');
ch = addCounterInputChannel(s,'Dev1', 'ctr0', 'EdgeCount')
s.resetCounters();
[data1,triggerTime1] = inputSingleScan(s);
pause(.01)
[data2,triggerTime2] = inputSingleScan(s);
res=((data2-data1)/((triggerTime2-triggerTime1)*(24*3600))

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!