Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

getting DAQmxErrorResourcesInUseForRoute_Routing error when using master device as a timer

I have been successfully synchronizing multiple AI devices for several years using NIDAQmx and C++.   I am now trying to use the master device (i.e. a NI6225) as a clock.  For this purpose, I configured a task to count the rising edges on the first counter (i.e. Counter 0 or ‘Ctr0’) at 100 KHz.  However, when my code attempts to start the AI task on the master device then I receive the following error:

 

Error code:          -89137

Error name:        DAQmxErrorResourcesInUseForRoute_Routing

Error message: Specified route cannot be satisfied, because it requires resources that are currently in use by another route.

 

The NI devices (PCI-6225 as the master and PCI-6220 as the slave) are connected using the RTSI cable.   My application uses reference clock synchronization as demonstrated in the following NI sample code project ‘NI-DAQ\Examples\DAQmx ANSI C\Synchronization\Multi-Device\Continuous AI. VC_ContinuousAI.dsw’.  The error only occurs when attempting to use multiple NI devices but not when only using a single NI device by itself.  

 

The NI knowledge base article states, “DAQmx will choose the Counter over the RTSI bus, so your RTSI connection will not work and you will receive this error”.   If I understand correctly, synchronizing the devices using RTSI uses Counter 0 but this fails because Counter 0 has already been allocated for use in my timing task.

 

The NI6225 has two counters.  I tried using Counter 1 as a timer but the same error occurs. 

 

So my questions are as follow:

  1. Is Counter 0 used when synchronizing multiple devices using RTSI?
  2. Is Counter 1 also used when synchronizing multiple devices using RTSI?   If not then should I be able to use it for timing purposes?
  3. Each NIDevice has quite a few different clocks.  If Counter 0 and 1 are required for RTSI then could I somehow use the 20 MHz timebase or 100 kHz  clocks for getting the time?  In other words, if I cannot use Counter 0 or 1 for timing purposes the how can I configure the master NI6225 device as the master device and, at the same time, use it as a timer?  

Thank you,

 

Ian

0 Kudos
Message 1 of 18
(5,039 Views)

Hi Ian,

 

I am sorry to hear you are having trouble with this example code.  Have you modified it in any way?  If so, how?

 

When Onboard Clock is selected, there are a number of resources on the board that may be in use depending on a number of factors - sampling rate being one of them.  The best way to ensure we know what resources are being used for your specific setup would be to manually set a clock source, such as (if your 6225 is named Dev1) /Dev1/ai/SampleClock.  Please note that in order to use your sample clock, you'll need to start a "dummy" task on your 6225 in order to get the sample clock to generate a signal.

 

Once we know what resource is being used for your sample clock, the next thing to do is manually specify on which PFI line you want to export your clock, e.g.:

 

DAQmxExportSignal (masterTaskHandle, DAQmx_Val_SampleClock, "/Dev1/PFI0");

 

Now that we know you are exporting a particular clock to a particular PFI line, you can check the device routes in Measurement & Automation Explorer.  For determining what resources are used for indirect routes, take a look at this article:

 

How Can I Know What Internal Routes are Available on My Device? - http://digital.ni.com/public.nsf/websearch/E539D226A643C1CE8625715E007C23C8

 

Essentially shift-clicking indirect (yellow) routes will tell you what path is taken inside your device.  This should answer questions 1 and 2 for determining what resources are in use.

 

As for your third question, yes you may use other clocks on the device.  Simply select a different clock as described above, but beware that some onboard clocks cannot be divided down natively; to do so you must use onboard counters, which is essentially what you are already doing now.

 

If you are still having issues, please let us know what version of DAQmx you are using and what clocks, PFI lines, etc. you are using.  Be sure to have configured your devices in MAX for RTSI (tutorial).

 

Regards,

Regards,
Chris Elliott
x36772
0 Kudos
Message 2 of 18
(5,030 Views)

Hello Chris,

 

I am able to replicate the error simply by adding a counter to the NI sample project 'NI-DAQ\Examples\DAQmx ANSI C\Synchronization\Multi-Device\Continuous AI'.   The attached file contains code you can use to reproduce the error.  All I have done is to add a counter task to the project.  Again, two NI devices (PCI-6225 as the master, PCI-6220 as the slave) are installed in the computer, a RTSI cable connects both devices and the RTSI connection is defined in MAX.

 

You wrote, "...the next thing to do is manually specify on which PFI line you want to export your clock".  I do not understand why it is necessary to do this if all I am trying to do is to read a counter on the master device.    If this is really necessary can you explain why? 

0 Kudos
Message 3 of 18
(5,024 Views)

Hello Chris,

 

In my last post I attached a file containing source code the generates the error DAQmxError​ResourcesI​nUseForRou​te_Routing.   This error occurs when when starting the master device (i.e.. executing line 57 DAQmxStartTask(masterTaskHandle)' on line 57).  To make the error message reported a bit more readable, I assigned names to each task (see attached file to this post).

 

 

The full error message as reported by the updated code in the attached file is as follows:

 

DAQmx Error: Specified route cannot be satisfied, because it requires resources that are currently in use by another route.

Property: DAQmx_RefClk_Src

Source Device: NI6225a

Source Terminal: 10MHzRefClock

 

Required Resources in Use by

Task Name: myCounter

Source Device: NI6225a

Source Terminal: None

Destination Device: NI6225a

Destination Terminal: RefClock

 

Task Name: myMaster

Status Code: -89137

 

 

Ian

0 Kudos
Message 4 of 18
(5,017 Views)

Hi Ian,

 

Thank you for the additional information.  Can you please also clarify what versions you are using of DAQmx and (I assume) Visual Studio?  Newer versions of Visual Studio C++ are not technically compatible with DAQmx as NI stopped supporting that language a few years ago.

 

By default, RTSI synchronization should export your 10 MHz clock to a RTSI line (a direct route on the 6225), but it sounds like your routing is using other resources to accomplish this.  My intent in requesting you manually specify your clocks was to maintain more control over how signals are routed so that we can know exactly what resources are in use.

 

Choosing Onboard Clock can obfuscate what resources get reserved for RTSI so it is best to manually choose a clock and export it to a specific RTSI line (I misspoke with PFI in my last post) of your choosing when synchronizing your two cards.  This will allow us to determine what resources are being used according to the Device Routes in Measurement & Automation Explorer.  Then we can see if both of your counters are being used by your AI task.

 

If both counters are in fact in use, there is not another solution for generating a timer without the use of additional counters.  Unfortunately, you would need a device with more counter/timers, such as our X Series line.

 

 

Regards,

 

Regards,
Chris Elliott
x36772
0 Kudos
Message 5 of 18
(5,001 Views)

Hello Chris,

1) I am working with DAQmx 9.5.1 and VS2010.   I am surprised that NI would stop supporting C/C++.   These are very common languages.   Please confirm this is true.

2) Sorry, I missed your point about manually selecting a reference clock.  I updated the code to include the following:

	char* referenceClock = "/NI6225a/ai/SampleClock";
	float64 clockRate = 10e6;
	DAQmxErrChk (DAQmxSetRefClkSrc(masterTaskHandle, referenceClock));
	DAQmxErrChk (DAQmxSetRefClkRate(masterTaskHandle,clockRate));
	DAQmxErrChk (DAQmxSetRefClkSrc(slaveTaskHandle,referenceClock)); 
	DAQmxErrChk (DAQmxSetRefClkRate(slaveTaskHandle,clockRate));

 

This code generates the following error when attempting to start the master task.   It makes sense if it is saying the 'ai/SampleClock' cannot be used for both analog input and as a reference clock.

 

DAQmx Error: Specified route cannot be satisfied, because it requires resources that are currently in use by another route.
Property: DAQmx_RefClk_Src
Source Device: NI6225a
Source Terminal: ai/SampleClock

Required Resources in Use by
Task Name: myCounter
Source Device: NI6225a
Source Terminal: None
Destination Device: NI6225a
Destination Terminal: RefClock

Task Name: myMaster

Status Code: -89137

 

How can manually selecting the refernce clock allow us to determine if both counters are being used?  MAX shows the counters are not used for the 'ai/SampleClock to RTSI' route.   In contrast, the '20MHzTimebase to RTSI' route does indeed use Counter 0.   Is this what you are referring to?

 

 

What do you suggest now?

 

Ian

0 Kudos
Message 6 of 18
(4,995 Views)

Hi Ian,

 

The Sample clock indeed does not use any counters when routing to RTSI, but my thoughts were focused on how the sample clock is derived.  When you specify a sample rate with an onboard clock, a divide down takes place from one of the timebases.  This can, and often does, use a counter.

 

With the information you have given me so far, I have currently reproduced your error on my machine using very similar M Series hardware.  I am looking into a solution for you and will keep you posted with any updates.

 

Please let us know if you find anything in the meantime.

 

Regards,

Regards,
Chris Elliott
x36772
0 Kudos
Message 7 of 18
(4,983 Views)

Hi Ian,

 

I apologize, I left out my reply to your first question.  I can confirm that we do not officially support C++ in Visual Studio 2010.  This is listed in our DAQmx driver readme, which can be found here for 9.5.1:

 


DAQmx 9.5.1 Readme - http://download.ni.com/support/softlib//multifunction_daq/nidaqmx/9.5.1/readme.html

DAQmx 9.6 (latest version) Readme - http://download.ni.com/support/softlib//multifunction_daq/nidaqmx/9.6/readme.html

Regards,
Chris Elliott
x36772
0 Kudos
Message 8 of 18
(4,975 Views)

Hi Ian,

 

Since your counter task is using RefClock (as specified by the error), you cannot also route your 10MHzRefClock to RefClock.  You do not actually have to set a source for your master's reference clock as the DAQmx driver takes care of this under the hood for you.  All you must do is route your 6225's 10MHzRefClock to your 6220's RefClkSrc.  Specifying a reference clock on your master device is not necessary because all clocks are divided down from the onboard 80 MHz timebase.  When your slave device syncs up, it will use a reference clock from the master that is divided down from the master 80 MHz timebase.

 

With this in mind, you do not need the following lines of code:

 

	DAQmxErrChk (DAQmxSetRefClkSrc(masterTaskHandle,"OnboardClock"));
	DAQmxErrChk (DAQmxGetRefClkSrc(masterTaskHandle,str1,256));

 

When you set your 6220's RefClkSrc, you will want to specify it as:

 

 

	DAQmxErrChk (DAQmxSetRefClkSrc(slaveTaskHandle,"NI6225a/10MHzRefClk"));

 

Page 154 of the M Series User Manual specifies that when RTSI is configured, your 10MHzRefClk clock can be exported over your RTSI lines (direct signal route with no counters used).  The above line of code will do this automatically with RTSI setup in Measurement & Automation Explorer.

 

When setting this up on my system, I was able to get the task working using the above steps.  Please let me know if this does not work for you.

 

Regards,

Regards,
Chris Elliott
x36772
0 Kudos
Message 9 of 18
(4,971 Views)

Hello Chris,

 

No luck!   I made the changes you recommended to the first source code file I sent you on 09-08-2012.   I removed the two  lines that set/get the master reference clock.   I then set the slave reference clock to “NI6225a/10MHzRefClk”.   The following error message is generated when attempting to start the slave task:

 

DAQmx Error: Source terminal to be routed could not be found on the device.

Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names.
Property: DAQmx_RefClk_Src
Source Device: NI6220a
Source Terminal: NI6225a/10MHzRefClk

Task Name: mySlave

Status Code: -89120

 

I am a little surprise that something so easy as attempting to read a clock can be so difficult.  I will wait to hear from you.

 

Ian

 

 

 

 

 

0 Kudos
Message 10 of 18
(4,962 Views)