LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

trying to use same device in subvi

I have a main vi that takes a measurement using the daqmx read vi.  I would then like to take another reading from a different channel in a sub vi.  I am getting the 50103 resource is reserved error.  My initial thoughts were that the stop task was supposed to release it, but from my reading the device is still reserved even after the task is stopped.  I don't want to include all channels in one task because I want to use the same sub vi in multiple main vi programs.  I would like the main to take most of the data from the sub and add a couple of things.  Is there anyway to get the device released before it enters the subvi?
 
Thanks for the help
0 Kudos
Message 1 of 10
(3,149 Views)

Hi rjennings-

DAQmx Stop Task will unreserve the hardware and a second task can then be started.  If you want to be more sure that the hardware is released you can call DAQmx Control Task to explicitly Unreserve the hardware.  Are you seeing the resource reservation error even if you use DAQmx Stop Task for the main task before calling your subVI?

Thanks-

Tom W
National Instruments
0 Kudos
Message 2 of 10
(3,147 Views)
Tom,
 
Thanks for the quick reply. 
 
I have a task constant lead to a start to the read to wait until complete to stop.  I still see the reservation error though.
0 Kudos
Message 3 of 10
(3,144 Views)

Hi rjennings-

Can you post a portion of your code?

Tom W
National Instruments
0 Kudos
Message 4 of 10
(3,141 Views)
Here is my code
Download All
0 Kudos
Message 5 of 10
(3,130 Views)
Hi rjennings-
 
In Flow.vi you do not force either of the DAQ operations (i.e. pressure.vi or the portion in the main VI) to operate/complete before the other one begins.  This creates a race condition in which both the DAQ code in the subVI and in the mainVI might (and probably will) execute at the same time.  You need to force the subVI to execute either before or after the DAQ code in the main VI, either by passing the error cluster between VIs (the preferred method since it preserves error information) or by using a sequence structure to make sure the two do not execute at the same time.  Since it appears that data captured by the subVI is needed in the calculations you perform before data from the main DAQ portion is needed, I would suggest that you force the subVI to execute first.
 
Hopefully this helps-
Tom W
National Instruments
0 Kudos
Message 6 of 10
(3,120 Views)
Well that makes sense.   I was wondering how you were suppose to make something happen in order. 
 
I did a little bit of searching, but didn't find much for how to pass error clusters.  How do you wire an error to a terminal in the connector?
0 Kudos
Message 7 of 10
(3,114 Views)

Hi rjennings-

You can just add an indicator the the Error Out terminal of your DAQmx Clear Task VI in the subVI and then "attach" it to a terminal via the usual method on the front panel.  If you then connect the newly-created Error Out terminal of your subVI to the Error In terminal of your DAQmx Start Task VI in the main VI you will force the mainVI code to execute only when the subVI is done.

Thanks-

Tom W
National Instruments
0 Kudos
Message 8 of 10
(3,107 Views)
Now we are getting somewhere.  I got the error passed from the sub to the main like you suggested.  It seemed more difficult than it maybe could be though.  The error is a cluster made up of a t/f, an I32, and a string.  I first made a cluster and then had to insert the three indicators inside the cluster.  Is there an easy way to create that cluster without having to put all three indicators in it?  I guess what I am asking is if there a sequence that will fill the cluster automatically with the correct type of indicators?
 
Thanks for all of your help.
0 Kudos
Message 9 of 10
(3,102 Views)

Hi rjennings-

The easiest way to create an error cluster is either to right-click on any Error In or Error Out terminal of a VI or drop the error cluster control or indicator directly from the Cluster palette on the front panel.

Tom W
National Instruments
0 Kudos
Message 10 of 10
(3,099 Views)