A system for analog filter design, realization and verification using Mathematica and SystemModeler

Tatjana Samardzic

University of Southern Maine

Abstract

Analog filters are an essential part of modern electronics; however, their design, realization and verification can be arduous and time consuming. This paper describes a Mathematica and SystemModeler platform for automated, fast analog filter design and simulation.  The platform consists of two key components:
1. SystemModeler library of first and second order low-pass, high-pass, band-pass, band-stop, and all-pass filters.  The models were created based on some of the most popular filter topologies: Sallen-Key, Tow-Thomas (biquad), State Variable, Multiple Feedback, Bainter, Boctor and Twin-T circuits.  They serve as basic building blocks in creation of higher order filters.
2. Mathematica package based on Butterworth, Chebyshev and elliptic frequency response approximations and different filter topologies.
For a given set of design specifications such as filter type, frequency range, attenuation and gain, the program returns the filter order, number of stages (first and second-order filter stages to be cascaded), and transfer function, gain, cutoff frequency and quality factor for each stage.  For any user-selected filter topology, the program returns values of filter components (resistors and capacitors) for each stage, applies them to the model and simulates the model to verify the time and frequency responses of the model.  We therefore, have a fast and effective means of filter realization and verification, with programmatic control of simulation and filter components.

Analog Filters

Fundamentals

Analog filters are present in just about every piece of electronic equipment: radios, televisions and stereo systems. Test equipment such as spectrum analyzers and signal generators also need filters. Even where signals are converted into a digital form using analog-to-digital converters, analog filters are usually needed to prevent aliasing.  Computers use filters: to reduce electro-magnetic interference from their power lead; to smooth the output of the switched-mode power supply: to limit the video bandwidth of signals going to the display.

Classification

By Frequency Selectivity

Lowpass

Highpass

Bandpass

Bandstop

,,,

By Approximation Method

Butterworth

Chebyshev

Inverse Chebyshev

Elliptic

Plot[Evaluate[Abs[#[{"Lowpass",{1.,1.3},{1.,20.}},s][I ω]//First//First]],{ω,0,4},PlotRange->{0,1},PlotLabel->#,AspectRatio->1/3,AxesLabel->{ω,None},Epilog->{Opacity[0.3],Pink,Rectangle[{0,0},{1.,0.89}],Rectangle[{1.3,0.1},{4,1}]}]&/@{ButterworthFilterModel,Chebyshev1FilterModel,Chebyshev2FilterModel,EllipticFilterModel}

Transfer Function

Transfer Function - factored form:

The squared magnitude response functions of the four classic analog filters  share common form :

\[VerticalSeparator] H(j ω) (\[VerticalSeparator]^2)= (1/(1 + ((Subscript[A, n])^2)(ω))), 
(Subscript[A, n])(ω) = {({{(ω^( n)), Butterworth,}, {ϵ (Subscript[T, n])(ω), Chebyshev I,}, {(1/(ϵ (Subscript[T, n])((1/ω)))), Chebyshev  II,}, {ϵ (Subscript[R, n])(ω), Elliptic,}})

where((Subscript[A, n])^2)(ω)is a polynomial of order2nwhich is specific to each of the analog filters and  (Subscript[T, n])(ω) is the Chebyshev polynomial of the first kind of order n and (Subscript[R, n])(ω) is the elliptic rational function.

Standard second order filter responses:
(obtained from http://www.analog.com/library/analogdialogue/archives/43-09/EDCh%208%20filter.pdf)

Filter Cascade Design Process

Specifications

passband frequency

stopband frequency

passband ripple

stopband attenuation

Approximation

transfer function

poles and zeros

order

pole frequency, q-factor

transfer function partitioned into first and second order sections

Sections are arranged in the order of increasing q-factor

Gain is optimized so that the voltage level at each section’s output is equal to circuit’s output

Nearest poles and zeros are paired

Realization

Transfer function is converted into an electrical circuit.  Circuit components are determined: resistor and capacitor values calculated based on circuit topology.

Topologies implemented:

Sallen-Key

Multiple Feedback

State Variable

Tow-Thomas

Bainter

Boctor

Single Pole (simple RC)

Inverter and Voltage Divider (for gain adjustments)

Simulation and Analysis

Libraries of first nad second order circuits were created in SystemModeler to be used as building blocks for higher order filter implementation. The completed circuit is tested and verified for satisfaction of specifications for exact component values and standard tolerance values.

Existing functions

Transfer Function:

tf=EllipticFilterModel[{"Lowpass",{960. 2 π,1200. 2 π},{1.,30.}}]//Simplify//Chop

TransferFunctionFactor[tf]

Poles and Zeros:

TransferFunctionPoles[tf]

TransferFunctionZeros[tf]

Order

SystemsModelOrder[StateSpaceModel[tf]]

Analog Filter Design Package

<<AnalogFilterDesign`

? AnalogFilterDesign`AnalogFilterDesign`*

Example: Elliptic Filter Design

Specification

spec={"Lowpass",{960. 2 π,1200. 2 π},{1.,30.}};

fullspec={spec,EllipticFilterModel};

fc=FilterCascade[{spec,EllipticFilterModel}]

Transfer Function Factored:

Transfer function of individual stages:

FilterStageTF[fullspec]

Bode Plot of individual stages:

Table[BodePlot[FilterStageTF[fullspec,i]],{i,3}]

Elliptic Filter Design: Bainter Circuit Realization

Componenet Calculation for each stage:

1st stage: Single pole lowpass

sp=SinglePole[{"Lowpass", FilterCascadeGain[fullspec,1], PoleFrequency[fullspec,1], 3.3 (10^(-8))}]

2nd stage: Lowpass notch (bandstop) filter

3rd stage: Lowpass notch (bandstop) filter

bn=BainterNotch[{Rest[FilterCascadeGain[fullspec]],Rest[ZeroFrequency[fullspec]],Rest[PoleFrequency[fullspec]],Rest[QualityFactor[fullspec]],3.3 (10^(-8)),10000}]

at=Attenuator[{Rest[FilterCascadeGain[fullspec]],10000.}]

Component values applied and circuit simulated:

baintersim=applySimulate[{sp,bn,at},"Model1",{UnitStep},0.01,1]

Comparing modeled circuit transfer function with mathematica calculation:

ellip=EllipticFilterModel[spec,s]//Simplify//Chop

comparison1={baintersim[[1]][[1]],baintersim[[2]][[1]],ellip}

BodePlot[comparison1,GridLines->Automatic]

State Variable Realization

Componenet Calculation for each stage:

1st stage: Single pole lowpass

sp=SinglePole[{"Lowpass", FilterCascadeGain[fullspec,1], PoleFrequency[fullspec,1], 3.3 (10^(-8))}]

2nd stage: Lowpass notch (bandstop) filter

3rd stage: Lowpass notch (bandstop) filter

sv=StateVariable[{"Bandstop", Rest[FilterCascadeGain[fullspec]],Rest[ZeroFrequency[fullspec]],Rest[PoleFrequency[fullspec]],Rest[QualityFactor[fullspec]], 3.3 (10^(-8)),10000.}]

Component values applied and circuit simulated:

statevarsim=applySimulate[{sp,sv},"Model2",{UnitStep},0.01]

Comparing modeled circuit transfer function with mathematica calculation:

ellip=EllipticFilterModel[spec,s]//Simplify//Chop

comparison2={statevarsim[[1]][[1]],statevarsim[[2]][[1]],ellip}

BodePlot[comparison2,GridLines->Automatic]

Improvements

SystemModeler 4.0

ability to create models from Mathematica enviroment

connecting existing models programatically

realistic op-amp models

Thank you

QUESTIONS?