Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Semaphors to synchronize several GPIB instruments?

Hello,

I have to develop a programm to diplay three different GPIB instruments on screen. The instruments should also be switchable between different modes. Thus, I have write and read access from time to time (of course read dominates to capture data).
I managed to program every single instrument with open/read/write/close VISA quite well, but when I first tried to implement two instruments in a block diagramm, I got error messages which disappeared when I switched to the slow highlighted execution. So I think there´s a problem with read an write access to the GPIB.
I now implemented semaphors to encapsulate every read and write access and it works.

Now, eventually, my question:
Is it common to use semaphor
s with GPIB access?
Should everything work without semaphors, which means that the architecture of GPIB should prevent such errors?

If you need additional information please let me know...

Thanks for any answer,

Andreas
0 Kudos
Message 1 of 3
(3,131 Views)
Andreas:

Needing synchronization is a very common issue because if one area of code writes a query, and then another section of code comes along and does a query, there are a couple of issues:
1) In most 488.2 instruments, the response to the second query will overwrite the response to the first query. Only one of the two pieces of code (depending on which runs next) will get that response.
2) Even if the instrument generates two responses, it is possible the pieces of code will be interleaved, generating strange results. For example, write A1, (context switch), write A2, (context switch), read A1, (context switch), read A2.

There are several solutions. You can use LabVIEW semaphores, which you have done. You can also use VISA locks, which do p
retty much the same thing, as long as each section of code has its own session. If you use the same session in both pieces of code, then VISA locks wouldn't help you.

So since your solution works as is, keep it. It's good, it's needed in your case, and it's the right thing to do.

Dan Mondrik
National Instruments
0 Kudos
Message 2 of 3
(3,131 Views)
Thanks a lot for the answer.
I'll also try it with VISA locks as I don't have to pass in semaphor references in every instrument-SubVI this way.

Andreas
0 Kudos
Message 3 of 3
(3,131 Views)