<< 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 mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
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