12-17-2018 04:33 PM
Hello,
I am attempting to write a simple LabVIEW application that uses DAQmx for digital input and output. I am using a cDAQ chassis with a NI-9401 digital I/O module. I have two classes in my code that will interact with the I/O device: one which performs edge detection on an input pin and one which sets an output pin. These actions will not occur at the same time however I would like to configure/initialize both "tasks" at the same time and perform "cleanup" at the same time.
I am currently creating a new DAQmx task in the Initialize method of my classes and assigning it to a member variable to use later in the class. However, when I attempt to call the DAQmx write function after the wait for an edge Read function has run, I get the following error "Device cannot be configured for input or output because lines and/or terminals on this device are in use by another task or route."
I am confused because I create both tasks initially before doing any input or output so they should already be configured. I don't fully understand the idea of "tasks" which is probably part of the problem. All I need to do is simple I/O.
Thanks for the help!
Solved! Go to Solution.
12-17-2018 04:50 PM
You can configure the tasks simultaneously and cleanup the tasks simultaneously but you cannot run them simultaneously. This is device specific. Some support it and some don't. If your device doesn't support it (which it obviously doesn't) you must wait for the read task to complete before calling the write function and vice versa. There is a function called "DAQmx Is Task Done" that might be useful for you.
12-18-2018 08:28 AM
That makes sense, but I am still confused because I am not attempting to perform a read and write at the same time in my code, I only have the tasks both created at the same time.
I have the following code in a "Wait For Sync" method in one of my classes:
The "Initialize" method for this class is:
And this is the code in my other class which sets a digital output:
The "Initialize" method for this class looks like:
These methods are called within a synchronous state machine and are never called at the same time in parallel so I don't understand why they would conflict unless I am setting something up incorrectly.
12-18-2018 08:53 AM
You probably need to stop the task after doing the read and write.
12-18-2018 09:01 AM
Yep, that was the magic solution! I just added a "Stop Task" VI in the member functions after performing the read and write.
Thank you!