Several experiments in the Advanced Physics Laboratory use MATLAB Version 2014a and National Instruments USB-GPIB controllers to communicate with GPIB capable lab equipment such as programmable power supplies or volt meters.

Note that using GPIB with MATLAB requires the MATLAB Instrument Control Toolbox. This should automatically be available when you use MATLAB on the Advanced Lab computers. To check which toolboxes have been installed you can use the MATLAB version command

>> ver

which will return a list of the installed toolboxes.

The commands used for controlling and reading instrumentation through GPIB will depend on the particular instrument is being used. However, the first step is always to establish a connection with a GPIB capable instrument.

To see a list of instruments that have an active GPIB connection use the

>> instrfind


Here is a typical set of MATLAB commands that can be used to setup up a GPIB connection to an instrument.

% Create an instrument object
% 'ni' is for National Instruments GPIB controllers
% 0 is the board index
% GPIB_address is the address of the instrument
inst_obj = gpib('ni',0,GPIB_address);

% Connect to the instrument

% Print command to instrument
% where 'string' is the command sent to the instrument.

% Read from the instrument
answer = fscanf(inst_obj)

% Close the connection to the instrument

% Delete the instrument object

Common error descriptions:

PhysicsWiki: MatLab (last edited 2014-08-22 15:37:05 by MikeMartens)