Esempio n. 1
0
    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)
Esempio n. 3
0
 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 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)
Esempio n. 5
0
 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
Esempio n. 6
0
    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)