Esempio 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)
Esempio n. 2
0
 def test_several_insts(self):
     test_instrument1 = Instrument('Warranty Deed', datetime.strptime('12/29/06', '%m/%d/%y'), datetime.strptime('1/3/07', '%m/%d/%y'), 'Real Property Book', 1842, 448)
     test_instrument2 = Instrument('Statutory Warranty Deed', datetime.strptime('02/09/12', '%m/%d/%y'), datetime.strptime('3/8/12', '%m/%d/%y'), 'Real Property Book', 1842, 448)
     test_instrument3 = Instrument('Easement', datetime.strptime('12/29/15', '%m/%d/%y'), datetime.strptime('1/3/16', '%m/%d/%y'), 'Real Property Book', 1842, 448)
     report = [test_instrument1, test_instrument2, test_instrument3]
     self.assertFalse(test_instrument1.get_name() is test_instrument2.get_name(), msg='Just as I suspected.')
     return report
Esempio 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_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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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])
Esempio n. 7
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'
Esempio 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._xze = None
        self._xin = None
        self._yze = None
        self._ymu = None
        self._yoff = None

        self.setup_curve()
        self.get_waveform_preamble()
Esempio n. 9
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)
Esempio n. 10
0
    def exit(self, instrument: Instrument = None, exit_all: bool = False):
        """
        Remove instrument from stage AND disconnect it if it is a physical
        instrument. Delete attribute too. Option to exit all instruments and
        reset stage.
        """
        if exit_all:
            for instr_name in self._instruments:
                delattr(self, instr_name)
                instrument_ = self._instruments[instr_name]
                if isinstance(instrument_, PhysicalInstrument):
                    instrument_.disconnect()
            self._instruments = dict()
            return

        # TODO catch error if instrument is None
        if instrument in self._instruments.values():
            if isinstance(instrument, PhysicalInstrument):
                instrument.disconnect()
            del self._instruments[instrument.name]
            delattr(self, instrument.name)
        else:
            print(
                'This instrument is not even part of the stage wot u doin ?!')
Esempio n. 11
0
"""

import numpy as np
import matplotlib.pyplot as plt
from instruments import Instrument
from lockin import Lockin
import time

path = r'D:/Grupo1-2do2017/'

loc_resource = 'GPIB0::8::INSTR'
gen_resource = 'USB0::0x0699::0x0346::C034167::INSTR'

loc = Lockin(resource=loc_resource, backend='', path=path)

gen = Instrument(resource=gen_resource, backend='', path=path)

#%% Medición 00 a 08

n = 500 + 1
prom = 1
Vi = -2.0
Vf = 2.0
V = np.linspace(Vi, Vf, n)
X = np.zeros(n)
Y = np.zeros(n)
R = np.zeros(n)

loc.auxiliar_outs.AuxOut1 = V[0]
#time.sleep(10)
Esempio n. 12
0
Created on Mon Jun 26 18:29:43 2017

@author: ??
"""
import numpy as np
import matplotlib.pyplot as plt

#==============================================================================
# Arreglar esto
# from instrumentosProvisorios import Osciloscopio
#==============================================================================
from instruments import Instrument, Oscilloscope
import time

tec = Instrument(resource='USB0::0x1313::0x804A::M00404166::0::INSTR',
                 backend='',
                 path='D:/ALUMNOS/Grupo 1/Espectro Rb')
osci = Oscilloscope(resource='USB0::0x0699::0x0363::C102220::0::INSTR',
                    backend='',
                    path='D:/ALUMNOS/Grupo 1/Espectro Rb')

#==============================================================================
# Ejemplos:
# tec.write('SOUR:CURR 0.0015')
# tec.write('SOUR2:TEMP 25C')
#==============================================================================


#%%%
# Adquisición de temperatura:
def medir(cantidad='TEMP', n=10000, ax=None, **kwargs):
Esempio n. 13
0
#!/usr/bin/python

# this contains functions to controll an HP 3325A frequency synthesizer using a Galvant industries USB-GPIB controller
# it depends on classes porvided by Galvant

from instruments import Instrument as ik
from time import sleep
from random import randint

#inst = ik.open_gpibusb('/dev/ttyUSB0', 17)
#inst.sendcmd('FR9KHZ')

inst = ik.open_gpibusb('/dev/ttyUSB0', 17)


def onstate():
    #continue to add functions i.e. sweep, offset
    inst.sendcmd('FU1AM1MVPH0DEFR1KH')


def set_frequency(freq, unit):

    if unit == 'HZ' or unit == 'KH' or unit == 'MH':
        inst.sendcmd('FR%s%s' % (str(freq), unit))
    else:
        print 'invalid unit or value'


def set_amplitude(value, unit):
    if unit == 'VO' or unit == 'MV' or unit == 'VR' or unit == 'MR':
        inst.sendcmd('AM%s%s' % (str(value), unit))
Esempio n. 14
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)
Esempio n. 15
0
 def test_dates(self):
     test_instrument = Instrument('Warranty Deed', datetime.strptime('12/29/06', '%m/%d/%y'), datetime.strptime('1/3/07', '%m/%d/%y'), 'Real Property Book', 1842, 448)
     self.assertIsInstance(test_instrument.get_inst_date(), datetime, msg='Instrument date did not go through as a datetime.')
     self.assertIsInstance(test_instrument.get_rec_date(), datetime, msg='Instrument rec date did not go through as a datetime.')
     return