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 = [];
[ 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.