I'm trying to collect a set number of samples at a specified rate from an analog input channel (PCIE 6321). I am using MATLAB and the NIDAQmx library (through myni) to communicate with the DAQ card. I'm using the code below. There are no errors until I run DAQmxStartTask, which returns error -89120. In the error list this is called DAQmxErrorInvalidRoutingSourceTerminalName_Routing but I have no clue what that means. Do any of you know what might be causing that?
Thanks!
Code:
%------------- Constants -----------------
num_chans = 2; %how many channels we collect data from
lockin_min_timeconst = 1*10^-3;
sampling_rate = cast(ceil(10/(lockin_min_timeconst)),'int32');
dwell_time = 5; %in miliseconds
pixel_dwell = dwell_time*10^-3; %this is how long the DAQ will collect data at a particular pixel. Units of seconds.
samps_per_chan = cast(ceil(sampling_rate*pixel_dwell),'uint64'); %number of samples the DAQ will collect on each active channel.
data_buffer = zeros(num_chans,samps_per_chan);
DAQmx_Val_Volts =10348; % Volts
DAQmx_Val_Diff = 10106; % Differential
DAQmx_Val_Rising = 10280;
DAQmx_Val_FiniteSamps =10178;
DAQmx_Val_ContSamps =10123;
DAQmx_Val_GroupByScanNumber =1;
DAQmx_Val_GroupByChannel = 0;
DAQmx_Val_ChanPerLine =0;
%------------- Create the task -----------------
taskName='';
taskHandle=uint32(1);
[E_create,taskName,taskHandle]=calllib('myni','DAQmxCreateTask',taskName,taskHandle);
TH = sprintf('%.0f', taskHandle); %I don't think this step is necessary?
task = uint32(str2double(TH));
%------------- Create the input channels -----------------
[E_init(1,1)]=calllib('myni','DAQmxCreateAIVoltageChan',task, strcat('Dev1/','ai1'),taskName,DAQmx_Val_Diff,-10,10, DAQmx_Val_Volts,'');
[E_init(2,1)]=calllib('myni','DAQmxCreateAIVoltageChan',task, strcat('Dev1/','ai2'),taskName,DAQmx_Val_Diff,-10,10, DAQmx_Val_Volts,'');
%------------- Configure up the clock -----------------
E_ClkConfig = calllib('myni','DAQmxCfgSampClkTiming',task,'NULL',sampling_rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, samps_per_chan);
%------------- Configure the buffer-----------------
[E_buffer] = calllib('myni','DAQmxCfgInputBuffer', task, samps_per_chan);
%------------- Start the task -----------------
[E_start] = calllib('myni','DAQmxStartTask', task);