Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx - counter input and output at the same time?

Hi! 

 

So I just got my first national instrument - a daq chassis with 2x NI-9401 moduels. 

 

Im using the DAQmx driver with C++ (without measurement studio), and currently trying to setup some counters - 

 

The main goal is to create 1 counter input and 2 counter output on 1 module - But I cant figure out how to configure the channels. 

 

The current relevant code is:

 

		DAQmxErrChk(DAQmxCreateTask("", &CItaskHandle));
		DAQmxErrChk(DAQmxCreateTask("", &COtaskHandle));

	DAQmxErrChk(DAQmxCreateCICountEdgesChan(CItaskHandle, "cDAQ2Mod1/ctr0", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp));
	DAQmxErrChk(DAQmxCreateCOPulseChanFreq(COtaskHandle, "cDAQ2Mod1/ctr1", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 10000.00, 0.50));
	DAQmxErrChk(DAQmxCreateCOPulseChanFreq(COtaskHandle, "cDAQ2Mod1/ctr2", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 60.00, 0.50));

	
	DAQmxErrChk(DAQmxStartTask(CItaskHandle));
	DAQmxErrChk(DAQmxStartTask(COtaskHandle));

the program only makes it too the line:

DAQmxErrChk(DAQmxCreateCOPulseChanFreq(COtaskHandle, "cDAQ2Mod1/ctr1", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 10000.00, 0.50));

 

When i try to run the program, I just get:

"DAQmx Error: Lines 0 through 3 of this port are configured for input. Cannot configure these lines for output at this time.
Device: cDAQ2Mod1
Digital Port: 0

Task Name: _unnamedTask<1>

Status Code: -200122
End of program, press Enter key to quit " 

 

So my guess is that the first task/line configures all 4 counters to input - But i only need one counter to be input, and 2 output - how do i configure this?

 

Best regards Martin. - Thanks for reading

0 Kudos
Message 1 of 13
(3,120 Views)

*note - the message first appears when i start the tasks 

 

DAQmxErrChk(DAQmxStartTask(CItaskHandle));
DAQmxErrChk(DAQmxStartTask(COtaskHandle));
0 Kudos
Message 2 of 13
(3,112 Views)

Hey Martin,

I just came across your thread. Sorry for the last answer.

Is this issue still relevant? Can you post /attach a minimal example that produces your error? I could then try to reproduce and solve it here.

 

I assume you are using LabWindows/CVI. What version of it and of DAQmx are you using?


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 3 of 13
(2,992 Views)

Hi

I have the similar question, which I want to one channel to read Encoder, two channels to write square waves with ctr0 and ctr1. But I got error 50103. I have attached the vi. I do not know how to solve it? Can someone help me?thanks!

 

The hardware is USB6229.

0 Kudos
Message 4 of 13
(323 Views)

I don't have LV 2024 installed and can't open your code.

 

But your 62xx device only contains 2 counters, which only allows 2 counter tasks at a time not 3.  Each counter can be set up for either input or output operations but not both at once.

 

About the only hope I can offer with that device is:

- 1 counter for encoder reading

- use "correlated DO" on port 0 for your 2 outputs

- 1 counter to generate the sample clock needed to support correlated DO

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 13
(301 Views)

Hi 

I saved the file in 2012 LV version.

0 Kudos
Message 6 of 13
(299 Views)

Same answer.  You can't run 3 counter tasks at the same time on a device with only 2 counters.

 

Also of note: you never read from your edge counting task.  What's it supposed to be for if you never pay attention to the count?

 

 

-Kevin P 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 7 of 13
(290 Views)

Hi Kevin

 

Thank you for the answers.

I need the edge count task for the speed measurement. Shall I use another hardware USB6229 parallel? I do have another USB6229 in the lab.

0 Kudos
Message 8 of 13
(286 Views)

Hi Kevin

Shall I try  "correlated DO" ? I did not find a example. Du you have one? Thanks!

0 Kudos
Message 9 of 13
(285 Views)

The choice between using correlated DO for the 2 outputs or using a 2nd USB-6259 may depend on whether you need to keep your tasks sync'ed at the hardware level.

 

If you do, I'd suggest the correlated DO approach using just 1 of the USB-6259 devices.   Here's one example from this site.   You can also run 2 of the shipping examples to explore it.  One of them should be a counter output (finite or continuous) where you can specify a PFI terminal for the pulse to be output.  The other should be a DO task (finite or continuous) where you can specify a PFI terminal as the source for a sample clock.

 

If the sync between output and input isn't so critical, it'll probably be easier to just use 2 of the USB-6259 devices.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 10 of 13
(268 Views)