11.4 MATLAB® code example
To communicate with the Quantifi Photonics 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 PXIe 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.
NOTE
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 PXIe module using MATLAB code.
% 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 response:'
);
disp
(response);
response = query(PXIE_Chassis,
'*OPT?'
);
disp
(
'The *OPT query response:'
);
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.
Quantifi Photonics | SLED 1000 / 1300 Series PXIe User Manual | Document version 1.08
53 / 61