{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 17 : Active filters"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.1, Page No 716"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "rs=600.0\n",
      "R1=12.0*10**3\n",
      "Rl=100.0*10**3\n",
      "C1=0.013*10**-6\n",
      "\n",
      "#Calculations\n",
      "print(\"when Rl is not connected\")\n",
      "fc=1.0/(2*3.14*R1*C1)\n",
      "print(\" when Rl is connected\")\n",
      "fc=1.0/(2*3.14*((R1*Rl)/(R1+Rl))*C1)\n",
      "Attn=3#at fc attenuation is =3dB\n",
      "falloffrate=6\n",
      "print(\"attenuation at 2fc\")\n",
      "Attn=3+6\n",
      "print(\"attenuation at 2fc is %ddB \" %Attn)\n",
      "Attn=3+6+6\n",
      "\n",
      "#Results\n",
      "print(\" attenuation at 4fc is %ddB \" %Attn)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "when Rl is not connected\n",
        " when Rl is connected\n",
        "attenuation at 2fc\n",
        "attenuation at 2fc is 9dB \n",
        " attenuation at 4fc is 15dB \n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.2, Page No 718"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialisation of variables\n",
      "Ib=500.0*10**-9\n",
      "f=1.0*10**3\n",
      "\n",
      "#Calculations\n",
      "R1=(70.0*10**-3)/Ib\n",
      "R1=140*10**3#use standard value\n",
      "R2=R1\n",
      "C1=(1/(2*3.14*R1*f))*10**12\n",
      "\n",
      "#Results\n",
      "print(\" capacitor used is of %.2f pF \" %C1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " capacitor used is of 1137.40 pF \n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.3 Page No 719"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialisation of variables\n",
      "\n",
      "print(\"first order high pass active filter\")\n",
      "f=5.0*10**3\n",
      "C1=1000.0*10**-12\n",
      "fu=1.0*10**6\n",
      "\n",
      "#Calculations\n",
      "R1=1.0/(2*3.14*f*C1)\n",
      "BW=fu-f\n",
      "print(\" bandwidth is %.2f kHz \" %(BW/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "first order high pass active filter\n",
        " bandwidth is 995.00 kHz \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.4, Page No 724"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "f=1.0*10**3\n",
      "Ib=500.0*10**-9\n",
      "print(\"butterworth second order filter\")\n",
      "\n",
      "#Calculations\n",
      "R=(70.0*10**-3)/Ib\n",
      "R1=R/2.0\n",
      "R1=68.1*10**3#use standard value\n",
      "R2=R1 \n",
      "R3=2.0*R1\n",
      "Xc1=math.sqrt(2)*R2\n",
      "C1=1/(2*3.14*f*math.sqrt(2)*R2)\n",
      "C2=2*C1\n",
      "fc=1/(2*3.14*(math.sqrt(R1*R2*C1*C2)))\n",
      "\n",
      "#Results\n",
      "print(\"actual cutoff frequency is %d kHz \" %(fc/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "butterworth second order filter\n",
        "actual cutoff frequency is 1 kHz \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.5 Page No 725"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "f=12.0*10**3\n",
      "C1=1000.0*10**-12\n",
      "print(\"butterworth second order filter\")\n",
      "C2=C1\n",
      "\n",
      "#Calculations\n",
      "R2=(math.sqrt(2))/(2*3.14*f*C1)\n",
      "R1=.5*R2\n",
      "R3=R2\n",
      "fc=1.0/(2*3.14*(math.sqrt(R1*R2*C1*C2)))\n",
      "\n",
      "#Results\n",
      "print(\"actual cutoff frequency is %d KHz \" %(fc/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "butterworth second order filter\n",
        "actual cutoff frequency is 11 KHz \n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.6 Page No 729"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialisation of variables\n",
      "f=30.0*10**3\n",
      "C1=1000.0*10**-12\n",
      "print(\" third order low pass filter\")\n",
      "print(\"-20 dB per decade stage\")\n",
      "\n",
      "#Calculations\n",
      "fc1=f/.65\n",
      "R1=1.0/(2*3.14*fc1*C1)\n",
      "R2=R1\n",
      "print(\"-40dB per decade stage\")\n",
      "C3=1000*10**-12\n",
      "C2=2*C3\n",
      "fc2=f/.8\n",
      "R4=1/(2*3.14*fc2*C3*(math.sqrt(2)))\n",
      "R3=R4\n",
      "R5=R3+R4\n",
      "\n",
      "#Results\n",
      "print(\"The value of R5 is %.2f kohm\" %(R5/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " third order low pass filter\n",
        "-20 dB per decade stage\n",
        "-40dB per decade stage\n",
        "The value of R5 is 6.01 kohm\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.7, Page No 730"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "f=20.0*10**3\n",
      "print(\"3rd order high pass filter\")\n",
      "print(\"-20dB per decade stage\")\n",
      "R1=121.0*10**3\n",
      "\n",
      "#Calculations\n",
      "fc1=.65*f\n",
      "C1=1/(2*3.14*fc1*R1)\n",
      "#this is so small it might be effected by stray capacitor.redesign  %first choosing a suitable capacitance C1\n",
      "C1=100*10**-12\n",
      "R1=1/(2*3.14*f*C1)\n",
      "R2=R1\n",
      "print(\"-40dB per decade stage\")\n",
      "C3=1000*10**-12\n",
      "R4=(math.sqrt(2))/(2*3.14*.8*f*C3)\n",
      "C2=C3\n",
      "R3=.5*R4\n",
      "R5=R4\n",
      "\n",
      "#Results\n",
      "print(\"The value of R5 is %.2f kohm\" %(R5/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "3rd order high pass filter\n",
        "-20dB per decade stage\n",
        "-40dB per decade stage\n",
        "The value of R5 is 14.07 kohm\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.8 Page No 734"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "f1=300.0\n",
      "f2=30.0*10**3\n",
      "print(\" single stage band pass filter\")\n",
      "\n",
      "#Calculations\n",
      "C2=1000*10**-12\n",
      "R2=1/(2*3.14*f2*C2)\n",
      "R1=R2\n",
      "Xc1=R1#at voltage gain Av=1\n",
      "C1=1/(2*3.14*f1*R1)\n",
      "R3=R2\n",
      "\n",
      "#Results\n",
      "print(\"The value of R3 is %.2f kohm\" %(R3/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " single stage band pass filter\n",
        "The value of R3 is 5.31 kohm\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.9 Page No 736"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "f1=300.0\n",
      "f2=30.0*10**3\n",
      "\n",
      "#Calculations\n",
      "fo=math.sqrt(f1*f2)\n",
      "BW=f2-f1\n",
      "Q=fo/BW\n",
      "\n",
      "#Results\n",
      "print(\"The value of Q is %.2f \" %(Q))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Q is 0.10 \n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.10 Page No 737"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialisation of variables\n",
      "\n",
      "R1=60.4*10**3\n",
      "R4=1.21*10**3\n",
      "C=.012*10**-6\n",
      "R2=121.0*10**3\n",
      "\n",
      "#Calculations\n",
      "Q=math.sqrt((R1+R4)/(2*R4))\n",
      "fo=Q/(3.14*C*R2)\n",
      "print(\" center frequency is %3.2fHz \" %fo)\n",
      "BW=fo/Q\n",
      "\n",
      "#Results\n",
      "print(\" bandwidth is %3.1fHz \" %BW)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " center frequency is 1106.68Hz \n",
        " bandwidth is 219.3Hz \n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.12, Page No 744"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialisation of variables\n",
      "f1=10.3*10**3\n",
      "f2=10.9*10**3\n",
      "C1=1000.0*10**-12\n",
      "\n",
      "#Calculations\n",
      "C2=C1\n",
      "fo=math.sqrt(f1*f2)\n",
      "R5=1.0/(2*3.14*fo*C1)\n",
      "R1=R5\n",
      "Q=fo/(f2-f1)\n",
      "R2=R1*(2*Q-1)\n",
      "\n",
      "#Results\n",
      "print(\"The value of R2 is %.2f kohm\" %(R2/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R2 is 515.76 kohm\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.13, Page No 750"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "f1=10.3*10**3\n",
      "f2=10.9*10**3\n",
      "Hobp=34\n",
      "\n",
      "#Calculations\n",
      "math.sqrt(f1*f2)\n",
      "Q=fo/(f2-f1)\n",
      "R3=120.0*10**3\n",
      "R2=R3/Q\n",
      "R1=R3/Hobp\n",
      "k=50*fo\n",
      "\n",
      "#Results\n",
      "print(\"The value of k is %.2f \" %(k/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of k is 529.79 \n"
       ]
      }
     ],
     "prompt_number": 27
    }
   ],
   "metadata": {}
  }
 ]
}