def refreshDevices(self):
        """Refresh the list of known devices on this bus.

        Currently supported are GPIB devices and GPIB over USB.
        """
        try:
            addresses = visa.get_instruments_list()
            additions = set(addresses) - set(self.devices.keys())
            deletions = set(self.devices.keys()) - set(addresses)
            for addr in additions:
                try:
                    if addr.startswith('GPIB'):
                        instName = addr
                    elif addr.startswith('USB'):
                        instName = addr + '::INSTR'
                    else:
                        continue
                    instr = visa.instrument(instName, timeout=1.0)
                    self.devices[addr] = instr
                    self.sendDeviceMessage('GPIB Device Connect', addr)
                except Exception, e:
                    print 'Failed to add ' + addr + ':' + str(e)
            for addr in deletions:
                del self.devices[addr]
                self.sendDeviceMessage('GPIB Device Disconnect', addr)
예제 #2
0
    def refreshDevices(self):
        """Refresh the list of known devices on this bus.

        Currently supported are GPIB devices and GPIB over USB.
        """
        try:
            addresses = visa.get_instruments_list()
            additions = set(addresses) - set(self.devices.keys())
            deletions = set(self.devices.keys()) - set(addresses)
            for addr in additions:
                try:
                    if addr.startswith('GPIB'):
                        instName = addr
                    elif addr.startswith('USB'):
                        instName = addr + '::INSTR'
                    else:
                        continue
                    instr = visa.instrument(instName, timeout=1.0)
                    instr.clear()
                    self.devices[addr] = instr
                    self.sendDeviceMessage('GPIB Device Connect', addr)
                except Exception, e:
                    print 'Failed to add ' + addr + ':' + str(e)
            for addr in deletions:
                del self.devices[addr]
                self.sendDeviceMessage('GPIB Device Disconnect', addr)
예제 #3
0
def FindUSBDevices() :
    vendors = {'Tektronix' : '0x0699', 'Rigol' : '0x1AB1'}
    devices = {'0x0699' : {'0x0366' : 'TDS1012B', '0x0346' : 'AFG3021B', '0x0368' : 'TDS2014B', '0x0367' : 'TDS2012B'}, '0x1AB1' : {'0x0588' : 'DG1022'}}
    a = v.get_instruments_list()
    # Sort the devices by vendor
    vendor_devices = {}
    for b in a :
        if b.find('USB') > -1 :
            bb = s.split(b, '::')
            for key in vendors :
                if vendors[key] == bb[1] :
                    if len(bb) > 3 :
                        sn = ' SN: ' + bb[3]
                        #print sn, key, vendors[key]
                        vendor_devices[devices[vendors[key]][bb[2]] + '-' + bb[3]] = v.instrument(b)
                    else :
                        vendor_devices[devices[vendors[key]][bb[2]]] = v.instrument(b)
    return vendor_devices   # This is a dictionary with device-sn keys.
예제 #4
0
 def visaHandle(self, forceReload=False):
     """
     Return the VISA handle for this instrument.
     If the VISA connection was lost, it reopens the VISA handle.
     """
     if forceReload or self._handle is None:
         try:
             if self._handle is not None:
                 try:
                     self._handle.close()
                 except:
                     pass
                 self._handle = None
         except:
             pass
         self._handle = visa.instrument(self._visaAddress)
     return self._handle
예제 #5
0
 def test ( self, outfile, s_port, multimeter ):
     #Configuracion de puerto serie para leer valores del LVDT
     self.ser = serial.Serial( port = s_port,
                       baudrate = 9600,
                       parity = serial.PARITY_NONE,
                       stopbits = 1,
                       bytesize = 8,
                       timeout = 2 )
     #Configuracion de Multimetro Agilent 33410A paqra leer termocupla
     self.multimeter = visa.instrument( multimeter )
     self.multimeter.write( '*CLS' )
     time.sleep( 0.1 )
     self.multimeter.write( 'CONF:VOLT:DC AUTO,MAX' )
     time.sleep( 0.5 )
     self.multimeter.write( 'INIT' )
     time.sleep( 0.5 )
     #Otras configuraciones
     self.time_stamp = 0
     self.savedata = False
     self.outfile = outfile
     self.start()
예제 #6
0
 def __init__(self, station_info):
     eqpt = []
     self.stnInst_info = {}
     self.station_info = station_info
     for key in self.station_info.keys():
         if key.startswith('eqpt'):
             eqpt.append(key)
             print "Eqpt List: %s" %eqpt
             self.visaCred = self.station_info[key].split('_')
             print "Visa Credentials %s" %self.visaCred
             addr = "%s::%s" % (self.visaCred[1], self.visaCred[2])
             self.instr = visa.instrument(addr)
             if key.endswith('VOA') and self.visaCred[0] == 'JDSU':
                 self.instrInst = OpticalAttenuator_JDSU(self.instr, self.visaCred)
             elif key.endswith('WLM') and self.visaCred[0] == 'HP86120C':
                 self.instrInst = WLMeter_HP86120C(self.instr)
             elif key.endswith('OPM') and self.visaCred[0] == 'HP81635A':
                 self.instrInst = OpticalPowerMeter_HP81635A(self.instr, self.visaCred)
             else:
                 pass
             res = key + "_" + self.station_info[key]
             self.stnInst_info[res] = self.instrInst
예제 #7
0
    def test(self, outfile, AG34410A, AG34405A):

        #Configuracion de Multimetro Agilent 33410A para leer termocupla
        self.termo = visa.instrument(AG34405A)
        self.lvdt = visa.Instrument(AG34410A)

        self.termo.write('*RST')
        self.lvdt.write('*RST')
        time.sleep(5)

        self.termo.write('CONF:VOLT:DC AUTO')
        self.lvdt.write('CONF:VOLT:AC 10')

        time.sleep(0.1)
        self.lvdt.write('SENS:VOLT:AC:BAND 20')
        time.sleep(0.5)

        #Otras configuraciones
        self.time_stamp = 0
        self.savedata = False
        self.outfile = outfile
        self.errorfile = outfile + '_errorlog.txt'
        self.start()
    def __init__(self, name, address):
        '''
        Initializes the Oxford Instruments IPS 120 Magnet Power Supply.

        Input:
            name (string)    : name of the instrument
            address (string) : instrument address
            number (int)     : ISOBUS instrument number

        Output:
            None
        '''
        logging.debug(__name__ + ' : Initializing instrument')
        Instrument.__init__(self, name, tags=['physical'])


        self._address = address
        self._visainstrument = visa.instrument(self._address,timeout=20)
        self._values = {}
        self._visainstrument.term_chars = '\r\n'

        #Add parameters
        
        #x,y,z -> enter setpoint
        #coordinate system
        #sweep mode: rate overall,time to setpoint, fast as possible
        #to setpoint
        #hold
        #to zero
        
        
        self.add_parameter('coordinatesys', type=types.StringType,
            #READ:SYS:VRM:COO
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            format_map = {
            'CART' : "Cartresian",
            'CYL' : "Cyclindrical",
            'SPH' : "Spherical",
            })
            
        # # channels with prefix
        # self.add_parameter('magn', type=types.FloatType,
                # flags=Instrument.FLAG_GETSET,
                # channels=('X', 'Y', 'Z'))
                
        self.add_parameter('vector', type=types.StringType,
            #dependent on coordinate system
            #get current magnet vector
            #READ:SYS:VRM:VECT
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            channels=('X', 'Y', 'Z'))
        
        self.add_parameter('target_vector', type=types.FloatType,
            #READ:SYS:VRM:TVEC
            flags=Instrument.FLAG_GETSET,
            channels=('X', 'Y', 'Z'))
        
        self.add_parameter('max_field_sweep', type=types.StringType,
            #max field sweep
            #[dBx/dt dBy/dt dBz/dt], tesla/minute
            #READ:SYS:VRM:RFMX
            flags=Instrument.FLAG_GET)
        
        self.add_parameter('sweep_mode', type=types.StringType,
            #READ:SYS:VRM:RVST:MODE 
            #return string+ asap | time | rate
            flags=Instrument.FLAG_GET)
        
        
        
        #magnet setpoints
        #READ:SYS:VRM:VSET
        #self.add_parameter('setpoint', type=types.FloatType,
        #    flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET)
            

        self.add_parameter('activity', type=types.StringType,
            #READ:SYS:VRM:ACTN 
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            format_map = {
            'RTOS' : "Sweep to setpoint",
            'RTOZ' : "Sweep to zero",
            'HOLD' : "Hold",
            'IDLE' : 'Idle',
            'PERS' : 'Make persistent',
            'NPERS': 'Make non-persistent',
            'SAFE' : "Safe"})
            


        # Add functions
        self.add_function('get_all')
        self.get_all()
예제 #9
0
from pyvisa import visa
from instruments.ThorlabsPM100_meta import *
from jds_ha9 import *
import numpy as np
from matplotlib import pyplot as plt
from time import sleep

#initiate the power meter
inst = visa.instrument('USB0::0x1313::0x8078::PM002229::INSTR',
                       term_chars='\n',
                       timeout=1)
pm = ThorlabsPM100Meta(inst)
#initiate the optical attenuator
att = JDSHA9('GPIB::5')
att.set_beam_block(False)

attenuation = np.linspace(5, 50, 20)
#the intial setting takes time
att.set_attenuation_db(attenuation[0])
sleep(1)

power = []
for attn in attenuation:
    att.set_attenuation_db(attn)
    sleep(0.5)
    power.append(pm.read_value())

plt.plot(np.array(attenuation), 10 * np.log10(np.array(power) * 1000), 'o')
plt.xlabel('Attenuation (dB)')
plt.ylabel('Optical Power (dBm)')
plt.title('Attenuation vs. Power')
    def __init__(self, name, address):
        '''
        Initializes the Oxford Instruments IPS 120 Magnet Power Supply.

        Input:
            name (string)    : name of the instrument
            address (string) : instrument address
            number (int)     : ISOBUS instrument number

        Output:
            None
        '''
        logging.debug(__name__ + ' : Initializing instrument')
        Instrument.__init__(self, name, tags=['physical'])


        self._address = address
        self._visainstrument = visa.instrument(self._address,timeout=100)
        self._values = {}
        self._visainstrument.term_chars = '\r\n'

        self._x = 0.
        self._y = 0.
        self._z = 0.

        #Add parameters
        
        #x,y,z -> enter setpoint
        #coordinate system
        #sweep mode: rate overall,time to setpoint, fast as possible
        #to setpoint
        #hold
        #to zero
        
        
        self.add_parameter('coordinatesys', type=types.StringType,
            #READ:SYS:VRM:COO
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            format_map = {
            'CYL' : "Cylindrical",
            'CART' : "Cartesian",
            'SPH' : "Spherical",
            })
            
        # # channels with prefix
        # self.add_parameter('magn', type=types.FloatType,
                # flags=Instrument.FLAG_GETSET,
                # channels=('X', 'Y', 'Z'))
                
        self.add_parameter('vector', type=types.StringType,
            #dependent on coordinate system
            #get current magnet vector
            #READ:SYS:VRM:VECT
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            channels=('X', 'Y', 'Z'))
        
        self.add_parameter('target_vector', type=types.FloatType,
            #READ:SYS:VRM:TVEC
            flags=Instrument.FLAG_GETSET,
            channels=('X', 'Y', 'Z'))
        
        self.add_parameter('max_field_sweep', type=types.StringType,
            #max field sweep
            #[dBx/dt dBy/dt dBz/dt], tesla/minute
            #READ:SYS:VRM:RFMX
            flags=Instrument.FLAG_GET)
        
        self.add_parameter('sweep_mode', type=types.StringType,
            #READ:SYS:VRM:RVST:MODE 
            #return string+ asap | time | rate
            flags=Instrument.FLAG_GET)
        
        
        
        #magnet setpoints
        #READ:SYS:VRM:VSET
        #self.add_parameter('setpoint', type=types.FloatType,
        #    flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET)
            

        self.add_parameter('activity', type=types.StringType,
            #READ:SYS:VRM:ACTN 
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            format_map = {
            'RTOS' : "Sweep to setpoint",
            'RTOZ' : "Sweep to zero",
            'HOLD' : "Hold",
            'IDLE' : 'Idle',
            'PERS' : 'Make persistent',
            'NPERS': 'Make non-persistent',
            'SAFE' : "Safe"})
            


        # Add functions
        self.add_function('get_all')
        self.get_all()