MATLAB® code example
To communicate with a Switch product in MATLAB® the installation of a VISA IO driver is required. These
drivers enable the creation of the Interface Object for instrument communication.
If developing locally on the Switch Platform, then these will already be installed. However, if
development is on a remotely connected system the VISA Libraries, e.g. National Instruments NI-VISA
will have to be installed.
MATLAB 2010x or later with the Instrument Control Toolbox is required to execute the code
detailed in this section.
The following example shows how to communicate with a Switch product using MATLAB code. For a list
of supported and valid SCPI commands, refer to the Programming Guide.
% Find a VISA-TCPIP object. This is if the VISA object has already been
% created with tmtool or has been removed from the workspace without
% first being closed (cleanly disconnected).
PXIE_Chassis = instrfind('Type', 'visa-tcpip',
'RsrcName', 'TCPIP0::10.10.10.89::inst0::INSTR', 'Tag', '');
% Create the 'agilent' VISA-TCPIP object if it does not exist
% otherwise use the object that was found.
if
isempty(PXIE_Chassis)
PXIE_Chassis = visa('agilent', 'TCPIP0::10.10.10.89::inst0::INSTR');
else
fclose(PXIE_Chassis);
PXIE_Chassis = PXIE_Chassis (1);
end
% Open the connection to the VISA object.
fopen(PXIE_Chassis);
% Query the PXIE_Chassis.
response = query(PXIE_Chassis, '*IDN?');
disp('The *IDN query
disp(response);
response = query(PXIE_Chassis, '*OPT?');
disp('The *OPT query
disp(response);
% Replace this with a valid command for your device (read the programming
% guide section for examples)
command =
''
% Close the connection to the object.
fclose(PXIE_Chassis);
% Clean up all objects.
delete(PXIE_Chassis);
Quantifi Photonics Ltd.
Automated Optical Switch | Switch 1000/1100/1400 Series
response:');
response:');
Version
...
3.04
52