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

3 visualizaciones (últimos 30 días)
Sanjna
Sanjna el 6 de Mayo de 2025
Respondida: Aravind el 13 de Mayo de 2025
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;

Respuestas (1)

Aravind
Aravind el 13 de Mayo de 2025
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.

Categorías

Más información sobre Counter and Timer Input and Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by