image thumbnail
from using GPIB & DAC board by Young-Sang Kim
using GPIB & DAC board

charcurve.m
%--------------------------------------------------------
% this is for get characteristic curves in a transister by using
% Kim Young-Sang 
% salut03@hanmail.net
% GPIB & DAC board. You give analog voltages and get current values.
% You have to set GPIB & DAC in your computer.
%-------------------------------------------------------


clear;
clf;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% GPIB connect  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
obj1 = gpib('NI', 0, 22); % set national instrument GPIB 
fopen(obj1);  %gpib open 
% Set the property values.
set(obj1, 'BoardIndex', 0);
set(obj1, 'ByteOrder', 'littleEndian');
set(obj1, 'BytesAvailableFcn', '');
set(obj1, 'BytesAvailableFcnCount', 48);
set(obj1, 'BytesAvailableFcnMode', 'eosCharCode');
set(obj1, 'CompareBits', 8);
set(obj1, 'EOIMode', 'on');
set(obj1, 'EOSCharCode', 'LF');
set(obj1, 'EOSMode', 'read&write');
set(obj1, 'ErrorFcn', '');
set(obj1, 'InputBufferSize', 512);
set(obj1, 'Name', 'GPIB0-22');
set(obj1, 'OutputBufferSize', 512);
set(obj1, 'OutputEmptyFcn', '');
set(obj1, 'PrimaryAddress', 22);
set(obj1, 'RecordDetail', 'compact');
set(obj1, 'RecordMode', 'overwrite');
set(obj1, 'RecordName', 'gp-mat.txt');
set(obj1, 'SecondaryAddress', 0);
set(obj1, 'Tag', '');
set(obj1, 'Timeout', 10);
set(obj1, 'TimerFcn', '');
set(obj1, 'TimerPeriod', 1);
set(obj1, 'UserData', []);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% dda06 connect  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dda=analogoutput('mcc',1); % setup measurement computing device
addchannel(dda,1:2); % set twe channels
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%v1=2;
%for v1=-0.8:0.1:0
s=char('y','k','r','g','b','m','c','y','k','r','g','b','m','c');
%L=char('+','^','v','*','x','>','<','.');
j=1;
for v1=-1:0.005:5 % Gate Voltage(v)
        j=j+1;
    for v2=-0.5:0.007:0.5   % Drain Voltage(v)

        putdata(dda,[v1,v2]);  % generate voltages, v1 & v2
        start(dda);
        cur=fscanf(obj1);  % Get current from GPIB
        cur=str2num(cur);
        plot(v2,cur,s(j));
        hold on;
        v(j)=v1;
        cu(j)=cur;
 
    end
end
hold off;
%h=[v cu];
save plotdata.mat v cu;        
%save plotdata.txt -ascii v cu;

%if nargout > 0 
%    out = [obj1]; 
%end

% terminate devices
stop (dda);
delete(dda);
clear dda;
fclose(obj1);
delete(obj1);
clear obj1;

Contact us at files@mathworks.com