def connect_inst(): rm = visa.ResourceManager() inst = rm.open_resource('GPIB0::%d::INSTR' % GPIB_address) return inst
def __init__(self, addr, delay=0): self.__delay_time = 0 visaObj = visa.ResourceManager() self.instr = visaObj.open_resource(addr) self.set_delay(delay)
def __init__(self): self.rm = visa.ResourceManager() self.hp = self.rm.open_resource('GPIB::19') #HP8341B GPIB address 19 self.hp.write("IP CW6Gz PL-10dB") #Set RF output to 6GHz and -10dBm
def __init__(self, name, address, reset=False): ''' Initializes the ZNB20 Input: name (string) : name of the instrument address (string) : TCPIP/GPIB address reset (bool) : Reset to default values Output: None ''' logging.debug(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) rm = visa.ResourceManager() self._address = address try: self._visainstrument = rm.open_resource(self._address) except: raise SystemExit self._visainstrument.write_termination = '\n' self._visainstrument.read_termination = '\n' self.add_parameter('frequencyspan', flags=Instrument.FLAG_GETSET, units='Hz', minval=100e3, maxval=20e9, type=types.FloatType) self.add_parameter('centerfrequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=100e3, maxval=20e9, type=types.FloatType) self.add_parameter('startfrequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=100e3, maxval=20e9, type=types.FloatType) self.add_parameter('stopfrequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=100e3, maxval=20e9, type=types.FloatType) self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='dBm', maxval=30.0, type=types.FloatType) self.add_parameter('startpower', flags=Instrument.FLAG_GETSET, units='dBm', maxval=30.0, type=types.FloatType) self.add_parameter('stoppower', flags=Instrument.FLAG_GETSET, units='dBm', maxval=30.0, type=types.FloatType) self.add_parameter('averages', flags=Instrument.FLAG_GETSET, units='', maxval=100000, type=types.FloatType) self.add_parameter('averagestatus', flags=Instrument.FLAG_GETSET, option_list=['on', 'off'], type=types.StringType) self.add_parameter('points', flags=Instrument.FLAG_GETSET, units='', minval=1, maxval=100000, type=types.FloatType) self.add_parameter('sweeps', flags=Instrument.FLAG_GETSET, units='', minval=1, maxval=1000, type=types.FloatType) self.add_parameter('measBW', flags=Instrument.FLAG_GETSET, units='Hz', minval=0.1, maxval=500e3, type=types.FloatType) self.add_parameter('status', flags=Instrument.FLAG_GETSET, option_list=['on', 'off'], type=types.StringType) self.add_parameter('cwfrequency', flags=Instrument.FLAG_GETSET, units='GHz', minval=1e-4, maxval=20, type=types.FloatType) self.add_parameter('driving_mode', flags=Instrument.FLAG_GETSET, option_list=['Auto', 'Alternated', 'Chopped'], type=types.StringType) self.add_parameter('delay_time_p1', flags=Instrument.FLAG_GETSET, units='s', minval=-3.336, maxval=3.336, type=types.FloatType) # self.add_parameter('delay_length_mech_p1', # flags = Instrument.FLAG_GETSET, # units = 'm', # minval = -3.4e38, # maxval = 3.4e38, # type = types.FloatType) # self.add_parameter('delay_length_ele_p1', # flags = Instrument.FLAG_GETSET, # units = 'm', # minval = -1e9, # maxval = 1e9, # type = types.FloatType) self.add_parameter('delay_time_p2', flags=Instrument.FLAG_GETSET, units='s', minval=-3.336, maxval=3.336, type=types.FloatType) # self.add_parameter('delay_length_mech_p2', # flags = Instrument.FLAG_GETSET, # units = 'm', # minval = -3.4e38, # maxval = 3.4e38, # type = types.FloatType) # self.add_parameter('delay_length_ele_p2', # flags = Instrument.FLAG_GETSET, # units = 'm', # minval = -1e9, # maxval = 1e9, # type = types.FloatType) self.add_function('get_all') self.add_function('reset') if reset: self.reset()
def __init__(self, VISA_address="GPIB1::18::INSTR"): self.io = visa.ResourceManager().open_resource(VISA_address)
import visa import struct import math import time import Keithley_Model_2380_VISA_Driver as kei2380 #===== MAIN PROGRAM STARTS HERE ===== rm = visa.ResourceManager( ) # Opens the resource manager and sets it to variabl Inst_1 = "GPIB0::6::INSTR" # Instrument ID String examples... # LAN -> TCPIP0::134.63.71.209::inst0::INSTR # USB -> USB0::0x05E6::0x2450::01419962::INSTR # GPIB -> GPIB0::16::INSTR # Serial -> ASRL4::INSTR timeout = 20000 KEI2380 = kei2380.LOAD2380() myID = KEI2380.Connect(rm, Inst_1, timeout, 1, 1, 1) KEI2380.echoCmd = 1 t1 = time.time() #KEI2380.Set_DisplayMode(KEI2380.DisplayMode.NORMAL) KEI2380.Set_Function(KEI2380.Function.CR) KEI2380.Set_LEDTest_State(KEI2380.State.ON) KEI2380.Set_Level(150) KEI2380.Set_Range(1500.0) KEI2380.Set_HighLow(120.0, 1.9) KEI2380.Set_LEDTest_Vd(43.0) KEI2380.Set_OutputState(KEI2380.State.ON) time.sleep(5.0)
stop_asap = False import visa def copytree(src, dst, symlinks=False, ignore=None): for item in os.listdir(src): s = os.path.join(src, item) d = os.path.join(dst, item) shutil.copytree(item, d, symlinks, ignore) def copynew(source,destination): for files in source: shutil.copy(files,destination) """#################SEARCH/CONNECT#################""" # establish communication with dpo rm = visa.ResourceManager('@py') dpo = rm.open_resource('TCPIP::192.168.155.159::INSTR') dpo.timeout = 3000000 dpo.encoding = 'latin_1' print(dpo.query('*idn?')) parser = argparse.ArgumentParser(description='Run info.') parser.add_argument('--numEvents',metavar='Events', type=str,default = 500, help='numEvents (default 500)',required=True) parser.add_argument('--runNumber',metavar='runNumber', type=str,default = -1, help='runNumber (default -1)',required=False) parser.add_argument('--sampleRate',metavar='sampleRate', type=str,default = 20, help='Sampling rate (default 20)',required=True) parser.add_argument('--horizontalWindow',metavar='horizontalWindow', type=str,default = 125, help='horizontal Window (default 125)',required=True) # parser.add_argument('--numPoints',metavar='Points', type=str,default = 500, help='numPoints (default 500)',required=True) parser.add_argument('--trigCh',metavar='trigCh', type=str, default='AUX',help='trigger Channel (default Aux (-0.1V))',required=False) parser.add_argument('--trig',metavar='trig', type=float, default= -0.05, help='trigger value in V (default Aux (-0.05V))',required=False) parser.add_argument('--trigSlope',metavar='trigSlope', type=str, default= 'NEGative', help='trigger slope; positive(rise) or negative(fall)',required=False)
def __init__(self, name, address, channel_index=1): ''' Initializes Input: name (string) : name of the instrument address (string) : GPIB address ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.ResourceManager().open_resource( self._address) # no term_chars for GPIB!!!!! self._zerospan = False self._freqpoints = 0 self._ci = channel_index self._start = 0 self._stop = 0 self._nop = 0 # Implement parameters #Sweep self.add_parameter('sweep_mode', type=str, flags=Instrument.FLAG_GETSET) self.add_parameter('nop', type=int, flags=Instrument.FLAG_GETSET, minval=1, maxval=100000, tags=['sweep']) ########### self.add_parameter('bandwidth', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=1e9, units='Hz', tags=['sweep']) #Averaging self.add_parameter('average_mode', type=str, flags=Instrument.FLAG_GETSET) self.add_parameter('averages', type=int, flags=Instrument.FLAG_GETSET, minval=1, maxval=1024, tags=['sweep']) self.add_parameter('average', type=bool, flags=Instrument.FLAG_GETSET) ########## self.add_parameter('frequency', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('centerfreq', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('startfreq', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('stopfreq', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('span', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('power', type=float, flags=Instrument.FLAG_GETSET, minval=-95, maxval=30, units='dBm', tags=['sweep']) self.add_parameter('zerospan', type=bool, flags=Instrument.FLAG_GETSET) self.add_parameter('channel_index', type=int, flags=Instrument.FLAG_GETSET) #Triggering Stuff self.add_parameter('trigger_source', type=str, flags=Instrument.FLAG_GETSET) self.add_parameter('timeout', type=int, flags=Instrument.FLAG_GETSET) self.add_parameter('status', type=bool, flags=Instrument.FLAG_GETSET) # sets the S21 setting in the PNA X #Do it in your script please!! #self.define_S21() #self.set_S21() # Implement functions self.add_function('get_freqpoints') self.add_function('get_tracedata') self.add_function('get_data') self.add_function('init') #self.add_function('set_S21') self.add_function('set_xlim') self.add_function('get_xlim') self.add_function('get_sweep_time') self.add_function('ask') self.add_function('write') #self.add_function('set_trigger_source') #self.add_function('get_trigger_source') #self.add_function('avg_clear') #self.add_function('avg_status') #self._oldspan = self.get_span() #self._oldnop = self.get_nop() #if self._oldspan==0.002: # self.set_zerospan(True) self.clear() self.select_measurement(1) self.get_all()
import visa import numpy as np import pylab from struct import unpack rm = visa.ResourceManager(r'C:\WINDOWS\system32\visa32.dll') print(rm.list_resources()) inst = rm.open_resource('USB0::0x0699::0x0368::C027917::INSTR') print(inst.query("*IDN?")) inst.write('Data:SOU CH1') inst.write('DATA:WIDTH 1') inst.write('DATA:ENC RPB') ymult = float(inst.ask('WFMPRE:YMULT?')) yzero = float(inst.ask('WFMPRE:YZERO?')) yoff = float(inst.ask('WFMPRE:YOFF?')) xincr = float(inst.ask('WFMPRE:XINCR?')) inst.write('CURVE?') data = inst.read_raw() headerlen = 2 + int(data[1]) header = data[:headerlen] ADC_wave = data[headerlen:-1] ADC_wave = np.array(unpack('%sB' % len(ADC_wave), ADC_wave)) Volts = (ADC_wave - yoff) * ymult + yzero Time = np.arrange(0, xincr * len(Volts), xincr) pylab.plot(Time, Volts) pylab.show()
def __init__(self, gpib_address=1): self.device = visa.ResourceManager().open_resource('GPIB0::%d::INSTR' % gpib_address) self.device.write('OUTP ON')
def __init__(self, visaaddr='GPIB0::3::INSTR'): rm = visa.ResourceManager() self.inst = rm.get_instrument(visaaddr)
# typically beeps after an error has occured. import visa import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import time mpl.style.use('ggplot') #%% # This section of the code cycles through all USB connected devices to the computer. # The code figures out the USB port number for each instrument. # The port number for each instrument is stored in a variable named “instrument_id” # If the instrument is turned off or if you are trying to connect to the # keyboard or mouse, you will get a message that you cannot connect on that port. device_manager = visa.ResourceManager() devices = device_manager.list_resources() number_of_device = len(devices) power_supply_id = -1; waveform_generator_id = -1; digital_multimeter_id = -1; oscilloscope_id = -1; # assumes only the DC power supply is connected for i in range (0, number_of_device): # check that it is actually the power supply try: device_temp = device_manager.open_resource(devices[i]) print("Instrument connect on USB port number [" + str(i) + "] is " + device_temp.query("*IDN?"))
def open(self): self.rm = visa.ResourceManager('@py') self.inst = self.rm.open_resource(self.resource) print('Connected to: ', self.inst.ask('*idn?').rstrip()) self.inst.write('*rst') #default the instrument
__author__ = "Vincent Musso" from sys import stdout import os import visa import SG_errors import SG_commands import logging rm = visa.ResourceManager(r"C:\Windows\System32\visa64.dll") #sg = rm.open_resource('GPIB0::27::INSTR') # Max input voltage = ~0.5 V # RF output max for Type-N port is 16 dBm # Front BNC max output is 13 dBm """ Ended up using "logging" instead class CommandError(Exception): def __init__(self, message): super(CommandError, self).__init__(message) """ class SG_Control(): err_dict = SG_errors.err_dict() """ Currently only load in one category of commands, sig_synth_commands(), for testing purposes. Define a variable for SG_commands.mod_commands() for access to more commands. See SG_commands.py for a list of the command codes, and see the SRS manual for the command descriptions. """ commands = SG_commands.sig_synth_commands()
def readinst(self): address = self.ui.testinst.text() io = visa.ResourceManager().open_resource(address) with self.reserved_access_to_instr: answer = io.read_raw() self.ui.testanswer.setPlainText(answer)
'--bin', action="store_true", help='use binary data transfer instead of the default ASCII') parser.add_argument( '--py', action="store_true", help='use PyVISA-py (by default the system visa library is used)') args = parser.parse_args() ############################################################################### # connect to the instrument ############################################################################### import visa rm = visa.ResourceManager('@py' if args.py else '') #rm.list_resources() rp = rm.open_resource('TCPIP::{}::{}::SOCKET'.format(args.adr, args.port), read_termination='\r\n') ############################################################################### # SCPI exchange ############################################################################### buffer_size = 2**14 # set output amplitude and offset rp.write(":SOURce1:VOLTage:IMMediate:AMPlitude 1") rp.write(":SOURce1:VOLTage:IMMediate:OFFSet 0") # specify peridic mode, sinusoidal waveform
def initiate_and_read_data(self): try: self.inst = visa.ResourceManager().open_resource( self.address, read_termination='\n') #initiate or trigger self.inst.write("INITiate1") #wait for completing operation self.inst.write("*OPC?") while True: try: self.inst.read() break except: pass #---- read data ---- #x axis data_str = self.inst.query("CALCulate1:X?").split(",") X_axis = list(map(float, data_str)) #select measurement self.inst.write("CALCulate1:PARameter:SELect '1'") #set format self.inst.write("FORMat ASCII") #read data data_str = self.inst.query("CALCulate1:DATA? FDATA").split(",") S21_real = list(map(float, data_str)) #select measurement self.inst.write("CALCulate1:PARameter:SELect '2'") #set format self.inst.write("FORMat ASCII") #read data data_str = self.inst.query("CALCulate1:DATA? FDATA").split(",") S21_imag = list(map(float, data_str)) #select measurement self.inst.write("CALCulate1:PARameter:SELect '3'") #set format self.inst.write("FORMat ASCII") #read data data_str = self.inst.query("CALCulate1:DATA? FDATA").split(",") S21_R = list(map(float, data_str)) #select measurement self.inst.write("CALCulate1:PARameter:SELect '4'") #set format self.inst.write("FORMat ASCII") #read data data_str = self.inst.query("CALCulate1:DATA? FDATA").split(",") S21_phase = list(map(float, data_str)) #convert unit if sweepType = LINear frequence sweepType = self.inst.query("SENSe:SWEep:TYPE?") if (sweepType == "LIN"): X_axis = list(map(lambda freq: freq / 10**9, X_axis)) #convert Hz to GHz return [X_axis, S21_real, S21_imag, S21_R, S21_phase, "No error"] except: return [[float("NAN")]] * 5 + [[ "Error:N5244A:initiate_and_read_data" ]]
def __init__(self, host, port, recvTimeout=20): self.logger = logging.getLogger('RamaLogger') self.host = host self.port = port self.session = visa.ResourceManager('@py') self.Connect()
def __init__(self, visa_name): self.rm = visa.ResourceManager() self.pyvisa = self.rm.open_resource(visa_name) self.pyvisa.timeout = 5000 # Set response timeout (in milliseconds)
def __init__(self, VISA_address="GPIB::17"): self.io = visa.ResourceManager().open_resource(VISA_address) #The OUTX command sets the output interface to RS232 (i=0) or GPIB (i=1) if VISA_address.count("GPIB"): self.io.write("OUTX 1") print self.io.query("*IDN?") self.sensitivity_dict = { '2 nV/fA': 0, '50 μV/pA': 13, '5 nV/fA': 1, '100 μV/pA': 14, '10 nV/fA': 2, '200 μV/pA': 15, '20 nV/fA': 3, '500 μV/pA': 16, '50 nV/fA': 4, '1 mV/nA': 17, '100 nV/fA': 5, '2 mV/nA': 18, '200 nV/fA': 6, '5 mV/nA': 19, '500 nV/fA': 7, '10 mV/nA': 20, '1 μV/pA': 8, '20 mV/nA': 21, '2 μV/pA': 9, '50 mV/nA': 22, '5 μV/pA': 10, '100 mV/nA': 23, '10 μV/pA': 11, '200 mV/nA': 24, '20 μV/pA': 12, '500 mV/nA': 25, '1 V/μA': 26 } sens_list_utf8 = [ '2 nV/fA', '5 nV/fA', '10 nV/fA', '20 nV/fA', '50 nV/fA', '100 nV/fA', '200 nV/fA', '500 nV/fA', '1 μV/pA', '2 μV/pA', '5 μV/pA', '10 μV/pA', '20 μV/pA', '50 μV/pA', '100 μV/pA', '200 μV/pA', '500 μV/pA', '1 mV/nA', '2 mV/nA', '5 mV/nA', '10 mV/nA', '20 mV/nA', '50 mV/nA', '100 mV/nA', '200 mV/nA', '500 mV/nA', '1 V/μA' ] self.sens_list_num = [ 2e-9, 5e-9, 10e-9, 20e-9, 50e-9, 100e-9, 200e-9, 500e-9, 1e-6, 2e-6, 5e-6, 10e-6, 20e-6, 50e-6, 100e-6, 200e-6, 500e-6, 1e-3, 2e-3, 5e-3, 10e-3, 20e-3, 50e-3, 0.1, 0.2, 0.5, 1 ] #the encoding of the python script file is utf8 but the Qt interface is unicode, so conversion is needed self.sensitivity = [] for txt in sens_list_utf8: self.sensitivity.append(unicode(txt, encoding='utf-8')) #time constant time_cste_list_utf8 = [ '10 μs', '30 μs', '100 μs', '300 μs', '1 ms', '3 ms', '10 ms', '30 ms', '100 ms', '300 ms', '1 s', '3 s', '10 s', '30 s', '100 s', '300 s', '1 ks', '3 ks', '10 ks', '30 ks' ] self.time_cste = [] for txt in time_cste_list_utf8: self.time_cste.append(unicode(txt, encoding='utf-8')) #filter slop self.filter_slop = map( unicode, ['6 dB/oct', '12 dB/oct', '18 dB/oct', '24 dB/oct'])
def __init__(self, name, address, reset=False, max_cw_pwr=-5): ''' Initializes the RS_SGS100A, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values, default=false Output: None ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical', 'source']) self._address = address # if address[:5] == 'TCPIP': # self._visainstrument = SocketVisa(self._address[8:], 5025) # else: rm = visa.ResourceManager() self._visainstrument = rm.open_resource(address, timeout=60000, read_termination='\n', write_termination='\n') self.add_parameter( 'frequency', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=1e9, maxval=20e9, units='Hz', # format='%.12e', tags=['sweep']) self.add_parameter('phase', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, minval=0, maxval=360, units='DEG', format='%.01e', tags=['sweep']) self.add_parameter('power', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, minval=-120, maxval=20, units='dBm', tags=['sweep']) self.add_parameter('status', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_parameter('pulm', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_parameter('iq', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) # self.add_parameter( # 'pulsemod_source', type=types.StringType, # flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_parameter('sweep_frequency_start', type=types.FloatType, flags=Instrument.FLAG_SET, minval=9e3, maxval=40e9, units='Hz', format='%.04e', tags=['sweep']) self.add_parameter('sweep_frequency_stop', type=types.FloatType, flags=Instrument.FLAG_SET, minval=9e3, maxval=40e9, units='Hz', format='%.04e', tags=['sweep']) self.add_parameter('sweep_frequency_step', type=types.FloatType, flags=Instrument.FLAG_SET, minval=1, maxval=1e9, units='Hz', format='%.04e', tags=['sweep']) self.add_parameter('max_cw_pwr', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=-30, maxval=30, units='dBm') # can be different from device to device, set by argument self.set_max_cw_pwr(max_cw_pwr) self.add_function('reset') self.add_function('get_all') self.add_function('get_errors') self.add_function('get_error_queue_length') if reset: self.reset() else: self.get_all()
def __init__(self, visa_backends='@ni'): self.__drivers = [] self.__instr = {} self.rm = visa.ResourceManager(visa_backends)
def listResources(self): rm = visa.ResourceManager() return rm.list_resources()
def __init__(self, verbose=False): self._verbose = verbose self._rigol = None self._resource_manager = visa.ResourceManager()
#ID-VG Leakage disconnecting source import xdrlib, sys import xlrd from xlwt import Workbook from xlrd import xldate_as_tuple import visa wb = Workbook() sheet1 = wb.add_sheet('Sheet 1') visa_dll = 'c:/windows/system32/visa32.dll' gpib_addr1 = 'GPIB0::9::INSTR' gpib_addr2 = 'GPIB0::22::INSTR' rm = visa.ResourceManager(visa_dll) gpib_inst1 = rm.open_resource(gpib_addr1) #PS gpib_inst2 = rm.open_resource(gpib_addr2) #DMM m = 1 n = 1 gpib_inst1.timeout = 5000 gpib_inst2.timeout = 5000 gpib_inst1.write('INST:SEL OUT1') gpib_inst1.write('VOLT 0') gpib_inst1.write('INST:SEL OUT2') gpib_inst1.write('VOLT 0') #1. Set VG starting value gpib_inst1.write('VOLT:STEP 0.1') #2. Set VG changing interval #gpib_inst2.write('CURRent:DC:NPLC 100') while n <= 52: #3. Set VG ending value gpib_inst1.write('INST:SEL OUT2') print("VG=" + gpib_inst1.query('VOLT?')) #print("ID=" + gpib_inst2.query('MEASure:CURRent:DC?')) sheet1.write(n, 1, float(gpib_inst1.query('VOLT?')))
import visa print(visa.ResourceManager().list_resources())
"There was a problem converting the voltage parameter. \nMaybe you made a mistake?" ) sys.exit() try: name = str(sys.argv[2]) except: print( "There was a problem converting provided name to string. \nMaybe you made a mistake?" ) sys.exit() # ------------------------- mid = prefix + name print('---------------------------------------------') rm = visa.ResourceManager('C:\Windows\System32\\visa32.dll') inst = rm.open_resource('GPIB0::17::INSTR') inst.write("F0,0X") # Source V, measure I, DC inst.write("H0X") # Immediate trigger # Output format (source+measure, no prefix or suffix, one line of DC data per talk) inst.write("G5,2,0X") inst.write("B" + str(voltage) + ",0,0X") # Bias current , auto range, no delay inst.write("N1X") # Operate filename = folder + mid.replace(':', '.') fallback_filename = fallback_folder + mid.replace(':', '.') with open(filename + ".txt", "w") as myfile: myfile.write("t [s] \t\t\t U [V] \t\t\t I[A]\n")
def write2inst(self): address = self.ui.testinst.text() io = visa.ResourceManager().open_resource(address) command = self.ui.testcommand.text() with self.reserved_access_to_instr: io.write(command)
com_port = 'COM10' ser = serial.Serial(port=com_port, baudrate=19200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) time.sleep(0.1) ser.write(b'test_pga\n') # for i in range(10): # print(ord(ser.read())) ser.close() ### Scratch: Connecting to the PSU via GPI ### if False: psu_name = 'USB0::0x0957::0x2C07::MY57801384::0::INSTR' rm = visa.ResourceManager() psu = rm.open_resource(psu_name) psu.query("*IDN?") psu.write('OUTPUT2:LOAD INF') psu.write('SOURCE2:FUNCTION DC') psu.write('OUTPUT2 ON') psu.close() ### PGA variance measurement ### if False: vin = 0.5 gain_bits = [0, 0] iterations = 500 vout = test_pga_variance(gain_bits, iterations, vin) # Plot Vout vs. iteration to see if there are any settling
def __init__(self,LockIn_port): self.rm = visa.ResourceManager() self.instrument = self.rm.open_resource(LockIn_port, read_termination = '\r\n') self.aidmap = {'x':2, 'y':3}