Hi Daram
This is how we normalize our Matlab filters vales that we send to the DSP.
[Bt, At] = mkfltr(T, Fs); Filter function – for example [Bt, At] = butter(2, 2*fc/Fs);
% The miniDSPs use a 1.23 format coefficient
intval = 1;
Fract =23;
NumScale = 1- 2^-Fract;
% Normalize the numerator for a 1.Fract format
sscale = 1;
if Bt(1, 1) > 1
sscale= Bt(1,1);
disp('Automatic Filter Scaling to be applied ')
disp([sprintf('Linear %1.6f dB %1.6f', 1/sscale, 20*log10(1/sscale))])
end
% Sometimes it is advantigious to set the scale manually.
G2 = input('Manually Scale Filter output in dB? (return for no change ) > ');
if isempty(G2)
sscale = sscale;
else
G2 = 1/10^(G2/20);
if G2 < sscale
disp([sprintf('Automatic Scale is %1.6f dB', 20*log10(sscale))])
disp('Must be less than Automatic Scale value - using automatic Scale value')
else
sscale = G2;
disp([sprintf('New Scaling Linear %1.6f dB %1.6f', 1/sscale, 20*log10(1/sscale))])
end
end
Bt = Bt./ sscale;
% Apply Scaling factor to coefficients
Bt = Bt.* NumScale;
At = At.* NumScale;
At(1,1) = 1;
% Scale B1 and A1 by 1/2
Bt(1,2) = Bt(1,2)/2;
At(1,2) = At(1,2)/2;
%Quantize coefficients to 1.Fract
Bt = quant(Bt, intval, Fract);
At = quant(At, intval, Fract);
David