Function Location
You can use the
DAQmx Self-Test Device function or the DAQmx Reset function in LabVIEW, and also in text-based environments through our support for LabWindows/CVI or ANSI C, and .NET with C# or Visual Basic.
Note: The Self-Test Device functionality was added to the NI-DAQmx driver in version 8.9.
LabVIEW
- DAQmx Driver: The DAQmx Reset VI and Self-Test functions are located in the Measurement I/O»NI-DAQmx»Dev Config palette on the Block Diagram.
- Traditional DAQ Driver: The Device Reset function is located in the Measurement I/O»Data Acquisition»Calibration and Configuration palette on the Block Diagram.
LabWindows/CVI & ANSI C
The DAQmx Reset and Self-test functions can be found in
Libraries»NI-DAQmx Library»Advanced»Device Control.
- DAQmx Reset:
- Function prototype: int32 DAQmxResetDevice (const char deviceName[])
- Example: int errorResult = DAQmxResetDevice("Dev1");
- DAQmx Self-Test:
- Function prototype: int32 DAQmxSelfTestDevice (const char deviceName[])
- Example: int selfTestResult = DAQmxSelfTestDevice("Dev1");
C# .NET
To perform a DAQmx reset or self-test in C# you must first have a Device object for your DAQ device and then you can call the reset or self-test functions on the Device object.
- DAQmx Reset:
- Function prototype: void Device.Reset();
- Example:
Device dev = DaqSystem.Local.LoadDevice("Dev1");
dev.Reset();
Device dev = DaqSystem.Local.LoadDevice("Dev1");
dev.SelfTest();
Visual Basic. NET
Similar to C# .NET, to perform a DAQmx reset or self-test in Visual Basic .NET you need a Device object to call the reset and self-test functions.
- DAQmx Reset:
- Function prototype: Public Sub Reset()
- Example:
Dim dev As Device = DaqSystem.Local.LoadDevice("Dev1")
dev.Reset()
- DAQmx Self-Test:
- Function prototype: Public Sub SelfTest()
- Example:
Dim dev As Device = DaqSystem.Local.LoadDevice("Dev1")
dev.SelfTest()
LabVIEW NXG
Note: LabVIEW NXG is not recommended for new applications. The final release of LabVIEW NXG was LabVIEW NXG 5.1 in 2021.
The DAQmx Reset VI and Self-Test functions are located in the
Hardware Interfaces»NI-DAQmx»Device Configuration palette on the Diagram.
Example Code in LabVIEW
Below is an example code written in LabVIEW that puts the Reset Device at the end of the program.
- The DAQmx task is initialized before the main loop and is here represented by the Task In control. The initialization steps are left out in this example.
- Start Task and enter the Acquisition Loop.
- The Acquisition Loop handles the acquisition. In this example the data acquisition is set up to continuously read N samples from one channel. If the user presses the stop button or an error occurs, the Acquisition Loop terminates and the program enters the Reset Device Polling loop.
- The Reset Device Polling loop clears current error and resets the device. The loop runs until the DAQmx Reset Device VI succeeds.
- Optional: A DAQmx Self-Test Device VI can be added to test if the device responds properly after being reset.
- Stop the current DAQmx task before starting it again, since starting an already started DAQmx task generates an error.
- When the program is finished the task is cleared and any remaining errors are handled by the Simple Error Handler VI.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.