Esempio n. 1
0
def get_model_name(address):
    """Physically queries the instrument model at the given address"""

    from visa import VisaIOError
    import visa
    model = "no device"
    try:
        instr = visa.Instrument(str(address))
        timeout = instr.timeout
    except VisaIOError:
        print("instrument at address " + str(address) + " didn't reply in "
              "time...")
    else:
        try:
            instr.timeout = 0.1
            ret = instr.ask("*IDN?")
        except (VisaIOError, TypeError):
            print("instrument at address " + \
                address + \
                " didn't reply in time...")
        else:
            model = ret.split(",")[1]
            model = model.replace(' ', '')
        finally:
            instr.timeout = timeout
    return model
Esempio n. 2
0
 def __connectLAN(self, device):
     """connects to the rigol powersupply"""
     if hasattr(visa, "instrument"):
         self.__ip = device
         self.__instr = visa.Instrument(self.__ip, term_chars='\n')
         self.__instr.timeout = 2
     else:
         self.__ip = device
         self.__instr = visa.ResourceManager().open_resource(device)
         self.__instr.read_termination = '\n'
         self.__instr.write_termination = '\n'
         self.__instr.timeout = 2000
     self.__instr.chunk_size = 4096
    def connect(self):
        """
		Make a connection to the device.
		"""

        log.info('Connecting to device "{0}" using {1} at "{2}".'.format(
            self.name, self.driver, self.connection_resource))

        if self.driver == drivers.pyvisa:
            try:
                self.device = visa.Instrument(**self.connection_resource)
            except visa.VisaIOError as e:
                raise DeviceNotFoundError(
                    'Could not open device at "{0}".'.format(
                        self.connection_resource), e)
        elif self.driver == drivers.lgpib:
            try:
                self.device = Gpib.Gpib(**self.connection_resource)
            except gpib.GpibError as e:
                raise DeviceNotFoundError(
                    'Could not open device at "{0}".'.format(
                        self.connection_resource), e)
        elif self.driver == drivers.pyvisa_usb:
            try:
                if not (legacyVisa):
                    rm = visa.ResourceManager()
                    self.device = rm.open_resource(**self.connection_resource)
                else:

                    class USBDevice(visa.Instrument):
                        """
						Using USB devices with PyVISA requires a small hack: the object must be an Instrument, but we can't call Instrument.__init__.
						"""
                        def __init__(self, *args, **kwargs):
                            # Bypass the initialization in visa.Instrument, due to "send_end" not being valid for USB.
                            visa.ResourceTemplate.__init__(
                                self, *args, **kwargs)

                    self.device = USBDevice(**self.connection_resource)

            except visa.VisaIOError as e:
                raise DeviceNotFoundError(
                    'Could not open device at "{0}".'.format(
                        self.connection_resource), e)

        try:
            self._connected()
        except Exception as e:
            raise DeviceNotFoundError(
                'Could not finish connection to device at "{0}".'.format(
                    self.connection_resource), e)
Esempio n. 4
0
 def __connectLAN(self, device):
     """connects to the tektronix function generator"""
     if hasattr(pyvisa, "instrument"):  #old visa
         self.__ip = device
         self.__instr = visa.Instrument(self.__ip, term_chars='\n')
         self.__instr.timeout = 2
     else:
         self.__ip = device
         rm = visa.ResourceManager()
         self.__instr = rm.open_resource(device)
         self.__instr.read_termination = '\n'
         self.__instr.write_termination = '\n'
         self.__instr.timeout = 2000
     self.__instr.chunk_size = 4096
Esempio n. 5
0
def get_model_name(address):
    """Physically queries the instrument model at the given address"""
    from visa import VisaIOError
    import visa
    model = "no device"
    try:
        instr = visa.Instrument(str(address))
        timeout = instr.timeout
    except VisaIOError:
        print "instrument at address " + str(
            address) + " didn't reply in time..."
    else:
        try:
            instr.timeout = 0.1
            ret = instr.ask("*IDN?")
        except VisaIOError, TypeError:
            print "instrument at address " + \
                address + \
                " didn't reply in time..."
        else:
Esempio n. 6
0
def test_itc4():
    print("Test start")
    itc4 = visa.Instrument("COM2", term_chars=b"\r", timeout=5)
    itc4.write(b"V")
    print(itc4.read())
    print("Test end")
Esempio n. 7
0
 def __connectGPIB(self, device):
     self.__instr = visa.Instrument(device)
Esempio n. 8
0
 def __init__(self, address='192.168.0.3', **kwargs):
     import vxi11 as v
 
     self.inst = v.Instrument(address)
     Driver.__init__(self, **kwargs)