Code covered by the BSD License  

Highlights from
KPIB: Kenny-Purpose Interface Bus

from KPIB: Kenny-Purpose Interface Bus by M. A. Hopcroft
A common interface for control of multiple scientific instruments with GPIB and serial connections.

Setup_Tools.m
% Setup_Tools: Initialize the tools for the experiment
%
% This script creates the tools variable which describes the instruments
%  used in an experimental setup. Run this script at the start of each
%  session to initialize the setup. The names of the instruments are
%  conventional, but you can use any name that you like, and modify this
%  file as desired.
%
% MH Jan2007
%    updated for distribution with kpib.m May2010
%
% KPIB can use a structure input to describe an instrument.
%  This allows each instrument to be described by a single variable. For
%  example, lets use an HP power supply for a heater voltage:
%
% >> heater.instr = 'HP_3631A';
% >> heater.gpib = 23;
% >> heater.channel = 2;
% >> heater
% heater = 
%       instr: 'HP_3631A'
%        gpib: 23
%     channel: 2
% >> 
%
% Now we can use KPIB to set the heater output to 2 Volts:
%
% >> kpib(heater,'setV',2)
% kpib: Output of HP_3631A Channel 2 set to 2 V.
%
% This type of input is convenient and also reduces confusion between
%  different instruments. Furthermore, the instruments can be collected
%  into a single variable called "tools". It is conventional for software
%  that uses KPIB to use a "tools" variable to hold all of the instruments.
%  For example:
%
% >> tools
% tools = 
%     analyzer: [1x1 struct]
%         oven: [1x1 struct]
%       sensor: [1x1 struct]
%      biasset: [1x1 struct]
%       heater: [1x1 struct]
%        scope: [1x1 struct]
%
% >> run_my_experiment(tools);
%
%
% This file is simply a script which creates tools.
% Modify this file as necessary for your experiment.
%

kpib('version',0,0,0,0,0,1);
% start by resetting the GPIB bus
kpib('clear',0,0,0,0,0,2);


% The network or spectrum analyzer is called "analyzer".
% For resonator measurement (measure_res.m), the analyzers use one channel for amplitude
%  (analyzer.ampchannel) and one for phase (analyzer.phasechannel). These
%  are usually channels 1 and 2. We can also specify the averaging
% trace1=kpib(tools.analyzer.instr,'getdata',0,ampchannel,'pow',verbose);
tools.analyzer.instr = 'HP_89410A'; % also HP_4395A, HP_8560A, etc
tools.analyzer.gpib = 16;
tools.analyzer.ampchannel=1;
toolsanalyzer.phasechannel=2;
tools.analyzer.averaging='on';  % Use measurement averaging ('on' | 'off')
tools.analyzer.avenum=5;  


% The thermal chamber (temperature controller) is called "oven".
%  There is usually no "channel" for the temperature controller.
% Toven = kpib(tools.oven,'read',0,0,0,verbose);
tools.oven.instr = 'BlueOven'; % also GreyOven, AO_800
tools.oven.gpib = 5;


% The oscilloscope is called "scope".
tools.scope.instr = 'TDS_TEK';
tools.scope.gpib = 16;
tools.scope.channel = 1;


% The bias voltage is set by the instrument "biasset".
% Vbias_set = kpib(tools.biasset,'read','V',0,verbose);
tools.biasset.instr = 'HP_6614C'; % KTH_236
tools.biasset.gpib = 14;
tools.biasset.channel = 1;
% if the bias cannot be read, use biasset.level to record the level
% tools.biasset.level = 12; % record a 12 V bias


% Sometimes a multimeter is used to read the bias voltage independently.
%  This is "biasread".
% Vbias_read = kpib(tools.biasread,'read','V',0,verbose);
tools.biasread.instr = 'HP_3478A'; % HP_34401A
tools.biasread.gpib = 21;
tools.biasread.channel = 1;


% Use "counter" for measuring frequency (f).
% freq = kpib(tools.counter,'getdata',0,0,verbose);
tools.counter.instr = 'HP_53132A';
tools.counter.gpib = 10;
tools.counter.channel = 1; 

% Use "counter2" for measuring frequency of a second device (f2).
%  Note that using the second channel of the HP_53132A is very slow!
% freq2 = kpib(tools.counter2,'getdata',0,0,verbose);
tools.counter2.instr = 'HP_53132A';
tools.counter2.gpib = 10;
tools.counter2.channel = 2;

% Use "countbeat" for measuring a beat frequency (fbeat).
% fbeat = kpib(tools.countbeat,'getdata',0,0,verbose);
tools.countbeat.instr = 'HP_53132A';
tools.countbeat.gpib = 11;
tools.countbeat.channel = 1; 


% Use "sensor" for measuring temperature of the device. This is usually a
%  Pt RTD or an LM35, using a multimeter. No channel is used.
% Tsensor = kpib(tools.sensor.instr,tools.sensor.gpib,'read','temp',0,0,verbose);
tools.sensor.instr = 'HP_34420A';
tools.sensor.gpib = 22;


% Use "RMS" for reading the RMS output level.
% Vrms = kpib(tools.RMS,'read','volt',0,verbose);
tools.RMS.instr = 'HP_34401A';
tools.RMS.gpib = 24;
tools.RMS.channel = 1;


% Use "heater" for providing heating power to the device.
% heater = kpib(tools.heater,'read',0,0,verbose);
%  Vheat = heater.volt;
%  Aheat = heater.curr;
%  Pheat = heater.volt*heater.curr;
tools.heater.instr = 'HP_E3634A';
tools.heater.gpib = 18;
tools.heater.channel = 1; 


% Use "clamp" for setting the oscillator clamp voltage.
% The clamp voltage is often set by a voltage divider, rather than an
%  instrument.
% Vclamp = kpib(tools.clamp,'read','V',0,verbose);
tools.clamp.instr = 'Vdivider';
tools.clamp.gpib = 30;
tools.clamp.channel = 1;
% if the clamp level cannot be read (using voltage divider), use clamp.level to record the level
tools.clamp.level = 0.1; % record a 100 mV clamp level


% Use "clampread" for reading the clamp level.
% Vclamp_read = kpib(tools.clampread,'read','V',0,verbose);
tools.clampread.instr = 'HP_34401A';
tools.clampread.gpib = 23;

fprintf(1,'Instument Setup complete.\n');
disp(tools)

Contact us at files@mathworks.com