Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems in creating channels (ni 6115)

Hi all,

 

I have used so far the Data acquisition toolbox in Matlab to operate with my NI 6115 card. Everything works fine. Now I would like to use NI-DAQmx functions to control the card. I'm pretty stuck with some basics and hopefully I can get some help. I cannot perform 'DAQmxCreateAIVoltageChan' without errors. My code starts as follows:

 

%loading library

 if ~libisloaded('nicaiu')
    hfile = ['C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\NIDAQmx.h'];
    funclist=loadlibrary('nicaiu.dll', hfile, 'mfilename', 'mxproto')
end

% Defining task
DAQmx_Val_Volts= 10348; % measure volts

% Creating task
taskh1=uint32(1);
[a,b,taskh1] = calllib('nicaiu','DAQmxCreateTask','master',taskh1)

% Defining channel
numofchans = 8;
taskchans1=['Dev2/ai0:' num2str(numofchans-1)];
[a,b,c,d] = calllib('nicaiu','DAQmxCreateAIVoltageChan',uint32(taskh1),taskchans1,'',-1,-10,10,DAQmx_Val_Volts,'')

The task is appropriately created but once I define the channels I get

 

>> a = -200088
>> b = 1844396652
>> c = Dev2/ai0:7
>> d =    ''

 

What could be the problem?

 

Thank you! 

 

Joonas 

0 Kudos
Message 1 of 6
(7,232 Views)
I have the same problem and haven't been able to figure it out. Everything returns the "Task specified is invalid or does not exist." error.
0 Kudos
Message 2 of 6
(7,174 Views)

I have the same problem. I've tried a variety of pointers for the taskHandle, to no avail. I'm running R2009b 32-bit on Windows 7.

 

 %%

DAQmx_Val_ChanPerLine = 0;

taskhDO0 = [0];

[err,b,taskhDO0] = calllib('nidaqmx','DAQmxCreateTask','DO2',uint32(taskhDO0))  % err = 0

[err,b,c,d] = calllib('nidaqmx','DAQmxCreateDOChan',uint32(taskhDO0),'Dev1/port0/line0','',DAQmx_Val_ChanPerLine)   % err = -200088

 

%%

    % setup MUX scanning task

charBuffer = '111111111111111111111111111111111111111111111111111111111111111111111';

muxHandle = libpointer('voidPtr',[0]);

muxHandle = uint32(1);

[result, ~, muxHandle] = calllib('nidaqmx','DAQmxCreateTask','aas2',muxHandle);

decodeDAQError(result); % result = 0

[result, ~, ~] = calllib('nidaqmx','DAQmxGetTaskName',uint32(muxHandle),charBuffer,length(charBuffer));

decodeDAQError(result); % result = -200088

[result,~,~,~] = calllib('nidaqmx','DAQmxCreateDOChan',uint32(muxHandle),'/Moo/port0/line0:3','MUXlines',0);

decodeDAQError(result); % result = -200088

0 Kudos
Message 3 of 6
(7,033 Views)
Also, I'm running NI-DAQmx 9.1.0.
0 Kudos
Message 4 of 6
(7,030 Views)
I figured out my error - code here.
0 Kudos
Message 5 of 6
(7,026 Views)
0 Kudos
Message 6 of 6
(6,976 Views)