06-13-2018 06:30 AM
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
06-13-2018 07:06 AM
*note - the message first appears when i start the tasks
DAQmxErrChk(DAQmxStartTask(CItaskHandle)); DAQmxErrChk(DAQmxStartTask(COtaskHandle));
08-27-2018 09:52 AM
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?
12-03-2024 04:25 PM
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.
12-04-2024 10:22 AM
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
12-04-2024 10:32 AM
Hi
I saved the file in 2012 LV version.
12-04-2024 11:02 AM
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
12-04-2024 11:12 AM
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.
12-04-2024 11:17 AM
Hi Kevin
Shall I try "correlated DO" ? I did not find a example. Du you have one? Thanks!
12-05-2024 09:43 AM
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