Main Content

icdevice

Create device object

    Description

    Use icdevice to create a MATLAB® device object.

    Creation

    Description

    obj = icdevice(driver,hwobj) creates the device object obj. The instrument-specific information is defined in the MATLAB interface instrument driver, driver, which is specified as a string. Communication to the instrument is done through the interface object, hwobj. The interface object can be a serial port, GPIB, VISA, TCPIP, or UDP object. If driver does not exist or if hwobj is invalid, the device object is not created.

    Device objects may also be used with VXIplug&play and Interchangeable Virtual Instrument (IVI®) drivers. To use these drivers, you must first have a MATLAB instrument driver wrapper for the underlying VXIplug&play or IVI driver. If the MATLAB instrument driver wrapper does not already exist, it may be created using makemid or midedit. Note that makemid or midedit only needs to be used once to create the MATLAB instrument driver wrapper.

    example

    obj = icdevice(driver,rsrcname) creates a device object obj, using the MATLAB instrument driver, driver. The specified driver must be a MATLAB VXIplug&play instrument driver or MATLAB IVI instrument driver and is specified as a string. Communication to the instrument is done through the resource specified by rsrcname as a string. For example, all VXIplug&play, and many IVI drivers require VISA resource names for rsrcname.

    example

    obj = icdevice(driver) constructs a device object obj, using the MATLAB instrument driver, driver. The specified driver must be a MATLAB IVI instrument driver, and the underlying IVI driver must be referenced using a logical name.

    obj = icdevice(___,LegacyMode=false) creates a device object using the non-legacy mode, consistent with the latest behaviors of the icdevice object. When LegacyMode=true (default), the icdevice behavior is consistent with past releases before R2024b. (Note: Legacy mode will be removed in a future release. See Version History.)

    obj = icdevice(___,Name,Value) constructs a device object obj using one or more name-value arguments in addition to the input arguments in previous syntaxes.

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter. You can specify names without regard to case, and you can make use of name completion. For example, these commands are all valid and equivalent:

    d = icdevice('tektronix_tds210',g,LegacyMode=false);
    d = icdevice('tektronix_tds210',g,Legacy=false);
    d = icdevice('tektronix_tds210',g,legacy=false);

    Note

    When deploying code using IVI-C or VXIplug&play drivers, executing your code will generate additional files in the folder specified by executing the following code at the MATLAB prompt:

    fullfile(tempdir,'ICTDeploymentFiles',sprintf('R%s',version('-release')))

    On all supported platforms, a file with the name MATLABPrototypeFor<driverName>.m is generated, where <driverName> the name of the IVI-C or VXIplug&play driver. With 64-bit MATLAB on Windows®, a second file by the name <driverName>_thunk_pcwin64.dll is generated. When creating your deployed application or shared library, manually include these generated files. If using the icdevice function, remember to also manually include the MDD-file in the deployed application or shared library. For more information on including additional files refer to the MATLAB Compiler™ documentation.

    Examples

    collapse all

    Create a device object for a Tektronix® TDS 210 oscilloscope that is connected to a MCC GPIB board, using a MATLAB interface object and MATLAB interface instrument driver.

    g = gpib('mcc',0,2);
    d = icdevice('tektronix_tds210',g,LegacyMode=false);

    Connect to the instrument.

    connect(d);

    List the oscilloscope settings that can be configured.

    props = set(d);

    Get the current configuration of the oscilloscope.

    values = get(d);

    Disconnect from the instrument and clean up.

    disconnect(d);
    delete([d g]);

    Create a device object for a Tektronix TDS 210 oscilloscope using a MATLAB VXIplug&play instrument driver.

    This example assumes that the 'tktds5k' VXIplug&play driver is installed on your system.

    This first step is necessary only if a MATLAB VXIplug&play instrument driver for the tktds5k does not exist on your system.

    makemid('tktds5k','Tktds5kMATLABDriver');

    Construct a device object that uses the VXIplug&play driver. The instrument is assumed to be located at GPIB primary address 2.

    d = icdevice('Tktds5kMATLABDriver','GPIB0::2::INSTR');

    Connect to the instrument.

    connect(d);

    List the oscilloscope settings that can be configured.

    props = set(d);

    Get the current configuration of the oscilloscope.

    values = get(d);

    Disconnect from the instrument and clean up.

    disconnect(d);
    delete(d);

    Tips

    At any time, you can use the instrhelp function to view a complete listing of properties and functions associated with device objects.

    instrhelp icdevice

    When you create a device object, these property values are automatically configured:

    • Interface specifies the interface used to communicate with the instrument. For device objects created using interface objects, it is that interface object. For VXIplug&play and IVI-C, this is the session handle to the driver session. For MATLAB instrument drivers, this is the handle to the driver's default COM interface.

    • LogicalName is an IVI logical name. For non-IVI drivers, it is empty.

    • Name is given by concatenating the instrument type with the name of the instrument driver.

    • RsrcName is the full VISA resource name for VXIplug&play and IVI drivers. For MATLAB interface drivers, RsrcName is an empty character vector.

    • Type is the instrument type, if known (for example, scope or multimeter).

    • The icdevicefind function finds only those device connections created with LegacyMode=false.

    To communicate with the instrument, the device object must be connected to the instrument with the connect function. When the device object is constructed, the object's Status property is closed. Once the device object is connected to the instrument with the connect function, the Status property is configured to open.

    Note

    On Mac platforms, icdevice is unable to open MDDs with non-ASCII characters in their name or path.

    Version History

    Introduced before R2006a

    expand all