number of cdaq modules that you can record data from with startbackground (matlab)

5 Ansichten (letzte 30 Tage)
Im having difficult with a NI-CDaq 9188x running from matlab. I have debugged this issue which seems to be related to the number of modules that can run at one time from the module.
I can run 3 modules (ni 9206) and record data. However, as soon as a 4th device is added, a 'hardware reserved error' occurs on that 4 device when s4.startbackground is called. If I change the order of the modules in the Cdaq chassis, I can see that the 4th module functions in other slots, it is not the issue. If I comment out the code for first module, and run 2,3,4, those positions will run without issue. The issue seems to be related to the amount of devices that can run at the same time. It maybe that there is a better way to call the devices or start them as opposed to the startbackground property?
Here is my base code for starting 4 modules in the cdaq chassis. In the end I have run a ver command which somehow got merged with the code.
function configure_daq(~,~)
figure_position = get(gcf,'Position');
h = waitbar(0,'Initializing DAQ');
d = daq.getDevices();
% DAQ Object S1
waitbar(1/5,h,'Initializing Module 1');
s1 = daq.createSession('ni');
s1.addAnalogInputChannel(d(1).ID,[[0:7] [16:23]],'Voltage');
s1.Channels(1).Name = 'mod1'
s1.Rate = 100;
set(s1,'IsContinuous',true)
fprintf('Created DAQ Object for %s\n',s1.Channels(1).Device.Model);
% Voltage DAQ Object S2
waitbar(2/5,h,'Initializing Module 2');
s2 = daq.createSession('ni');
s2.addAnalogInputChannel(d(2).ID,[[0:7] [16:23]],'Voltage');
s2.Channels(1).Name = 'mod2'
s2.Rate = 100;
set(s2,'IsContinuous',true)
fprintf('Created DAQ Object for %s\n',s2.Channels(1).Device.Model);
% Voltage DAQ Object S3
waitbar(3/5,h,'Initializing Module 3');
s3 = daq.createSession('ni');
s3.addAnalogInputChannel(d(3).ID,[[0:7] [16:23]],'Voltage');
s3.Channels(1).Name = 'mod3'
s3.Rate = 100;
set(s3,'IsContinuous',true)
fprintf('Created DAQ Object for %s\n',s3.Channels(1).Device.Model);
Voltage DAQ Object S4
waitbar(4/5,h,'Initializing Module 4');
s4 = daq.createSession('ni');
s4.addAnalogInputChannel(d(4).ID,[[0:7] [16:23]],'Voltage');
s4.Channels(1).Name = 'mod4'
s4.Rate = 100;
set(s4,'IsContinuous',true)
fprintf('Created DAQ Object for %s\n',s4.Channels(1).Device.Model);
Event Handlers
addlistener(s1,'DataAvailable',@(src, event)logDataToFile(src, event, fid1));
addlistener(s1,'DataAvailable',@(src, event)update_fifo(src, event));
addlistener(s1,'DataAvailable',@(src, event)update_ui_text_fields(src, event,fid1));
s1.NotifyWhenDataAvailableExceeds = s1.Rate;
Voltage Data File Logging and Realtime Plot
addlistener(s2,'DataAvailable',@(src, event)logDataToFile(src, event, fid2));
addlistener(s2,'DataAvailable',@(src, event)update_fifo(src, event));
addlistener(s2,'DataAvailable',@(src, event)update_ui_text_fields(src, event,fid2));
s2.NotifyWhenDataAvailableExceeds = s2.Rate;
% Voltage Data File Logging and Realtime Plot
addlistener(s3,'DataAvailable',@(src, event)logDataToFile(src, event, fid3));
addlistener(s3,'DataAvailable',@(src, event)update_fifo(src, event));
addlistener(s3,'DataAvailable',@(src, event)update_ui_text_fields(src, event,fid3));
s3.NotifyWhenDataAvailableExceeds = s3.Rate;
% Voltage Data File Logging and Realtime Plot
addlistener(s4,'DataAvailable',@(src, event)logDataToFile(src, event, fid4));
addlistener(s4,'DataAvailable',@(src, event)update_fifo(src, event));
addlistener(s4,'DataAvailable',@(src, event)update_ui_text_fields(src, event,fid4));
s4.NotifyWhenDataAvailableExceeds = s4.Rate;
s1.startBackground();
s2.startBackground();
s3.startBackground();
s4.startBackground();
end
if true
%>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.4.0.150421 (R2014b)
Operating System: Microsoft Windows 7 Professional Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.4 (R2014b)
Data Acquisition Toolbox Version 3.6 (R2014b)
Instrument Control Toolbox Version 3.6 (R2014b)
Signal Processing Toolbox Version 6.22 (R2014b)
Wavelet Toolbox Version 4.14 (R2014b)
end
  1 Kommentar
Jim Mac
Jim Mac am 11 Jun. 2016
Bearbeitet: Jim Mac am 11 Jun. 2016
I was able to solve this on my own. I put all the modules under 1 DAQ object. Then the channels from each module are just as part of it which is some ways makes it easier. There does appear to be a limit though of 3 daq objects which is not a big deal...
s1.addAnalogInputChannel(d(1).ID,[[0:7] [16:23]],'Voltage');
s1.addAnalogInputChannel(d(2).ID,[[0:7] [16:23]],'Voltage');
s1.addAnalogInputChannel(d(3).ID,[[0:7] [16:23]],'Voltage');
s1.addAnalogInputChannel(d(4).ID,[[0:7] [16:23]],'Voltage');
s1.Channels(1).Name = 'mod1'
s1.Rate = 100;
set(s1,'IsContinuous',true)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by