04-16-2010 04:48 AM
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
04-26-2010 05:24 PM
06-01-2010 06:57 PM
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
06-01-2010 07:08 PM
06-01-2010 07:16 PM
06-07-2010 03:22 PM
Found the solution, posted in this thread:
http://forums.ni.com/ni/board/message?board.id=250&message.id=57767&jump=true#M57767