In order to test the filter, I used a DTMF tone generated using Audacity, a free audio editing, and recording software. The C code can be found at FIR-filter/code/fft-scilab directory. This algorithm is implemented by the fir_func() described below: In easy words, the output is equal to the product of input samples and filter coefficients generated for the input signal sampled at a certain frequency, in the time domain. As discussed, the FIR filter generates the output signal based on discrete-convolution between the input signal and impulse response of the signal. The C code implements FIR filter equation mentioned in the Introduction section. Frequency Response curve of FIR band-pass filter. The above code will generate a coeff.txt file, containing the filter coefficients. The code will also generate a plot, displaying the relationship between frequency (x-axis) and amplitude (y-axis). Title('Frequency Response of FIR BPF using REMEZ algorithm') * plot relationship between frequency and amplitude. * 256 indicates the length of the array that will be returned * convert floating point coefficients to signed int16_t format. * save the coefficients in a text file */ = eqfir(n, bnd_edge, des_magnit, rel_wght_err) * generate band-pass filter coefficients as floating point values. * This defines magnitude of weighted error across the frequency spectrum. * This is the desired magnitude for the central frequencies of the spectrum. * Central frequency = fo * sampling frequency = 0.115 * 44100 * bnd_edge: determines filter's frequency window. * n: determines the number of filter coefficients to be generated. Or you can paste the following code into a new file in Scilab and run it. You may choose to directly open the fir-bandpass-coeff.sce file once you have Scilab installed and run it. The Scilab script can be found in the FIR-filter/code/fft-scilab directory at the above-mentioned repository. Wate = M-vector that defines the weight of error in each band. It should hold either 0 or 1, depending on the type of filter. The eqfir() method is a Minimax approximation method to compute filter coefficients for multi-band, linear phase FIR filter.Īs per the Scilab documentation, eqfir() is defined as, = eqfir ( nf, bedge, des, wate )īedge = bandwidth edge that define the cut-off frequency.ĭes = M-vector defining the desired magnitude for each band. It is available across all the major platforms and can be found here.įor this demo, I used eqfir() method to generate coefficients for a band-pass filter centered at 5000 Hz. Scilab is an open-source alternative to MATLAB. a low-pass, high-pass, band-pass or band-stop filter. Scilab provides various functions to generate filter coefficients. the filter coefficients for the type of filter being used i.e. In the equation above, y(n) is the output, x(n) is the input and h(k) is the impulse response i.e. The output is a discrete-time convolution between the input signal and impulse response of the filter to be used with a shift in the time domain. IntroductionĪn FIR filter is the type of filter in which the output of the filter depends only on the input provided to the filter. The code for this project can be found in my github repository. In this post, I shall delineate the working and implementation of a finite-impulse-response (FIR) filter using Scilab and C. I have tried to accumulate everything in a single blog post for a quick demo. However, for a beginner, a great deal of information seemed scattered over the internet. Shawn Stevenson’s blog proved to be a great guide to get me started in this domain. However, designing a filter using passive components completes only half the picture, the other half is the design and analysis of these filters using mathematical equations and software such as MATLAB and Scilab.īeing a beginner in the field of signal processing, this post is my attempt to understand the intricacies involved in filter design. While transistors and other passive components, were an introduction to analog electronics and circuit building, filter design proved to be the first set of more advanced circuits. During my years pursuing Bachelors in Engineering, filters were one of the more complicated yet interesting topics.
0 Comments
Leave a Reply. |