| Contents | Index |
| On this page… |
|---|
Base and Interface-Specific Properties |
You establish the desired instrument object behavior by configuring property values. You can configure property values using the set function or the dot notation, or by specifying property name/property value pairs during object creation. You can return property values using the get function or the dot notation.
Interface objects possess two types of properties:
Base Properties: These are supported for all interface objects (serial port, GPIB, VISA-VXI, and so on). For example, the BytesToOutput property is supported for all interface objects.
Interface-Specific Properties: These are supported only for objects of a given interface type. For example, the BaudRate property is supported only for serial port and VISA-serial objects.
Once the instrument object is created, you can use the set function to return all configurable properties to a variable or to the command line. Additionally, if a property has a finite set of string values, then set also returns these values.
For example, the configurable properties for the GPIB object g are shown below. The base properties are listed first, followed by the GPIB-specific properties.
g = gpib('ni',0,1);
set(g)
ByteOrder: [ {littleEndian} | bigEndian ]
BytesAvailableFcn
BytesAvailableFcnCount
BytesAvailableFcnMode: [ {eosCharCode} | byte ]
ErrorFcn
InputBufferSize
Name
OutputBufferSize
OutputEmptyFcn
RecordDetail: [ {compact} | verbose ]
RecordMode: [ {overwrite} | append | index ]
RecordName
Tag
Timeout
TimerFcn
TimerPeriod
UserData
GPIB specific properties:
BoardIndex
CompareBits
EOIMode: [ {on} | off ]
EOSCharCode
EOSMode: [ {none} | read | write | read&write ]
PrimaryAddress
SecondaryAddressYou can use the get function to return one or more properties and their current values to a variable or to the command line.
For example, all the properties and their current values for the GPIB object g are shown below. The base properties are listed first, followed by the GPIB-specific properties.
get(g)
ByteOrder = littleEndian
BytesAvailable = 0
BytesAvailableFcn =
BytesAvailableFcnCount = 48
BytesAvailableFcnMode = eosCharCode
BytesToOutput = 0
ErrorFcn =
InputBufferSize = 512
Name = GPIB0-1
OutputBufferSize = 512
OutputEmptyFcn =
RecordDetail = compact
RecordMode = overwrite
RecordName = record.txt
RecordStatus = off
Status = closed
Tag =
Timeout = 10
TimerFcn =
TimerPeriod = 1
TransferStatus = idle
Type = gpib
UserData = []
ValuesReceived = 0
ValuesSent = 0
GPIB specific properties:
BoardIndex = 0
BusManagementStatus = [1x1 struct]
CompareBits = 8
EOIMode = on
EOSCharCode = LF
EOSMode = none
HandshakeStatus = [1x1 struct]
PrimaryAddress = 1
SecondaryAddress = 0To display the current value for one property, you supply the property name to get.
get(g,'OutputBufferSize') ans = 512
To display the current values for multiple properties, you include the property names as elements of a cell array.
get(g,{'BoardIndex','TransferStatus'})
ans =
[0] 'idle'You can also use the dot notation to display a single property value.
g.PrimaryAddress
ans =
1You can configure property values using the set function
set(g,'EOSMode','read')
or the dot notation.
g.EOSMode = 'read';
To configure values for multiple properties, you can supply multiple property name/property value pairs to set.
set(g,'EOSCharCode','CR','Name','Test1-gpib')
Note that you can configure only one property value at a time using the dot notation.
In practice, you can configure many of the properties at any time while the instrument object exists — including during object creation. However, some properties are not configurable while the object is connected to the instrument or when recording information to disk. Use the propinfo function, or refer to Properties — Alphabetical List to understand when you can configure a property.
Instrument object property names are presented using mixed case. While this makes property names easier to read, you can use any case you want when specifying property names. Additionally, you need use only enough letters to identify the property name uniquely, so you can abbreviate most property names. For example, you can configure the EOSMode property in any of these ways.
set(g,'EOSMode','read') set(g,'eosmode','read') set(g,'EOSM','read')
However, when you include property names in a file, you should use the full property name. This practice can prevent problems with future releases of the Instrument Control Toolbox software if a shortened name is no longer unique because of the addition of new properties.
If you do not explicitly define a value for a property, then the default value is used. All configurable properties have default values.
Note Default values are provided for all instrument object properties. For serial port objects, the default values are provided by your operating system. For GPIB and VISA instrument objects, the default values are provided by vendor-supplied tools. However, these settings are overridden by your MATLAB code, and will have no effect on your instrument control application. |
If a property has a finite set of string values, then the default value is enclosed by {} (curly braces). For example, the default value for the EOSMode property is none.
set(g,'EOSMode')
[ {none} | read | write | read&write ]You can also use the propinfo function, or refer to Functions — Alphabetical List to find the default value for any property.
The Property Inspector enables you to inspect and set properties for one or more instrument objects. It provides a list of all properties and displays their current values.
Settable properties in the list are associated with an editing device that is appropriate for the values accepted by the particular property. For example, a callback configuration GUI to set ErrorFcn, a pop-up menu to set RecordMode, and a text field to specify the TimerPeriod. The values for read-only properties are grayed out.
You open the Property Inspector with the inspect function. Alternatively, you can open the Property Inspector via the Workspace browser by right-clicking an instrument object and selecting Call Property Inspector from the context menu, or by double-clicking the object.

![]() | Connecting to the Instrument | Writing and Reading Data | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |