Transition Your Code to visadev
Interface
The visa
function, its object functions, and its properties will be
removed. Use visadev
instead.
visa Interface | visadev Interface | Example |
---|---|---|
instrhwinfo | visadevlist | Discover VISA Devices |
instrfind and
instrfindall | visadevfind | Find Existing VISA Device Connections |
visa and fopen | visadev | Connect to VISA Device |
fwrite | write | Write and Read Binary or String Data |
fread | read | |
fprintf | writeline | Read Terminated String |
fscanf | readline | Read Terminated String |
fgetl | Read and Parse String Data | |
fgets | ||
query | writeread | Write and Read Back Data |
binblockwrite | writebinblock | Write and Read Binblock Data |
binblockread | readbinblock | |
flushinput , flushoutput , and
clrdevice | flush | Flush Data from Memory |
Terminator | configureTerminator | Set Terminator |
spoll | visastatus | |
trigger | visatrigger | |
PinStatus | getpinstatus | |
DataTerminalReady and
RequestToSend | setDTR and setRTS | |
RsrcName | ResourceName | |
EOSMode and EOSCharCode | Terminator | |
ErrorFcn | ErrorOccurredFcn | |
ManufacturerID | VendorID | |
ModelCode | ProductID | |
fclose | clear and delete | Disconnect VISA Device Connection |
Removed Functionality
The memmap
, mempeek
,
mempoke
, memread
,
memunmap
, and memwrite
functions and
the MappedMemoryBase
, MappedMemorySize
,
MemoryBase
, MemoryIncrement
,
MemorySize
, MemorySpace
properties
will be removed. VISA-VXI register-based communication is not available in the
updated interface.
The TriggerFcn
, TriggerLine
, and
TriggerType
properties will be removed. You can send a
trigger message to VISA-GPIB or VISA-VXI instruments using
visatrigger
in the updated interface.
The ValuesReceived
and
ValuesSent
properties will be removed.
The readasync
and
stopasync
functions and the
ReadAsyncMode
and TransferStatus
properties will be removed. The updated interface reads data synchronously.
The BytesToOutput
,
InputBufferSize
, and OutputBufferSize
properties will be removed. Buffer sizes are automatically managed and sized as
needed in the updated interface.
The BytesAvailableFcnCount
,
BytesAvailableFcnMode
,
BytesAvailableFcn
, BytesAvailable
,
OutputEmptyFcn
, and InterruptFcn
properties will be removed. Callback functions are not supported in the updated
interface.
The RecordDetail
, RecordMode
,
RecordName
, and RecordStatus
properties will be removed.
The TimerFcn
and TimerPeriod
properties
will be removed. Use timer
instead.
The Name
, Type
,
ObjectVisibility
, Status
, and
Tag
properties will be removed.
Discover VISA Devices
This example shows how to discover VISA devices using the recommended functionality.
Functionality | Use This Instead |
---|---|
instrhwinfo('visa','ni') |
visadevlist |
For more information, see visadevlist
.
Find Existing VISA Device Connections
instrfind
and instrfindall
will be removed.
Use visadevfind
instead. (since R2024a)
Connect to VISA Device
These examples show how to connect to a VISA device and disconnect from it using the recommended functionality.
Functionality | Use This Instead |
---|---|
v = visa('ni','GPIB::1::0::INSTR') fopen(v) |
v = visadev("GPIB::1::0::INSTR"); |
The fopen
function is not available in the updated interface.
The object creation function visadev
both creates the object
and connects the object to the device.
For more information, see visadev
.
Write and Read Binary or String Data
These examples show how to perform a binary write and read, and how to write and read nonterminated string data, using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object
fwrite(v,1:5)
data = fread(v,5) data = 1 2 3 4 5 |
% v is a visadev object
write(v,1:5)
data = read(v,5) data = 1 2 3 4 5 |
% v is a visa object fwrite(v,"hello","char") length = 5; data = fread(v,length,"char") data = 104 101 108 108 111 data = char(data)' data = 'hello' |
% v is a visadev object write(v,"hello","string") length = 5; data = read(v,length,"string") data = "hello" |
Read Terminated String
This example shows how to perform a terminated string write and read using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object v.Terminator = "CR"; fprintf(v,"hello") data = fscanf(v) data = 'hello ' |
% v is a visadev object configureTerminator(v,"CR") writeline(v,"hello") data = readline(v) a = "hello" |
% v is a visa object v.Terminator = "CR"; fprintf(v,"hello") data = fgetl(v) data = 'hello'
| |
% v is a visa object v.Terminator = "CR"; fprintf(v,"hello") data = fgets(v) data = 'hello '
|
Read and Parse String Data
This example shows how to read and parse string data using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object data = scanstr(v,';') data = 3×1 cell array {'a'} {'b'} {'c'} |
% v is a visadev object
data = readline(v) data = "a;b;c" data = strsplit(v,";") data = 1×3 string array "a" "b" "c" |
For more information, see readline
.
Write and Read Back Data
This example shows how to write ASCII terminated data and read ASCII terminated data back using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object data = query(v,'ctrlcmd') data = 'success' |
% v is a visadev object data = writeread(v,"ctrlcmd") data = "success" |
Write and Read Binblock Data
This example shows how to write data with the IEEE standard binary block protocol using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object
binblockwrite(v,1:5);
data = binblockread(v) data = 1 2 3 4 5 |
% v is a visadev object
writebinblock(v,1:5)
data = readbinblock(v) data = 1 2 3 4 5 |
For more information, see writebinblock
or readbinblock
.
Flush Data from Memory
This example shows how to flush data from the buffer using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object
flushinput(v)
clrdevice(v) |
% v is a visadev object flush(v,"input") |
% v is a visa object
flushoutput(v)
clrdevice(v) |
% v is a visadev object flush(v,"output") |
% v is a visa object
flushinput(v)
flushoutput(v)
clrdevice(v) |
% v is a visadev object
flush(v) |
For more information, see flush
.
Set Terminator
These examples show how to set the terminator using the recommended functionality.
Functionality | Use This Instead |
---|---|
% v is a visa object v.Terminator = "CR/LF"; |
% v is a visadev object configureTerminator(v,"CR/LF") |
% v is a visa object v.Terminator = {"CR/LF" [10]}; |
% v is a visadev object configureTerminator(v,"CR/LF",10) |
For more information, see configureTerminator
.
Disconnect VISA Device Connection
The fclose
function is not available in the updated
interface. To disconnect a VISA device, use clear
or delete
instead, depending upon
whether you are working in a single workspace or multiple workspaces. For details,
see the following examples on the visadev
reference page: