<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="m10126">

  <name>Practical Filters</name>

  <metadata>
  <md:version>2.5</md:version>
  <md:created>2001/06/21</md:created>
  <md:revised>2002/06/14</md:revised>
  <md:authorlist>
      <md:author id="richb">
      <md:firstname>Richard</md:firstname>
      <md:othername>G.</md:othername>
      <md:surname>Baraniuk</md:surname>
      <md:email>richb@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="jrom">
      <md:firstname>Justin</md:firstname>
      
      <md:surname>Romberg</md:surname>
      <md:email>jrom@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="richb">
      <md:firstname>Richard</md:firstname>
      <md:othername>G.</md:othername>
      <md:surname>Baraniuk</md:surname>
      <md:email>richb@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mjhaag">
      <md:firstname>Michael</md:firstname>
      
      <md:surname>Haag</md:surname>
      <md:email>mjhaag@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>all pass</md:keyword>
    <md:keyword>bandpass</md:keyword>
    <md:keyword>bandstop</md:keyword>
    <md:keyword>highpass</md:keyword>
    <md:keyword>lowpass</md:keyword>
    <md:keyword>pass band</md:keyword>
    <md:keyword>signals</md:keyword>
    <md:keyword>stop band</md:keyword>
    <md:keyword>systems</md:keyword>
    <md:keyword>transition band</md:keyword>
  </md:keywordlist>

  <md:abstract>Describes how real-world filters behave.</md:abstract>
</metadata>

  <content>

    <para id="para1">
      An <cnxn strength="5" document="m10103">ideal filter</cnxn> simply
      removes all unwanted frequencies, preserving the remaining
      frequencies exactly.  This would resemble some sort of a finite
      rectangle function in frequency.  However, a simple, finite
      rectangle function in frequency is an infinite sinc function in
      time.  This is a problem.  A sinc function is an infinite length
      signal in both the positive and negative directions, making it
      impossible to create in the real-world.  This leads us to as
      what would happen if we just made this sinc function causal by
      "chopping it off" somewhere.  What we find when we do this is
      that the frequency domain representation is no longer a perfect
      rectangle: it now does not fall off immediately and shows some
      wiggling where it was flat before.
    </para>

    <figure id="fig1" orient="horizontal">
      <subfigure id="fig1a">
	<media type="image/png" src="practical1.png"/>
	<caption>A truncated sinc function in time...</caption>
      </subfigure>
      <subfigure id="fig1b">
	<media type="image/png" src="practical2.png"/>
	<caption>
	  ... leads to a smooth, wiggly, "rectangle" in
	  frequency.</caption>
      </subfigure>
    </figure>

    <section id="sect1">
      <name>The Bands</name>
      <para id="para2">
	An ideal filter has two types of bands: the <term>stop
	band</term> defines the region of frequencies that are
	eliminated by the filter, while the <term>pass band</term>
	defines the region of frequencies that the filter allows
	through.  Practical filters add one more, the <term>transition
	band</term>.  This is the area where the filter is moving
	between the stop band and pass band.
      </para>
    </section>

    <section id="sect2">
      <name>Filter Design Specifications</name>
      <para id="para3">
	In our look at filter design specifications, we will use the
	example of a lowpass filter.  The extension to the other kinds
	of filters should be fairly straightforward.  <cnxn target="fig2"/>
	shows the parameters for a lowpass filter in the frequency
	domain.
      </para>

      <figure id="fig2">
	<media type="image/png" src="practical3.png"/>
      </figure>

      <para id="para4">
	From this image, the passband is the region from
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci><m:msub>
		<m:mi>ω</m:mi>
		<m:mi>p</m:mi>
	      </m:msub></m:ci>
	  </m:apply>
	</m:math>
	to
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>ω</m:mi>
	      <m:mi>p</m:mi>
	    </m:msub></m:ci>
	</m:math>,
	the transition bands are the regions from
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci><m:msub>
		<m:mi>ω</m:mi>
		<m:mi>s</m:mi>
	      </m:msub></m:ci>
	  </m:apply>
	</m:math>
	to
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci><m:msub>
		<m:mi>ω</m:mi>
		<m:mi>p</m:mi>
	      </m:msub></m:ci>
	  </m:apply>
	</m:math>
	and from
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>ω</m:mi>
	      <m:mi>p</m:mi>
	    </m:msub></m:ci>
	</m:math>
	to
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>ω</m:mi>
	      <m:mi>s</m:mi>
	    </m:msub></m:ci>
	</m:math>
	while the stop band is the region less than
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci><m:msub>
		<m:mi>ω</m:mi>
		<m:mi>s</m:mi>
	      </m:msub></m:ci>
	  </m:apply>
	</m:math>
	or greater than
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>ω</m:mi>
	      <m:mi>s</m:mi>
	    </m:msub></m:ci>
	</m:math>.
      </para>

      <para id="para5">
	In the figure above,
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>e</m:mi>
	      <m:mi>p</m:mi>
	    </m:msub></m:ci>
	</m:math>
	and
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>e</m:mi>
	      <m:mi>s</m:mi>
	    </m:msub></m:ci>
	</m:math>
	represent the acceptable tolerance (or error) around the
	desired level that the passband and stopband respectively may
	vary.  The behavior within the transition band is not
	specified, allowing anything to occur there, as long as the
	width is within specifications.
      </para>

      <example id="exa1">
	<para id="para6">
	  This example will look at a moving average system.
	</para>
	<figure id="fig3" orient="horizontal">
	  <subfigure id="fig3a">
	    <media type="image/png" src="practical4.png"/>
	    <caption>
	      Time domain representation of the moving
	      average.</caption>
	  </subfigure>
	  <subfigure id="fig3b">
	    <media type="image/png" src="practical5.png"/>
	    <caption>
	      The frequency domain representation of the moving
	      average system is a sinc function.
	      <m:math>
		<m:apply>
		  <m:eq/>
		  <m:apply>
		    <m:ci type="fn">H</m:ci>
		    <m:apply>
		      <m:times/>
		      <m:imaginaryi/>
		      <m:ci>ω</m:ci>
		    </m:apply>
		  </m:apply>
		  <m:apply>
		    <m:times/>
		    <m:apply>
		      <m:exp/>
		      <m:apply>
			<m:minus/>
			<m:apply>
			  <m:times/>
			  <m:imaginaryi/>
			  <m:ci>ω</m:ci>
			  <m:apply>
			    <m:divide/>
			    <m:ci>T</m:ci>
			    <m:cn>2</m:cn>
			  </m:apply>
			</m:apply>
		      </m:apply>
		    </m:apply>
		    <m:apply>
		      <m:divide/>
		      <m:apply>
			<m:sin/>
			<m:apply>
			  <m:times/>
			  <m:ci>ω</m:ci>
			  <m:apply>
			    <m:divide/>
			    <m:ci>T</m:ci>
			    <m:cn>2</m:cn>
			  </m:apply>
			</m:apply>
		      </m:apply>
		      <m:apply>
			<m:times/>
			<m:ci>ω</m:ci>
			<m:apply>
			  <m:divide/>
			  <m:ci>T</m:ci>
			  <m:cn>2</m:cn>
			</m:apply>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:math>
	    </caption>
	  </subfigure>
	</figure>

	<para id="para7">
	  Some notes about this system:
	  <list id="list1" type="bulleted">
	    <item>It is lowpass</item>
	    <item>
	      It has linear phase with jumps of
	      <m:math><m:pi/></m:math> radians when the sinc function
	      changes sign </item>
	    <item>
	      The duration of the filter is inversely proportional to
	      its bandwidth </item>
	    <item>
	      This filter is finite impulse response (FIR) </item>
	    <item>
	      It cannot be built with passive R, L, C circuits </item>
	    <item>
	      We do not have independent control over all four design
	      specifications
	    </item>
	  </list>
	</para>

	<para id="para8">
	  We are going to design a moving average filter with the
	  following design specs:
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:ci><m:msub>
		  <m:mi>ω</m:mi>
		  <m:mi>p</m:mi>
		</m:msub></m:ci>
	      <m:apply>
		<m:times/>
		<m:cn>100</m:cn>
		<m:pi/>
	      </m:apply>
	    </m:apply>
	  </m:math>,
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:ci><m:msub>
		  <m:mi>e</m:mi>
		  <m:mi>s</m:mi>
		</m:msub></m:ci>
	      <m:cn>0.1</m:cn>
	    </m:apply>
	  </m:math>,
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:ci><m:msub>
		  <m:mi>e</m:mi>
		  <m:mi>p</m:mi>
		</m:msub></m:ci>
	      <m:cn>0.1</m:cn>
	    </m:apply>
	  </m:math>
	</para>

	<figure id="fig4">
	  <media type="image/png" src="practical6.png"/>
	</figure>

	<para id="para9">
	  With this specification, we are allowing
	  <m:math>
	    <m:ci><m:msub>
		<m:mi>ω</m:mi>
		<m:mi>s</m:mi>
	      </m:msub></m:ci>
	  </m:math>
	  to be a dependant variable (since we need one).  We can now
	  find the equation for this moving average system.
	</para>

	<para id="para10">
	  We begin with
	  <equation id="eqn1">
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply>
		  <m:abs/>
		  <m:apply>
		    <m:ci type="fn">H</m:ci>
		    <m:apply>
		      <m:times/>
		      <m:imaginaryi/>
		      <m:ci>ω</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:times/>
		  <m:cn>1.1</m:cn>
		  <m:apply>
		    <m:divide/>
		    <m:apply>
		      <m:sin/>
		      <m:apply>
			<m:times/>
			<m:ci>ω</m:ci>
			<m:apply>
			  <m:divide/>
			  <m:ci>T</m:ci>
			  <m:cn>2</m:cn>
			</m:apply>
		      </m:apply>
		    </m:apply>
		    <m:apply>
		      <m:times/>
		      <m:ci>ω</m:ci>
		      <m:apply>
			<m:divide/>
			<m:ci>T</m:ci>
			<m:cn>2</m:cn>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:math>
	  </equation>
	  We will now solve for <m:math><m:ci>T</m:ci></m:math>
	  with 
	  <equation id="eqn2">
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply>
		  <m:abs/>
		  <m:apply>
		    <m:ci type="fn">H</m:ci>
		    <m:apply>
		      <m:times/>
		      <m:imaginaryi/>
		      <m:cn>100</m:cn>
		      <m:pi/>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:times/>
		  <m:cn>1.1</m:cn>
		  <m:apply>
		    <m:divide/>
		    <m:apply>
		      <m:sin/>
		      <m:apply>
			<m:cn>50</m:cn>
			<m:pi/>
			<m:ci>T</m:ci>
		      </m:apply>
		    </m:apply>
		    <m:apply>
		      <m:times/>
		      <m:cn>50</m:cn>
		      <m:pi/>
		      <m:ci>T</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:cn>0.9</m:cn>
	      </m:apply>
	    </m:math>
	  </equation>
	  For these specs, 
	  <m:math>
	    <m:apply>
	      <m:approx/>
	      <m:ci>T</m:ci>
	      <m:cn>0.007</m:cn>
	    </m:apply>
	  </m:math>.
	  This means that
	  <m:math>
	    <m:apply>
	      <m:abs/>
	      <m:apply>
		<m:ci type="fn">H</m:ci>
		<m:apply>
		  <m:times/>
		  <m:imaginaryi/>
		  <m:ci>ω</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	  does not stay below
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:ci><m:msub>
		  <m:mi>e</m:mi>
		  <m:mi>s</m:mi>
		</m:msub></m:ci>
	      <m:cn>0.1</m:cn>
	    </m:apply>
	  </m:math>
	  until
	  <m:math>
	    <m:apply>
	      <m:approx/>
	      <m:ci><m:msub>
		  <m:mi>ω</m:mi>
		  <m:mi>s</m:mi>
		</m:msub></m:ci>
	      <m:apply>
		<m:times/>
		<m:cn>771</m:cn>
		<m:pi/>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	</para>

	<figure id="fig5">
	  <media type="image/png" src="practical7.png"/>
	  <caption>
	    A graphical look at the transfer function of this lowpass
	    filter with the passband and stopband noted.</caption>
	</figure>

	<para id="para11">
	  It is very clear from this representation that the
	  transition band is huge (
	  <m:math>
	    <m:apply>
	      <m:times/>
	      <m:cn>671</m:cn>
	      <m:pi/>
	    </m:apply>
	  </m:math>).  This is a very bad filter, especially when you
	  consider that it cannot be implemented with passive
	  circuitry.  Fortunately better filters
	  (<foreign>e.g.</foreign> <cnxn strength="9" document="m10127">Butterworth</cnxn>, <cnxn strength="9" document="m10104">Chebyshev</cnxn> and <cnxn strength="9" document="m10105">Elliptical</cnxn>) do exist.
	</para>
      </example>
    </section>

    <section id="sect3">
      <name>Beyond Lowpass Filter Design</name>
      <para id="para12">
	In the discussion of the different filters (Butterworth,
	Chebyshev and Elliptical) is common to see explanations based
	on lowpass filters.  This explanation is very nice when first
	learning about them, because it is sufficient to understand
	the fundamentals of each of them.  It is acceptable, because
	there exist fairly straightforward techniques to convert these
	lowpass filters into highpass, bandpass or bandstop filters.
	These techniques are the <cnxn strength="9" document="LowHighTransformation">lowpass to highpass
	transformation</cnxn>, <cnxn strength="9" document="LowBandpassTransformation">lowpass to bandpass
	transformation</cnxn> and <cnxn strength="9" document="LowBandstopTransformation">lowpass to bandstop
	transformation</cnxn>.
      </para>
    </section>

  </content>
</document>
