icdevice
Create device object
Description
Use icdevice to create a MATLAB® device object.
Creation
Syntax
Description
obj = icdevice(
creates the device object driver,hwobj)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.
obj = icdevice(
creates a device object driver,rsrcname)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.
obj = icdevice( constructs a device
object driver)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(___,
constructs a device object Name,Value)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
Tips
At any time, you can use the instrhelp function to view a complete
listing of properties and functions associated with device objects.
instrhelp icdeviceWhen you create a device object, these property values are automatically configured:
Interfacespecifies 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.LogicalNameis an IVI logical name. For non-IVI drivers, it is empty.Nameis given by concatenating the instrument type with the name of the instrument driver.RsrcNameis the full VISA resource name for VXIplug&play and IVI drivers. For MATLAB interface drivers,RsrcNameis an empty character vector.Typeis the instrument type, if known (for example,scopeormultimeter).The
icdevicefindfunction finds only those device connections created withLegacyMode=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.