Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the GPIB via a Global Variable

Helo community!

 

I'm trying to set my GPIB parameters and some COM parameters with Global Variables. The reason I want to do this is that I have several VIs using the same instruments. I'm starting those VIs with an eventhandler in a Top level VI. Those VIs wont run simultaniously. I don't want to set my connection parameters in every VI but am looking for a solution to set them once in th top level VI. My first idea was to use Global variables. However, I haven't worked with them jet so my aproach might be wrong.

 

I would greatly apreciate some help on how to do this

 

 

Florian

Windows XP Professional, Labview 9
0 Kudos
Message 1 of 5
(3,745 Views)

I believe your approach is correct: that's what global variables are intended for. Furthermore, GPIB address is set once and for all, so no risk of race conditions.

However I'm not a guru, maybe there's a risk I don't see?

Regards

0 Kudos
Message 2 of 5
(3,729 Views)

Hello xdaf!

 

Thanks for the reply. However, I can't conect a global variable to where I set my GPIB Adress. Like I said, I never worked with Variables so a simple example would be very helpfull.

 

 

thx Florian

Windows XP Professional, Labview 9
0 Kudos
Message 3 of 5
(3,723 Views)

There's a thread in the Breakpoint forum debating the "evilness" of global variables. You can read that if you wish. I do not sit in the "global variables are evil" camp, but they can easily be abused/misused by newbies. The primary problem that regulars on these forums see is that of race conditions. There are other issues, such as data copying, but for something relatively simple like GPIB addresses, that's a non-issue.

 

Can you use global variables for what you're doing? Yes. Is it a good solution? Define "good solution" is my first response. Smiley Wink

 

An alternative is to use a class-based approach for your instruments. This approach is scalable, but obviously more complicated, and requires a little knowledge in object-oriented programming. I use a pseudo-class-based approach in the programming I do primarily because the object-oriented support in LabVIEW 8.2 is flaky. It's all based around storing the instrument information around a LV-2 style global, aka functional global, aka Action Engine

0 Kudos
Message 4 of 5
(3,721 Views)

FlorianJ wrote:

Hello xdaf!

 

Thanks for the reply. However, I can't conect a global variable to where I set my GPIB Adress. Like I said, I never worked with Variables so a simple example would be very helpfull.

 

 

thx Florian


Examples ship with LabVIEW. Open the Example Finder and search for "global".

0 Kudos
Message 5 of 5
(3,720 Views)