From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital Output and Counter resource conflict - how to change Ctr0 default output terminal to avoid conflict?

I'm using the C API for NIDAQmx (via VB6) with a USB-6212.  I have run into a problem setting up for both Digital Output on Port 1 and Port 2, and using the Ctr0 for pulse train generation at the same time.  I get an error message when I try to start the counter:  -89132: Specified property value cannot be used, because it requires resources that are currently in use.

 

Here is sample code that reproduces the problem.

 

   ' ----------set up the counter
   DAQmxErrChk (DAQmxCreateTask("", Ctr0TaskHandle))
   DAQmxErrChk (DAQmxCreateCOPulseChanFreq(Ctr0TaskHandle, "/KPDAQ/ctr0", "", DAQmx_Val_Hz, _
            DAQmx_Val_High, 0, 1000#, 0.5))
   DAQmxErrChk (DAQmxCfgImplicitTiming_VB6(Ctr0TaskHandle, DAQmx_Val_ContSamps, 128))

   ' ----------setup the DO task
   DAQmxErrChk (DAQmxCreateTask("", DOTaskHandle))
   DAQmxErrChk (DAQmxCreateDOChan(DOTaskHandle, "/KPDAQ/port1", "", DAQmx_Val_ChanForAllLines)) '<----- OK line
   DAQmxErrChk (DAQmxCreateDOChan(DOTaskHandle, "/KPDAQ/port2", "", DAQmx_Val_ChanForAllLines)) '<----- Problem line
   
   ' ----------start the tasks
   DAQmxErrChk (DAQmxStartTask(DOTaskHandle))
   DAQmxErrChk (DAQmxStartTask(Ctr0TaskHandle)) ' This is where the error -89132 is genearted.

 

If I remove the DO Channel created in the line marked "problem line", then the problem goes away.  It appears to be an issue with Port 2.  Port 2 happens to include PFI12, which is where the Ctr0 output is.  So I figure I have to re-route the output of the Ctr0.  I only use it internally, to clock the AO and AI tasks.

 

I've tried using these functions to no avail:

   DAQmxErrChk (DAQmxExportSignal(Ctr0TaskHandle, DAQmx_Val_CounterOutputEvent, TermName$))

   DAQmxErrChk (DAQmxSetExportedCtrOutEventOutputTerm(Ctr0TaskHandle, TermName$))

 

What I don't know is where to send it - what should TermName$ be?.  I tried sending it to "PFI17" and "" but that did not work.

 

Any help appreciated!


Van

 

 

 

0 Kudos
Message 1 of 3
(3,341 Views)

It appears that on the OK line and Problem line you're reserving all the lines. You then start the task which reserves all the lines and leaves the counter unable to reserve it's resource. Try limiting which lines you reserve.

 

Refer to http://digital.ni.com/public.nsf/allkb/9A2AF5E10E0C893386256FE8006807DF for useful string naming conventions.

 

Hope this helps!

0 Kudos
Message 2 of 3
(3,316 Views)

I need to use all 24 DIO lines on the card, so need to assign all of them to DIO tasks.  In order to avoid the resource conflict with Ctr0, I have to assign the Ctr0 output to something else.  The documentation does not say what to do in this case (at least not that I could find).

 

I finally found the solution by trying every variation I could think of.  The one that worked was

   DAQmxErrChk (DAQmxSetExportedCtrOutEventOutputTerm(Ctr0TaskHandle, "/dev1/"))

 

I don't know what this does with the output - hopefully it just disappears.

 

Van

 

0 Kudos
Message 3 of 3
(3,269 Views)