icdevice
Create device object
Syntax
obj = icdevice('driver', hwobj)
obj = icdevice('driver', 'RsrcName')
obj = icdevice('driver')
obj = icdevice('driver', hwobj, 'P1
',
V1, 'P2
', V2,...)
obj = icdevice('driver', 'RsrcName','P1
',
V1, 'P2
', V2,...)
obj = icdevice('driver','P1
',
V1, 'P2
', V2,...)
Arguments
| A MATLAB® instrument driver. |
| An interface object. |
| VISA resource name. |
| Device-specific property names. |
| Property values supported by corresponding
|
| A device object. |
Description
obj = icdevice('driver', hwobj)
creates
the device object obj
. The instrument-specific information is
defined in the MATLAB interface instrument driver, driver
. 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('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. Communication to the instrument is done through the
resource specified by rsrcname
. For example, all
VXIplug&play, and many IVI drivers require VISA resource names for
rsrcname
.
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('driver', hwobj, '
,
P1
',
V1, 'P2
', V2,...)obj = icdevice('driver', 'RsrcName','
,
and
P1
',
V1, 'P2
', V2,...)obj = icdevice('driver','
,
construct a device object, P1
',
V1, 'P2
', V2,...)obj
, with the specified property
values. If an invalid property name or property value is specified, the object will
not be created.
Note that the parameter-value pairs can be in any format supported by the
set
function: parameter-value character vector pairs,
structures, and parameter-value cell array pairs.
Additionally, you can specify property names without regard to case, and you can make use of property name completion. For example, these commands are all valid and equivalent:
d = icdevice('tektronix_tds210',g,'ObjectVisibility','on'); d = icdevice('tektronix_tds210',g,'objectvisibility','on'); d = icdevice('tektronix_tds210',g,'ObjectVis','on');
Note About Deploying Code
When using IVI-C or VXI Plug&Play drivers, executing your code will generate additional file(s) 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 VXI Plug&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
The first example creates 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);
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]);
The second example creates 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
ormultimeter
).
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
ICDEVICE is unable to open MDDs with non-ascii characters either in their name or path on Mac platforms.
Note
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.
Version History
Introduced before R2006a
See Also
connect
| disconnect
| Status