Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Reserved Hardware problem in Matlab using the NI PCI-6259

Hello,
I have the task to transition a Matlab project from the session based interface to the newer Data Acquisition interface. The old version works and can be used to take potential measurements. The device that is used is a NI PCI-6259 and I am running Matlab Version R2024b.
Most part of the code is working with the new interface but when I try to perform the measurements I get this error message after the first data point: "Error using: daqcli:daq:hardwareResourceReserved Hardware is reserved, possibly by an external applicator or another DataAcquisition object. To unreserve the hardware, exit the external application or stop the other DataAcquisition."
The error occurs in:
start(obj.fsession, "Continuous");

I also checked the 'Running' property of "fsession" and its always '0' before calling the function. There is a function, which is called after one measurement to stop 'fsession':

function stopmeasure(obj) 
% Stops the background sampling.
    try
        % obj.fsession.stop;
        stop(obj.fsession);
        % release(obj.fsession);
    catch err
        showErrorInBox(err);
    end       
end
The commented parts are from the old session based version. When I checked correctly there is no alternative for the release-function in the new daq interface, right?
How can I get this error when the 'Running' property of my daq object is 0? Did I miss something in my stopmeasure function (instead of release() ?) or has it something to do with my NI device?
I'm not a pro in Matlab so I don't quite understand everything 😉
Any tips would be helpful!
Thea
0 Kudos
Message 1 of 2
(95 Views)

@TP2000 Stuff Your Kindled Day in 2025wrote:
Hello,
I have the task to transition a Matlab project from the session based interface to the newer Data Acquisition interface. The old version works and can be used to take potential measurements. The device that is used is a NI PCI-6259 and I am running Matlab Version R2024b.
Most part of the code is working with the new interface but when I try to perform the measurements I get this error message after the first data point: "Error using: daqcli:daq:hardwareResourceReserved Hardware is reserved, possibly by an external applicator or another DataAcquisition object. To unreserve the hardware, exit the external application or stop the other DataAcquisition."
The error occurs in:
start(obj.fsession, "Continuous");

I also checked the 'Running' property of "fsession" and its always '0' before calling the function. There is a function, which is called after one measurement to stop 'fsession':

function stopmeasure(obj) 
% Stops the background sampling.
    try
        % obj.fsession.stop;
        stop(obj.fsession);
        % release(obj.fsession);
    catch err
        showErrorInBox(err);
    end       
end
The commented parts are from the old session based version. When I checked correctly there is no alternative for the release-function in the new daq interface, right?
How can I get this error when the 'Running' property of my daq object is 0? Did I miss something in my stopmeasure function (instead of release() ?) or has it something to do with my NI device?
I'm not a pro in Matlab so I don't quite understand everything 😉
Any tips would be helpful!
Thea

The "Hardware is reserved" error, even with `Running` as 0, means your `daq` object (obj.fsession) isn't fully releasing the NI PCI-6259 device. Unlike the old session interface, the new `daq` object manages resource release automatically when it's **cleared from the workspace or goes out of scope**. The most common fix is to explicitly **delete** the `daq` object using `delete(obj.fsession)` or set it to empty (`obj.fsession = [];`) in your `stopmeasure` function to ensure it releases the hardware. Also, confirm no other applications are using the device and try clearing your Matlab workspace.

0 Kudos
Message 2 of 2
(6 Views)