{

 "metadata": {

  "name": "",

  "signature": "sha256:f9ba841d51e943eb842cd7b286030046166ba358e1dbe882cc0bc48bab2a1a28"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter3: Linear Application of IC Op-Amps"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.1:pg-95"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Given\n",

      "R1=2.2#kohm\n",

      "G=-100 #Voltage gain\n",

      "Rf=-G*R1#kohm\n",

      "print \"Value of Rf: \",Rf ,\"kohm\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Value of Rf:  220.0 kohm\n"

       ]

      }

     ],

     "prompt_number": 3

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.2:pg-95"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Given\n",

      "Vin=2.5 #mV\n",

      "R1=2 #kohm\n",

      "Rf=200 #kohm\n",

      "G=-Rf/R1 #Gain\n",

      "Vo=G*Vin/1000.0 #V\n",

      "print \"Output Voltage Vo=\",Vo \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Output Voltage Vo= -0.25\n"

       ]

      }

     ],

     "prompt_number": 5

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.3:pg-96"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Given\n",

      "G=-10 #Gain\n",

      "Ri=100 #kohm input resistance \n",

      "R1=Ri #kohm\n",

      "R2=-G*R1 #kohm\n",

      "print R1,\"is the Value of R1 in kohm \"  \n",

      "print int(R2/1000),\"the Value of R2 in Mohm \"  \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "100 is the Value of R1 in kohm \n",

        "1 the Value of R2 in Mohm \n"

       ]

      }

     ],

     "prompt_number": 9

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.4:pg-119"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "import math\n",

      "#Given\n",

      "FT1=1  #Filter Transmission\n",

      "FT2=0.99  #Filter Transmission\n",

      "FT3=0.9  #Filter Transmission\n",

      "FT4=0.1  #Filter Transmission\n",

      "A1= int(-20*math.log10(FT1))  #dB\n",

      "A2= round(-20*math.log10(FT2),3)  #dB\n",

      "A3= round(-20*math.log10(FT3),3)  #dB\n",

      "A4= -20*math.log10(FT4)  #dB\n",

      "print \"For filter transmission=1, Attenuation(dB)=\", A1 \n",

      "print \"For filter transmission=0.99, Attenuation(dB)=\",A2 \n",

      "print \"For filter transmission=0.9, Attenuation(dB)=\",A3\n",

      "print \"For filter transmission=0.1, Attenuation(dB)=\",A4 \n",

      " #Answer in the book is wrong for 0.99 filter transmission.\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "For filter transmission=1, Attenuation(dB)= 0\n",

        "For filter transmission=0.99, Attenuation(dB)= 0.087\n",

        "For filter transmission=0.9, Attenuation(dB)= 0.915\n",

        "For filter transmission=0.1, Attenuation(dB)= 20.0\n"

       ]

      }

     ],

     "prompt_number": 24

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.5:pg-119"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Given\n",

      "import math\n",

      "fo=2 #kHz\n",

      "Ap=10.0 #Band pass gain\n",

      "C=0.1 #micro F(have to choose C, 0.01<C<1)\n",

      "R2=round(1/(2*math.pi*fo*math.pow(10,3)*C*math.pow(10,-6)),1) #ohm\n",

      "R1=R2/Ap #ohm\n",

      "print \"Design values are :\"\n",

      "print C,\"is the Capacitance(micro F)\"\n",

      "print int(round(R1)),\"is the Resistance R1(ohm)\"\n",

      "print round(R2/1000.0,1),\"is the Resistance R2(kohm)\"\n",

      " #Answer in the book is wrong R2 should be .8kohm instead of 8kohm.\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.1 is the Capacitance(micro F)\n",

        "80 is the Resistance R1(ohm)\n",

        "0.8 is the Resistance R2(kohm)\n"

       ]

      }

     ],

     "prompt_number": 100

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.6:pg-129"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "import math\n",

      "#Given\n",

      "fo=1  #kHz\n",

      "Ap=1.586  #Band pass gain\n",

      "C=0.005 #micro F C1=C2=0.005(Assumed)\n",

      "R=round(1/(2*math.pi*fo*math.pow(10,3)*C*math.pow(10,-6)),2) #ohm\n",

      "Rf=10  #kohm(Assumed)\n",

      "Ri=Rf/(Ap-1)  #kohm\n",

      "print \"Design values are :\" \n",

      "print round(R/1000,2),\" is the Resistance in kohm, R1=R2=R\"\n",

      "print round(Ri,2),\"is the Resistance Ri(kohm)\" \n",

      "print Rf,\"is the Resistance Rf(kohm)\" \n",

      "print C,\"is the Capacitance(micro F), C1=C2=C\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "31.83  is the Resistance in kohm, R1=R2=R\n",

        "17.06 is the Resistance Ri(kohm)\n",

        "10 is the Resistance Rf(kohm)\n",

        "0.005 is the Capacitance(micro F), C1=C2=C\n"

       ]

      }

     ],

     "prompt_number": 101

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.7:pg-134"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "import math\n",

      "#Given\n",

      "fo=3  #kHz\n",

      "Ap=4  #Band pass gain\n",

      "alfa=1.414  #for butterworth filter\n",

      "C1=0.01  #micro F(Assumed)\n",

      "C2=round(math.pow(alfa,2)*C1/4.0,3)  #micro F\n",

      "R=round(1/(2*math.pi*fo*math.pow(10,3)*math.sqrt(C1*math.pow(10,-6)*C2*math.pow(10,-6))*1000.0),3)  #kohm\n",

      "Rf=2*R  #kohm(Assumed)\n",

      "print \"Design values are :\" \n",

      "print C1,\"is the Capacitance C1(micro F)\" \n",

      "print C2,\"is the Capacitance C2(micro F)\" \n",

      "print R,\"is the Resistance R(kohm)\" \n",

      "print \"For offset minimization, Resistance Rf(kohm)=\",Rf\n",

      " #/For additional pass band gain\n",

      "Ri=10.0  #kohm(Assumed)\n",

      "Rf=(Ap-1)*Ri  #kohm\n",

      "print \"For additional band pass gain:\" \n",

      "print Ri,\"is the Resistance Ri(kohm)\" \n",

      "print Rf,\"is the Resistance Rf(kohm)\" \n",

      " #Answer in the book is incorrect for C2.\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.01 is the Capacitance C1(micro F)\n",

        "0.005 is the Capacitance C2(micro F)\n",

        "7.503 is the Resistance R(kohm)\n",

        "For offset minimization, Resistance Rf(kohm)= 15.006\n",

        "For additional band pass gain:\n",

        "10.0 is the Resistance Ri(kohm)\n",

        "30.0 is the Resistance Rf(kohm)\n"

       ]

      }

     ],

     "prompt_number": 49

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.8:pg-136"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "import math\n",

      "#Given  \n",

      "fo=2 #kHz\n",

      "alfa=1.414 #for butterworth filter\n",

      "Ap=3-alfa #band pass gain\n",

      "RfBYRi=(Ap-1) #op-amp gain\n",

      "C=0.05 #micro F(Assumed)\n",

      "R=round(1/(2*math.pi*fo*10**3*C*10**-6)/1000,1) #kohm\n",

      "#For offset minimization 2*R=Rf||Ri\n",

      "Rf=round(2*R*RfBYRi+2*R,2) #kohm\n",

      "Ri=round(Rf/RfBYRi,3) #kohm\n",

      "print \"Design values are :\"\n",

      "print C,\"is the Capacitance C(micro F)\" \n",

      "print R,\"is the Resistance R(kohm)\" \n",

      "print Rf,\"is the Resistance Rf(kohm)\"\n",

      "print Ri,\"is the Resistance Ri(kohm)\" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.05 is the Capacitance C(micro F)\n",

        "1.6 is the Resistance R(kohm)\n",

        "5.08 is the Resistance Rf(kohm)\n",

        "8.669 is the Resistance Ri(kohm)\n"

       ]

      }

     ],

     "prompt_number": 102

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.9:pg-139"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.9  \n",

      "import math\n",

      "fo=1.2 #kHz\n",

      "alfa=1.414 #for butterworth filter\n",

      "Ap=3-alfa #band pass gain\n",

      "RfBYRi=(Ap-1) #op-amp gain\n",

      "C=0.03 #micro F(have to choose C, 0.01<C<1)\n",

      "R=round(1/(2*math.pi*fo*10**3*C*10**-6)/1000,1) #kohm\n",

      "#For offset minimization 2*R=Rf||Ri\n",

      "Rf=round(2*R*RfBYRi+2*R,2) #kohm\n",

      "Ri=round(Rf/RfBYRi,1) #kohm\n",

      "print \"Design values are :\" \n",

      "print C,\"is the Capacitance(micro F)\" \n",

      "print R,\"is the Resistance R(kohm)\" \n",

      "print Rf,\"is the Resistance Rf(kohm)\" \n",

      "print Ri,\"is the Resistance Ri(kohm)\" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.03 is the Capacitance(micro F)\n",

        "4.4 is the Resistance R(kohm)\n",

        "13.96 is the Resistance Rf(kohm)\n",

        "23.8 is the Resistance Ri(kohm)\n"

       ]

      }

     ],

     "prompt_number": 64

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.10:pg-141"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " #Ex 3.10\n",

      "import math    \n",

      "fL=200  #Hz\n",

      "fH=1*1000  #Hz\n",

      "Ap=4  #band pass gain\n",

      "BW=fH-fL  #Hz\n",

      "f0=math.sqrt(fH*fL)  #Hz\n",

      "fc=math.sqrt(fH*fL)  #Hz\n",

      "Q=fc/BW  #Quality factor\n",

      "print round(Q,2),\"is the Quality factor \" \n",

      "print \"As Q<12   it is wide band filter \" \n",

      "print fL,\"is the Design values for high pass section with Ap1=2 & fL(Hz) : \" \n",

      "Ap1=2  #band pass gain for high pass section\n",

      "C=0.033  #micro F(have to choose C, 0.01<C<1)\n",

      "R=int(1/(2*math.pi*fL*C*10 **-6)/1000.0)  #kohm\n",

      "RfBYRi=(Ap-1)  #op-amp gain\n",

      "Rf=2*R  #kohm\n",

      "Ri=2*R  #kohm\n",

      "print C,\"is the Capacitance(micro F) \" \n",

      "print R,\"is the Resistance R(kohm) \" \n",

      "print Rf,\"=Resistance Rf(kohm) \" \n",

      "print Ri,\"=Resistance Ri(kohm) \" \n",

      "print fH,\"=Design values for low pass section with Ap2=2 & fH(Hz) : \" \n",

      "Ap2=2  #band pass gain for low pass section\n",

      "C=0.033  #micro F(have to choose C, 0.01<C<1)\n",

      "k=fL/fH  #scaling factor\n",

      "Rdash=0.2*R  #kohm\n",

      "Ri=2*Rdash  #kohm\n",

      "Rf=Ri  #kohm(for Ap2=2)\n",

      "print C,\"=Capacitance(micro F) \" \n",

      "print Rdash,\"=Resistance Rdash(kohm) \" \n",

      "print Rf,\"=Resistance Rf(kohm) \" \n",

      "print Ri,\"=Resistance Ri(kohm) \" \n",

      "print \"For design purpose use rounded value 10 kohm for Rf & Ri \" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.56 is the Quality factor \n",

        "As Q<12   it is wide band filter \n",

        "200 is the Design values for high pass section with Ap1=2 & fL(Hz) : \n",

        "0.033 is the Capacitance(micro F) \n",

        "24 is the Resistance R(kohm) \n",

        "48 =Resistance Rf(kohm) \n",

        "48 =Resistance Ri(kohm) \n",

        "1000 =Design values for low pass section with Ap2=2 & fH(Hz) : \n",

        "0.033 =Capacitance(micro F) \n",

        "4.8 =Resistance Rdash(kohm) \n",

        "9.6 =Resistance Rf(kohm) \n",

        "9.6 =Resistance Ri(kohm) \n",

        "For design purpose use rounded value 10 kohm for Rf & Ri \n"

       ]

      }

     ],

     "prompt_number": 103

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.11:pg-144"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.11\n",

      "import math \n",

      "fL=200 #Hz\n",

      "fH=1*1000 #Hz\n",

      "Ap=4 #band pass gain\n",

      "BW=fH-fL #Hz\n",

      "f0=math.sqrt(fH*fL) #Hz\n",

      "fc=math.sqrt(fH*fL) #Hz\n",

      "Q=int(fc/BW) #Quality factor\n",

      "print Q, \"=Quality factor\" \n",

      "print \"As Q<10   it is wide band filter\" \n",

      "print fH, \"=Design values for low pass section with Ap2=2 & fH(Hz) :\" \n",

      "Ap2=2 #band pass gain for low pass section\n",

      "C=0.03 #micro F(have to choose C, 0.01<C<1)\n",

      "Rdash=round(1/(2*math.pi*fH*C*10**-6)/1000,1) #kohm\n",

      "print C, \"=Capacitance(micro F)\" \n",

      "print Rdash, \"=Resistance Rdash(kohm)\" \n",

      "print \"Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\" \n",

      "print fL, \"=Design values for high pass section with Ap1=2 & fL(Hz) :\" \n",

      "Ap1=2 #band pass gain for high pass section\n",

      "C=0.05 #micro F(have to choose C, 0.01<C<1)\n",

      "R=round(1/(2*math.pi*fL*C*10**-6)/1000,1) #kohm\n",

      "RfBYRi=(Ap-1) #op-amp gain\n",

      "print C, \"=Capacitance(micro F)\" \n",

      "print R, \"=Resistance R(kohm)\" \n",

      "print \"Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0 =Quality factor\n",

        "As Q<10   it is wide band filter\n",

        "1000 =Design values for low pass section with Ap2=2 & fH(Hz) :\n",

        "0.03 =Capacitance(micro F)\n",

        "5.3 =Resistance Rdash(kohm)\n",

        "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\n",

        "200 =Design values for high pass section with Ap1=2 & fL(Hz) :\n",

        "0.05 =Capacitance(micro F)\n",

        "15.9 =Resistance R(kohm)\n",

        "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\n"

       ]

      }

     ],

     "prompt_number": 104

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.12:pg-150"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.12\n",

      "import math\n",

      "fo=1.2*1000 #Hz\n",

      "Q=4 #Quality factor\n",

      "Ap=10 #band pass gain\n",

      "C=0.05 #micro F(have to choose C, 0.01<C<1)\n",

      "R2=round(2*Q/(2*math.pi*fo*C*10** -6)/1000,2) #kohm\n",

      "R1=round(R2/2/Ap,2) #kohm\n",

      "R3=round(R1/(4*math.pi**2*R1*1000*R2*1000*(C*10** -6)** 2*fo** 2-1),2) #kohm\n",

      "print  \"Design values are :\"  \n",

      "print  C,\"=  Capacitance(micro F)\"  \n",

      "print  R1,\"=  Resistance R1(kohm)\"  \n",

      "print  R2,\"=  Resistance R2(kohm)\"  \n",

      "print  R3*1000,\"=  Resistance R3(ohm)\"  \n",

      "#Answer in the book is wrong for R3.\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.05 =  Capacitance(micro F)\n",

        "1.06 =  Resistance R1(kohm)\n",

        "21.22 =  Resistance R2(kohm)\n",

        "480.0 =  Resistance R3(ohm)\n"

       ]

      }

     ],

     "prompt_number": 105

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.13:pg-153"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.13\n",

      "import math\n",

      "fH=100 #Hz\n",

      "fL=1*1000 #Hz\n",

      "print  \"This filter is a combination of -:\"  \n",

      "print  \"High pass filter having fH=100 Hz\"  \n",

      "print  \"Low pass filter having fL=1 kHz\"  \n",

      "print  \"And a summing amplifier\"  \n",

      "#High pass filter\n",

      "print  \"Design values for high pass section :\"  \n",

      "C=0.05 #micro F(have to choose C, 0.01<C<1)\n",

      "R=round(1/(2*math.pi *fL*C*10 **-6)/1000,2) #kohm\n",

      "Ap=2 #assumed\n",

      "#Rf=Ri #for gain=2\n",

      "Rf=10 #kohm(assumed)\n",

      "Ri=10 #kohm(assumed)\n",

      "print  C,\"=  Capacitance(micro F)\"  \n",

      "print  R,\"=  Resistance R(kohm)\"  \n",

      "print  \"Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\"  \n",

      "#Low pass filter\n",

      "print  \"Design values for low pass section :\"  \n",

      "C=0.1 #micro F(have to choose C, 0.01<C<1)\n",

      "Rdash=round(1/(2*math.pi *fH*C*10 **-6)/1000,2) #kohm\n",

      "Ap=2 #assumed\n",

      "#Rfdash=Ridash #for gain=2\n",

      "Rf_dash=10 #kohm(assumed)\n",

      "Ri_dash=10 #kohm(assumed)\n",

      "print  C,\"=  Capacitance(micro F)\"  \n",

      "print  Rdash,\"=  Resistance Rdash(kohm)\"  \n",

      "print  \"Value of Resistance Rf_dash & Ri_dash can be choosen as 10 kohm for filter design.\"  \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "This filter is a combination of -:\n",

        "High pass filter having fH=100 Hz\n",

        "Low pass filter having fL=1 kHz\n",

        "And a summing amplifier\n",

        "Design values for high pass section :\n",

        "0.05 =  Capacitance(micro F)\n",

        "3.18 =  Resistance R(kohm)\n",

        "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design.\n",

        "Design values for low pass section :\n",

        "0.1 =  Capacitance(micro F)\n",

        "15.92 =  Resistance Rdash(kohm)\n",

        "Value of Resistance Rf_dash & Ri_dash can be choosen as 10 kohm for filter design.\n"

       ]

      }

     ],

     "prompt_number": 106

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.14:pg-156"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.14\n",

      "import math\n",

      "fN=50  #Hz\n",

      "C=0.5  #micro F(have to choose C, 0.01<C<1)\n",

      "R=round(1/(2*math.pi*fN*C*10 **-6)/1000,2)  #kohm\n",

      "print \"Design values are : \" \n",

      "print C ,\"= Capacitance(micro F) \" \n",

      "print R ,\"= Resistance R(kohm) \" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are : \n",

        "0.5 = Capacitance(micro F) \n",

        "6.37 = Resistance R(kohm) \n"

       ]

      }

     ],

     "prompt_number": 107

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.15:pg-157"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.15\n",

      "import math\n",

      "fo=1*1000#Hz\n",

      "fo_dash=1.5*1000#Hz\n",

      "C=0.01#micro F(have to choose C, 0.01<C<1)\n",

      "R=round(1/(2*math.pi*fo*C*10**-6)/1000,3)#kohm\n",

      "K=1.2*1000/fo_dash#scaling factor\n",

      "Rdash=round(K*R,3)#/kohm\n",

      "print \"Design values are :\"\n",

      "print C,\"= Capacitance(micro F)\"\n",

      "print R,\"= Resistance R(kohm)\"\n",

      "print Rdash,\"= Resistance Rdash(kohm)\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "0.01 = Capacitance(micro F)\n",

        "15.915 = Resistance R(kohm)\n",

        "12.732 = Resistance Rdash(kohm)\n"

       ]

      }

     ],

     "prompt_number": 108

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.16:pg-179"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.16\n",

      "Vf=0.0125 #V\n",

      "Vo=0.5 #V\n",

      "Beta=Vf/Vo #unitless\n",

      "#A*Beta=1 for oscillation\n",

      "A=1/Beta #gain\n",

      "print A,\"= Minimum Gain\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "40.0 = Minimum Gain\n"

       ]

      }

     ],

     "prompt_number": 110

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.17:pg-179"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.17\n",

      "import math\n",

      "R=50#kohm(R1=R2=R3=R)\n",

      "C=60#pF(C1=C2=C3=C)\n",

      "f=round(1/(2*math.pi*R*1000*C*10**-12*math.sqrt(6)),2)#Hz\n",

      "print round(f/1000,3),\"= Frequency of oscillation(kHz)\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "21.658 = Frequency of oscillation(kHz)\n"

       ]

      }

     ],

     "prompt_number": 112

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.18:pg-185"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.18\n",

      "import math\n",

      "f=2*1000#Hz\n",

      "R=10#kohm(Assumed)(R1=R2=R)\n",

      "C=1/(2*math.pi*R*1000*f)#F\n",

      "print \"Value of resistance R1=R2 can be choosen as 10 kohm\"\n",

      "print round(C*10**9,2),\"= Cpacitance(nF)\"\n",

      "print \"Value of resistance R4 can be choosen as 10 kohm & R3=2*R4=20 kohm for Beta to be 1/3\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Value of resistance R1=R2 can be choosen as 10 kohm\n",

        "7.96 = Cpacitance(nF)\n",

        "Value of resistance R4 can be choosen as 10 kohm & R3=2*R4=20 kohm for Beta to be 1/3\n"

       ]

      }

     ],

     "prompt_number": 113

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.19:pg-185"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.19\n",

      "import math \n",

      "R=200#kohm(R1=R2=R)\n",

      "C=200#pF(C1=C2=C)\n",

      "f=1/(2*math.pi*R*1000*C*10**-12)#Hz\n",

      "print round(f*10**-3,3),\"= Frequency of oscillation(kHz)\"\n",

      "#Answer in the book is wrong"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "3.979 = Frequency of oscillation(kHz)\n"

       ]

      }

     ],

     "prompt_number": 116

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.20:pg-187"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " #Ex 3.20\n",

      "import math\n",

      "import numpy\n",

      "omegaBYomega0=[0, 0.5, 1, 5, 10, 100] \n",

      "T=numpy.zeros(6);\n",

      "G=numpy.zeros(6);\n",

      "A=numpy.zeros(6);\n",

      "f=numpy.zeros(6);\n",

      " #T=omega0/sqrt(omega0**2+omega**2)  #Gain\n",

      "for i in range(0,6):\n",

      "    T[i]=round(1/sqrt(1**2+omegaBYomega0[i]**2),3)  #Gain    \n",

      "    G[i]=round(20*math.log10(T[i]),2)  #dB\n",

      "    A[i]=round(-20*math.log10(T[i]),2)  #dB\n",

      "    f[i]=round(-math.atan(omegaBYomega0[i])*180/math.pi,2)  #degree\n",

      "\n",

      "print  \"omega/omega0  T(j*omega)  (G(dB))  A(dB) f\"\n",

      "for i in range(0,6):\n",

      "    print omegaBYomega0[i],\"\\t\\t\\t\\t\",T[i],\"\\t\\t\\t\\t\",G[i],\"\\t\\t\\t\\t\",A[i],\"\\t\\t\\t\\t\",f[i]  \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "omega/omega0  T(j*omega)  (G(dB))  A(dB) f\n",

        "0 \t\t\t\t1.0 \t\t\t\t0.0 \t\t\t\t-0.0 \t\t\t\t-0.0\n",

        "0.5 \t\t\t\t0.894 \t\t\t\t-0.97 \t\t\t\t0.97 \t\t\t\t-26.57\n",

        "1 \t\t\t\t0.707 \t\t\t\t-3.01 \t\t\t\t3.01 \t\t\t\t-45.0\n",

        "5 \t\t\t\t0.196 \t\t\t\t-14.15 \t\t\t\t14.15 \t\t\t\t-78.69\n",

        "10 \t\t\t\t0.1 \t\t\t\t-20.0 \t\t\t\t20.0 \t\t\t\t-84.29\n",

        "100 \t\t\t\t0.01 \t\t\t\t-40.0 \t\t\t\t40.0 \t\t\t\t-89.43\n"

       ]

      }

     ],

     "prompt_number": 135

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.21:pg-188"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.21\n",

      "import math\n",

      "omega1=0.1#rad/s\n",

      "omega2=1.0#rad/s\n",

      "omega3=10.0#rad/s\n",

      "T1=round(1/math.sqrt(1+omega1**6))#Transfer function\n",

      "T2=round(1/math.sqrt(1+omega2**6),3)#Transfer function\n",

      "T3=round(1/math.sqrt(1+omega3**6),3)#Transfer function\n",

      "f1=-math.atan((2*omega1-omega1**3)/real(1-2*omega1**2))*180/math.pi#degree\n",

      "f2=-math.atan((2*omega2-omega2**3)/real(1-2*omega2**2))*180/math.pi#degree\n",

      "f3=-math.atan((2*omega3-omega3**3)/real(1-2*omega3**2))*180/math.pi#degree\n",

      "print \"Value of T= \",T1,\"& f1 for 0.1 rad/s:\",round(f1,1),\"degree\"\n",

      "print \"Value of T= \",T2,\"& f2 for 1 rad/s: \",f2-180,\"degree\"\n",

      "print \"Value of T= \",T3,\"& f3 for 10 rad/s: \",round(f3,2),\"degree\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Value of T=  1.0 & f1 for 0.1 rad/s: -11.5 degree\n",

        "Value of T=  0.707 & f2 for 1 rad/s:  -135.0 degree\n",

        "Value of T=  0.001 & f3 for 10 rad/s:  -78.52 degree\n"

       ]

      }

     ],

     "prompt_number": 145

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.22:pg-189"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " #Ex 3.22\n",

      "import math\n",

      "f0=10*1000 #Hz(3-dB frequency)\n",

      "DCgain=10 #dc gain\n",

      "R1=10 #kohm\n",

      "R2=DCgain*R1 #kohm\n",

      "C=round(1/(2*math.pi*f0*R2*1000)*10**9,3) #nF\n",

      "print \"Design values are :\"\n",

      "print R2,\"= Resistance R2(kohm) \"\n",

      "print C,\"= Capacitance C(nF)\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "100 = Resistance R2(kohm) \n",

        "0.159 = Capacitance C(nF)\n"

       ]

      }

     ],

     "prompt_number": 147

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.23:pg-190"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " #  Ex 3.23\n",

      "import math\n",

      "f0=100 #  Hz(3-dB frequency)\n",

      "Ri_inf=100 #  kohm(High frequency input resistance)\n",

      "Tinf=1 #  high frequency gain\n",

      "R1=Ri_inf #  kohm\n",

      "R2=Tinf*R1 #  kohm\n",

      "C=round(1/(2*math.pi*f0*R2*1000)*10**9,1) #nF\n",

      "print \"Design values are :\"\n",

      "print R2,\"= Resistance R1=R2(kohm) \"\n",

      "print C,\"= Capacitance C(nF)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values are :\n",

        "100 = Resistance R1=R2(kohm) \n",

        "15.9 = Capacitance C(nF)\n"

       ]

      }

     ],

     "prompt_number": 194

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.24:pg-190"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Ex 3.24 \n",

      "import math\n",

      "Ap=12 # dB(Pass band gain)\n",

      "G=round(10**(Ap/20)) # gain(unitless)\n",

      "Ri=100 # kohm(as high input impedence required)\n",

      "R1=Ri # kohm\n",

      "# Low pass filter design\n",

      "ALP=-1\n",

      "AHP=-4 # (to satisfy R2<=100 # kohm)\n",

      "R2=-ALP*R1 # kohm\n",

      "f0=10*1000 # Hz(3-dB frequency)\n",

      "C=round(1/(2*math.pi*f0*R2*1000)*10**9,3) # nF\n",

      "print \"Design values for low pass filter \" \n",

      "print R2,\"= Resistance R1=R2 in kohm \" \n",

      "print C,\"= Capacitance C(nF)\" \n",

      "# High pass filter design\n",

      "R3=25 # kohm(Assumed)\n",

      "R4=-AHP*R3 # kohm\n",

      "f0=100 # Hz(3-dB frequency)\n",

      "C=round(1/(2*math.pi*f0*R3*1000)*10**9,1) # nF\n",

      "print \"Design values for high pass filter \" \n",

      "print R4,\",\",R3,\"= Resistance R3 & R4 in kohm respectively \" \n",

      "print C,\"= Capacitance C(nF)\" \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values for low pass filter \n",

        "100 = Resistance R1=R2 in kohm \n",

        "0.159 = Capacitance C(nF)\n",

        "Design values for high pass filter \n",

        "100 , 25 = Resistance R3 & R4 in kohm respectively \n",

        "63.7 = Capacitance C(nF)\n"

       ]

      }

     ],

     "prompt_number": 193

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.25:pg-192"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " #Ex 3.25 \n",

      "import math    \n",

      "omega=10**4 #rad/s\n",

      "C=10.0 #nF\n",

      "fi1=math.radians(-30.0) #degree\n",

      "fi2=math.radians(-90.0) #degree\n",

      "fi3=math.radians(-120.0) #degree\n",

      "fi4=math.radians(-150.0) #degree\n",

      "R1=(math.tan(-fi1/2)/(C*10**-9*omega)/1000) #kohm\n",

      "R2=math.tan(-fi2/2)/(C*10**-9*omega)/1000 #kohm\n",

      "R3=math.tan(-fi3/2)/(C*10**-9*omega)/1000  #kohm\n",

      "R4=math.tan(-fi4/2)/(C*10**-9*omega)/1000 #kohm\n",

      "print \"For phase shift=-30 degree, Resistance(kohm=\",round(R1,2) \n",

      "print \"For phase shift=-90 degree, Resistance(kohm)=\",round(R2,2)\n",

      "print \"For phase shift=-120 degree, Resistance(kohm)=\",round(R3,2)\n",

      "print \"For phase shift=-150 degree, Resistance(kohm)=\",round(R4,2)\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "For phase shift=-30 degree, Resistance(kohm= 2.68\n",

        "For phase shift=-90 degree, Resistance(kohm)= 10.0\n",

        "For phase shift=-120 degree, Resistance(kohm)= 17.32\n",

        "For phase shift=-150 degree, Resistance(kohm)= 37.32\n"

       ]

      }

     ],

     "prompt_number": 178

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.26:pg-194"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      " # Ex 3.26 \n",

      "import math    \n",

      "omega1=0 # rad/s\n",

      "omega2=inf # rad/s\n",

      "omega0=math.degrees(10**4) # rad/s(Assumed)\n",

      "fi1=math.atan(omega2/omega0)-math.atan(omega2/-omega0) # degree\n",

      "fi2=math.atan(omega1/omega0)-math.atan(omega1/-omega0) # degree\n",

      "print \"For omega=0 phase shift(degree)=\",int(fi1*180/math.pi)\n",

      "print \"For omega=infinity phase shift(degree)=\",int(fi2*180/math.pi)\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "For omega=0 phase shift(degree)= 180\n",

        "For omega=infinity phase shift(degree)= 0\n"

       ]

      }

     ],

     "prompt_number": 187

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.28:pg-197"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Ex 3.28\n",

      "import math\n",

      "f0=1*1000 #Hz\n",

      "BW=2*math.pi*50 #Hz\n",

      "C=10 #nF\n",

      "Q=2*math.pi*f0/BW #quality factor\n",

      "R=1/(2*math.pi*f0*C*10**-9)/1000 #kohm\n",

      "R1=10 #kohm(Assumed)\n",

      "RF=10 #kohm(Assumed)\n",

      "R3BYR2=2*Q-1\n",

      "R2=10 #kohm(Assumed)\n",

      "R3=R3BYR2*R2 #kohm\n",

      "print \"Design values for KHN circuit:\"\n",

      "print RF,\",\",R1,\"= Use Resistance R1 & RF in kohm\"\n",

      "print R2,\"= Use Resistance R2 in kohm\"\n",

      "print R3,\"= Resistance R3 in kohm\"\n",

      "K=2-1/Q #scaling factor\n",

      "CenterFrequency=K*Q\n",

      "print CenterFrequency,\"= CenterFrequency \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Design values for KHN circuit:\n",

        "10 , 10 = Use Resistance R1 & RF in kohm\n",

        "10 = Use Resistance R2 in kohm\n",

        "390.0 = Resistance R3 in kohm\n",

        "39.0 = CenterFrequency \n"

       ]

      }

     ],

     "prompt_number": 2

    }

   ],

   "metadata": {}

  }

 ]

}