Ejemplo n.º 1
0
    def __init__(self,
                 resource=None,
                 sim_mode=False,
                 backend="@py",
                 query='GPIB?*::INSTR',
                 name=None,
                 path='./'):

        Instrument.__init__(self, resource, sim_mode, backend, query, name,
                            path)

        if not self._name == 'Stanford_Research_Systems-SR830':
            raise Warning('Using {}'.format(self._name))

        self._inst.write('OUTX 1')

        self.adquisition = _lockin_adquisition(self)
        self.input_panel = _lockin_input(self)
        self.ch1_panel = _lockin_ch1(self)
        self.ch2_panel = _lockin_ch2(self)
        self.auto_panel = _lockin_autofuncs(self)
        self.setup_panel = _lockin_setup(self)
        self.interface_panel = _lockin_interface(self)
        self.reference_panel = _lockin_reference(self)
        self.auxiliar_outs = _lockin_auxout(self)
Ejemplo n.º 2
0
    def __init__(self, _name, _cfg):
        Instrument.__init__(self, _name)

        # No Responsive Counter
        self.m_maxNoResponse = 10

        # Do specific configuration
        self.m_connect_need_port = True
        self.m_varnames = None

        # Initialize serial communication
        self.m_serial = Serial()
        self.m_serial.baudrate = 19200
        self.m_serial.bytesize = 8
        self.m_serial.parity = 'N'  # None
        self.m_serial.stopbits = 1
        self.m_serial.timeout = 1   # 1 Hz

        # Load cfg
        if 'variables' in _cfg.keys():
            self.m_varnames = _cfg['variables']
        else:
            print(_name + ': Missing varriables')
            exit()
        if 'units' in _cfg.keys():
            units = _cfg['units']
        else:
            print(_name + ': Missing units')
            units = ['Unknown' for i in range(len(self.m_varnames))]

        # Init cache in case log starts before instrument is connected
        for v in self.m_varnames:
            self.m_cache[v] = None
            self.m_cacheIsNew[v] = False
            self.m_units[v] = units.pop(0)
Ejemplo n.º 3
0
    def __init__(self, _name, _cfg):
        Instrument.__init__(self, _name)

        # No Responsive Counter
        self.m_maxNoResponse = 10

        # Do specific configuration
        self.m_connect_need_port = True
        self.m_pins = []
        self.m_pin2var = {}

        # Initialize serial communication
        self.m_serial = Serial()
        self.m_serial.baudrate = 9600
        self.m_serial.bytesize = 8
        self.m_serial.parity = 'N'  # None
        self.m_serial.stopbits = 1

        # Load cfg
        if 'frequency' in _cfg.keys():
            self.m_frequency = _cfg['frequency']
            self.m_serial.timeout = 1 / _cfg['frequency']  # seconds
            self.m_serial.write_timeout = self.m_serial.timeout
        else:
            print(_name + ' missing frequency')
            exit()
        if 'variables' in _cfg.keys():
            if any(_cfg['variables']):
                for var, val in _cfg['variables'].items():
                    self.m_cache[var] = None
                    self.m_cacheIsNew[var] = False
                    if 'pin' in val.keys():
                        if val['pin'] in self.m_pin_list:
                            self.m_pin2var[val['pin']] = var
                        else:
                            print(_name + ':' + var + ' Unknown pin ' +
                                  val['pin'])
                            exit()
                    else:
                        print(_name + ':' + var + ' missing pin')
                        exit()
                    if 'units' in val.keys():
                        self.m_units[var] = val['units']
                    else:
                        print(_name + ':' + var + ' missing units')
                        exit()
                    self.m_varnames.append(var)
            else:
                print(_name + ' variables are empty')
                exit()
        else:
            print(_name + ' missing variables')
            exit()

        # Build ordered list of pin
        for p in self.m_pin_list:
            if p in self.m_pin2var.keys():
                self.m_pins.append(p)
        self.m_n_pins = len(self.m_pins)
Ejemplo n.º 4
0
    def __init__(self,
                 resource=None,
                 sim_mode=False,
                 backend="@py",
                 query='?*::INSTR',
                 name=None,
                 path='./'):

        Instrument.__init__(self, resource, sim_mode, backend, query, name,
                            path)
Ejemplo n.º 5
0
    def __init__(self, _name, _cfg):
        Instrument.__init__(self, _name)

        # Init Parameters
        self.m_timeout = None  # in seconds
        self.m_rnd = {}
        self.m_seed = {}
        self.m_mu = {}    # mean
        self.m_sigma = {}  # standard deviation
        self.m_connect_need_port = False

        # Load & Check configuration
        if 'frequency' in _cfg.keys():
            self.m_timeout = 1 / _cfg['frequency']
        else:
            print('Missing frequency in ' + _name + '.')
            exit()
        if 'variables' in _cfg.keys():
            if any(_cfg['variables']):
                for var, val in _cfg['variables'].items():
                    self.m_cache[var] = None
                    self.m_cacheIsNew[var] = False
                    if 'seed' in val.keys():
                        self.m_seed[var] = val['seed']
                    else:
                        self.m_seed[var] = None
                    if 'mu' in val.keys():
                        self.m_mu[var] = val['mu']
                    else:
                        print(_name + ':' + var + ' missing mu')
                        exit()
                    if 'sigma' in val.keys():
                        self.m_sigma[var] = val['sigma']
                    else:
                        print(_name + ':' + var + ' missing sigma')
                        exit()
                    if 'units' in val.keys():
                        self.m_units[var] = val['units']
                    else:
                        print(_name + ':' + var + ' missing units')
                        exit()
                    self.m_varnames.append(var)
            else:
                print('No variables in ' + _name + '.')
                exit()
        else:
            print('Missing variables in ' + _name + '.')
            exit()

        # Initialize random generators
        for var in self.m_seed.keys():
            if self.m_seed[var] is None:
                self.m_rnd[var] = Random()
            else:
                self.m_rnd[var] = Random(self.m_seed[var])
Ejemplo n.º 6
0
 def __init__(self,name,address):
     try:
         self._inst=visa.instrument(address)
     except:
         print "ERROR! Failed to initialize VISA instrument"
         self._inst=None
     if not(self._inst==None):
         self._address=address
     
     logging.info(__name__ + ' : Initializing instrument')
     Instrument.__init__(self, name, address)
     self.status='Ready'
Ejemplo n.º 7
0
    def __init__(self, resource=None, sim_mode=False, backend="@py",
                 query='?*::INSTR', name=None, path='./'):

        Instrument.__init__(self, resource, sim_mode,
                            backend, query, name, path)

        self._xze = None
        self._xin = None
        self._yze = None
        self._ymu = None
        self._yoff = None

        self.setup_curve()
        self.get_waveform_preamble()
Ejemplo n.º 8
0
    def __init__(self,
                 resource=None,
                 sim_mode=False,
                 backend="@py",
                 query='?*::INSTR',
                 name=None,
                 path='./'):

        Instrument.__init__(self, resource, sim_mode, backend, query, name,
                            path)

        self.adquisition = _lockin_adquisition(self)
        self.input_panel = _lockin_input(self)
        self.ch1_panel = _lockin_ch1(self)
        self.ch2_panel = _lockin_ch2(self)
        self.auto_panel = _lockin_autofuncs(self)
        self.setup_panel = _lockin_setup(self)
        self.interface_panel = _lockin_interface(self)
        self.reference_panel = _lockin_reference(self)
        self.auxiliar_outs = _lockin_auxout(self)
Ejemplo n.º 9
0
    def __init__(self, _name, _cfg):
        Instrument.__init__(self, _name)

        # No Responsive Counter
        self.m_maxNoResponse = 10

        # Do specific configuration
        self.m_connect_need_port = True
        self.m_lambda = []

        # Initialize serial communication
        self.m_serial = Serial()
        self.m_serial.baudrate = 19200
        self.m_serial.bytesize = 8
        self.m_serial.parity = 'N'  # None
        self.m_serial.stopbits = 1
        self.m_serial.timeout = 1   # 1 Hz

        # Load cfg
        if 'lambda' in _cfg.keys():
            self.m_lambda = _cfg['lambda']
        else:
            print(_name + ': Missing lambda')
            exit()
        if 'varname_header' in _cfg.keys():
            if isinstance(_cfg['varname_header'], str):
                varname_header = [_cfg['varname_header']
                                  for i in range(len(self.m_lambda))]
            elif isinstance(_cfg['varname_header'], list):
                varname_header = _cfg['varname_header']
            else:
                print(_name + ':Incompatible instance type for varname_header')
                exit()
        else:
            if __debug__:
                print(_name + ': Missing varname_header')
            varname_header = ['' for i in range(len(self.m_lambda))]
        if 'units' in _cfg.keys():
            if isinstance(_cfg['units'], str):
                units = [_cfg['units'] for i in range(len(self.m_lambda))]
            elif isinstance(_cfg['units'], list):
                units = _cfg['units']
            else:
                print(_name + ': Incompatible instance type for units')
                exit()
        else:
            print(_name + ': Missing units')
            units = ['Unknown' for i in range(len(self.m_lambda))]

        # Check size of arrays
        if len(self.m_lambda) != len(units) or \
                len(self.m_lambda) != len(varname_header):
            print(_name + ': arrays units, varname_header and lambda ' +
                  'have different size')
            print(self.m_lambda, units, varname_header)
            exit()

        # Init cache in case log starts before instrument is connected
        for l in self.m_lambda:
            varname = varname_header.pop(0) + str(l)
            self.m_cache[varname] = None
            self.m_cacheIsNew[varname] = False
            self.m_units[varname] = units.pop(0)
            self.m_varnames.append(varname)