How to go from filter designer to C/C++ Code

8 visualizaciones (últimos 30 días)
Dario Vazquez
Dario Vazquez el 14 de Feb. de 2019
I am now being acostumed to using the Filter Builder GUI to create a simple or complex filter function. I need to implement this on a DSP chip, I think the first natural step is to get it to work on my sandbox on my Host Computer, I havent found a simple way to get the C code, I have tried to used Matlab Coder but built int function like 'fdesign.lowpass'
I have also used Filter Designer to get the SOS and G coefficients for the filter, but I am failing to get a hold on code that will apply the filtering just by adding the coeficients.
Another requirement as is normal in DSP aplications, is that the function needs to work on a pre-defined number of samples at a time.
function y = doFilter(x)
%DOFILTER Filters input x and returns output y.
% MATLAB Code
% Generated by MATLAB(R) 9.1 and the DSP System Toolbox 9.3.
% Generated on: 14-Feb-2019 10:31:58
persistent Hd;
if isempty(Hd)
Fpass = 9000; % Passband Frequency
Fstop = 10000; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 30; % Stopband Attenuation (dB)
Fs = 44100; % Sampling Frequency
h = fdesign.lowpass('fp,fst,ap,ast', Fpass, Fstop, Apass, Astop, Fs);
Hd = design(h, 'equiripple', ...
'MinOrder', 'any', ...
'StopbandShape', 'flat');
set(Hd, 'Arithmetic', 'single');
set(Hd,'PersistentMemory',true);
end
y = filter(Hd,x);

Respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by