<< Chapter < Page Chapter >> Page >
This module describes how to implement an FIR filter using a FIFO buffer where the elements are shifted and another that uses a circular buffer.

Introduction

This module explains how to implement an FIR filter in the Direct-Form structure. It explains how data is stored as samples are received and how to use a circular buffer in the algorithm.

Reading

Fir filtering

The difference equation for an N -order FIR filter is given by:

y ( n ) = k = 0 N 1 b k x ( n k ) = k = 0 N 1 h ( k ) x ( n k ) size 12{y \( n \) = Sum cSub { size 8{k=0} } cSup { size 8{N - 1} } {b rSub { size 8{k} } x \( n - k \) } = Sum cSub { size 8{k=0} } cSup { size 8{N - 1} } {h \( k \) x \( n - k \) } } {}

For each new input sample, x ( n ), the filter produces an output y ( n ). To calculate the new output sample, the input must be convolved with the FIR filter impulse response, h ( n ). Notice that the summation requires the input samples starting with the most recent sample, x ( n ) through the N -1 most recent samples, through x ( n - N -1). In a DSP system, these previous samples must be saved in an array in memory. Usually there will be one new sample received, x ( n ), and any previous samples that were received must be saved in memory.

Fifo buffer

Since the algorithm only needs the previous N -1 samples to be saved there must be a way for the algorithm to update the array when a new sample is input. This can be accomplished in two ways. The first way is to shift all the samples in the array by copying them to the shifted location and then storing the new value at the beginning of the array. This is a first-in-first-out (FIFO) buffer. If this method is used then the FIR algorithm is given by

y out = k = 0 N 1 h ( k ) x saved ( k ) size 12{y rSub { size 8{ ital "out"} } = Sum cSub { size 8{k=0} } cSup { size 8{N - 1} } {h \( k \) x rSub { size 8{ ital "saved"} } \( k \) } } {}

Figure 1 shows a diagram of the implementation of the FIR filter using the array shifting method. In the diagram the "*" indicates multiplication. The new value is shifted into the x (0) spot and all the others are shifted to the right.

Diagram of the FIR filter implementation using the shifting method

The following pseudo-code shows how to implement the FIR filter using the FIFO type buffer. In the code the following definitions are used:

N - number of coefficients

h(n) - filter coefficients, n = 0...N-1

x(n) - stored input data, n = 0...N-1

input_sample - variable that contains the newest input sample

// Shift in the new sample. Note the data is shifted starting at the end. for (i=N-2; i>=0; i--){ x[i+1]= x[i];} x[0]= input_sample // Filter the dataynew = 0; for(i=0;i<N;i++){ ynew = ynew + h(i)*x(i);}

Double size fifo buffer

In the example above, the data in the FIFO buffer is shifted every time a new sample is received. This could lead to inefficient code. It is better to do processing on blocks of data. For instance, you could use a DMA to copy a block of data from one place to another and free up the processor from doing the work.

One solution could be to make a FIFO buffer that is twice as large as the data that is needed to store. When this is done, shifting of the data can be done after a block of data is received.

The following figures show the data buffer as data is being received and stored. Figure 2 shows the buffer when the first new value is received. Of course the buffer would be zeroed before processing begins. The shaded area shows the part of the buffer that is used in the algorithm.

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Dsp lab with ti c6x dsp and c6713 dsk. OpenStax CNX. Feb 18, 2013 Download for free at http://cnx.org/content/col11264/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Dsp lab with ti c6x dsp and c6713 dsk' conversation and receive update notifications?

Ask