Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

problem routing with ANSI C DAQmx on PCI-6601 error 89132

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));

   

0 Kudos
Message 1 of 3
(4,904 Views)
Hi Ksg,

Thank you for the great explanation of the problem. I would use the channel property nodes to make those routes. Currently you are using:

DAQmxConnectTerms("/Dev1/Ctr2InternalOutput","/Dev1/Ctr0Source",DAQmx_Val_DoNotInvertPolarity);

When in fact you want to use:

DAQmxSetCICountEdgesTerm(readCntr0Hndl, "/Dev1/Ctr0", "/Dev1/Ctr2InternalOutput");

This function definition can be found on the C Reference Help "List of Channel Properties" located under NI-DAQmx C Properties. Then look for Counter Input » Count Edges » Input Terminal.

Hope this helps,
Gerardo O.
RF SW Engineering R&D
National Instruments
Message 2 of 3
(4,895 Views)
Gerardo,

Thank you so much for your rapid and helpful response.  
This solved my problem perfectly. I knew it had to be something basic
that I was missing.

To summarize the solution:

I am generating a 5 MHz continuous pulse on counter 2
and counting the pulses with counter 0.  Counter 1 is being used to
count the number of roll overs of counter 0.  The relevant portion of
my code now looks like:


   // 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));

   // set "input" or source for counter 0 to be output of counter 2
   errChk(DAQmxSetCICountEdgesTerm(readCntr0Hndl, "/Dev1/ctr0",
                                   "/Dev1/Ctr2InternalOutput"));


   // setup counter 1 to count roll overs from counter 0
   TaskHandle readCntr1Hndl;

   errChk(DAQmxCreateTask("readCntr1", &readCntr1Hndl));

   errChk(DAQmxCreateCICountEdgesChan(readCntr1Hndl, "/Dev1/Crt1",
                                      "", DAQmx_Val_Rising,
                                      0, DAQmx_Val_CountUp));

   // set "input" or source for counter 1 to be output of counter 0
   errChk(DAQmxSetCICountEdgesTerm(readCntr1Hndl, "/Dev1/ctr1",
                                   "/Dev1/Ctr0InternalOutput"));

   errChk(DAQmxStartTask(pulseHndl));
   errChk(DAQmxStartTask(readCntr1Hndl));
   errChk(DAQmxStartTask(readCntr0Hndl));
   
   while (1)
   {
      uInt32 count1;
      errChk(DAQmxReadCounterScalarU32(readCntr1Hndl, -1, &count1, 0));
      
      uInt32 count0;
      errChk(DAQmxReadCounterScalarU32(readCntr0Hndl, -1, &count0, 0));

      cout << "cnt1: "<< count1 << "  cnt0: " << count0 << endl;
   }


Message 3 of 3
(4,887 Views)