Acquiring Data from Four NI Devices at Different Rates

2 visualizaciones (últimos 30 días)
Calum
Calum el 10 de Mzo. de 2025
I've developed a Matlab application to connect to and collect data from an NI data acquistion chassis populated with multiple modules. Using example code in: https://uk.mathworks.com/help/daq/acquire-data-from-two-devices-at-different-rates.html
I am able to connect to and collect data simulatanously from three DAQ objects, where I select a single module as the source and use hardware triggering over the PFI terminal to trigger the other DAQ objects. This approach works fine for three objects however when I modify the code to acquire data from 4 modules I receive an error (detailed below)
The below example is based on cDAQ-9178 chassis populated with 2x NI 9213 (modules 1 & 2), an NI 9205 (module 3) and NI 9218 (module 4)
%% Multiple device operation at various DAQ rates (NI) %%
% Specify a common acquisition duration for both devices, in seconds
daqDuration = 3;
% Create and configure DataAcquisition object and channels for cDAQ 9201 module
d1 = daq('ni');
addinput(d1, 'cDAQ4Mod1', 'ai0', 'Thermocouple');
d1.Channels(1).ThermocoupleType = 'K';
d1.Rate = 10;
% Create and configure DataAcquisition object and channels for cDAQ 9211 module
d2 = daq('ni');
addinput(d2, 'cDAQ4Mod2', 'ai0', 'Thermocouple');
d2.Rate = 10;
d3 = daq('ni');
addinput(d3, 'cDAQ4Mod3', 'ai0', 'Voltage');
d3.Rate = 10240;
d4 = daq('ni');
addinput(d4, 'cDAQ4Mod4', 'ai0', 'Voltage');
d4.Rate = 2048;
% Configure the source data acquisition object to export a triggering
% signal on the PFI0 terminal of cDAQ4 chassis
addtrigger(d1, 'Digital', 'StartTrigger', 'cDAQ4/PFI0', 'External');
% d1.DigitalTriggerTimeout = 30;
% Configure the destination data acquisition object to start acquisition when an
% external triggering signal is received at PFI0 terminal of cDAQ4 chassis
addtrigger(d2, 'Digital', 'StartTrigger', 'External', 'cDAQ4/PFI0');
% Configure the destination data acquisition object to start acquisition when an
% external triggering signal is received at PFI0 terminal of cDAQ4 chassis
addtrigger(d3, 'Digital', 'StartTrigger', 'External', 'cDAQ4/PFI0');
% Configure the destination data acquisition object to start acquisition when an
% external triggering signal is received at PFI0 terminal of cDAQ4 chassis
addtrigger(d4, 'Digital', 'StartTrigger', 'External', 'cDAQ4/PFI0');
start(d2, 'Duration', daqDuration)
start(d3, 'Duration', daqDuration)
start(d4, 'Duration', daqDuration)
while ~d2.WaitingForDigitalTrigger && ~d3.WaitingForDigitalTrigger && ~d4.WaitingForDigitalTrigger
pause()
end
start(d1, 'Duration', daqDuration)
% Wait until data acquisition is complete
while d1.Running || d2.Running || d3.Running || d4.Running
pause()
end
data1 = read(d1, 'all');
data2 = read(d2, 'all');
data3 = read(d3, 'all');
data4 = read(d3, 'all');
Error message:
Hardware is reserved, possibly by an external application or another DataAcquisition object. To ureserve the hardware, exit the external application or stop the other DataAcquisition.
Timeout expired before start trigger received.
(3x Timeout messages received - one for each recipient DAQ object)
Is there a specific reason why the hardware becomes reserved? Do i need to modify the trigger properties of each object for successful DAQ session?
Any help would be much appreciated.

Respuestas (0)

Categorías

Más información sobre Simultaneous and Synchronized Operations en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by