Solution
The error is caused by the impossibility of routing the reference clock to all the created DAQmx tasks or routes specified.
If you are using the
DAQmx Connect Terminals VI, be sure to also use the
DAQmx Disconnect Terminals VI for the terminals that were connected. This will prevent error
-89137 when trying to access the same hardware resources in different DAQmx tasks or section of your program. You can also manually disconnect all routes by resetting your device(s) in NI MAX.
This error can occur any time separate tasks require access to a shared resource. Therefore, it is important that you verify that there aren't any unexpected LabVIEW or DAQmx tasks running while you are executing/troubleshooting your VI.
If you plan to use multiple subsystems like AI, AO, DIO, or Counters at the same time, you must define the same reference clock for
all of the tasks created. Do this by using the NI-DAQmx timing properties (
Reference Clock Rate and
Reference Clock Source), which should be set before any other channel configurations (such as triggering and timing).
In order to set these properties, you need to call the appropriate API based on your development environment:
- If you are programming in LabVIEW, you should:
- Add a DAQmx Timing Property Node after channel creation
- Right-click the property node and select Add element
- Select More:Reference Clock:Rate Property and More:Reference Clock:Source Property, as shown in the image below (an example is also attached):
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.
- set RefClk.Src input to the Source Terminal value that was indicated by the error message, for example PXIe_Clk100 (thus, RefClk Rate input should be set to 100 MHz in this case)
- If you are programming in LabWindows™/CVI, you should add the following functions to your code, after channel creation and before configuring task timing:
DAQmxErrChk(DAQmxSetTimingAttribute(TaskHandle,DAQmx_RefClk_Src,"PXIe_Clk100"));
DAQmxErrChk(DAQmxSetTimingAttribute(TaskHandle,DAQmx_RefClk_Rate,100000000.0));