LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make two VIs run simultaneoulsy without conflicting with each other?

Hi guys,
I've run into the following problem: I want to run simultaneously two pieces of equipment (Temperature Controller (Scientific Instruments 9700) and Lock-In amplifier (Stanford Research Systems SR810 DSP)) by two different VIs working simultaneously via GPIB cables connected to the same GPIB-USB converted. Each of the VIs works well when the other one is not running. But when both the VIs are running after some time of proper simultaneous work (~ 10 min) both the VIs freeze at the same time. The time delay of 200 msec is included on both the VIs. In case anybody knows how to solve the problem in such a way that I do have both of them running simultaneously but not conflicting with each other let me know.
 
Alex from UCF
0 Kudos
Message 1 of 7
(3,174 Views)
Howdy Alex,

If I understand correctly what you are asking, you have two VI's communicating over one GPIB communication channel?  If so, it looks like a job for a semaphore.  You might want to check that out.  It's a way to give multiple processes access to a single resource.

If I'm completely off target..  then I never wrote this and plead the 5th.  Smiley Very Happy
Greg Cole
“It is not the ship so much as the skillful sailing that ensures the prosperous voyage.”
0 Kudos
Message 2 of 7
(3,159 Views)
Alex,

One method is to use semaphores (found in the Synchronization palette).

Another method is to encapsulate all the GPIB communications into a single VI. Send commands such as Write-then-Read along with the ID of the instrument and any data to the VI. When it has finished communicating with that instrument then the VI will be available for talking to the other instrument. I think Ben's Action Engine Nugget talks about this kind of application.

In a similar way, putting the GPIB communications in a parallel loop with inter-loop communications handled by queues can eliminate the resource contention.

Lynn
0 Kudos
Message 3 of 7
(3,157 Views)

Although Action Engines will be helpful if the interface was serial, GPIB accounts for simultaneous device access.

Similarly, the semaphores would help with serial but not GPIB.

Now for my wild guess!

Is this version 7.1 or less?

There was a bug in the VISA driver that would look-up LV if talking to multiple devices back then. I believe this bug was fixed.

Ben

PS the above assumes the two programs are not trying to acess the same instrument AND there are waits in loops so both can share the CPU!



Message Edited by Ben on 12-12-2007 12:45 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(3,146 Views)

Hi Ben,

Actually it's 8.2 version. Do you know of any bugs which can cause the problem in this version?

Alex from UCF

0 Kudos
Message 5 of 7
(3,132 Views)
Hi Alex

it is not a bug but a race condition. Probably the write to one instrument is messing up the read from the other instrument.
The implementation of Lyn Johnson is in fact the easiest one.
write a vi thta combines the write and read to an instrument (call it "Query VISA")
implement also that if you don't wite (empty string check) just don't write with a case statement.
and also if you don't want to read (zero characters) don't call the visa read (another case)
Also connect everything nicely with errorIO.

If implemented this way LabVIEW will synchronise because this subvi will only be active for one instrument. The other is queued until the first is finished.
Ben is pointing to action engines but in fact this is a one action action engine
greetings from the Netherlands
0 Kudos
Message 6 of 7
(3,122 Views)

"...know of any bugs..."

No Sir!

Post all of your VI's and someone may be able to spot a conflict or problem.

Just trying to help,

Ben



Message Edited by Ben on 12-12-2007 01:22 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(3,122 Views)