12-10-2008 04:49 PM - edited 12-10-2008 04:52 PM
I am trying to write a program in MatLab that uses the C++ functions. I have been successful in collection data from one strain gage but I don't understand how to configure multiplexing.
I am using a SCXI-1600 DAQ in a SCXI-1001 chassis with 9 SCXI-1520 8-channel universal bridge input modules.
I know that the hardware can multiplex all 9 SCXI-1520's to the DAQ because we have done this in LabView. I do not currently have LabView on my computer.
My question is:
How does labview use the C++ functions to set up this hardware to record 72 straingage channels.
This is what my code looks like:
clear, clc
rate = 100
time = 1
if ~libisloaded('myni')
disp('Matlab: Load nicaiu.dll')
[notfound, warnings]=loadlibrary('C:\WINDOWS\system32\nicaiu.dll',...
'C:\Program Files\National Instruments\Shared\CVI\include\NIDAQmx.h',...
'alias', 'myni')
end
cards = 1
chans = 8
taskh(1) = uint32(1);
% This is the C++ function called from MatLab -> int32 DAQmxCreateTask( 'master', taskh(1) )
[a,b,taskh(1)] = calllib('myni', 'DAQmxCreateTask', 'master', taskh(1))
% strings for two SCXI-1520 cards and channels 0 to 7 on each.
taskchans = {'SC1Mod3/ai0:7', 'SC1Mod4/ai0:7'};
samples = time*rate;
chanName = '';
minV = -10e-4;
maxV = +10e-4;
excitV = 3;
gageFactor = 2.09;
iniBrdgV = 0;
nomGageR = 350;
poissonR = 0.3;
wireR = 0;
scaleName = '';
DAQmx_Val_Strain = 10299;
DAQmx_Val_FromCustomScale = 10065;
DAQmx_Val_QuarterBridgeI = 10271;
DAQmx_Val_Internal = 10200;
DAQmx_Val_Rising = 10280;
DAQmx_Val_FiniteSamps = 10178;
DAQmx_Val_GroupByScanNumber = 1;
%create Strain Gage channel (virtual)
[c] = calllib('myni', 'DAQmxCreateAIStrainGageChan', taskh(1), char(taskchans(i)),...
chanName, minV, maxV, DAQmx_Val_Strain, DAQmx_Val_QuarterBridgeI,...
DAQmx_Val_Internal, excitV, gageFactor, iniBrdgV, nomGageR, poissonR,...
wireR, scaleName);
%set samplerate, and number of samples
for i = 1:cards
[a,b]=calllib('myni', 'DAQmxCfgSampClkTiming', taskh(i), '', rate, DAQmx_Val_Rising,...
DAQmx_Val_FiniteSamps, samples)
end
%Disable the Start Trigger
for i = 1:cards
[a]=calllib('myni','DAQmxDisableStartTrig',taskh(i))
end
% setting up variables to read the data
readarray1=ones(cards,samples);
readarray1_ptr=libpointer('doublePtr',readarray1);
arraylength = samples;
sampread=0;
sampread_ptr=libpointer('int32Ptr',sampread);
empty=[];
empty_ptr=libpointer('uint32Ptr',empty);
% organizing and reading in raw data
strain = ones(cards*chans+1, samples);
t = 0:1/rate:time-1/rate;
strain(1, : )=t;
for i = 1:cards
[a,readarray1,sampread,empty]=calllib('myni','DAQmxReadAnalogF64',taskh(i),-1,-1,...
DAQmx_Val_GroupByScanNumber,readarray1_ptr,arraylength,sampread_ptr,empty_ptr);
strain(chans*i-(chans-2):chans*i+1, : ) = readarray1;
end
% Stop all Tasks
for i = 1:cards
[a] = calllib('myni','DAQmxStopTask',taskh(i));
if a == 0
fprintf('Stoping Task %s ... OK \n', char(j(i)));
else
fprintf('Starting Task %s ... Failed \n', char(j(i)));
end
end
% Clear all Tasks
for i = 1:cards
[a] = calllib('myni','DAQmxClearTask',taskh(i));
if a == 0
fprintf('Clear Task %s ... OK \n', char(j(i)));
else
fprintf('Clear Task %s ... Failed \n', char(j(i)));
end
end
This is the general form of my code.
I have tried to make one task per channel but I can only start one task at a time.
I have tried using DAQmxSwitchCreateScanList and DAQmxSwitchSetTopologyAndReset.
->but I don't know what the device name for the switch.
If someone can explane how Labview multiplex's all these SCXI-1520 cards that would help alot.
Thanks.
Solved! Go to Solution.
12-10-2008 06:20 PM
Ok I found the solution to this problem.
The SCXI-1600 multiplexes based on what channels you have set up. I just add all 72 channels to the taskh(1) with the DAQmxCreateAIStrainGageChan(...) function then my samples are multiplied by the number of channels I added.