Main Content

visadev

Create connection to device using VISA

    Description

    A visadev object represents a connection to a device or instrument using the VISA interface. The following interface types are supported: TCP/IP (using VXI11 and HiSLIP), TCP/IP Socket, USB, GPIB, Serial, VXI, and PXI. Identify devices available to connect to using visadevlist. Then, connect to the device or instrument using visadev.

    Creation

    Description

    example

    v = visadev(resourceName) creates a connection to a device using its VISA resource name. Establish a connection using an installed VISA driver. If you have multiple VISA drivers installed, MATLAB® uses the preferred VISA set in your VISA vendor's configuration utility software.

    example

    v = visadev(resourceAlias) creates a connection to a device using its VISA alias, if it has one. If the configuration utility does not yet recognize the device, you cannot connect using the alias and must use the resource name.

    Input Arguments

    expand all

    VISA resource name, specified as a character vector or string scalar. You can identify the name of the resource you want to connect to using the information returned by visadevlist. This input sets the ResourceName property.

    Example: gpibdev = visadev("GPIB0::5::INSTR") connects to the GPIB device specified by the VISA resource name GPIB0::5::INSTR.

    Data Types: char | string

    VISA alias associated with a resource, specified as a character vector or string scalar. Identify the alias of the resource you want to connect to using the information returned by visadevlist. You can use an alias only if an alias is assigned using the VISA vendor’s configuration utility software. This input sets the Alias property.

    Example: serialdev = visadev("COM4") connects to the serial device specified by the VISA resource alias COM4.

    Data Types: char | string

    Properties

    See visadev Properties for a full list of properties.

    Object Functions

    readRead data from VISA resource
    readlineRead line of ASCII string data from VISA resource
    readbinblockRead one binblock of data from VISA resource
    writeWrite data to VISA resource
    writelineWrite line of ASCII data to VISA resource
    writebinblockWrite one binblock of data to VISA resource
    writereadWrite command to VISA resource and read response
    configureTerminatorSet terminator for ASCII string communication with VISA resource
    configureCallbackSet callback function and trigger condition for communication with VISA resource
    flushClear buffers for communication with VISA resource
    visastatusCheck status of VISA resource
    visatriggerSend trigger message to GPIB or VXI instruments
    setDTRSet serial DTR pin
    setRTSSet serial RTS pin
    getpinstatusGet serial pin status

    Examples

    collapse all

    Search for and establish a connection to your VISA resource.

    Search for available VISA resources.

    resourceList = visadevlist
    resourceList =
    
      6×6 table
    
                            ResourceName                         Alias                  Vendor               Model       SerialNumber     Type 
             __________________________________________    _________________    ______________________    ___________    ____________    ______
    
        1    "USB0::0x0699::0x036A::CU010105::0::INSTR"    "NI_SCOPE_4CH"       "TEKTRONIX"               "TDS 2024B"    "CU010105"      usb   
        2    "TCPIP0::169.254.2.20::inst0::INSTR"          "Keysight_33210A"    "Agilent Technologies"    "33210A"       "MY57003523"    tcpip 
        3    "ASRL1::INSTR"                                "COM1"               ""                        ""             ""              serial
        4    "ASRL3::INSTR"                                "COM3"               ""                        ""             ""              serial
        5    "GPIB0::5::INSTR"                             "FGEN_2CH"           "Agilent Technologies"    "33522B"       "MY52800145"    gpib  
        6    "GPIB0::11::INSTR"                            "OSCOPE_2CH"         "TEKTRONIX"               "TDS 1002"     "0"             gpib  
    

    Create a connection to the first resource over the VISA-USB interface using the resource name.

    usbdev = visadev("USB0::0x0699::0x036A::CU010105::0::INSTR")
    usbdev = 
    
      USB with properties:
    
             ResourceName: "USB0::0x0699::0x036A::CU010105::0::INSTR"
                    Alias: "NI_SCOPE_4CH"
                   Vendor: "TEKTRONIX"
                    Model: "TDS 2024B"
        NumBytesAvailable: 0
    
      Show all properties, functions
    

    Alternatively, you can connect to a device using its alias.

    serialdev = visadev("COM1")
    serialdev = 
    
      Serial with properties:
    
             ResourceName: "ASRL1::INSTR"
                    Alias: "COM1"
                     Port: "ASRL1"
                 BaudRate: 9600
        NumBytesAvailable: 0
    
      Show all properties, functions
    

    See Also

    Introduced in R2021a