필터 지우기
필터 지우기

Current vs time for fixed voltage controlling Keithley 2400?

조회 수: 14 (최근 30일)
Robert
Robert 2014년 9월 23일
편집: Robert 2014년 9월 23일
Hi,
I'm new to instrument control with matlab and have been trying to make a simple script that sets a fixed voltage and measures current vs time. I'm having a few problems and was wondering if anyone had a sample script on how to measure this? I would really like to get time and current from the keithley rather than defining it here.
This is my script so far (and doesn't work). I think it works up until where I set the fixed voltage value..
Cheers in advance and apologies for noob errors!
CODE:
serialObject = serial('/dev/tty.usbserial')
if nargout > 0
out = [serialObject];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Model 2400 Specific Functions
fopen(serialObject)
fprintf(serialObject,':*RST')
time = now;
current = 0;
figureHandle = figure('NumberTitle','off',...
'Name','Current Characteristics',...
'Color',[0 0 0],'Visible','off');
%%Set the time span and interval for data collection
stoptime = 60*60*1; %1hr of seconds
timeInterval = 0.005;
% Setup Current fixed level and read current.
fprintf(serialObject,':SOUR:FUNC:MODE VOLT'); % voltage source selection.
fprintf(serialObject,':SOUR:CURR:MODE FIXED'); % changes voltage mode to fixed
fprintf(serialObject,':SOUR:VOLT:LEV 5'); % sets voltage to 5V (works)
fprintf(serialObject,':SENS:FUNC “CURR”');
fprintf(serialObject,':SENS:CURR:RANG:AUTO ON');
fprintf(serialObject,':SENS:CURR:PROT 1');
% fprintf(serialObject,':TRAC:COUN 1') fprintf(serialObject,':TRAC:FEED:CONT NEV'); fprintf(serialObject,':OUTP ON');
%%Collect data
count = 1;
tic;
while count<=stoptime/timeInterval
fprintf(serialObject,':INIT');
fprintf(serialObject,':TRAC:FEED: SENS')
fprintf(serialObject,':TRAC:DATA?');
% To measure current the command is MEASURE:CURRENT:DC?
current(count) = fscanf(serialObject,'%f');
time(count) = toc;
set(plotHandle,'YData',current,'XData',time);
set(figureHandle,'Visible','on');
pause(timeInterval);
count = count +1;
end
%%Put the instrument in local mode
fprintf(serialObject,'SYSTEM:LOCAL');
%% Clean up the serial object fclose(serialObject); delete(serialObject); clear serialObject;

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by