Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA: Parallel threads and locking instruments

Hello,

i have 50 instruments that are controlled in two threads running at the same time.

Thread 1: Only VISA write (configuration of the instruments)

Thread 2: Visa write and Visa read (read measurement from instrument)

 

Can i now simply add the "Visa Lock Async VI" before the write and "Visa Unlock" at the end?

 

Thread 1: Visa Lock -> Write -> Visa Unlock

Thread 2: Visa Lock -> Write -> Read -> Visa Unlock

 

Thanks

0 Kudos
Message 1 of 4
(4,567 Views)

It is really best if you can put all of the instrument control into a single thread.  That way you don't have to play these lock-do something-unlock games.  A Queued Message Handler works wonderfully for this situation.  But if you insist on not doing that (I know there are situations where you can't), then a Semaphore is really the way to go.

 

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(4,557 Views)

Thanks for the help.

But it is also working with the Visa lock/unlock?

 

Using sempahores makes it very unreadable as i have to create new input/outputs to all VIs for the semaphores.

And the Visa addresses are already available for lock/unlock.

Message 3 of 4
(4,555 Views)

Hello OnlyOne,

 

yes this should work.

 

What you can also try is to set read and write to synchronous mode

 

Choosing between Synchronous and Asynchronous VISA Functions

 

Hope this helps a little bit.

best regards
Alexander
0 Kudos
Message 4 of 4
(4,534 Views)