def __init__(self, ip="10.25.124.252", gpib_address=10, loglevel=20): """ Connect to the power supply via Prologix GPIB connector This class is based on information provided by the AFG3021B Programmer Manual. For more information, please see AFG3000 Series Arbitrary/Function Generators Programmer Manual offered by Tecktronix. Keyword Args: ip (str): IP adress of the Prologix GPIB connector gpib_address (int): The GPIB address of the power supply connected to the Prologix connector """ try: gpib = PrologixGPIBEthernet(ip, timeout=15) gpib.connect() except OSError: raise ValueError( 'Connection to plx_gpib_ethernet failed, check connection!') try: gpib.select(gpib_address) except OSError: raise ValueError( 'Connection to plx_gpib_ethernet failed, check IP address!') self.logger = loggers.get_logger(loglevel) self.instrument = gpib
def __init__(self, ip="10.25.123.111", gpib_address=15, loglevel=20): """ Connect to the power supply via Prologix GPIB connector Keyword Args: ip (str): IP adress of the Prologix GPIB connector gpib_address (int): The GPIB address of the power supply connected to the Prologix connector """ gpib = PrologixGPIBEthernet(ip) gpib.connect() gpib.select(gpib_address) self.logger = loggers.get_logger(loglevel) self.instrument = gpib
class Gigatronics2520A(): def __init__(self, prologix=False, gpib_addr=GPIB_ADDR_2520A): if not prologix: self.gpib = PrologixGPIBEthernet('192.168.1.128') self.gpib.connect() else: self.gpib = prologix self.gpib_addr = gpib_addr self.gpib.select(self.gpib_addr) self.gpib.write('*RST') assert '2520A' in self.gpib.query('*IDN?') def set_cw_frequency(self, freq): self.gpib.select(self.gpib_addr) self.gpib.write('SOURCE:FREQUENCY:FIX {}HZ'.format(str(int(freq)))) f_readback = float(self.gpib.query('SOURCE:FREQUENCY?')) assert f_readback == freq def set_cw_power(self, power_dbm): self.gpib.select(self.gpib_addr) self.gpib.write('SOURCE:POWER:LEVEL:IMM:AMPLITUDE {}DBM'.format( str(int(power_dbm)))) p_readback = float( self.gpib.query('SOURCE:POWER:LEVEL:IMM:AMPLITUDE?')) assert int(p_readback) == power_dbm def output_on(self): self.gpib.select(self.gpib_addr) self.gpib.write('OUTPUT ON') assert float(self.gpib.query('OUTPUT:STATE?')) == 1 def output_off(self): self.gpib.select(self.gpib_addr) self.gpib.write('OUTPUT OFF') assert float(self.gpib.query('OUTPUT:STATE?')) == 0
if __name__ == '__main__': parser = argparse.ArgumentParser(description='scalar network analyzer') parser.add_argument('--cal', default=False, help='specify name of calibration file') parser.add_argument('--ddir', default='./data/', help='specify name of calibration file') parser.add_argument('filename', help='specify name of output file') args = parser.parse_args() prologix = PrologixGPIBEthernet('192.168.1.128', timeout=10) prologix.connect() meter = AgilentE4418B(prologix=prologix) synth = Gigatronics2520A(prologix=prologix) freqs = np.arange(1e9, 20.1e9, .25e9) synth.set_cw_power(0) synth.output_on() meas = np.empty_like(freqs) for (i, f) in enumerate(freqs): synth.set_cw_frequency(f) meas[i] = meter.read_power(f) print('f: {}, p: {}'.format(f / 1e9, meas[i]))
class FSP30(): def __init__(self, prologix=False, gpib_addr=GPIB_ADDR_FSP30): if not prologix: self.gpib = PrologixGPIBEthernet('192.168.1.128') self.gpib.connect() else: self.gpib = prologix self.gpib_addr = gpib_addr self.gpib.select(self.gpib_addr) self.preset() pdb.set_trace() assert 'FSP-30' in self.gpib.query('*IDN?') def read_peak(self): self.gpib.select(self.gpib_addr) self.gpib.write('INIT:IMM;*WAI') self.gpib.write('CALC:MARK:MAX') f = float(self.gpib.query('CALC:MARK:X?')) amp = float(self.gpib.query('CALC:MARK:Y?')) return {'freq': f, 'amp': amp} def get_sweep(self): self.gpib.select(self.gpib_addr) self.gpib.write('FORM:DATA: REAL,32') self.gpib.write('INIT:IMM;*WAI') vals = self.gpib.query('TRACE? TRACE1') # this probably won't work, I need to read back the sweep size # see FSP operator manual page 4.259 return vals def set_reflevel(self, reflevel): self.gpib.select(self.gpib_addr) # sets ref level, units of dBm self.gpib.write('DISP:WIND:TRAC:Y:SPAC LOG') self.gpib.write('DISP:WIND:TRAC:Y:RLEV ' + str(reflevel) + 'dBm') def set_vrange(self, vrange): self.gpib.select(self.gpib_addr) self.gpib.write('DISP:WIND:TRAC:Y' + str(vdiv) + ' dB') def set_span(self, span, center, points): self.gpib.select(self.gpib_addr) self.gpib.write("SWE:TIME:AUTO ON") self.gpib.write("SENSe:SWEep:POINts " + str(points)) self.gpib.write("SENSe:FREQuency:CENTer " + str(center) + 'Hz') self.gpib.write("SENSe:FREQuency:SPAN " + str(span) + 'Hz') def get_span(self): self.gpib.select(self.gpib_addr) points = int(self.gpib.query("SENSe:SWEep:POINts?")) center = float(self.gpib.query("SENSe:FREQuency:CENTer?")) span = float(self.gpib.query("SENSe:FREQuency:SPAN?")) return linspace(center - span / 2.0, center + span / 2.0, points) * 1e9 def preset(self): self.gpib.select(self.gpib_addr) self.gpib.write('*RST') self.gpib.write('*CLS') self.gpib.write('INIT:CONT OFF')