Syncing digital counter input to external trigger.
5 views (last 30 days)
Show older comments
Hello,
I am having some problems getting the digital counter to work the way I want to on an NI-DAQ that I want to control using MATLAB.
Setup: I am receiving TTL pulses on the ctr0 input on an NI-6229 DAQ and I want to count how many of them I am getting under various conditions.
The input is gated in 350 nanosecond chunks. Meaning there is a switch before DAQ, this switch is closed by default and on a semi-regular interval it opens for 350 ns and closes again. (I control when this happens, but it is not on a fixed frequency)
Desired outcome: I want to acquire data for some (long) period of time but I need to know which data comes from which window.
The output should ideally be a vector where each entry is the total number of received pulses during one 350 ns window but I at least need some method for distinguishing counts from different acquisition windows.
Here is what I have tried so far:
s = daq.createSession('ni');
ch = addCounterInputChannel(s,'Dev1','ctr0','EdgeCount');
for iDx = 1:7
resetCounters(s)
pause(1)
test(iDx) = inputSingleScan(s);
end
display(test)
test =
650 639 662 653 599 631 662
So I am receiving approximately 600 counts a second (this is a sensible number). The cabling works etc. However, I am at a loss for how to break this up so I know which counts come from which counting window.
Next thing I tried was adding a trigger that is synced to the acquisition windows. It produces a TTL pulse some arbitrary (chosen by me) time before each acquisition window. I wired this trigger to one of the digital input channels on the DAQ and setup the counter channel to use this signal as a clock. (When I tried to use it as a trigger I get a device does not support triggers on this channel error). I tried setting the rate as the approximate frequency of the counting windows.
s = daq.createSession('ni');
ch = addCounterInputChannel(s,'Dev1','ctr0','EdgeCount');
clk = addClockConnection(s,'external','Dev1/PFI7','ScanClock');
s.Rate = 1*125000;
[data, timeStamps,triggerTime] = startForeground(s);
This gives me a vector of increasing counts and when they were counted but it doesn’t actually tell me anything about the counter windows. What more with this setup the total number of counters acquired after 1 second now strongly depends on the number I chose for s.Rate which doesn’t make physical sense.
Does anyone have any suggestions for how I can distinguish counts coming from different windows?
I can show more outputs or provide more details if that would be helpful.
Many thanks!
0 Comments
Answers (0)
See Also
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!