Esempio n. 1
0
    def set_dccurrent(self, **kwargs):
        # if first time, initialize instrument
        if not self.ready_dccurrent:
            print('Connecting to dc current source...')
            self.instr_dccurrent = instruments_gpib.SR830()
            self.ready_dccurrent = True

        i = kwargs.get('i', 0)
        dbl_bias = kwargs.get('dbl_bias', False)
        if dbl_bias:  # 20 mA range
            v = float(i) / self.daqparams.i_per_v_dcbias / 2
            if abs(v) > 10:
                v = 10 if v > 10 else -10
                print('Exceeded max V. Setting V = %f' % (v))
            self.instr_dccurrent.dacout(self.daqparams.dacch_bias, v)
            self.instr_dccurrent.dacout(self.daqparams.dacch_bias2, v)
            if 't' in kwargs:  # if pulse
                sleep(kwargs['t'])
                self.instr_dccurrent.dacout(self.daqparams.dacch_bias, 0)
                self.instr_dccurrent.dacout(self.daqparams.dacch_bias2, 0)
        else:  # 10 mA range
            v = float(i) / self.daqparams.i_per_v_dcbias
            if abs(v) > 10:
                v = 10 if v > 10 else -10
                print('Exceeded max V. Setting V = %f' % (v))
            self.instr_dccurrent.dacout(self.daqparams.dacch_bias, v)
        if 't' in kwargs:  # if pulse
            sleep(kwargs['t'])
            self.instr_dccurrent.dacout(self.daqparams.dacch_bias, 0)
            if dbl_bias:
                self.instr_dccurrent.dacout(self.daqparams.dacch_bias2, 0)
Esempio n. 2
0
    def get_dvdi(self, ch=1):
        # if first time, initialize instrument
        if not self.ready_lockin:
            print('Connecting to lockin...')
            self.instr_lockin = instruments_gpib.SR830()
            self.ready_lockin = True

        #return self.instr_lockin.getdisp(ch)/self.daqparams.gain/ \
        #  (self.daqparams.ampl_lockin*self.daqparams.i_per_v_acbias)
        return self.instr_lockin.getdisp(ch)/self.daqparams.gain/ \
          self.daqparams.ampl_lockin
Esempio n. 3
0
    def set_accurrent(self, **kwargs):
        # if first time, initialize instrument
        if not self.ready_lockin:
            print('Connecting to lockin...')
            self.instr_lockin = instruments_gpib.SR830()
            self.ready_lockin = True

        if 'ampl' in kwargs:
            ampl = kwargs['ampl'] / self.daqparams.i_per_v_acbias
            self.instr_lockin.sinelvl(ampl)
        if 'freq' in kwargs:
            self.instr_lockin.freq(kwargs['freq'])
Esempio n. 4
0
    def set_vout(self, dev, ch, v):
        # Helper function for DAC out.

        if dev == 'mccdaq':
            if not self.ready_mccdaq:
                print('First use of MCCDAQ...')
                self.instr_mccdaq = instruments_mccdaq.MCCDAQ()
                self.ready_mccdaq = True
            self.instr_mccdaq.vout(ch, v)
            #print(v)
        else:
            if not self.ready_SR830:
                print('First use of SR830...')
                self.instr_sr830 = instruments_gpib.SR830()
                self.ready_sr830 = True
            self.instr_sr830.dacout(ch, v)
Esempio n. 5
0
    def set_heat(self, **kwargs):
        # if first time, initialize instrument
        if not self.ready_heat:
            print('Connecting to heat source...')
            self.instr_heat = instruments_gpib.SR830()
            self.ready_heat = True

        i = kwargs.get('i', .09)
        if abs(i) > .1:
            i = .1 if i > .1 else -.1
            print('Exceeded max I. Setting I = %f' % (i))
        v = i / self.daqparams.i_per_v_heat
        self.instr_heat.dacout(self.daqparams.dacch_heat, v)
        if 't' in kwargs:  # if pulse
            sleep(kwargs['t'])
            self.instr_heat.dacout(self.daqparams.dacch_heat, 0)
Esempio n. 6
0
    def ramp_vout(self, dev, ch, **kwargs):
        # Helper function for DAC ramp out.

        step = kwargs.get('step', 0.001)

        # setup dependent on DAC
        if dev == 'mccdaq':
            if not self.ready_mccdaq:
                print('First use of MCCDAQ...')
                self.instr_mccdaq = instruments_mccdaq.MCCDAQ()
                self.ready_mccdaq = True
            v1 = kwargs['v1']
            v2 = kwargs['v2']
            delay_dac = 0.01
            #self.instr_mccdaq.vout(ch, v)
        else:
            if not self.ready_SR830:
                print('First use of SR830...')
                self.instr_sr830 = instruments_gpib.SR830()
                self.ready_sr830 = True
            v1 = self.instr_sr830.get_auxvout(self.daqparams.dacch_field)
            v2 = kwargs['v']
            delay_dac = 0.1
            #self.instr_sr830.dacout(ch, v)

        # common codes independent of DAC
        if v1 == v2:
            varray = [v1]
        else:
            step = np.sign(v2 - v1) * abs(step)
            varray = np.arange(v1, v2, step)
        t0 = time()
        for v in varray[1:]:
            t = time()
            if t - t0 > 1:
                print('%10.4f' % v, end="", flush=True)
                t0 = t
            self.set_vout(dev, ch, v)
            sleep(delay_dac)
        print('%10.4f' % v2, end="\n", flush=True)
        self.set_vout(dev, ch, v2)
Esempio n. 7
0
    def sqwave_field(self, **kwargs):
        # if first time, initialize instrument
        if not self.ready_field:
            print('Connecting to field source...')
            self.instr_field = instruments_gpib.SR830()
            self.ready_field = True

        h = kwargs.get('h', 0)
        v = h / self.daqparams.h_per_i / self.daqparams.i_per_v_coil
        if abs(v) > 2:
            v = 2 if v > 2 else -2
            print('Exceeded max V. Setting V = %f' % (v))
        while 1:
            self.instr_field.dacout(self.daqparams.dacch_field, v)
            h1 = self.instr_field.get_auxvout(self.daqparams.dacch_field)\
              *self.daqparams.h_per_i*self.daqparams.i_per_v_coil
            self.instr_field.dacout(self.daqparams.dacch_field, 0)
            h1 = self.instr_field.get_auxvout(self.daqparams.dacch_field)\
              *self.daqparams.h_per_i*self.daqparams.i_per_v_coil
        if 't' in kwargs:  # if pulse
            sleep(kwargs['t'])
            self.instr_field.dacout(self.daqparams.dacch_field, 0)
Esempio n. 8
0
    def set_field(self, **kwargs):
        if ('ramp' in kwargs and kwargs['ramp'] == True) or\
                ('h1' in kwargs and 'h2' in kwargs):
            ramp = True
        else:
            ramp = False
        vmax = self.daqparams.i_coil_max / self.daqparams.i_per_v_coil
        if not ramp:  # simple set
            h = kwargs.get('h', 0)
            v = h / self.daqparams.h_per_i / self.daqparams.i_per_v_coil
            if abs(v) > vmax:
                v = vmax if v > vmax else -vmax
                print('Max V is %f. Setting V = %f' % (vmax, v))

            print('Field: ', self.daqparams.dac_field, ', Ch',\
                    self.daqparams.dacch_field, ', %6.4f V'%v)
            self.set_vout(self.daqparams.dac_field, self.daqparams.dacch_field,
                          v)

            # if pulse, delay and reset.
            if 't' in kwargs:
                sleep(kwargs['t'])
                self.set_vout(self.daqparams.dac_field,\
                        self.daqparams.dacch_field, 0)

        else:  # ramp
            step = kwargs.get('step', 5)
            if self.daqparams.dac_field == 'mccdaq':
                h1 = kwargs['h1']
                h2 = kwargs['h2']
                delay_dac = 0.01
            elif 'h' in kwargs:  # SR830 with only final field given
                h2 = h
                if not self.ready_sr830:
                    print('First use of SR830...')
                    self.instr_sr830 = instruments_gpib.SR830()
                    self.ready_sr830 = True
                h1 = self.instr_sr830.get_auxvout(self.daqparams.dacch_field)
            else:  # SR830 with two fields given
                h1 = kwargs['h1']
                h2 = kwargs['h2']
                delay_dac = 0.1

            # voltage out
            v1 = h1 / self.daqparams.h_per_i / self.daqparams.i_per_v_coil
            v2 = h2 / self.daqparams.h_per_i / self.daqparams.i_per_v_coil
            vstep = step / self.daqparams.h_per_i / self.daqparams.i_per_v_coil
            if abs(v1) > vmax:
                v1 = vmax if v1 > vmax else -vmax
                print('Max V is %f. Setting V = %f' % (vmax, v1))
            if abs(v2) > vmax:
                v2 = vmax if v2 > vmax else -vmax
                print('Max V is %f. Setting V = %f' % (vmax, v2))
            self.ramp_vout(self.daqparams.dac_field,\
                    self.daqparams.dacch_field, v1=v1, v2=v2, step=vstep)

            # if pulse, delay and reset.
            if 't' in kwargs:
                sleep(kwargs['t'])
                self.ramp_vout(self.daqparams.dac_field,\
                        self.daqparams.dacch_field, v1=v2, v2=0, step=vstep)