SNLA428 june 2023 DP83826E
The following code is an example of how to implement the TDR algorithm in Matlab. The input to the program is the 6x3 matrix.
function [tdr_results] = tdr_826(input_matrix)
%segment = tmp(1:4:end);
peak_indx = tmp(1:3:end)
peak_indx %first column in 6x3 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 = 5.2;
offset = 5;
flt_found = 0;
flt_loc = 0;
flt_sign = 0;
%% Process the TDR data from Segment 2 onwards
for jj = 0:3
if peak_val(jj+1) > thr
flt_loc = ((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 Segment 1..
thr_seg1_2 = 24;
if flt_found == 0
if peak_val(5) > thr_seg1_2
flt_loc = ((peak_indx(2) - offset)*8)/(2*prop_dly);
if peak_sign(2) > 0
flt_sign = 1;
else
flt_sign = 0;
end
flt_found = 1;
end
end
thr_seg1_1 = 24;
if flt_found == 0
if peak_val(6) > thr_seg1_1
flt_loc = ((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