How can you arm a counter connected to NI -DAQ without a trigger?

조회 수: 3 (최근 30일)
Sanjna
Sanjna 2025년 5월 6일
답변: Aravind 2025년 5월 13일
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;

답변 (1개)

Aravind
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.

카테고리

Help CenterFile 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!

Translated by