Programming Manual MSO/UPO2000 Series
151 / 156
Instruments.uni-trend.com
MATLAB
Example
Environment: Window system, MATLAB
Description: Access the instrument via USBTMC and TCP/IP, and send "*IDN?" command on NI-VISA
to query the device information.
Steps:
1.
Open MATLAB software, click File>>New>>Script on Matlab interface to create an empty M file.
2.
Source code:
a)
USBTMC Example
function usbtmc_test()
% This code demonstrates sending synchronous read & write commands
% to an USB Test & Measurement Class (USBTMC) instrument using
% NI-VISA
%Create a VISA-USB object connected to a USB instrument
vu = visa('ni','USB0::0x5345::0x1234::SN20220718::INSTR');
%Open the VISA object created
fopen(vu);
%Send the string "*IDN?",asking for the device's identification.
fprintf(vu,'*IDN?');
%Request the data
outputbuffer = fscanf(vu);
disp(outputbuffer);
%Close the VISA object
fclose(vu);
delete(vu);
clear vu;
end
b)
TCP/IP
Example
function tcp_ip_test()
% This code demonstrates sending synchronous read & write commands
% to an TCP/IP instrument using NI-VISA
%Create a VISA-TCPIP object connected to an instrument
%configured with IP address.
vt = visa('ni',['TCPIP0::','192.168.20.11','::inst0::INSTR']);
%Open the VISA object created