LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple inputs and outputs using DAQmx VIs

Hello,

I am fairly new with the LabView programming language.  I have a few training books that I have been reading, and I have been following online tutorials and reading the forums.  However, I have come to a problem where I don’t see a clear solution.  I am using LabView 2009 (9.0f3) and DAQmx VIs.

 

I am using a NI 9172 chassis PLC, with two 9201 AI cards, 9217 AI RTD card, 9472 DO card, 9263 AO card, and two 9237 AI Bridge cards.

I am reading eight analog inputs with the 9201 cards, two analog RTD inputs with the 9217 card, three digital outputs with the 9472 card, three analog outputs with the 9263, and eight analog inputs with the 9237 cards.

 

I wrote a simple program to test one digital output task, two of the analog output tasks, and a single analog input task.  I put all of them in the same while loop, and it worked perfectly.  However, when I add analog input tasks to the same loop, I get an error 200022.    So I tested each sensor individually by changing the channel before each run.  I searched error 200022 and found that this is because I cannot start another analog input task until the previous one ends.  With this said, I don’t know how to acquire an analog voltage in the same task as an analog RTD voltage.  Both inputs take different constants in the start task DAQmx icon.

 

Attached is my test program.  It is titled “Test All”. This is the program I used to test the various sensors.  I tested the input sensors one at a time, and it worked fine.  A few tasks are written just to test functionality, and will be added to later.  The data is only displayed on the screen.  I will add triggers and data write to disk functions later.  This program works now, but if I add more analog inputs, it will generate the 200022 error.

 

Can someone show me how to correctly write the code for multiple inputs and outputs using DAQmx?  All training materials and tutorials I can find all show a single input or single output, not multiples of each.  Thanks for looking.

-Randy

0 Kudos
Message 1 of 4
(3,348 Views)

You can create all your channels as virtual global channels in max.  Then put them into tasks sorted by AO, AI, DO.  That way you only read or write to one AO task instead of 2 tasks and get your error.

 

 

0 Kudos
Message 2 of 4
(3,335 Views)

I am also not really sure what you are doing with the error clusters and feedback nodes.  If you set up the tasks as above you only need a daqmx read or write inside the while loop (for each task) and the clear task outside the loop.

0 Kudos
Message 3 of 4
(3,327 Views)

Hi RandyC,

 

The Knowledge Base article Using Different Types of DAQmx Global Channels in the Same Task goes into a little more depth of what Bryan is talking about, and it also includes some example code to help show what to do.

 

Hope that helps,

0 Kudos
Message 4 of 4
(3,301 Views)