Created
February 28, 2011 17:18
-
-
Save cwoodall/847651 to your computer and use it in GitHub Desktop.
loss_calculations.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function watts = dBm2watts( dBm ) | |
watts = 10^-3*10.^(dBm/10); | |
endfunction | |
function [loss_min loss_max] = loss_per_meter( meters ) | |
loss_min = meters*.19; | |
loss_max = meters*.43; | |
endfunction | |
function [loss_min loss_max] = loss_per_bulkhead( bulkheads ) | |
loss_min = .7*bulkheads; | |
loss_max = 2.8*bulkheads; | |
endfunction | |
function [loss_min loss_max] = system_loss( meters, bulkheads ) | |
[loss_m_min loss_m_max] = loss_per_meter( meters ); | |
[loss_b_min loss_b_max] = loss_per_bulkhead( bulkheads ); | |
loss_min = loss_m_min + loss_b_min; | |
loss_max = loss_m_max + loss_b_max; | |
endfunction | |
function [OPB] = calculateOPB( PTmin, PLmin) | |
OPB = PTmin - PLmin; | |
endfunction | |
function [ROPB] = calculateROPB( OPB, loss_max, power_margin) | |
ROPB = OPB - (loss_max+power_margin); | |
endfunction | |
function [amt_of_decrease] = calcDecrease(PTmax, PLmax, loss_min) | |
amt_of_decrease = (PTmax - loss_min) - PLmax; | |
endfunction | |
% Set the min and max values for the Transmitter/Receiver Pair | |
PL_min = -39; | |
PL_max = -13.7; | |
PH_max = -53; | |
PT_min = -13.6; | |
PT_max = -4.5; | |
bulkheads = 0; | |
% Generate a vector of meters | |
meters = 0:5:40; | |
power_margin = 0; | |
% Calculate the min and max total system loss | |
[sys_loss_min sys_loss_max]= system_loss( meters, bulkheads); | |
% Calculates the Optical Power Budget (OPB) | |
OPB = calculateOPB( PT_min, PL_min ); | |
% Calculates the Remaining OPB (ROPB) for each length of link | |
% This will function as the minumum power | |
ROPB = zeros(1, numel(sys_loss_max)); | |
for loss = 1:numel(sys_loss_max) | |
ROPB(loss) = calculateROPB( OPB, sys_loss_max(loss), power_margin ); | |
endfor | |
% Calculate the amount of decrease | |
% This will function as the maximum power | |
amt_of_decrease = zeros(1, numel(sys_loss_min)); | |
for loss = 1:numel(sys_loss_min) | |
amt_of_decrease(loss) = calcDecrease(PT_max, PL_max, sys_loss_min(loss)); | |
endfor | |
% Plot in terms of dB | |
%subplot(1,3,1) | |
plot(meters, -amt_of_decrease, 'r-') | |
hold on | |
plot(meters, -ROPB, 'b-') | |
title('Power (dB) vs Length') | |
legend('Line of Max Current','Line of Min Current') | |
xlabel('Length of Link (m)') | |
ylabel('Output Power (dB)') | |
print('-dpng','current_analysis.png') | |
a = find(meters == 30); | |
fprintf('%d meters: %.2f, %.2f\n',meters(a),amt_of_decrease(a), ROPB(a)) | |
input(''); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment