lineWidth = 50 %unit mil
lineLength = 1000 %unit mil
diEC = 4.4
disp(['SIMULATING TRANSMISSION LINE WITH WIDTH = ' num2str(lineWidth) ' MIL, LENGTH = ' num2str(lineLength) ' MIL '])
%--------------------------------------------------------------------------
% ============ _
% // | \\ ^
% // | \\ |
% // | \\ |
% = <------E W------> = E H
% \\ | // |
% \\ | // |
% \\ | // v
% ============== -
%--------------------------------------------------------------------------
tline1 = rfckt.microstrip('Width',lineWidth*127/5e6,...
'Height',12*127/5e6,...
'Thickness',1.2*127/5e6,...
'EpsilonR',diEC,...
'LossTangent',0.01,...
'SigmaCond',5.8e7,...
'LineLength',lineLength*127/5e6);
tline2 = rfckt.microstrip('Width',1.5*lineWidth*127/5e6,...
'Height',12*127/5e6,...
'Thickness',1.2*127/5e6,...
'EpsilonR',diEC,...
'LossTangent',0.01,...
'SigmaCond',5.8e7,...
'LineLength',lineLength*127/5e6);
tline3 = rfckt.microstrip('Width',2.0*lineWidth*127/5e6,...
'Height',12*127/5e6,...
'Thickness',1.2*127/5e6,...
'EpsilonR',diEC,...
'LossTangent',0.01,...
'SigmaCond',5.8e7,...
'LineLength',lineLength*127/5e6);
freq = ((0.01:0.01:10)*1e9)'; %0.01 to 10GHz
analyze(tline1, freq);
analyze(tline2, freq);
analyze(tline3, freq);
SP_1 = sparameters(tline1);
SP_2 = sparameters(tline2);
SP_3 = sparameters(tline3);
%**************************************************************************
% creating voltage source to be the same as Voltage Source: Pseudo-Random Pulse Train Defined at Discrete Time Step
% refer to http://literature.cdn.keysight.com/litweb/pdf/rfde2003a/rfdeccsrc/ccsrc0518.html
ak = [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
Dk = [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1];
numofSR = length(Dk);
out = [];
for k = 1:1000
out = [out,Dk(numofSR)];
newbit = mod(sum(ak.*Dk),2);
Dk(numofSR) = []; Dk = [newbit, Dk];
end
datarate = 1*1e9; % Data rate: 1 Gbps
samplespersymb = 100;
pulsewidth = 1/datarate;
ts = pulsewidth/samplespersymb;
numsamples = 5000;
numplotpoints = 100000;
t_in = double((1:numsamples)')*ts;
%out?
input_signal = out;
input_signal = repmat(input_signal,[samplespersymb, 1]);
input_signal = input_signal(:);
%**************************************************************************
%------------------------------------------------------------------
%------------------------------------------------------------------
hckt1 = circuit('new_circuit1');
add(hckt1,[1 2], SP_1);
add(hckt1,[2 3], SP_2);
add(hckt1,[2,4], SP_3);
add(hckt1,[4 0], resistor(50));
add(hckt1,[4 0], capacitor(10e-12));
setports(hckt1,[1 0],[3,0])
S = sparameters(hckt1,freq);
% computing transfer function
difftf = s2tf(S,50,100e6,2);
[rationalfunc, errdb] = rationalfit(freq,difftf);
freqsforresp = linspace(0,10e9,1001)';
resp = freqresp(rationalfunc,freqsforresp);
npoles = length(rationalfunc.A);
fprintf('The derived rational function contains %d poles.\n',npoles);
%plot freq response
figure
subplot(2,1,1)
plot(freq*1.e-9,(abs(difftf)),'r',freqsforresp*1.e-9, ...
(abs(resp)),'b--','LineWidth',2)
title(sprintf('Rational Fitting with %d poles',npoles),'FontSize',12)
ylabel('Magnitude')
xlabel('Frequency (GHz)')
legend('Original data','Fitting result')
subplot(2,1,2)
origangle = unwrap(angle(difftf))*180/pi+360*freq*rationalfunc.Delay;
plotangle = unwrap(angle(resp))*180/pi+360*freqsforresp*rationalfunc.Delay;
plot(freq*1.e-9,origangle,'r',freqsforresp*1.e-9,plotangle,'b--', ...
'LineWidth',2)
ylabel('Detrended phase (deg.)')
xlabel('Frequency (GHz)')
legend('Original data','Fitting result')
[output_signal,t_out] = timeresp(rationalfunc,input_signal,ts);
figure;
plot(t_in, input_signal(1:length(t_in)), 'b'); hold on; plot(t_in, output_signal(1:length(t_in)), '--r');
overSampleRate = round((1/ts)/datarate);