def get_instrument(self, name, param_type=None): """Return an instrument instance name : the name of the instrument name can be - a number (item in the list of detected instrument) - a string representing the visa resource name or id param_type : 'number', 'resource_name', 'resource_id' if None, try to automatically detect the param_type """ if param_type is None: if type(name) is int: param_type = 'number' else: if name.find('::')>=0: param_type = "resource_name" else: param_type = "resource_id" if param_type=='number': return visa.instrument(self.resource_names[name]) elif param_type=='resource_name': return visa.instrument(name) else: return visa.instrument(self.resource_names[self.resource_ids.index(name)])
def _find_connection(self): """Find the appropriate GPIB connection """ instrument_list = [] print visa.get_instruments_list() for instrument in visa.get_instruments_list(): if instrument.startswith("GPIB"): temp_conn = visa.instrument(instrument) try: response = temp_conn.ask("*IDN?") except VisaIOError: # Need to release connection somehow! print "Cannot connect with %s" % instrument temp_conn.write("GTL") raise if response.startswith("*IDN LE"): instrument_list.append(instrument) if len(instrument_list)==0: raise ScopeException("Cannot find LeCroy684 GPIB") elif len(instrument_list)==1: return visa.instrument(instrument_list[0]) else: print "Select instrument:" for i, instrument in enumerate(instrument_list): temp_conn = visa.instrument(instrument) print "\t%s:\t%s" % (i, temp_conn.ask("*IDN?")) number = raw_input("Make selection [number]: ") return visa_instrument(instrument_list[number])
def WriteVToKeithley(self, voltage): """Sets the Keithley to a specified voltage and returns a single reading""" try: wx.Sleep(0.2) visa.instrument("GPIB::22").write("SOUR:VOLT " + str(voltage)) wx.Sleep(0.2) return visa.instrument("GPIB::22").ask("READ?") except: self.errorMessage("An error talking to the keithley has occurred")
def OnButton1Button(self, event): [vStart, vStop, numSteps] = [self.VoltStart.GetValue(), self.VoltStop.GetValue(), self.numSteps.GetValue()] vList = self.MakeVList(vStart, vStop, numSteps) self.outFile = [] self.IntializeKeithley() for index, v in enumerate(vList): self.outFile.append([index, self.WriteVToKeithley(v)]) visa.instrument("GPIB::22").write("CURR:RANG:AUTO ON") self.errorMessage("Done!") self.WriteVToKeithley(0)
def connect(self): if (self.communicationProtocol is 'serial') or (self.communicationProtocol is 'usb'): if self.instrumentAddress is not None: #if user specified instrument address, try connecting to it try: self.handle = visa.instrument(self.instrumentAddress) #set termination characters so instrument knows when to stop listening and execute a command self.handle.term_chars = self.terminationCharacters if self.get_id() == self.id: print '%s connected to %s.' % (self.name, self.instrumentAddress) else: #wrong instrument raise Exception('The instrument you are attempting to connect to does not match its corresponding object class') self.disconnect() except: print 'Could not connect to %s.' % self.instrumentAddress else: #if user did not specify instrument address, try connecting to all available addresses for instrumentAddress in INSTRUMENT_ADDRESSES: if self.instrumentAddress is None: try: self.handle = visa.instrument(instrumentAddress) #set termination characters so instrument knows when to stop listening and execute a command self.handle.term_chars = self.terminationCharacters if self.get_id() == self.id: print '%s connected to %s.' % (self.name, instrumentAddress) self.instrumentAddress = instrumentAddress break else: #wrong instrument self.disconnect() except: pass elif self.communicationProtocol is 'ethernet': #check if device can connect via ethernet if self.ipAddress is None: print 'Error. This instrument has not been configured to connect via ethernet. Please specify the instrument\'s IP address in its corresponding JSON file.' else: try: self.handle = visa.instrument(self.ipAddress) #set termination characters so instrument knows when to stop listening and execute a command self.handle.term_chars = self.terminationCharacters if self.get_id() == self.id: print '%s connected to %s.' % (self.name, self.ipAddress) else: #wrong instrument raise Exception('The instrument you are attempting to connect to does not match its corresponding object class') self.disconnect() except: print 'Could not connect to %s.' % ipAddress
def detect(self): try: from visa import get_instruments_list, instrument except: return [] devlist = get_instruments_list() retval = [] for handle in devlist: if (handle.find("GPIB") != -1): instr = instrument(handle) version = instr.ask("*IDN?") if (version.find("ESP300") != -1 ): for ax in range(1,4): # motion controller - probe axes #print "probe axis #%d" % (ax) try: print "probe ESP axis ", ax ID = instr.ask(str(ax) + " ID?") err = int(instr.ask("TE?")) print " ..returns ", ID, " and error ", err if(ID != "Unknown" and err == 0): retval.append([handle,"Ax:"+str(ax)+" "+version,ax]) except: print "exception" return retval
def __init__(self, resource, *args, **kwargs): if type(resource) is str: self.instrument = visa.instrument(resource, *args, **kwargs) else: self.instrument = resource self.buffer = io.BytesIO()
def __init__(self, GPIB): # Set Address self.pulse = visa.instrument("GPIB::%s"%GPIB) # Select Channel A and turn output off self.pulse.write("CHA") self.pulse.write("D1")
def getfra(channel): try: fra = visa.instrument('GPIB::' + str(channel)) print('FRA ready on gpib channel ' + str(channel)) return fra except: print('FRA not found on gpib channel ' + str(channel))
def detect(self): try: from visa import get_instruments_list, instrument, no_parity except: return [] devlist = get_instruments_list() retval = [] for handle in devlist: if (handle.find("COM") != -1): try: instr = instrument(handle, baud_rate=921600, data_bits=8, stop_bits=1, parity=no_parity, timeout = 0.1, term_chars = "\r\n") version = instr.ask("VE") except: version = "" if (version.find("AG-UC8") != -1 ): for ax in range(1,5): # motion controller - probe axes try: print "probe AG-UC8 axis ", ax ID = instr.ask(str(ax) + " TS")[3:] err = int(instr.ask("TE")[-1]) print ID if(ID != "" and err == 0): retval.append([handle,"Ax:"+str(ax)+" "+version,ax]) else: print "Error "+err except: print "exception" return retval
def __init__(self, name, address): ''' Initializes the LeCroy 44Xi. Input: name (string) : name of the instrument address (string) : VICP address Output: None ''' logging.debug(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) self._values = {} # Add parameters self.add_parameter('timebase', type=types.FloatType, flags=Instrument.FLAG_GETSET) self.add_parameter('vertical', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 4), channel_prefix='ch%d_') self.add_parameter('msize', type=types.FloatType, flags=Instrument.FLAG_GETSET) # Make Load/Delete Waveform functions for each channel for ch in range(1, 5): self._add_save_data_func(ch) self.get_all()
def __init__(self, *args, **kwds): """ args are logical_name, address, simulate """ super(VisaDriver, self).__init__(*args) self.visa_instr = visa.instrument(self.address,**kwds)
def __init__(self): self.PicoVisa = visa.instrument("GPIB0::20::INSTR",delay=0.04) self.PicoVisa.write("HDR0") self.PicoVisa.write("ARN 1") self.PicoVisa.write("REM 1") self.TCSVisa = VisaSubs.InitializeSerial("ASRL5",idn="ID?",term_chars="\\n") address = ('localhost',18871) self.Server = SocketUtils.SockServer(address) self.ResThermometer = 1 self.Temperature = 0.0 self.PicoChannel = 0 self.PicoRange = 0 self.SetTemp = -1 self.Status = -1 self.TCSHeater = [0,0,0] self.TCSRange = [1,1,1] self.TCSCurrent = [0,0,0] self.ConstCurrent = False self.CurrentConst = 0 self.DeltaTemp = 0 self.MaxTemp = 5000 self.MaxCurrent = 25000 self.ErrorTemp = 10 # The acceptable error in temperature self.ErrorDeltaTemp = 10 # The acceptable stability self.Sweep = False self.SweepStart = 0 self.SweepFinish = 0 self.SweepRate = 0 # rate in mK/s self.SweepTime = 0 self.SweepDirection = 1.0 return
def __init__(self, name, address, reset=False): ''' Input: name (string) : name of the instrument address (string) : GPIB address ''' logging.info(__name__ + ' : Initializing instrument JDSU_SWS15101') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='mW', minval=0, maxval=10, type=types.FloatType) self.add_parameter('diode_current', flags=Instrument.FLAG_GETSET, units='mA', minval=0, maxval=150, type=types.FloatType) self.add_parameter('wavelength', flags=Instrument.FLAG_GETSET, units='nm', minval=1460, maxval=1600, type=types.FloatType) self.add_parameter('output_status', flags=Instrument.FLAG_GETSET, type=types.BooleanType) self.add_parameter('FSCWaveL', flags=Instrument.FLAG_SET, units='pm', minval=-22.4, maxval=+22.4, type=types.FloatType) self.add_function ('get_all')
def __init__(self, name, address, reset=False): ''' Initializes the Agilent_E8257D, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values, default=False ''' logging.info(__name__ + ' : Initializing instrument Agilent_E8257D') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='dBm', minval=-135, maxval=16, type=types.FloatType) self.add_parameter('phase', flags=Instrument.FLAG_GETSET, units='rad', minval=-numpy.pi, maxval=numpy.pi, type=types.FloatType) self.add_parameter('frequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=1e5, maxval=20e9, type=types.FloatType) self.add_parameter('status', flags=Instrument.FLAG_GETSET, type=types.StringType) self.add_parameter('ALC', flags=Instrument.FLAG_GETSET, type=types.StringType) self.add_function('reset') self.add_function ('get_all') if (reset): self.reset() else: self.get_all()
def laserScan2D(width, height, delta, peakArea, fileName): # Scans an area with given width and height at a # step rate of delta. peakArea is int value for # the location of peak with a scale from 0 to 10,000 startTime = time.clock() h = 0 w = 0 n = 0 m = 0 x = np.arange(0, width + delta, delta) y = np.arange(0, height + delta, delta) Y, X = np.meshgrid(y, x) tValues = np.zeros((np.size(x), np.size(y))) vValues = np.zeros((np.size(x), np.size(y))) # set up scope scanRange = 1000 scope = vi.instrument("TCPIP::138.67.12.235::INSTR") sRead.setParam(scope, peakArea - scanRange, peakArea + scanRange) # get motor and zero location motor = mC.setupMotor() while w <= width: h = 0 m = 0 while h <= height: mC.moveTo(motor, w, h) time.sleep(0.5) x, y = sRead.getData(scope, peakArea - scanRange, peakArea + scanRange) t, v = findPeak(x, y) tValues[n, m] = t vValues[n, m] = v h = h + delta m = m + 1 w = w + delta n = n + 1 # Estimates Time Left timeLeft = (width - w) / w * (time.clock() - startTime) / 60 print "Est. Time Left " + np.str(timeLeft) + "min" mC.moveTo(motor, 0, 0) # Contour Plot of Time makePlot2D(X, Y, tValues, fileName + " Time") # Contour Plot of Voltage makePlot2D(X, Y, vValues, fileName + " Voltage") # File Output np.savez(fileName + ".npz", X=X, Y=Y, tValues=tValues, vValues=vValues) # Time Taken Calc timeTaken = (time.clock() - startTime) / 60 # in min print "Time Taken " + np.str(timeTaken) motor.close() scope.close() return timeTaken, tValues
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address) self.add_parameter('identification', flags=Instrument.FLAG_GET) self.add_parameter('power', flags=Instrument.FLAG_GET, type=types.FloatType, units='W') self.add_parameter('head_info', flags=Instrument.FLAG_GET, type=types.StringType) self.add_parameter('wavelength', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='m') if reset: self.reset() else: self.get_all()
def refreshDevices(self): """Refresh the list of known devices on this bus. Currently supported are GPIB devices and GPIB over USB. """ try: addresses = visa.get_instruments_list() additions = set(addresses) - set(self.devices.keys()) deletions = set(self.devices.keys()) - set(addresses) for addr in additions: try: if addr.startswith('GPIB'): instName = addr elif addr.startswith('USB'): instName = addr + '::INSTR' else: continue instr = visa.instrument(instName, timeout=self.defaultTimeout['s']) self.devices[addr] = instr self.sendDeviceMessage('GPIB Device Connect', addr) except Exception, e: print 'Failed to add ' + addr + ':' + str(e) for addr in deletions: del self.devices[addr] self.sendDeviceMessage('GPIB Device Disconnect', addr)
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address) self.add_parameter('identification', flags=Instrument.FLAG_GET) self.add_parameter('internal_temperature', flags=Instrument.FLAG_GET, type=types.FloatType, units='deg C') self.add_parameter('probe1_temperature', flags=Instrument.FLAG_GET, type=types.FloatType, units='deg C') self.add_parameter('probe2_temperature', flags=Instrument.FLAG_GET, type=types.FloatType, units='deg C') self.add_parameter('humidity', flags=Instrument.FLAG_GET, type=types.FloatType, units='percent') if reset: self.reset() else: self.get_all()
def get830(): try: sr830 = visa.instrument('GPIB::' + str(sr830ch)) print('SR830 ready on gpib channel ' + str(sr830ch)) return sr830 except: print('SR830 not found on gpib channel ' + str(sr830ch))
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address) self._channels = ('A', 'B', 'C', 'D') self.add_parameter('identification', flags=Instrument.FLAG_GET) self.add_parameter('kelvin', flags=Instrument.FLAG_GET, type=types.FloatType, channels=self._channels, units='K') self.add_parameter('sensor', flags=Instrument.FLAG_GET, type=types.FloatType, channels=self._channels, units='') self.add_parameter('heater_range', flags=Instrument.FLAG_GETSET, type=types.IntType, format_map={ 1: '25 W', 2: '2.5 W', 3: '250 mW', 4: '25 mW', 5: '2.5 mW', }) self.add_parameter('heater_output', flags=Instrument.FLAG_GET, type=types.FloatType, units='%') self.add_parameter('mode', flags=Instrument.FLAG_GETSET, type=types.IntType, format_map={1: 'Local', 2: 'Remote', 3: 'Remote, local lock'}) self.add_parameter('pid', flags=Instrument.FLAG_GETSET, type=types.TupleType, channels=(1,4)) self.add_parameter('setpoint', flags=Instrument.FLAG_GETSET, type=types.FloatType, channels=(1,4)) self.add_function('local') self.add_function('remote') if reset: self.reset() else: self.get_all()
def _ask(self, str): try: val = self.instr.ask(str) except: self.instr = visa.instrument(self.visa_address) val = self.instr.ask(str) return val
def __init__(self, name, address): ''' Initializes the Cryocon62, and comunicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address Output: None ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('temperature', type=types.FloatType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2)) self.add_parameter('units', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2)) self.add_parameter('sensor_index', type=types.IntType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2)) self.add_parameter('vbias', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2)) self.add_parameter('channel_name', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2)) self.add_parameter('sensor_name', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1,2))
def __init__(self, name, address, reset=False): logging.info(__name__ + ' : Initializing instrument Newport ESP100') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) # Add functions self.add_function('init_default') self.add_function('define_home') self.add_function('move_1000mu_p') self.add_function('move_0100mu_p') self.add_function('move_0010mu_p') self.add_function('move_0001mu_p') self.add_function('move_1000mu_n') self.add_function('move_0100mu_n') self.add_function('move_0010mu_n') self.add_function('move_0001mu_n') # Add parameters self.add_parameter('position',tags=['sweep'], flags=Instrument.FLAG_GETSET, units='mm', minval=-300, maxval=300, type=types.FloatType) self.add_parameter('ismoving', flags=Instrument.FLAG_GET, type=types.StringType) #self.init_default() if reset: self.init_default()
def __init__(self,VISA_address="GPIB1::12"): self.io = visa.instrument(VISA_address) print self.query_unit_Id() #the encoding of the python script file is utf8 but the Qt interface is unicode, so conversion is needed self.channels_names=[] for txt in ['A','B','C','D']: self.channels_names.append(unicode(txt,encoding='utf-8'))
def signal_analyzer_init(): signal_analyzer = visa.instrument(SIGNAL_ANALYZER_ADDR) signal_analyzer_preset(signal_analyzer) signal_analyzer.write('UNIT:POW DBM') signal_analyzer.write('INIT:CONT 0') return signal_analyzer
def __init__(self): resource_names = [] find_list, return_counter, instrument_description = \ vpp43.find_resources(visa.resource_manager.session, "?*") resource_names.append(instrument_description) for i in range(return_counter - 1): resource_names.append(vpp43.find_next(find_list)) # print "\nVisa resources found:" # for a in range(len(resource_names)): # print a, resource_names[a] # print "Attempting to Identify Instruments. Please Wait..." resource_ids = [] for a in range(len(resource_names)): interface_type, _ = \ vpp43.parse_resource(visa.resource_manager.session, resource_names[a]) if interface_type == visa.VI_INTF_ASRL: resource_ids.append("RS232 not Supported") else: try: tempscope = visa.instrument(resource_names[a], timeout = 10) scopename = tempscope.ask("*IDN?") scopename = scopename.split(',') resource_ids.append(scopename[0] + '-' + scopename[1] + \ ' ' + scopename[2]) except visa.VisaIOError: resource_ids.append(" No Instrument Found ") except: resource_ids.append(" Error Communicating with this device") self.resource_names = resource_names self.resource_ids = resource_ids
def get830(): try: global sr830 sr830 = visa.instrument('GPIB::' + str(sr830ch)) return True except: return False
def _connect_serial(self, device): import visa instr=visa.instrument('ASRL11::INSTR') instr.term_chars='\n' instr.chunk_size=4096 instr.timeout=1.0 self.instr = instr
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address, baud_rate=9600, data_bits=8, stop_bits=1, parity=visa.no_parity, term_chars='\r\n')
def __init__(self, logID): if logID == 'labalyzer': self.logger = logging.getLogger('labalyzer') elif logID == 'starkalyzer': self.logger = logging.getLogger('starkalyzer') try: import visa #pylint: disable=F0401 # try-clause self.__pulse = visa.instrument('TCPIP0::10.0.0.3::gpib0,15::INSTR', timeout=1) self.logger.warn("SRS pulse generator loaded") except: self.logger.warn( "can't load visa driver for SRS Pulse generator, using simulator" ) self.__pulse = SRSPulseSimulator()
def __init__(self, name, address, reset=False): ''' Initializes the Newfocus Laser. Input: name (string) : name of the instrument address (string) : GPIB address Output: None ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address)
def __init__(self, resource): self.instrument = visa.instrument(resource, term_chars='\n', timeout=0.1) time.sleep(2) try: idn_response = self.instrument.ask('*IDN?') except: self.instrument.close() raise #Exception("Could not interrogate device.") if idn_response != 'OIC,Embedded SCPI Example,1,10': self.instrument.close() raise Exception("Incorrect IDN response.")
def __init__(self, name, address, type, reset=False, freq=1e6, pow=None): ''' Initializes the HP_8657A/B, and communicates with the wrapper. This instrument does not support GPIB talking, so 'get' functions are not available. Only use with reset=True, otherwise warning will be given. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values, default=False freq (float) : initial frequency in Hz, default=1e9 pow (float) : initial power in dBm, default=-143.4 ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) lim = HP_8657.LIMITS[type] self._address = address self._visainstrument = visa.instrument(self._address) sleep(1) # Implement parameters self.add_parameter('frequency', type=types.FloatType, flags=Instrument.FLAG_SET, minval=lim['minfreq'], maxval=lim['maxfreq'], units='Hz', format='%.04e', tags=['sweep']) self.add_parameter('power', type=types.FloatType, flags=Instrument.FLAG_SET, minval=lim['minpow'], maxval=lim['maxpow'], units='dBm', tags=['sweep']) self.add_parameter('status', type=types.StringType, flags=Instrument.FLAG_SET) # Implement functions self.add_function('reset') # (re)set device to specified values if reset: if pow is None: pow = lim['minpow'] self.reset(freq, pow) else: logging.warning('instrument does not support getting of values \ you need to run set_power and set_frequency manually!')
def __init__(self, name, address, reset=False): ''' Initializes the RS_SMR40, 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']) self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('frequency', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, minval=1e9, maxval=40e9, units='Hz', format='%.04e', tags=['sweep']) self.add_parameter('power', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, minval=-30, maxval=25, units='dBm', tags=['sweep']) self.add_parameter('status', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_function('reset') self.add_function('get_all') if reset: self.reset() else: self.get_all()
def __init__(self, name, address): ''' Initializes the Cryocon62, and comunicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address Output: None ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('temperature', type=types.FloatType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2)) self.add_parameter('units', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2)) self.add_parameter('sensor_index', type=types.IntType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2)) self.add_parameter('vbias', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2)) self.add_parameter('channel_name', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2)) self.add_parameter('sensor_name', type=types.StringType, channel_prefix='ch%d_', flags=Instrument.FLAG_GET, channels=(1, 2))
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address) self.add_parameter('identification', flags=Instrument.FLAG_GET) self.add_parameter('units', flags=Instrument.FLAG_GETSET, type=types.StringType) self.add_parameter('mode', flags=Instrument.FLAG_GETSET, format_map={'S': 'Sample', 'C': 'Continuous'}, type=types.StringType) self.add_parameter('length', flags=Instrument.FLAG_GET, type=types.FloatType) self.add_parameter('lastval', flags=Instrument.FLAG_GET, type=types.FloatType, units='cm') self.add_parameter('interval', flags=Instrument.FLAG_GETSET, type=types.IntType, minval=0, units='s') self.add_parameter('alarmlim', flags=Instrument.FLAG_GETSET, type=types.FloatType, minval=0, units='cm') self.add_function('local') self.add_function('remote') self.add_function('measure') if reset: self.reset() else: self.get_all()
def __init__(self, visa_address='GPIB0::2', ao_chan='/Dev2/ao0', co_dev='/Dev2/Ctr1', ci_dev='/Dev2/Ctr2', ci_port='/Dev2/PFI0'): self.visa_address = visa_address self.ni_task = AnalogOutSyncCount(ao_chan, co_dev, ci_dev, ci_port, ao_range=(-10.0, 10.0), duty_cycle=0.9) self.set_detuning_voltage(0.0) self.set_piezo_voltage(50.0) self.instr = visa.instrument(self.visa_address) self.instr.delay = 0.5
def __init__(self, name, address, reset=False): ''' Initializes the HP_81110A, 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 ''' Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) self._channels = self._get_number_of_channels() self.add_parameter('delay', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, channels=(1, self._channels), minval=0.0, maxval=999, units='sec',channel_prefix='ch%d_') self.add_parameter('width', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, channels=(1, self._channels), minval=-6.25e-9, maxval=999.5, units='sec',channel_prefix='ch%d_') self.add_parameter('high', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, channels=(1, self._channels), minval=-9.90, maxval=10.0, units='Volts',channel_prefix='ch%d_') self.add_parameter('low', type=types.FloatType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, channels=(1, self._channels), minval=-10.0, maxval=9.90, units='Volts',channel_prefix='ch%d_') self.add_parameter('status', type=types.StringType, channels=(1, self._channels), flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,channel_prefix='ch%d_') self.add_parameter('display', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_function('reset') self.add_function('get_all') self.add_function('set_mode_triggered') self.add_function('set_mode_continuous') if reset: self.reset() else: self.get_all()
def __init__(self, name, address, reset=False): ''' Initializes the Agilent_E8257D, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values, default=False ''' logging.info(__name__ + ' : Initializing instrument Agilent_E8257D') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='dBm', minval=-135, maxval=16, type=types.FloatType) self.add_parameter('phase', flags=Instrument.FLAG_GETSET, units='rad', minval=-numpy.pi, maxval=numpy.pi, type=types.FloatType) self.add_parameter('frequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=1e5, maxval=20e9, type=types.FloatType) self.add_parameter('status', flags=Instrument.FLAG_GETSET, type=types.StringType) self.add_function('reset') self.add_function('get_all') if (reset): self.reset() else: self.get_all()
def __init__(self, name, address, reset=False): ''' Initializes the Rigol, 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 ''' self._Ires = 0.01 logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address, timeout=2) print ' Rigol timeout set to: %s s' % self._visainstrument.timeout # add parameters self.add_parameter('channel', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_parameter('status', type=types.StringType, flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET) self.add_parameter('current', type=types.FloatType, flags=Instrument.FLAG_GETSET, units='Amps') self.add_function('reset') self.add_function('get_all') if reset: self.reset() else: self.get_all()
def __init__(self): self.Visa = visa.instrument("GPIB::27::INSTR") # start the server address = ('localhost', 18871) self.Server = SocketUtils.SockServer(address) self.Temperature = np.zeros((2, )) self.SensorName = ["Probe", "VTI"] self.SensorLocation = ["A", "B"] self.SetTemp = np.zeros((2, )) self.Status = -1 self.LoopNumber = [1, 2] self.ZoneControl = [False, False] self.LoopEnable = [False, False] self.PIDVals = np.empty((3, 3)) self.HeaterCommand = ["HTR?"] self.HeaterCurrent = np.zeros((3, )) self.DeltaTemp = np.zeros((2, )) self.MaxSetTemp = np.array([400.0, 400.0, 400.0]) # The acceptable error in temperature as a factor of the # set temperature e.g. 2.0 K x 0.005 = 0.01 K self.ErrorTemp = 0.001 # The acceptable stability as a factor of the error self.ErrorDeltaTemp = 0.001 # We maintain the VTI slightly below the probe self.DeltaProbe = 0.0 # Sweep description, temperature denotes probe temperatures self.SweepFinish = 0.0 self.SweepRate = 0. # rate in K/min self.SweepTime = 0. # in seconds self.SweepDirection = 1.0 self.SweepStartTime = [] self.SweepTimeLength = 0.0 self.SweepMaxOverTime = 60.0 # minutes # Status Parameters # Modes are 0: set, 1: sweep self.AtSet = False self.SweepMode = False self.StatusMsg = 0 # Status events, every so often we push a status to the terminal self.StatusInterval = 0.1 # minutes self.LastStatusTime = datetime.now() # Turn off ramp mode self.Visa.write("RAMP 1,0,0") return
def __init__(self, name, address, reset=False): ''' Input: name (string) : name of the instrument address (string) : GPIB address ''' logging.info(__name__ + ' : Initializing instrument JDSU_SWS15101') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='mW', minval=0, maxval=10, type=types.FloatType) self.add_parameter('diode_current', flags=Instrument.FLAG_GETSET, units='mA', minval=0, maxval=150, type=types.FloatType) self.add_parameter('wavelength', flags=Instrument.FLAG_GETSET, units='nm', minval=1460, maxval=1600, type=types.FloatType) self.add_parameter('output_status', flags=Instrument.FLAG_GETSET, type=types.BooleanType) self.add_parameter('FSCWaveL', flags=Instrument.FLAG_SET, units='pm', minval=-22.4, maxval=+22.4, type=types.FloatType) self.add_function('get_all')
def __init__(self, name, address, model = 'Anritsu'): ''' Initializes the Anritsu_MG37022, and communicates with the wrapper. 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._model = model self._visainstrument = visa.instrument(self._address) self._slope = None #set _slope to True if frequency dependent power compensation is requested sleep(1) # Implement parameters self.add_parameter('frequency', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz',tags=['sweep']) self.add_parameter('phase_offset', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=-360, maxval=360, units='deg') self.add_parameter('slope', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=100, units='dB@10GHz') self.add_parameter('power', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=-130, maxval=29, #29dBm possible, this is security JB units='dBm', tags=['sweep']) self.add_parameter('status', type=types.BooleanType, flags=Instrument.FLAG_GETSET) # Implement functions self.add_function('get_all') self.get_all() self.enable_high_power = False
def __init__(self, name, address, reset=False): ''' Initializes the Picowatt_AVS47A, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values change_display (bool) : If True (default), automatically turn off display during measurements. change_autozero (bool) : If True (default), automatically turn off autozero during measurements. Output: None ''' # Initialize wrapper functions logging.info('Initializing instrument Picowatt_AVS47A') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) # Add parameters to wrapper #self.add_parameter('range', # flags=Instrument.FLAG_GETSET, # units='', minval=0.1, maxval=1000, type=types.FloatType) # Add functions to wrapper ## self.add_function('set_mode_volt_ac') # Connect to measurement flow to detect start and stop of measurement qt.flow.connect('measurement-start', self._measurement_start_cb) qt.flow.connect('measurement-end', self._measurement_end_cb) #if reset: # self.reset() #else: # self.get_all() # self.set_defaults() self._visainstrument.write('ADC')
def _worker(self, inputQ, outputQ): #local, threadsafe instrument object created here v = visa.instrument(self.locationString, timeout=self.timeout, chunk_size=self.chunk_size, delay=self.delay, values_format=self.values_format) for func, args in iter(inputQ.get, 'STOP'): #queue processing going on here try: toCall = getattr(v, func) ret = toCall(*args) #visa function call occurs here except: ret = None if ret: #don't put None outputs into output queue outputQ.put(ret) print "queue worker closed properly" v.close() inputQ.close() outputQ.close()
def __init__(self, locationString=None, timeout=30, useQueues=False): self.locationString = locationString self.timeout = timeout self.useQueues = useQueues if self.locationString is not None: if self.useQueues: #queue mode #build the queues self.task_queue = Queue() self.done_queue = Queue() #kickoff the worker process self.p = Process(target=self._worker, args=(self.task_queue, self.done_queue)) self.p.start() else: #non-queue mode self.v = visa.instrument(self.locationString, timeout=self.timeout, chunk_size=self.chunk_size, delay=self.delay, values_format=self.values_format)
def __init__(self, name, address, reset=False): logging.info(__name__ + ' : Initializing instrument EG&G Model 5209') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) #self.init_default() # Sensitivity self._sen = 1.0 # Add functions self.add_function('init_default') self.add_function ('get_all') self.add_function ('auto_measure') self.add_function ('auto_phase') # Add parameters self.add_parameter('value', flags=Instrument.FLAG_GET, units='V', type=types.FloatType,tags=['measure']) self.add_parameter('frequency', flags=Instrument.FLAG_GET, units='mHz', type=types.FloatType) self.add_parameter('sensitivity', flags=Instrument.FLAG_GETSET, units='', minval=1, maxval=15, type=types.IntType) self.add_parameter('timeconstant', flags=Instrument.FLAG_GETSET, units='', minval=1, maxval=15, type=types.IntType) self.add_parameter('sensitivity_v', flags=Instrument.FLAG_GETSET, units='V', minval=0.0, maxval=15.0, type=types.FloatType) self.add_parameter('timeconstant_t', flags=Instrument.FLAG_GETSET, units='s', minval=0.0, maxval=15.0, type=types.FloatType) self.add_parameter('filter', flags=Instrument.FLAG_GETSET, units='', minval=0, maxval=3, type=types.IntType) if reset: self.init_default() #self.get_all() self.get_sensitivity_v()
def __init__(self, name, address, reset=False): logging.info(__name__ + ' : Initializing instrument Fluke PM5138A') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) # Add functions self.add_function('init_default') self.add_function('get_all') # Add parameters self.add_parameter('frequency', flags=Instrument.FLAG_GETSET, units='Hz', minval=0, maxval=16000, type=types.FloatType) self.add_parameter('ac_amplitude', flags=Instrument.FLAG_GETSET, units='V', minval=-15, maxval=25, type=types.FloatType) self.add_parameter('dc_amplitude', flags=Instrument.FLAG_GETSET, units='V', minval=-15, maxval=25, type=types.FloatType) self.add_parameter('dutycycle', flags=Instrument.FLAG_GETSET, units='pct', minval=0, maxval=100, type=types.FloatType) if reset: self.init_default() self.get_all()
def _initialise(self): """Iterates through all devices on the GPIB bus until it finds the parameter analyser with ID _self.deviceName. If no parameter analyser found the initiation is aborted and a sys.exit is called""" print("HP4156C Initialisation") _devices = visa.get_instruments_list() for _x in range(0, len(_devices)): try: self.pa = visa.instrument(_devices[_x]) self.device_id = self.pa.ask("*IDN?") if (self.device_id == self.deviceName): print("Found device %s" % self.device_id) break except: print("Could not connect to device %s" % _devices[_x]) if (self.device_id != self.deviceName): print("Could not find the parameter analyser.") print("Exiting.") sys.exit() else: self.pa.write("*rst") print("Connected to device %s" % _devices[_x])
def __init__(self, name, address, ctr_addr=1, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address, baud_rate=57600, data_bits=8, stop_bits=1, parity=visa.no_parity, term_chars='\r\n') # Initial visa.write, this one usually gives a time-out #so run it in the beginning to get rid of this problem self._visa.write('1TS') self._visa.read() self._ctr_addr = ctr_addr self.add_parameter('position', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='mm') self.add_parameter('state', flags=Instrument.FLAG_GET, type=types.StringType) self.add_parameter('velocity', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='mm/s') # Functions self.add_function('stop_motion') self.add_function('set_state_ready') self.add_function('get_error') self.add_function('go_home') if reset: self.reset()
def __init__(self, name, address, ctr_addr=1, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address, baud_rate=57600, data_bits=8, stop_bits=1, parity=visa.no_parity, term_chars='\r\n') self._ctr_addr = ctr_addr self.add_parameter('position', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='mm') self.add_parameter('state', flags=Instrument.FLAG_GET, type=types.StringType) self.add_parameter('velocity', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='mm/s') # Functions self.add_function('stop_motion') self.add_function('set_state_ready') self.add_function('get_error') self.add_function('go_home') self.add_function('go_left') self.add_function('go_right') if reset: self.reset() else: self.get_all()
def __init__(self, name, address, reset=False): Instrument.__init__(self, name) self._address = address self._visa = visa.instrument(self._address, baud_rate=115200, data_bits=8, stop_bits=1, parity=visa.no_parity, term_chars='\r\n') self.add_parameter('identification', flags=Instrument.FLAG_GET, type=types.StringType) self.add_parameter('power', flags=Instrument.FLAG_GET, type=types.FloatType, units='W') self.add_parameter('head_info', flags=Instrument.FLAG_GET, type=types.StringType) self.add_parameter('wavelength', flags=Instrument.FLAG_GETSET, type=types.FloatType, units='m') self.add_parameter('filter_freq', flags=Instrument.FLAG_GETSET, type=types.IntType, units='Hz') if reset: self.reset() else: self.get_all()
def open_visa(cls, resource_name): """ Opens an instrument, connecting using the VISA library. Note that `PyVISA`_ and a VISA implementation must both be present and installed for this method to function. :param str resource_name: Name of a VISA resource representing the given instrument. :rtype: `Instrument` :return: Object representing the connected instrument. .. seealso:: `National Instruments help page on VISA resource names <http://zone.ni.com/reference/en-XX/help/371361J-01/lvinstio/visa_resource_name_generic/>`_. .. _PyVISA: http://pyvisa.sourceforge.net/ """ if visa is None: raise ImportError("PyVISA is required for loading VISA " "instruments.") ins = visa.instrument(resource_name) return cls(VisaWrapper(ins))
def __init__(self, name, address): ''' Initializes the RS_Step_Attenuator, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address Output: None ''' logging.info(__name__ + ' : Initializing instrument') Instrument.__init__(self, name, tags=['physical']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) self.add_parameter('attenuation', flags=Instrument.FLAG_SET, units='dB', minval=1, maxval=139, type=types.IntType) self.set_attenuation(139)
def __init__(self, name, address): ''' Initializes the any_device, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB address reset (bool) : resets to default values Output: None ''' # Initialize wrapper functions logging.info('Initializing instrument') Instrument.__init__(self, name, tags=['virtual']) # Add some global constants self._address = address self._visainstrument = visa.instrument(self._address) # Add parameters to wrapper self.add_parameter('start_frequency', type=types.FloatType, flags=Instrument.FLAG_GETSET, units='Hz', minval=10e6, maxval=13500e6) # Add functions to wrapper self.add_function('set_mode_volt_ac') # Connect to measurement flow to detect start and stop of measurement qt.flow.connect('measurement-start', self._measurement_start_cb) qt.flow.connect('measurement-end', self._measurement_end_cb)
def __init__(self, name=None, wait_for_settle=True, reset=True): self.wait_for_settle = wait_for_settle if not name: instruments = visa.get_instruments_list() # find first GPIB interface for dev in instruments: if "gpib" in dev.lower(): name = dev break else: raise exception('cannot find device') # connect to device and configure VISA settings self.device = visa.instrument(name) vpp43.gpib_control_ren( self.device.vi, visa.VI_GPIB_REN_ASSERT_ADDRESS) # doesn't work without this self.device.clear() self.set_output_enabled(False) if reset: self.reset()
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.instrument(self._address) self._zerospan = False self._freqpoints = 0 self._ci = channel_index self._start = 0 self._stop = 0 self._nop = 0 # Implement parameters self.add_parameter('nop', type=types.IntType, flags=Instrument.FLAG_GETSET, minval=1, maxval=100000, tags=['sweep']) self.add_parameter('bandwidth', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=1e9, units='Hz', tags=['sweep']) self.add_parameter('averages', type=types.IntType, flags=Instrument.FLAG_GETSET, minval=1, maxval=1024, tags=['sweep']) self.add_parameter('Average', type=types.BooleanType, flags=Instrument.FLAG_GETSET) self.add_parameter('centerfreq', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('cwfreq', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('startfreq', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('stopfreq', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('span', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=0, maxval=20e9, units='Hz', tags=['sweep']) self.add_parameter('power', type=types.FloatType, flags=Instrument.FLAG_GETSET, minval=-25, maxval=30, units='dBm', tags=['sweep']) self.add_parameter('cw', type=types.BooleanType, flags=Instrument.FLAG_GETSET) self.add_parameter('zerospan', type=types.BooleanType, flags=Instrument.FLAG_GETSET) self.add_parameter('channel_index', type=types.IntType, flags=Instrument.FLAG_GETSET) self.add_parameter('source_attenuation', type=types.IntType, flags=Instrument.FLAG_GETSET,channels=(1,2), minval=0, maxval=60, units='dB', tags=['sweep']) self.add_parameter('source_power_start', type=types.FloatType, flags=Instrument.FLAG_GETSET,channels=(1,2), minval=-2.9e1, maxval=3e1, units='dBm', tags=['sweep']) self.add_parameter('source_power_stop', type=types.FloatType, flags=Instrument.FLAG_GETSET,channels=(1,2), minval=-2.9e1, maxval=3e1, units='dBm', tags=['sweep']) self.add_parameter('calibration_state', type=types.BooleanType, flags=Instrument.FLAG_GETSET) self.add_parameter('sweep_type', type=types.StringType, flags=Instrument.FLAG_GETSET,tags=['sweep']) self.add_parameter('power_nop', type=types.IntType, flags=Instrument.FLAG_GETSET,channels=(1,2), minval=0, maxval=60, tags=['sweep']) self.add_parameter('avg_type', type=types.StringType, flags=Instrument.FLAG_GETSET,tags=['sweep']) self.add_parameter('edel', type=types.FloatType, #added by MW flags=Instrument.FLAG_GETSET, minval=0, maxval=1e-3, units='s', tags=['sweep']) self.add_parameter('sweeptime', type=types.FloatType, #JB flags=Instrument.FLAG_GET, minval=0, maxval=1e-3, units='s', tags=['sweep']) self.add_parameter('sweeptime_averages', type=types.FloatType, #JB flags=Instrument.FLAG_GET, minval=0, maxval=1e-3, units='s', tags=['sweep']) #Triggering Stuff self.add_parameter('trigger_source', type=types.StringType, flags=Instrument.FLAG_GETSET) # Implement functions self.add_function('get_freqpoints') self.add_function('get_tracedata') self.add_function('init') self.add_function('returnToLocal') self.add_function('pre_measurement') self.add_function('start_measurement') self.add_function('ready') self.add_function('post_measurement') 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.get_all()
def __init__(self, name, address, reset=False): ''' Initializes the Keysight_33500B, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : GPIB, TCPIP or USB address reset (bool) : resets to default values, default=false Output: None ''' logging.info('Initializing Keysight 33500B series AWG') Instrument.__init__(self, name, tags=['physical']) self._address = address self._visainstrument = visa.instrument(self._address) self._visainstrument.term_chars = '\n' self._idn = self._visainstrument.ask('*IDN?') self._model = self._idn.split(',')[1] self._channels = (1, 2) self._installed_options = self._visainstrument.ask('*OPT?').split(',') logging.info('The connected AWG is a {0}'.format(self._model)) if 'MEM' in self._installed_options: logging.info('The extended memory option is installed') self._mem_size = 16e6 else: self._mem_size = 1e6 logging.debug('Extended memory option not installed') self._visainstrument.write('FORM:BORD SWAP') # correct byte order # Output self.add_parameter( 'output', type=types.BooleanType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', ) self.add_parameter('sync_source', type=types.StringType, flags=Instrument.FLAG_GETSET, option_list=('CH1', 'CH2')) # General parameters self.add_parameter('frequency', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=1e-6, maxval=30e6, units='Hz') self.add_parameter('amplitude', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=1e-3, maxval=5.0, format='%.3f', units='Vpp') self.add_parameter('offset', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=-5.0, maxval=5.0, format='%.3f', units='V') self.add_parameter( 'load', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=1.0, maxval=10000, units='Ohm', ) # Function parameter self.add_parameter( 'apply', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', ) self.add_parameter('function', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('SIN', 'SQU', 'TRI', 'RAMP', 'PULS', 'PRBS', 'NOIS', 'ARB', 'DC')) # Burst mode parameters self.add_parameter('burst_cycle', type=types.IntType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=1, maxval=1e8, units='#') self.add_parameter('burst_state', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('ON', 'OFF')) self.add_parameter('burst_mode', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('TRIG', 'GAT')) self.add_parameter('burst_gate_polarity', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('NORM', 'INV')) self.add_parameter('burst_phase', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=-360.0, maxval=360.0, units='degree') self.add_parameter('burst_period', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=1e-6, maxval=8e3, units='second') # Pulse mode parameters self.add_parameter('pulse_dutycycle', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=0, maxval=100, units='%') self.add_parameter('pulse_trans_leading', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=8.4e-9, maxval=1e-6, units='second') self.add_parameter('pulse_trans_trailing', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=8.4e-9, maxval=1e-6, units='second') self.add_parameter('pulse_width', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=16e-9, maxval=1e6, units='second') # Trigger parameters self.add_parameter( 'continuous', type=types.BooleanType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', ) self.add_parameter('trigger_source', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('IMM', 'EXT', 'TIM', 'BUS')) self.add_parameter('trigger_delay', type=types.FloatType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', minval=0.0, maxval=1e3, units='second') # memory self.add_parameter( 'free_volatile_memory', type=types.IntType, flags=Instrument.FLAG_GET, channels=(1, 2), channel_prefix='ch%i_', ) # display self.add_parameter( 'display', type=types.BooleanType, flags=Instrument.FLAG_GET, ) # arbitrary waveform system self.add_parameter( 'arbitrary_waveform', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', ) self.add_parameter( 'arbitrary_waveform_frequency', type=types.FloatType, flags=Instrument.FLAG_GET, channels=(1, 2), channel_prefix='ch%i_', units='Hz', format='%.1f', ) self.add_parameter( 'arbitrary_waveform_period', type=types.FloatType, flags=Instrument.FLAG_GET, channels=(1, 2), channel_prefix='ch%i_', units='s', ) self.add_parameter( 'arbitrary_waveform_points', type=types.IntType, flags=Instrument.FLAG_GET, channels=(1, 2), channel_prefix='ch%i_', units='#', ) self.add_parameter( 'arbitrary_waveform_samplerate', type=types.IntType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', maxval=62500000, ) self.add_parameter( 'arbitrary_waveform_filter', type=types.StringType, flags=Instrument.FLAG_GETSET, channels=(1, 2), channel_prefix='ch%i_', option_list=('NORMAL', 'STEP', 'OFF'), ) self.add_parameter( 'arbitrary_waveform_peak_to_peak', type=types.FloatType, flags=Instrument.FLAG_GET, channels=(1, 2), channel_prefix='ch%i_', units='V', format='%.3f', ) self.add_function('imm_trigger') self.add_function('ext_trigger') self.add_function('bus_trigger') self.add_function('send_trigger1') self.add_function('send_trigger2') self.add_function('send_trigger') self.add_function('initiate') self.add_function('get_volatile_memory_catalog') self.add_function('synchronize_waveforms') self.add_function('reset') self.add_function('get_all') if reset: self.reset() else: self.get_all()