def __init__(self, amplitude, offset, freq, ACCoupling = 0, inChannel = 0, outChannel = 0, auxChannel = 0, add = 1, range = 10, canvas = None): ''' initializes values :param amplitude: output channel amplitude (Vpk) :param offset: auxillary channel output (V), only functions as offset if aux1 (value 0) connected to inChannel add port :param freq: output channel frequence (Hz) :param ACCoupling: turns ac coupling on (1) or off (0), default off (0) :param inChannel: specifies input channel number, default channel 1 as listed on device (value 0) :param outChannel: specifies output channel number, default channel 1 as listed on device (value 0) :param auxChannel: specifies auxillary channel to use, default channel 1 as listed on device (value 0) :param add: turns add mode on output channel on (1) or off (0), default 1 :param range: sets output range (V), default 10 :param find and connect to device ''' self.daq = utils.autoConnect(8005,1) # connect to ZI, 8005 is the port number self.device = utils.autoDetect(self.daq) self.options = self.daq.getByte('/%s/features/options' % self.device) #channel settings self.in_c = inChannel self.out_c = outChannel self.demod_c = 0 self.demod_rate = 10e3 # sample rate of low pass filtered signal after mixing self.osc_c = 0 if (not re.match('MF', self.options)): self.out_mixer_c = 6 else: self.out_mixer_c = 0 self.plotting = 0 self.canvas = canvas self.line = None self.yLim = None self.dataFinal = None # Configure the settings relevant to this experiment # note that the output amplitude has to be scaled with the range to give the right result # todo: JG - this can probably be written in a single line using a propper dictionary self.exp_setting = [ ['/%s/sigins/%d/imp50' % (self.device, self.in_c), 1], ['/%s/sigins/%d/ac' % (self.device, self.in_c), ACCoupling], ['/%s/sigins/%d/range' % (self.device, self.in_c), 2*amplitude], ['/%s/demods/%d/order' % (self.device, self.demod_c), 4], ['/%s/demods/%d/rate' % (self.device, self.demod_c), self.demod_rate], ['/%s/demods/%d/harmonic' % (self.device, self.demod_c), 1], ['/%s/demods/%d/phaseshift' % (self.device, self.demod_c), 0], ['/%s/sigouts/%d/on' % (self.device, self.out_c), 1], ['/%s/sigouts/%d/range' % (self.device, self.out_c), range], ['/%s/sigouts/%d/enables/%d' % (self.device, self.out_c, self.out_mixer_c), 1], ['/%s/sigouts/%d/amplitudes/%d' % (self.device, self.out_c, self.out_mixer_c), float(amplitude)/range], ['/%s/AUXOUTS/%d/OFFSET'% (self.device, auxChannel), offset], ['/%s/oscs/%d/freq'% (self.device, auxChannel), freq]] self.exp_setting.append(['/%s/demods/%d/oscselect' % (self.device, self.demod_c), self.osc_c]) self.exp_setting.append(['/%s/demods/%d/adcselect' % (self.device, self.demod_c), self.in_c]) self.exp_setting.append(['/%s/sigins/%d/diff' % (self.device, self.in_c), 0]) self.exp_setting.append(['/%s/sigouts/%d/add' % (self.device, self.out_c), add]) self.daq.set(self.exp_setting) print(self.exp_setting)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" try: self.ziConnection = zi.autoConnect(8004, 4) except: raise InstrumentDriver.CommunicationError("Could not connect to Zurich Instruments Data Server. Is it running?") return if self.comCfg.address == "": self.device = zi.autoDetect(self.ziConnection) self.log("Autodetected Zurich Instruments device \"" + self.device + "\". Use the address field to set a specific device.") else: self.device = self.comCfg.address try: devtype = self.ziConnection.getByte(str('/%s/features/devtype' % self.device)) except: raise InstrumentDriver.CommunicationError("Device " + self.device + " not found.") return if re.match('UHF', devtype): self.log("Zurich Instruments device \"" + self.device + "\" has been accepted by the driver.") else: self.log("Zurich Instruments device \"" + self.device + "\" has been rejected by the driver.", 50) raise InstrumentDriver.CommunicationError("Device " + self.device + " is not an UHF lock-in") return #Check Options devoptions = self.ziConnection.getByte(str('/%s/features/options' % self.device)) detectedOptions = [] if re.search('MOD', devoptions): detectedOptions.append("MOD") self.instrCfg.setInstalledOptions(detectedOptions)
def connect(port_number, timeout): self.daq = utils.autoConnect( port_number, 1) # connect to ZI, 8005 is the port number self.device = utils.autoDetect(self.daq) self.options = self.daq.getByte('/%s/features/options' % self.device) self.sweeper = self.daq.sweep(timeout) self._timeout = timeout
def autoconnect(self): if not self.daq: raise (ziShellDAQError()) try: self.devices.add(utils.autoDetect(self.daq)) except Exception: pass
def UHF_save_settings(path = None, filename = 'UHFLI_settings_file.xml'): """ Saving UHF Lockin settings file to a location defined by path in a file defined by filename. Arguments: daq (ziDAQServer): Instance of UHFLI device path (str): Location on disk where settings file is going to be saved filename (str): File name of saved settings file """ dev = utils.autoDetect(daq) # Get a device string - needed for save_settings function utils.save_settings(daq, dev, path + os.sep + filename) # saving setting file
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" try: self.ziConnection = zi.autoConnect(8004, 4) except: raise InstrumentDriver.CommunicationError( "Could not connect to Zurich Instruments Data Server. Is it running?" ) return if self.comCfg.address == "": self.device = zi.autoDetect(self.ziConnection) self.log( 'Autodetected Zurich Instruments device "' + self.device + '". Use the address field to set a specific device.' ) else: self.device = self.comCfg.address try: devtype = self.ziConnection.getByte("/%s/features/devtype" % self.device) except: raise InstrumentDriver.CommunicationError("Device " + self.device + " not found.") return if re.match("UHF", devtype): self.log('Zurich Instruments device "' + self.device + '" has been accepted by the driver.') else: self.log('Zurich Instruments device "' + self.device + '" has been rejected by the driver.', 50) raise InstrumentDriver.CommunicationError("Device " + self.device + " is not an UHF lock-in") return # Check Options devoptions = self.ziConnection.getByte("/%s/features/options" % self.device) detectedOptions = [] if re.search("MOD", devoptions): detectedOptions.append("MOD") self.instrCfg.setInstalledOptions(detectedOptions)
def __init__(self, ip='127.0.0.1', port=8004, api_level=6, repRate=1500, timeOut=30): # Create a connection to a Zurich Instruments Data Server print 'connecting ...' self.daq = zh.ziDAQServer(ip, port, api_level) self.daq.connect() self.timeOut = timeOut self.acqStartTime = None self.acqEndTime = None self.isAcquiring = False # Detect a device self.device = utils.autoDetect(self.daq) # Find out whether the device is an HF2 or a UHF self.devtype = self.daq.getByte('/%s/features/devtype' % self.device) self.options = self.daq.getByte('/%s/features/options' % self.device) self.clock = self.daq.getDouble('/%s/clockbase' % self.device) if not re.search('BOX', self.options): raise Exception( "This example can only be ran on a UHF with the BOX option enabled." ) if self.daq.getConnectionAPILevel() != 6: warnings.warn("ziDAQServer is using API Level 1, it is strongly recommended " * \ "to use API Level 6 in order to obtain boxcar data with timestamps.") self.daq.sync() self.daq.subscribe('/%s/boxcars/%d/sample' % (self.device, 0)) self.daq.subscribe('/%s/boxcars/%d/sample' % (self.device, 1)) print 'connected'
def __init__(self, server_address = 'localhost', server_port = 8005 , device_serial = '', in_channel = None, meas_type='V'): ''' Creates the HF2LI object. By choosing server address, can connection to HF2LI on remote (local network) computer. Arguments: server_address (str,optional) = Private IPV4 address of the computer hosting the zurich. Defults to 'localhost', the computer the python kernel is running on. server_port (int, optional) = Port of Zurich HF2LI. For local is always 8005 (default), usually 8006 for remote. device_serial (str, optional) = Serial number of prefered zurich hf2li. If empty string or does not exist, uses first avaliable ZI. in_channel: if None, will use both inputs (TODO). Else, choose input 1 or 2. meas_type: 'I' or 'V'. Choose whether this channel measures current (via transimpedance amplifier) or voltage. ''' super().__init__() self.daq = ziP.ziDAQServer(server_address, server_port) deviceList = utils.devices(self.daq) # Find device if device_serial in deviceList: self.device_id = device_serial elif device_serial != '': print('Requested device not found.') if self.device_id is None: self.device_id = utils.autoDetect(self.daq) # first available print('Using Zurich HF2LI with serial %s' % self.device_id) if in_channel is None: raise Exception() self.in_channel = in_channel self.meas_type = meas_type
def __init__(self, name, device='auto', interface='USB', address='127.0.0.1', port=8004, DIO=True, nr_integration_channels=9, **kw): ''' Input arguments: name: (str) name of the instrument server_name: (str) qcodes instrument server address: (int) the address of the data server e.g. 8006 ''' # self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) # #suggestion W vlothuizen t0 = time.time() super().__init__(name, **kw) self.nr_integration_channels = nr_integration_channels self.DIO = DIO self._daq = zi.ziDAQServer(address, int(port), 5) # self._daq.setDebugLevel(5) if device.lower() == 'auto': self._device = zi_utils.autoDetect(self._daq) else: self._device = device self._daq.connectDevice(self._device, interface) #self._device = zi_utils.autoDetect(self._daq) self._awgModule = self._daq.awgModule() self._awgModule.set('awgModule/device', self._device) self._awgModule.execute() self.acquisition_paths = [] s_node_pars = [] d_node_pars = [] path = os.path.abspath(__file__) dir_path = os.path.dirname(path) self._s_file_name = os.path.join(dir_path, 'zi_parameter_files', 's_node_pars.txt') self._d_file_name = os.path.join(dir_path, 'zi_parameter_files', 'd_node_pars.txt') init = True try: f = open(self._s_file_name).read() s_node_pars = json.loads(f) except: print("parameter file for gettable parameters {} not found".format( self._s_file_name)) init = False try: f = open(self._d_file_name).read() d_node_pars = json.loads(f) except: print("parameter file for settable parameters {} not found".format( self._d_file_name)) init = False self.add_parameter('timeout', unit='s', initial_value=30, parameter_class=ManualParameter) for parameter in s_node_pars: parname = parameter[0].replace("/", "_") parfunc = "/" + self._device + "/" + parameter[0] if parameter[1] == 'float': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setd, parfunc), get_cmd=self._gen_get_func(self.getd, parfunc), vals=vals.Numbers(parameter[2], parameter[3])) elif parameter[1] == 'float_small': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setd, parfunc), get_cmd=self._gen_get_func(self.getd, parfunc), vals=vals.Numbers(parameter[2], parameter[3])) elif parameter[1] == 'int_8bit': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1] == 'int': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1] == 'int_64': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1] == 'bool': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) else: print( "parameter {} type {} from from s_node_pars not recognized" .format(parname, parameter[1])) for parameter in d_node_pars: parname = parameter[0].replace("/", "_") parfunc = "/" + self._device + "/" + parameter[0] if parameter[1] == 'float': self.add_parameter(parname, get_cmd=self._gen_get_func( self.getd, parfunc)) elif parameter[1] == 'vector_g': self.add_parameter(parname, get_cmd=self._gen_get_func( self.getv, parfunc)) elif parameter[1] == 'vector_s': self.add_parameter(parname, set_cmd=self._gen_set_func( self.setv, parfunc), vals=vals.Anything()) elif parameter[1] == 'vector_gs': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setv, parfunc), get_cmd=self._gen_get_func(self.getv, parfunc), vals=vals.Anything()) else: print("parameter {} type {} from d_node_pars not recognized". format(parname, parameter[1])) self.add_parameter('AWG_file', set_cmd=self._do_set_AWG_file, vals=vals.Anything()) # storing an offset correction parameter for all weight functions, # this allows normalized calibration when performing cross-talk suppressed # readout for i in range(self.nr_integration_channels): self.add_parameter( "quex_trans_offset_weightfunction_{}".format(i), unit='', # unit is adc value label='RO normalization offset', initial_value=0.0, parameter_class=ManualParameter) if init: self.load_default_settings() t1 = time.time() print('Initialized UHFQC', self._device, 'in %.2fs' % (t1 - t0))
def reconnect(self): zi_utils.autoDetect(self._daq)
def connect(port_number, timeout): self.daq = utils.autoConnect(port_number,1) # connect to ZI, 8005 is the port number self.device = utils.autoDetect(self.daq) self.options = self.daq.getByte('/%s/features/options' % self.device) self.sweeper = self.daq.sweep(timeout) self._timeout = timeout
def __init__(self, amplitude, offset, freq, ACCoupling=0, inChannel=0, outChannel=0, auxChannel=0, add=1, range=10, canvas=None): ''' initializes values :param amplitude: output channel amplitude (Vpk) :param offset: auxillary channel output (V), only functions as offset if aux1 (value 0) connected to inChannel add port :param freq: output channel frequence (Hz) :param ACCoupling: turns ac coupling on (1) or off (0), default off (0) :param inChannel: specifies input channel number, default channel 1 as listed on device (value 0) :param outChannel: specifies output channel number, default channel 1 as listed on device (value 0) :param auxChannel: specifies auxillary channel to use, default channel 1 as listed on device (value 0) :param add: turns add mode on output channel on (1) or off (0), default 1 :param range: sets output range (V), default 10 :param find and connect to device ''' self.daq = utils.autoConnect( 8005, 1) # connect to ZI, 8005 is the port number self.device = utils.autoDetect(self.daq) self.options = self.daq.getByte('/%s/features/options' % self.device) #channel settings self.in_c = inChannel self.out_c = outChannel self.demod_c = 0 self.demod_rate = 10e3 # sample rate of low pass filtered signal after mixing self.osc_c = 0 if (not re.match('MF', self.options)): self.out_mixer_c = 6 else: self.out_mixer_c = 0 self.plotting = 0 self.canvas = canvas self.line = None self.yLim = None self.dataFinal = None # Configure the settings relevant to this experiment # note that the output amplitude has to be scaled with the range to give the right result # todo: JG - this can probably be written in a single line using a propper dictionary self.exp_setting = [ ['/%s/sigins/%d/imp50' % (self.device, self.in_c), 1], ['/%s/sigins/%d/ac' % (self.device, self.in_c), ACCoupling], ['/%s/sigins/%d/range' % (self.device, self.in_c), 2 * amplitude], ['/%s/demods/%d/order' % (self.device, self.demod_c), 4], [ '/%s/demods/%d/rate' % (self.device, self.demod_c), self.demod_rate ], ['/%s/demods/%d/harmonic' % (self.device, self.demod_c), 1], ['/%s/demods/%d/phaseshift' % (self.device, self.demod_c), 0], ['/%s/sigouts/%d/on' % (self.device, self.out_c), 1], ['/%s/sigouts/%d/range' % (self.device, self.out_c), range], [ '/%s/sigouts/%d/enables/%d' % (self.device, self.out_c, self.out_mixer_c), 1 ], [ '/%s/sigouts/%d/amplitudes/%d' % (self.device, self.out_c, self.out_mixer_c), float(amplitude) / range ], ['/%s/AUXOUTS/%d/OFFSET' % (self.device, auxChannel), offset], ['/%s/oscs/%d/freq' % (self.device, auxChannel), freq] ] self.exp_setting.append([ '/%s/demods/%d/oscselect' % (self.device, self.demod_c), self.osc_c ]) self.exp_setting.append([ '/%s/demods/%d/adcselect' % (self.device, self.demod_c), self.in_c ]) self.exp_setting.append( ['/%s/sigins/%d/diff' % (self.device, self.in_c), 0]) self.exp_setting.append( ['/%s/sigouts/%d/add' % (self.device, self.out_c), add]) self.daq.set(self.exp_setting) print(self.exp_setting)
def __init__(self, name, device='auto', interface='USB', address='127.0.0.1', port=8004, **kw): ''' Input arguments: name: (str) name of the instrument server_name: (str) qcodes instrument server address: (int) the address of the data server e.g. 8006 ''' #self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) #suggestion W vlothuizen t0 = time.time() super().__init__(name, **kw) self._daq = zi.ziDAQServer(address, int(port), 5) if device.lower() == 'auto': self._device = zi_utils.autoDetect(self._daq) else: self._device = device self._daq.connectDevice(self._device, interface) self._device = zi_utils.autoDetect(self._daq) s_node_pars=[] d_node_pars=[] path = os.path.abspath(__file__) dir_path = os.path.dirname(path) self._s_file_name = os.path.join(dir_path, 'zi_parameter_files', 's_node_pars.txt') self._d_file_name = os.path.join(dir_path, 'zi_parameter_files', 'd_node_pars.txt') init = True try: f = open(self._s_file_name).read() s_node_pars = json.loads(f) except: print("parameter file for gettable parameters {} not found".format(self._s_file_name)) init=False try: f = open(self._d_file_name).read() d_node_pars = json.loads(f) except: print("parameter file for settable parameters {} not found".format(self._d_file_name)) init = False for parameter in s_node_pars: parname=parameter[0].replace("/","_") parfunc="/"+device+"/"+parameter[0] if parameter[1] == 'float': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setd, parfunc), get_cmd=self._gen_get_func(self.getd, parfunc), vals=vals.Numbers(parameter[2], parameter[3])) elif parameter[1] == 'float_small': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setd, parfunc), get_cmd=self._gen_get_func(self.getd, parfunc), vals=vals.Numbers(parameter[2], parameter[3])) elif parameter[1] == 'int_8bit': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1]=='int': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1]=='int_64': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) elif parameter[1]=='bool': self.add_parameter( parname, set_cmd=self._gen_set_func(self.seti, parfunc), get_cmd=self._gen_get_func(self.geti, parfunc), vals=vals.Ints(int(parameter[2]), int(parameter[3]))) else: print("parameter {} type {} from from s_node_pars not recognized".format(parname,parameter[1])) for parameter in d_node_pars: parname=parameter[0].replace("/","_") parfunc="/"+device+"/"+parameter[0] if parameter[1]=='float': self.add_parameter( parname, get_cmd=self._gen_get_func(self.getd, parfunc)) elif parameter[1]=='vector_g': self.add_parameter( parname, get_cmd=self._gen_get_func(self.getv, parfunc)) elif parameter[1]=='vector_s': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setv, parfunc), vals=vals.Anything()) elif parameter[1]=='vector_gs': self.add_parameter( parname, set_cmd=self._gen_set_func(self.setv, parfunc), get_cmd=self._gen_get_func(self.getv, parfunc), vals=vals.Anything()) else: print("parameter {} type {} from d_node_pars not recognized".format(parname,parameter[1])) self.add_parameter('AWG_file', set_cmd=self._do_set_AWG_file, vals=vals.Anything()) if init: self.load_default_settings() t1 = time.time() print('Initialized UHFQC', self._device, 'in %.2fs' % (t1-t0))