LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the same output from multiple locations in vi

Hi

 

I have a very basic question which I do not seem to find the answer to though.

 

When programming a VI for measurement and control using a standard DAQ device, for example 6281 I

often want to control the same digital out pin from various places in the program.

F.ex. In the beginning I want P0,0 to be high, then later somewhere deep in the program in a while loop I want

to set P0,0 to low. How do I do this. I keep getting the message that the resource is reserved.

This I have the same question with AI, AO and Digital in.

The DAQassistant does not work and doing this more manually by creating a task, stopping it and clearing it has been problematic.

 

Can anyone help? Hopefully with a demonstration VI if you have it?

 

Thanks for reading all the way down though;)  

0 Kudos
Message 1 of 6
(3,202 Views)

You should create a functional global that stores tasks for each port.

In the following image I have some code that should work.

It looks up the addressed port and creates a new task if needed, otherwise it will call the old task.

Be sure to call this VI with 'Stop?'=True at the end of your program.

 

 

 


 

Ton

Message Edited by TonP on 10-11-2008 08:41 PM
Message Edited by TonP on 10-11-2008 08:42 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 6
(3,181 Views)

Thanks TonP

 

I see your point but I don't think you are seeing mine;)

 

Wether it is AI, AO, DI, or DO is actually beside the point concerning my question, I am just wondering if identical acquisition can exist in various locations in a block diagram.

I know it can but I don't know if that is the right or "legal" way to program in Labview. I attached an example which I extracted from an old program of mine.

There a task is created, ai2 is measured then the task is stopped and cleared, in the following the sequence the same is repeated, I needed to measure the same channel at multiple locations in my program and it worked, sometimes I got an error though and I am wondering if this could be the reason? (I don´t remember the name of the error)

 

Hope somebody understands my strangely written question:)

0 Kudos
Message 3 of 6
(3,142 Views)
0 Kudos
Message 4 of 6
(3,140 Views)

I see what you mean.

 

My previous VI was purely meant for demonstartion, and works best for DI and DO.

 

By the way the program you posted should never give an error, if you get one report it to NI.

 

Here's the code a little bit altered. It is important to think in tasks:

 

 

Ton

Message Edited by TonP on 10-16-2008 08:04 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 6
(3,112 Views)

Thanks man, that is exactly the answer I was hoping/looking for:)

 

and also thanks for the task tip,,, appreciated!

 

 

Ice_man

0 Kudos
Message 6 of 6
(3,096 Views)