LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running two labview instance accessing the same hardware ressources

Hi, 

I am currently wondering whether it is possible to launch two labview instances in same time running in parallel while those two instances would access successively the same hardware device (meaning when one instance use the hardware resoure, the other instance don't need to access it and vice-versa) ?

0 Kudos
Message 1 of 10
(1,195 Views)

Actually, it is not logical, instead create another LabVIEW application which will control the instrument. Now your applications A and B will communicate with the instrument control application C, this way you can ensure both applications A and B do not attempt to control the instrument at the same time.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 10
(1,187 Views)

@santo_13 wrote:

Actually, it is not logical, instead create another LabVIEW application which will control the instrument. Now your applications A and B will communicate with the instrument control application C, this way you can ensure both applications A and B do not attempt to control the instrument at the same time.


Yes, this is the same concept as having two VIs in the same instance accessing an instrument through a (non-reentrant) subVI.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 10
(1,137 Views)

I agree with the answers you already got, but strictly sticking to your question: yes, in principle it's possible but only one of them at a time must have a reference/handle open on the shared resource.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 10
(1,129 Views)

Depending on your requirements it can work. I did it with a simple weighing program.

The user could have 2-4 objects that they needed the weight of from time to time, so each instance was a test of an object with a timer and they had a button that read the measurement from a scale (they did a number of steps in between). It opened VISA, took a reading and closed the ref.

It was a very low frequency scenario and no chance of simultaneous readings.

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 10
(1,124 Views)

@pincpanter wrote:

I agree with the answers you already got, but strictly sticking to your question: yes, in principle it's possible but only one of them at a time must have a reference/handle open on the shared resource.


Expanding on this statement... You must handle the condition where one program has the HW handle locked while the second program wants to use it. So think ahead. What is going to happen to the second program? Hopefully it will not crash (error out).

 

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 6 of 10
(1,099 Views)

I've used both of the methods suggested (one by Santhosh, one by Yamaeda).

 

What Santhosh described is more generally applicable, but also takes more work to create and debug.  I've done both at various times. 

 

I recently had the kind of app Yamaeda referred to where the need for the shared resource was on a low duty cycle.  Each app would need it occasionally and very briefly, so contention would be fairly rare.  Roughly once every couple of minutes there might be contention for a half second or so.  So I decided to just go with the easier approach he mentioned.

 

There's still some extra work, but not very much.  You just code each app to *expect* that some of its attempts to open the VISA resource will fail with a particular error stating that the resource is present in the system but not available to reserve.  Then make sure both apps keep trying a few times, not forever but long enough to be sure that it isn't the other known app causing the unavailability.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 7 of 10
(1,086 Views)

Can you share some examples / .vi or anything so we can visualize a bit better ?

0 Kudos
Message 8 of 10
(1,067 Views)

I would suggest you combine the two seperate programs into one program instead of two independent programs fighting over the same resource.

 

It's far easier to control access to a single resource from two independent loops in one program than two independent programs.

 

But honestly I need more information, what kind of instrument and what do the two programs do?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 10
(1,043 Views)

@Kevin_Price wrote:

I've used both of the methods suggested (one by Santhosh, one by Yamaeda).

 

What Santhosh described is more generally applicable, but also takes more work to create and debug.  I've done both at various times. 

 

I recently had the kind of app Yamaeda referred to where the need for the shared resource was on a low duty cycle.  Each app would need it occasionally and very briefly, so contention would be fairly rare.  Roughly once every couple of minutes there might be contention for a half second or so.  So I decided to just go with the easier approach he mentioned.

 

There's still some extra work, but not very much.  You just code each app to *expect* that some of its attempts to open the VISA resource will fail with a particular error stating that the resource is present in the system but not available to reserve.  Then make sure both apps keep trying a few times, not forever but long enough to be sure that it isn't the other known app causing the unavailability.

 

 

-Kevin P


I like your approach Kevin but.....

 

Nobody has yet suggested the simple expedient of interpreters communication by simply writing to a *.loc file.  Just a quick text that tracks what app is just about to lock a resource (potentially even a list of what apps are waiting) then only allow attempts to open the resource after successfully writing to the file.  And, of course, the app using the resource should clear the *.loc file after closing is session.

 

essentially its the dining philosophers problem

You have to pick up a fork and wait for the other


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(1,024 Views)