SNLA334 june 2023 DP83867CR , DP83867CS , DP83867E , DP83867IR , DP83867IS , DP83869HM
The following code is an example of how to implement the TDR algorithm in Matlab. The input to the program is the 5x3 matrix.
function [tdr_results] = tdr_869(input_matrix)
tmp = input_matrix
%iteration = tmp(1:4:end);
peak_indx = tmp(1:3:end);
peak_indx %first column in 5x3 matrix
peak_val = tmp(2:3:end);
peak_val %second column
peak_sign = tmp(3:3:end);
peak_sign %third column
thr = 10;
prop_dly = 4.6; % ns perm %propogation delay of the cable type
offset = 16;
flt_found = 0;
flt_loc = 0;
flt_sign = 0;
%% Process the TDR data from Iteration 5 to Iteration 2
for jj = 1:4 %% 1,2,3,4,5 => 5,4,3,2,1
jj=5-jj;
jj+1
peak_val(jj+1)
if peak_val(jj+1) > thr
flt_loc = abs(((peak_indx(jj+1) - offset)*8)/(2*prop_dly));
if peak_sign(jj+1) > 0
flt_sign = 1;
else
flt_sign = 0;
end
flt_found = 1;
break;
end
end
%% Process the TDR data for Iteration 1..
%% 1st for the offset seting of 0xC..
threshold2 = 17;
if flt_found == 0
fprintf('Peak not found in higher iterations\n')
peak_val(1)
if peak_val(1) > thr_seg1_2
fprintf('peak val : %d\n', peak_val(1));
flt_loc = abs(((peak_indx(1) - offset)*8)/(2*prop_dly));
if peak_sign(1) > 0
flt_sign = 1;
else
flt_sign = 0;
end
flt_found = 1;
end
end
%% Print the Results..
if flt_found == 1
fprintf('\n');
if flt_sign == 0
fprintf('Fault location = %6.2f; Fault = Open\n',flt_loc);
else
fprintf('Fault location = %6.2f; Fault = Short\n',flt_loc);
end
else
fprintf('\n');
fprintf('No Fault found\n');
end
tdr_results.flt_loc = flt_loc;
tdr_results.flt_sign = flt_sign;
return
end