function [data] = testing(Curl,sampleCurrh,CurrIncrement,fname)
pause on
%*****************************************************************************
%Initialize Matlab function parameters
	comp = 105; %max out compliance--nothing to harm here
	dvmRange = 10;
	Volts = '0';
    a='0';
    b='0';
    c='0';
    data=[0 0];
%*****************************************************************************
%create and open instrument objects, and echo their names
	lakeshore = visa('ni','gpib0::12::INSTR');
	fopen(lakeshore);
		fprintf(lakeshore,'*IDN?');
	lakeshoreName = fscanf(lakeshore);

	keithley = visa('ni','gpib0::13::INSTR');
	fopen(keithley);
		fprintf(keithley,'*IDN?');
	keithleyName = fscanf(keithley);

	disp('Successfully connected to:');
	disp(lakeshoreName(1:end-2)); %eliminates trailing whitespace
	disp(keithleyName(1:end-2));  %eliminates trailing whitespace
	disp(' ');
%check keithley internal setup--IS THIS NECESSARY AND RIGHT?
		fprintf(keithley,'SOUR:DELT:NVPR?');
	is2182aConnected = fscanf(keithley);
	if is2182aConnected == 1
	disp('WARNING: Voltmeter is not connected.');
	disp(' ');
	end
%*****************************************************************************
%Initialize the 6220
		fprintf(keithley,'*RST');
		fprintf(keithley,'TRAC:CLE');
		fprintf(keithley,'TRAC:POIN 10');
		fprintf(keithley,'SOUR:CURR:COMP %e', comp);        
        
%set the 2182 triggering loop--copied from 2182 manual, p. E-6
				fprintf(keithley,'SYST:COMM:SER:SEND "*RST"');
				fprintf(keithley,'SYST:COMM:SER:SEND "STAT:PRES;*CLS"');
				fprintf(keithley,'SYST:COMM:SER:SEND "STAT:MEAS:ENAB 512"');
				fprintf(keithley,'SYST:COMM:SER:SEND "*SRE 1"');
				fprintf(keithley,'SYST:COMM:SER:SEND "TRIG:COUN 10"');
	pause(1);
%tell the 2182 what to look at				
				fprintf(keithley,'SYST:COMM:SER:SEND "SENS:VOLT:CHAN1:RANG 10.0"');
				%fprintf(keithley,'SYST:COMM:SER:SEND "SENS:VOLT"');
				%fprintf(keithley,'SYST:COMM:SER:SEND "VOLT:RANG 10.0"');
	pause(1);

%set up 2182 buffer to snarf up 10 readings from the appropriate channel
				fprintf(keithley,'SYST:COMM:SER:SEND "TRAC:CLE"');
				fprintf(keithley,'SYST:COMM:SER:SEND "TRAC:POIN 10"');
				fprintf(keithley,'SYST:COMM:SER:SEND "TRAC:FEED SENS1; FEED:CONT NEXT"');
%set the serial format
                fprintf(keithley,'SYST:COMM:SER:SEND "FORM:DATA ASC"');
	pause(1);          
%*******************************************************************************	
%The measurement	
	disp('Strike any key...');
	pause
%Set the current and turn on the 6220
		fprintf(keithley,'SOUR:CURR %e',Curl);
		fprintf(keithley,'OUTP ON');
%Take 10 points into the 2182 buffer
				fprintf(keithley,'SYST:COMM:SER:SEND "INIT"');
	pause(10);
%Try to read the buffer out to the 6220
				fprintf(keithley,'SYST:COMM:SER:SEND "TRAC:DATA?"');
				fprintf(keithley,'SYST:COMM:SER:ENT?');
	pause(1);
%Reset for the next round			
		fprintf(keithley,'OUTP OFF');
		%fprintf(keithley,'SYST:COMM:SER:SEND "TRAC:CLE"');
	%disp(Volts);
%*******************************************************************************		
		fprintf(keithley, 'SOUR:CLE');
%save data file to folder as tabs-delimited text file
	cd 'C:\Documents and Settings\Student\My Documents\MATLAB\supercond\data';
%fname = ['sc' datestr(now,30) '.txt'];
	fname = [fname '.txt'];
	dlmwrite (fname,data,'-append','delimiter','\t','precision',10,'newline','pc');
		
%close instrument objects and delete them
	fclose(lakeshore);
	fclose(keithley);
	delete(instrfind);
	disp('supercond.m was successfully closed.')
end