How can you arm a counter connected to NI -DAQ without a trigger?
2 次查看(过去 30 天)
显示 更早的评论
I am trying to arm a counter input channel using NI DAQ USB 6341. Counter Input Channels are incompatible with the start trigger available on Matlab. How can I arm the counter to ensure that it collects data without a trigger? Attached is my code so far.
instrreset;
det = daq('ni');
ch = addinput(det,"Dev1", "ctr1", "EdgeCount");
addinput(det,"Dev1","ai0","Voltage");
ch.ActiveEdge = 'Falling';
get(ch)
det.Rate = samplerate*samplepoint;
data=[];
time_acq=[];
t0=clock;
0 个评论
回答(1 个)
Aravind
2025-5-13
You do not need to "arm" the counter before beginning the counting. On the NI USB-6431, the counter input channels start counting as soon as the session is initiated in MATLAB by calling start(det). There is no separate "arming" step for these counters. Once the session is started, the counter will count all edges on the specified input pin from that point onwards, until you stop or read the data. Remember to start the acquisition just before the event you want to measure.
Here is an example workflow for your use case:
instrreset;
det = daq('ni');
samplerate = 1000; % Example value
samplepoint = 10; % Example value
% Add counter input channel
ch = addinput(det, "Dev1", "ctr1", "EdgeCount");
ch.ActiveEdge = 'Falling';
% Add analog input channel
addinput(det, "Dev1", "ai0", "Voltage");
% Set rate (applies to analog input; counter is event-driven)
det.Rate = samplerate * samplepoint;
% Prepare data storage
data = [];
time_acq = [];
t0 = clock;
% Start acquisition; both AI and CI start together
start(det, "Duration", seconds(5)); % e.g., acquire for 5 seconds
% Fetch data after acquisition
data = read(det);
stop(det); % Not strictly required, but good practice
I hope this resolves your query.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Counter and Timer Input and Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!