MATLAB Answers

NI-DAQ device working on some PCs but not others

조회 수: 5(최근 30일)
Leigh Martin
Leigh Martin 2021년 6월 1일
답변: Leigh Martin 2021년 6월 4일
We are running a National Instruments DAQ (NI-DAQ) in Matlab using the provided dll (NIDAQmx.dll). It is working on one of our PCs (Windows 7, Matlab 2015a), but not two of our other PCs (Windows 10, Matlab 2015a nor 2021a, Windows 10, 2017b). We are confident that it worked in December 2020 on at least one of the Windows 10 PCs. On the Windows 10 PCs, we can use it fine via the built-in NI interface and Matlabs 'session-based' interface, but we have lots of code written around the dll version and need that working.
Below is a minimum example that reproduces our issue:
Device = 'Dev2/ao0';
DAQmx_Val_Volts = 10348;
Voltage = 0.0;
TaskName = []; % An additional error occurs if this is non-empty, but only on Windows 10.
[ statusCreateTask, TaskName, task ] = DAQmxCreateTask_(TaskName);
statusCreateChannel = DAQmxCreateAOVoltageChan(task,Device,-10,10,DAQmx_Val_Volts);
statusWriteAnalog = DAQmxWriteAnalogScalarF64(task,1,0,Voltage);
statusClearTask = DAQmxClearTask(task);
fprintf('%i, %i, %i, %i\n', statusCreateTask, statusCreateChannel, statusWriteAnalog, statusClearTask)
CreateVoltageChan and WriteAnalogScalar both produce the error -200088, which means "-200088::Task specified is invalid or does not exist." This occurs regardless of whether the device is plugged into our PC.
Strangely, Setting TaskName to anything but [] raises the additional error "-200089 DAWmxErrorDuplicateTask" after subsequent calls, but only on the Windows 10 PCs.
We have also tried restarting everything, installing Windows updates, installing the latest NI drivers and rolling back to previous drivers.
This post from 2013 describes a very similar problem. However TaskHandle is already defined as uInt32 in our NIDAQmx.h file, so the answer there doesn't seem to be relevant.

채택된 답변

Leigh Martin
Leigh Martin 2021년 6월 4일
In the NI I/O Trace capture program, I noticed that the handle generated by DAQmxCreateTask didn't match the handle passed to subsequent functions. 0x000001EE81212De0 would get truncated to 0x0000000081212DE0, which is a 32 bit number. So in NIDAQmx.h, I changed the following line:
typedef uInt32 TaskHandle;
To
typedef uInt64 TaskHandle;
And now the problem is solved.

추가 답변(1개)

LO
LO 2021년 6월 1일
Have you tried uninstalling completely and reinstalling the NI-DAQ Data Acquisition Toolbox ?
I have encountered troubles with the 2020 version of MATLAB (on windows 10) and it did not work until Irepeated the install process, at least a couple of times. In some cases the download&install package did not work properly (it got stuck).
If that happens, try to remove the installed components form MATLAB and also erase them from the PC (from the MATLAB installation folder). Install again.
  댓글 수: 3
Leigh Martin
Leigh Martin 2021년 6월 1일
I think I misunderstood dependencies between software then. We do have the data acquisition toolbox installed. We don't use direclty use any functions from it (at the lowest level, all we use are 'loadlibrary' and 'calllib', which calls functions from micaiu.dll).
A fresh install on a completely separate computer did not fix the problem, so it seems like this is a lower-level compatibility issue.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by