Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-Device interface to GPIB bus

I'm trying to figure out the best way to write a .NET program that controls multiple interfaces.  My first effort was the obvious approach:  creating several Device objects and then using each one's write method to send commands, but this appears not to work.  Creating a new Device object seems to reconfigure the whole bus to reroute all commands to the second device.  So, what is the correct approach?  I could use the Board class, but this seems like much more of a pain and less intuitive.  The old library used to include a set of Multi-Device procedures that presumably handled the details behind the scenes.  Is this functionality been eliminated in the .NET library?

Thanks,

Alex Gerdemann
University of Illinois Urbana-Champaign
0 Kudos
Message 1 of 6
(3,864 Views)

It seems to me that you're taking the right approach.  When you say "multiple interfaces" do you mean multiple devices on 1 GPIB card, or multiple cards?  If you mean multiple devices, I think you're on the right track.  What's going wrong with your multiple device objects?

Scott B.
GPIB Software
National Instruments

0 Kudos
Message 2 of 6
(3,842 Views)
Sorry if my explanation was confusing.  I have just the one GPIB card in the computer, but it's connected to several pieces of equipment.  I've included a short bit of VB code that illustrates the problem.

The code should program dev1 to 20 volts, clear dev2, and then program dev1 to 10 volts.  In reality, after dev2 is cleared, the second command to dev1 does not go through.  Instead, I can see that the command gets routed to dev2 because when I step through the program, I get an invalid command error on dev2 when the line dev1.Write("P0.0100K") is excecuted (and another for the next line).  Upon further infestigation, I have found that the problem is eliminated if a regular command is sent to dev2 after the clear (eliminate the comment in my code) .  Then, subsequent commands go to dev1 as desired.  Is there something about the clear command that I don't understand that makes this the predicted behavior?

Any insight would be greatly appreciated,

-Alex Gerdemann
University of Illinois Urbana-Champaign

Imports NationalInstruments.NI4882

Module Module1
    Dim dev1, dev2 As Device
   
    Sub Main()
        dev1 = New Device(0,5)
        dev1.Clear()
        dev1.Write("P0.0200K")
        dev1.Write("G")
        dev2 = New Device(0,4)
        dev2.Clear()
        ' dev2.Write("VOLT 4")
        dev1.Write("P0.0100K")
        dev1.Write("G")
    End Sub
End Module
0 Kudos
Message 3 of 6
(3,830 Views)
This problem is occurring because the GPIB interface is not properly addressing the GPIB bus when switching between instruments.  To resolve this issue, enable readdressing on your devices after opening them, as shown below:

         dev1 = New Device(0, 2)
    dev1.ReaddressingEnabled = True
    dev2 = New Device(0, 4)
    dev2.ReaddressingEnabled = True



Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(3,817 Views)
Thank you.  That fixed it.  Is there any reason I wouldn't want readdressing enabled?

-Alex
0 Kudos
Message 5 of 6
(3,803 Views)
Enabling readdressing can add some overhead to your GPIB operations, as it will readdress your GPIB instrument with each command, even though it may not be necessary.  This becomes important if you are doing a lot of small high speed bus transactions.  In normal circumstances, the effect will not be noticeable. 

The issue that has made readdressing necessary in this case is in fact a defect in the driver, and will be resolved in a future release.  For now, enabling readdressing is a good workaround to the problem.

Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(3,792 Views)