I am trying to design a FIR bandpass filter for a STM32F407 microcontroller with a passband of 1kHz between 59500 Hz and 60500 Hz or something similar (since I don't really know how tight I can squeeze it). I am trying to design the filter in MATLAB so I can get the co-efficents for later implementing them in C.
While simulating it in MATLAB the problem seems to be with the high sampling frequency. The microcontroller that I'm using is sampling at 5.25 MSPS so the FIR filter will have a pretty high filter order and I am wondering if there is something that I can change or can a filter really have this high order? Because it kind of looks like it would be working if the order is around 3000-4000.
Am I doing this correct and are these parameters even realistic?
% MATLAB Code
% Generated by MATLAB(R) 8.3 and the DSP System Toolbox 8.6.
% Generated on: 28-Jun-2016 09:43:38
% FIR Window Bandpass filter designed using the FIR1 function.
% All frequency values are in Hz.
Fs = 5250000; % Sampling Frequency
N = 3500; % Order
Fc1 = 59500; % First Cutoff Frequency
Fc2 = 60500; % Second Cutoff Frequency
flag = 'scale'; % Sampling Flag
% Create the window vector for the design algorithm.
win = blackman(N+1);
% Calculate the coefficients using the FIR1 function.
b = fir1(N, [Fc1 Fc2]/(Fs/2), 'bandpass', win, flag);
Hd = dfilt.dffir(b);
%----------------------------------------------------------
t = 0:1/Fs:0.01; % time vector
signal1 = sin(2*pi*58000*t);
signal2 = sin(2*pi*60000*t);
signal3 = sin(2*pi*62000*t);
signal4 = sin(2*pi*80000*t);
hold on;
length = size(t);
subplot(4,1,1);
plot(filter(Hd,signal1));
axis([0 length(2) -1 1]);
title('58kHz');
subplot(4,1,2);
plot(filter(Hd, signal2));
axis([0 length(2) -1 1]);
title('60kHz');
subplot(4,1,3);
plot(filter(Hd, signal3));
axis([0 length(2) -1 1]);
title('62kHz');
subplot(4,1,4);
plot(filter(Hd, signal4));
axis([0 length(2) -1 1]);
title('80kHz');
hold off;

I want my transition band to be as short as possible ofcourse, so we don't get any unwanted signals at all. But if I shoot from the hip I could probably say 1kHz transition band or something(?).
How much ripple in the passband that is allowed, I don't really know...
– Pethead Jun 28 '16 at 12:13