% [filename, pathname, filterindex] = uigetfile('*.
csv', 'Pick an data file')
% cd(pathname)
% fid=fopen(filename,'r')
% data_import=textscan(fid,'%s %f %f %f %f');
% data=[data_import{1,2} data_import{1,4} data_import{1,5}];
voltage = data(:,1);
cp= data(:,3);
len = length(voltage);
l=len/2;
for i =1:1:len
cs(i) = cp(i);
end
% splitting the data , to get forward and backward curves
voltage_forward(1:len/2)=voltage(1:len/2);
voltage_backward(1:len/2)=voltage(len/2+1:len);
cs_forward(1:len/2) = cs(1:len/2);
cs_backward(1:len/2)= cs(len/2+1:len);
% % reversing the voltage , to get data for gate voltage (we were applying
% % voltage to the substrate)
% for i = 0: len/2 -1
% voltage_forward(i+1) = - voltage_forward(i+1) ;
% voltage_backward(i+1) = - voltage_backward(i+1);
% end
% plot capacitance per unit area
area = 1e-2; % in cm2-converted from mm2
cs_forward = cs_forward /area ;
cs_backward = cs_backward /area ;
i=1:1:len/2;
plot(voltage_forward ,cs_forward ,'g',voltage_backward,cs_backward,'m')
grid on
% calculate accumulation capacitance in farads
cox_accumulation1= max(cs_forward);
cox_accumulation2= max(cs_backward);
cox_accumulation = 1/2 *( cox_accumulation1 + cox_accumulation2)
% calculate thickness of oxide
epsilon_sio2 = 3.5;
epsilon_air = 8.85e-14;
epsilon_silicon=11.8
thickness_oxide = 1e7* epsilon_sio2 * epsilon_air / cox_accumulation % in nm
% calculate inversion capacitance in farads
c_inversion1= min(cs_forward);
c_inversion2= min(cs_backward);
c_inversion = 1/2*(c_inversion1 + c_inversion2) % in farads
% calculate max depletion width
c_s = (c_inversion)*(cox_accumulation) / ( cox_accumulation - c_inversion) %
in farads
epsilon_si = 11.8 ;
max_depletion_width = (10 ^ (7))* epsilon_si * epsilon_air / c_s; % in nm
max_dep_width_cm = (epsilon_si * epsilon_air )/ c_s
% calculate doping concentration
% Na = 10 ^ 15 ; % initial assumption
% calculate doping concentration
boltzman_constant = 1.38*(10^-23);
temperature = 298; % in Kelvin
intrinsic_concentration = 1.5e10; % in cm -3
charge = 1.6e-19; % in cm-3
vt = 0.0259 ;
Na = 1e15 ; % initial assumption
% bulk_function = vt * log(Na/intrinsic_concentration);
% x0=[1e15;1]; % Make a starting guess at the solution
% options=optimset('Display','iter'); % Option to display output
% [x,fval] = fsolve(@iteration,x0,options) % Call solver
% calculate doping concentration
x0=[1e15 1e17]
options = optimset('Display','iter');
[x,fval,exitflag,output] = fzero(@fun,x0,options)
%calculate debye length
lambda = sqrt ( (vt * epsilon_si * epsilon_air) / (charge * Na ) ) % in cm
% calculate C_FB
C_FlatBand= 1 / (lambda/( epsilon_si * epsilon_air ) + (1/cox_accumulation))
% calculate C_midgap
bulk_function = vt * log (Na / intrinsic_concentration );
dep_width_midgap = sqrt((2 * bulk_function * epsilon_si * epsilon_air) /
(charge * Na))
C_midgap= 1 /((dep_width_midgap/ (epsilon_si * epsilon_air))
+(1/cox_accumulation))
% calculate V_mg
voltage_fit = -2.5:0.01:0;
imax = length(voltage_fit);
voltage_mg1 = interp1(cs_forward , voltage_forward , C_FlatBand);
voltage_mg2 = interp1(cs_backward , voltage_backward , C_FlatBand);
voltage_midgap = (voltage_mg1 + voltage_mg2 )/2
% calculate V_fb
voltage_fit = -2.5:0.01:0;
imax = length(voltage_fit);
voltage_fb1 = interp1(cs_forward , voltage_forward , C_FlatBand);
voltage_fb2 = interp1(cs_backward , voltage_backward , C_FlatBand);
voltage_flatband = (voltage_fb1 + voltage_fb2 )/2
% to calculate the threshold voltage
Voltage_threshold = voltage_flatband + 2 * bulk_function +(charge* Na*
max_dep_width_cm / cox_accumulation )
% to calculate charge defects
work_func_al = 4.08;
work_func_si = 4.05;
work_function = work_func_al - work_func_si ;
charge_defect_combined =(1/1.6)* (10 ^(19))*(-voltage_flatband + work_func_al-
work_func_si )* cox_accumulation
% to calculate generation lifetime of carriers
sigma = 10 ^ (-15); % in cm2
thermal_velocity = 10 ^ 7 ;% in cm_sec-1
tow_g = (10 ^ 6 )*(1 / (sigma * thermal_velocity * charge_defect_combined ))
% to caluclate generation current , Jgen
Jgen = (10^6)*(charge * max_dep_width_cm * intrinsic_concentration / tow_g)
% to calulate fixed charge density
Qf = (cox_accumulation /charge)*(-voltage_midgap + work_function +
bulk_function +(charge*Na *dep_width_midgap / cox_accumulation))
% to calculate interface charge density
Qit = charge_defect_combined - Qf