Main Content

visadev

Create connection to device using VISA

Since R2021a

    Description

    Avisadevobject 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 usingvisadevlist. Then, connect to the device or instrument usingvisadev.

    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 byvisadevlist. This input sets the再保险sourceNameproperty.

    Example:gpibdev = visadev(“GPIB0:: 5:: INSTR”)connects to the GPIB device specified by the VISA resource nameGPIB0::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 byvisadevlist. You can use an alias only if an alias is assigned using the VISA vendor’s configuration utility software. This input sets theAliasproperty.

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

    Data Types:char|string

    Properties

    Seevisadev Propertiesfor a full list of properties.

    Object Functions

    read 再保险ad data from VISA resource
    readline 再保险ad line of ASCII string data from VISA resource
    readbinblock 再保险ad one binblock of data from VISA resource
    write Write data to VISA resource
    writeline Write line of ASCII data to VISA resource
    writebinblock Write one binblock of data to VISA resource
    writeread Write command to VISA resource and read response
    configureTerminator Set terminator for ASCII string communication with VISA resource
    flush Clear buffers for communication with VISA resource
    visastatus Check status of VISA resource
    visatrigger Send trigger to GPIB or VXI instruments
    setDTR Set serial DTR pin
    setRTS Set serial RTS pin
    getpinstatus Get 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" 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 Show all properties, functions

    Version History

    Introduced in R2021a

    expand all

    See Also