Skip to content
Snippets Groups Projects
Commit db2bd88a authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Normalize the coefficients to fit in range +-1, so h_fir_max = 1.

parent 89541917
Branches
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
% bandwidth BWchan. Typically BWchan = 1/N or somewhat more have -3dB % bandwidth BWchan. Typically BWchan = 1/N or somewhat more have -3dB
% reponse between channels. % reponse between channels.
% %
% The FIR coeeficients can be caluculated with Matlab 'fir1' or with % The FIR coefficients can be caluculated with Matlab 'fir1' or with
% Matlab 'fircls1' dependend on config.design. % Matlab 'fircls1' dependend on config.design.
% %
% For Matlab fircls1() r_pass and r_stop are the maximum passband and % For Matlab fircls1() r_pass and r_stop are the maximum passband and
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
% interpolating a shorter filter with an upsampling factor Q. This % interpolating a shorter filter with an upsampling factor Q. This
% reduces computation time substantially. N, L and Q must be powers of 2. % reduces computation time substantially. N, L and Q must be powers of 2.
% %
% The FIR coefficients are normalized to fit in range +-1. Given that
% the impulse response has a sync pulse shape this implies that the
% largest coefficient is h_fir_max = 1. Most energy is passed on via
% the center tap and therefore the filter DC gain per poly phase
% h_fir_dc_gain is close to 1.
%
% For nof_bits>1, the FIR filter coefficients are quantized with % For nof_bits>1, the FIR filter coefficients are quantized with
% nof_bits bits. % nof_bits bits.
% %
...@@ -114,13 +120,20 @@ else ...@@ -114,13 +120,20 @@ else
end end
end; end;
% normalization, scale coefficients to have DC response is 1 % normalize the coefficients to fit in range +-1
h_fir = h_fir / sum(h_fir); disp(sprintf('pfir_coeff : Normalizing the PFIR coefficients to fit in range +-1.'));
h_fir = h_fir / max(h_fir);
h_fir_max = max(h_fir); % note: is 1 due to the normalization
h_fir_min = min(h_fir);
h_fir_dc_gain = sum(h_fir) / N;
disp(sprintf(' . Maximum coefficient value : %f', h_fir_max));
disp(sprintf(' . Minimum coefficient value : %f', h_fir_min));
disp(sprintf(' . DC gain per polyphase : %f\n', h_fir_dc_gain));
% quantize the coeffients % quantize the coeffients
if nof_bits>0 if nof_bits>0
disp(sprintf('pfir_coeff : Quantizing FIR coefficients nof_bits = %d\n', nof_bits)); disp(sprintf('pfir_coeff : Quantizing FIR coefficients nof_bits = %d\n', nof_bits));
h_fir = quantize(h_fir, max(h_fir), nof_bits, 'half_away'); h_fir = quantize(h_fir, h_fir_max, nof_bits, 'half_away'); % note: h_fir_max is 1 due to the normalization
end; end;
% output FIR coefficient % output FIR coefficient
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment