09-23-2010 11:13 AM
Let me start by saying this is the first time writing code to communicate to DAQ devices and i'm trying to learn. I am developing a test stand that will have various inputs and outputs listed below:
cDAQ 9172:
Mod1: NI-9211 (4 Thermocouples)
Mod2: NI-9211 (3 Thermocouples)
Mod3: Not Used Currently
Mod4: NI-9201 (6 Flowrate Sensors)
Mod5: NI-9201 (5 Pressure Sensors)
Mod6: NI-9481 (4 Relays)
Mod7: NI-9481 (3 Relays)
Mod8: NI-9401 (2 Float Switches)
Based on a suggestion from a more experienced co-worker, I was going to have a separate while loop for each type of module running in parallel to my main program. For those loops, I do a "Create Channel" and then "Start Task" as well as a clock setup before entering the while loop. I started doing that with the float switch (DI) and the 1 loop for each fo the relay cards (DO) and then 1 loop for the 7 thermocouples (AI). That all ran fine with values updating as needed and I could control all relays. When I then added the next loop to read in the pressure sensors, I get an error in "Start Task" for the loop doing the thermocouple input saying the resource is reserved. I'm not sure what is causing this, the task name is unique to each loop and they are acquiring signals from different modules. Will my method work? Do I need to have just a single loop for all modules? I'm just not sure how I would do one loop when I have so many different types of data. I can add screenshots later if need be, I'm just not near that workstation currently and it isn't connected to the internet.
Solved! Go to Solution.
09-23-2010 08:31 PM
Did you do a search for the error code or message? It's a common mistake. Since you have a single A/D clock, you cannot have separate tasks. You have to use all your analog input channels in a single task.
09-27-2010 07:01 AM - edited 09-27-2010 07:02 AM
That is what I thought was the issue. What I'm trying to find is how to take in different types of AI in the same task. I'm using "Create Channel (AI-Temperature-Thermocouple)" and "Create Channel (AI-Voltage-Basic)". How would I combine those into one loop?
09-27-2010 09:17 AM
Here's a knowledgebase that gives one way how to do this
...but really, all this is doing is creating a "DAQmx Task" and then passing that task to multiple "Create Channel XX" VIs (Tasks are comprised of one or more Channels). It's more readable if you call "Create DAQmx Task.vi" and then use the task as an input to each of your "Create Channel XX.vi" VIs. This was you can even name your task "My AI Task" and then it's easier to debug.
Just FYI, the knowledgebase does not call "Create DAQmx Task" explicitly since the first "Create Channel XX.vi" will do it implicitly for him.
09-27-2010 09:20 AM
Not sure how I didn't find that in my searching, but thanks for the link and explanation. I think I understand how I need to set it up now.