I'm having trouble with routing with a PCI 6601. I think what I'm
trying to do is very basic, but I keep getting resource conflict
errors no matter how I try it. I'm working with DAQmx version 8.3 in
ANSI C++ - so I'm using the ANSI C library.
My ultimate goal is to apply a 10 MHz pulse to the source of counter 0
(using an external wired connection) and route the internal output of
counter 0 to the source of counter 1 so that counter 1 will register
the number of roll-overs of counter 0. I want to be able to get
readings from counter 0 and 1 on demand (unbuffered) at asynchronous
times and thereby determine the time elapsed since the counting
started.
I want to test things by generating a 5 MHz continuous pulse train
with counter 2 and routing this to the input of counter 0 internally
in place of the external signal I will be using later. Whenever I try
include code to route signals, however, I get error messages when I
actually try to read the counter. For example:
-89127 Specified route cannot be satisfied, because it requires
resources that are currently in use by another route.
Property: DAQmx_CI_CountEdges_Term
Property: DAQmx_CI_CountEdges_ActiveEdge
Source Device: Dev1
Source Terminal: PFI39
Required Resources in Use By
Source Device: Dev1
Source Terminal: Ctr2InternalOutput
Destination Device: Dev1
Destination Terminal: Ctr0Source
Task Name: readCntr0
The relevant parts of the code that generated this are (errChk is a
macro that prints the error messages similar to the one in the library
example code):
// setup continuous pulse
TaskHandle pulseHndl=0;
errChk(DAQmxCreateTask("",&pulseHndl));
errChk(DAQmxCreateCOPulseChanFreq(pulseHndl, "/Dev1/ctr2", "",
DAQmx_Val_Hz, DAQmx_Val_Low, 0.0,
5e6, 0.50));
errChk(DAQmxCfgImplicitTiming(pulseHndl, DAQmx_Val_ContSamps, 1));
// setup counter 0 to count pulses from counter 2
TaskHandle readCntr0Hndl;
errChk(DAQmxCreateTask("readCntr0", &readCntr0Hndl));
errChk(DAQmxCreateCICountEdgesChan(readCntr0Hndl, "/Dev1/Crt0",
"", DAQmx_Val_Rising,
0, DAQmx_Val_CountUp));
// route output of Ctr2 to input of Ctr0
errChk(DAQmxConnectTerms("/Dev1/Ctr2InternalOutput",
"/Dev1/Ctr0Source",
DAQmx_Val_DoNotInvertPolarity));
errChk(DAQmxStartTask(pulseHndl));
errChk(DAQmxStartTask(readCntr0Hndl));
while (1)
{
uInt32 count0;
// this is where it gives the error message:
errChk(DAQmxReadCounterScalarU32(readCntr0Hndl, 0, &count0, 0));
cout << "count0: " << count0 << endl;
}
I would also like to setup counter 1 to get the rollovers from counter 0:
// setup counter 1 task to do edge counting, then:
// route output of Ctr2 to input of Ctr0
errChk(DAQmxConnectTerms("/Dev1/Ctr0InternalOutput",
"/Dev1/Ctr1Source",
DAQmx_Val_DoNotInvertPolarity));