How to access Agilent Devices using python and GPIB interface (with help of NI GPIB to USB converter)?

StackOverflow https://stackoverflow.com/questions/22935566

  •  29-06-2023
  •  | 
  •  

Question

I want to access Agilent Device N3301A using python. In purpose to connect to GPIB port I am using a GPIB to USB adapter from National Instruments. I have installed PyVisa, Agilent Connection Expert as well.

The code which I used in python is

import sys
# create visa object
import visa
dcel = visa.instrument('GPIB::17::INSTR')
print dcel.ask('*idn?')

This code does not works. Please, explain?

Was it helpful?

Solution

Another useful tool is the Agilent Connection Expert. This will show you whether you have GPIB connections or not. Your code will not work if you are not connected by the connection you are specifying. This software will tell you the address and whether it is under GPIB0, GPIB1... etc. I have used in the past:

import visa
from subprocess import Popen, PIPE

rm = visa.ResourceManager()
siggen = rm.get_instrument("GPIB1::19")
siggen.write("OUTP:STAT ON")

then you can write any SCPI command that works with your device. There's manuals on each one. I don't know what your device is, so I haven't tried yours, but it works on my signal generator. I hope this helps!

OTHER TIPS

please try to go with following code

import visa
import pylab
#Get instrument VISAname
visaInstrList = visa.get_instruments_list()
myScope = visaInstrList[0]+'::INSTR'
scope = visa.instrument(myScope)

please try to go with following code

    import visa

    rm=visa.ResourceMananger()
    rm.list_resources()
    #you can get a list of gpib address
    test=rm.open_resource('your gpib address')
    #try to open one of it
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top