How to handle multiple devices with an external trigger signal in NI-PXI platform?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a NI-PXI chassis(model: 1042Q) and multiple data aquisition devices(PXI-4496) for multi-channel signal acquisition and processing.
With an external digital trigger, how can I connect the trigger signal and make a matlab program. Please let me know the useful code to deal with multiple devices with an external trigger signal in a PXI chassis.
0 comentarios
Respuestas (2)
R
el 25 de Jun. de 2024
Editada: R
el 25 de Jun. de 2024
To acquire data from multiple NI PXI-4496 devices using an external digital trigger in a PXI chassis (model: 1042Q) with MATLAB, use the 'Data Acquisition Toolbox'. First, ensure the NI-DAQmx drivers and Data Acquisition Toolbox are installed. Use daqlist("ni") to identify connected devices and create a DataAcquisition object with daq("ni").
Add analog input channels from each PXI-4496 device using addinput, specifying channels (e.g., addinput(d, deviceIDs{i}, "ai0:7", "Voltage")). Configure the external digital trigger with addtrigger, setting the trigger type to "Digital", source to "StartTrigger", and condition to "RisingEdge" (e.g., addtrigger(d, "Digital", "StartTrigger", "Dev1/PFI0", "External")).
Set the sample rate and duration and start the session to begin data acquisition when the external trigger is received.
Below is a sample code you can refer:
% Ensure the Data Acquisition Toolbox is installed and NI-DAQmx drivers are available
% Step 1: List all connected DAQ devices
devices = daq.getDevices;
% Display connected devices
disp('Connected DAQ devices:');
disp(devices);
% Step 2: Create a data acquisition session
s = daq.createSession('ni');
% Step 3: Add analog input channels from each PXI-4496 device
% Replace 'Dev1', 'Dev2', etc. with the actual device IDs from the devices list
deviceIDs = {'Dev1', 'Dev2'}; % Example device IDs
numDevices = length(deviceIDs);
for i = 1:numDevices
% Add all channels from each device
addAnalogInputChannel(s, deviceIDs{i}, 0:7, 'Voltage'); % PXI-4496 has 8 channels (0-7)
end
% Step 4: Configure the external digital trigger
% Replace 'PFI0' with the actual PFI line used for the external trigger
s.addTriggerConnection('External', 'Dev1/PFI0', 'StartTrigger');
% Step 5: Set the rate and duration of the acquisition
s.Rate = 50000; % Sample rate in Hz (50 kHz)
s.DurationInSeconds = 10; % Duration of the acquisition in seconds
% Step 6: Start the session and acquire data
disp('Waiting for external trigger...');
[data, time] = s.startForeground;
% Step 7: Process the acquired data
disp('Data acquisition complete.');
plot(time, data);
xlabel('Time (s)');
ylabel('Voltage (V)');
title('Acquired Data from Multiple PXI-4496 Devices');
legend(arrayfun(@(x) sprintf('Channel %d', x), 1:size(data, 2), 'UniformOutput', false));
% Save the data to a file if needed
save('acquired_data.mat', 'data', 'time');
Refer to the documentation link and examples to know more:
0 comentarios
Hyu-Sang Kwon
el 25 de Jun. de 2024
4 comentarios
R
el 26 de Jun. de 2024
@Hyu-Sang Kwon, it seems that you need to ensure all devices in a session start together and use the same scan clock. You can add this configuration before Step 5, i.e., setting the rate and duration of the acquisition:
% Ensure that all devices use the same clock
for i = 2:numDevices
s.addClockConnection('Dev1/PFI0', deviceIDs{i}, 'ScanClock');
end
Ver también
Categorías
Más información sobre Simultaneous and Synchronized Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!