{
 "metadata": {
  "name": "",
  "signature": "sha256:5a78eb3c7cc2f82cd21ccad707b4376bdb45f22452d4892c16308b1bdd58f45f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter08:Multistage Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 276"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Express the gain in decibel\n",
      "#given\n",
      "#Powere gain of 1000\n",
      "import math\n",
      "Pg1=1000.;\n",
      "Pgd1=10.*math.log10(Pg1);\n",
      "print '%s %.f %s' %(\"Power gain (in dB)=\",Pgd1,\"dB\\n\");\n",
      "\n",
      "#Voltage gain of 1000\n",
      "Vg1=1000.;\n",
      "Vgd1=20.*math.log10(Vg1);\n",
      "print '%s %.f %s' %(\"Voltage gain (in dB)=\",Vgd1,\"dB\\n\");\n",
      "\n",
      "#Powere gain of 1/100\n",
      "Pg2=1./100.;\n",
      "Pgd2=10.*math.log10(Pg2);\n",
      "print '%s %.f %s' %(\"Power gain (in dB)=\",Pgd2,\"dB\\n\");\n",
      "\n",
      "#Voltage gain of 1/100\n",
      "Vg2=1./100.;\n",
      "Vgd2=20.*math.log10(Vg2);\n",
      "print '%s %.f %s' %(\"Voltage gain (in dB)=\",Vgd2,\"dB\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power gain (in dB)= 30 dB\n",
        "\n",
        "Voltage gain (in dB)= 60 dB\n",
        "\n",
        "Power gain (in dB)= -20 dB\n",
        "\n",
        "Voltage gain (in dB)= -40 dB\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 276"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Determine power and voltage gain\n",
      "#given\n",
      "#For  Gain = 10 dB\n",
      "G=10.;#dB\n",
      "Pg1=10.**(G/10.);       #taking antilog\n",
      "Vg1=10.**(G/20.);       #taking antilog\n",
      "print '%s %.f %s' %(\"For Gain\",G,\"dB\\n\")\n",
      "print '%s %.f %s' %(\"Power gain ratio =\",Pg1,\"\\n\");\n",
      "print '%s %.2f %s' %(\"Voltage gain ratio =\",Vg1,\"\\n\");\n",
      "\n",
      "#For Gain 3 dB\n",
      "G=3.;#dB\n",
      "Pg2=10.**(G/10.);       #taking antilog\n",
      "Vg2=10.**(G/20.);       #taking antilog\n",
      "print '%s %.f %s' %(\"For Gain\",G,\"dB\\n\")\n",
      "print '%s %.2f %s' %(\"Power gain ratio =\",Pg2,\"\\n\");\n",
      "print '%s %.3f %s' %(\"Voltage gain ratio =\",Vg2,\"\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For Gain 10 dB\n",
        "\n",
        "Power gain ratio = 10 \n",
        "\n",
        "Voltage gain ratio = 3.16 \n",
        "\n",
        "For Gain 3 dB\n",
        "\n",
        "Power gain ratio = 2.00 \n",
        "\n",
        "Voltage gain ratio = 1.413 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the overall voltage gain\n",
      "#given\n",
      "import math\n",
      "A1=80.\n",
      "A2=50.\n",
      "A3=30.\n",
      "Ad=20.*math.log10(A1)+20.*math.log10(A2)+20.*math.log10(A3);\n",
      "\n",
      "#Alternatively\n",
      "A=A1*A2*A3;\n",
      "Ad=20.*math.log10(A);\n",
      "print '%s %.2f %s' %(\"The Voltage gain is =\",Ad,\"dB\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Voltage gain is = 101.58 dB\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 283"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate quiescent output voltage and small signal voltage gain\n",
      "#given\n",
      "#At input Voltage =3V\n",
      "Vi1=3.##V      #input voltage\n",
      "Vbe=0.7##V\n",
      "B=250.#\n",
      "Vcc=10.##V     #Supply\n",
      "Re1=1.*10.**3.##ohm\n",
      "Rc1=3.*10.**3.##ohm\n",
      "Re2=2.*10.**3.##ohm\n",
      "Rc2=4.*10.**3.##ohm\n",
      "Vb1=Vi1#        #Voltage at the base of transistor T1\n",
      "Ve1=Vb1-Vbe#      #Voltage at the emitter of transistor T1\n",
      "Ie1=Ve1/Re1#\n",
      "Ic1=Ie1#\n",
      "Vc1=Vcc-Ic1*Rc1#\n",
      "Vb2=Vc1#\n",
      "Ve2=Vb2-Vbe#\n",
      "Ie2=Ve2/Re2#\n",
      "Ic2=Ie2#\n",
      "Vo1=Vcc-Ic2*Rc2#\n",
      "print '%s %.1f %s' %(\"The quiescent output voltage(At input Voltage = 3V) is =\",Vo1,\"V\\n\")#\n",
      "\n",
      "#At input Voltage =3.2 V\n",
      "Vi2=3.2##V      #input voltage\n",
      "Vb1=Vi2#        #Voltage at the base of transistor T1\n",
      "Ve1=Vb1-Vbe#      #Voltage at the emitter of transistor T1\n",
      "Ie1=Ve1/Re1#\n",
      "Ic1=Ie1#\n",
      "Vc1=Vcc-Ic1*Rc1#\n",
      "Vb2=Vc1#\n",
      "Ve2=Vb2-Vbe#\n",
      "Ie2=Ve2/Re2#\n",
      "Ic2=Ie2#\n",
      "Vo2=Vcc-Ic2*Rc2#\n",
      "print '%s %.1f %s' %(\"The quiescent output voltage (At input Voltage =3.2 V) is =\",Vo2,\"V\\n\")#\n",
      "\n",
      "#Small Signal input and output voltage\n",
      "vi=Vi2-Vi1#\n",
      "vo=Vo2-Vo1#\n",
      "Av=vo/vi#\n",
      "print '%s %.f' %(\"The small signal voltage gain is =\",Av)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The quiescent output voltage(At input Voltage = 3V) is = 5.2 V\n",
        "\n",
        "The quiescent output voltage (At input Voltage =3.2 V) is = 6.4 V\n",
        "\n",
        "The small signal voltage gain is = 6\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 296"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the maximum voltage gain and bandwidth of multistage amplifier\n",
      "#FUNCTIONS\n",
      "#given\n",
      "def  prll(r1,r2):\n",
      "\tz=r1*r2/(r1+r2)#\n",
      "\treturn z\n",
      "\n",
      "import math\n",
      "rin=10.*10.**6.;#ohm #input resistance of JFET\n",
      "Rd=10.*10.**3.;#ohm\n",
      "Rs=500.;#ohm\n",
      "Rg=470.*10.**3.;#ohm\n",
      "Rl=470.*10.**3.;#ohm\n",
      "Cc=0.01*10.**-6.;#Farad\n",
      "Csh=100.*10.**-12.;#Farad\n",
      "Cs=50.*10.**-6.;#Farad\n",
      "rd=100.*10.**3.;#ohm\n",
      "gm=2.*10.**-3.;#S\n",
      "Rac2=prll(Rd,Rl);\n",
      "Rac1=prll(Rd,Rg);\n",
      "Req=prll(rd,prll(Rd,Rl));\n",
      "Am=math.ceil(gm*Req);\n",
      "Am2=Am*Am;       #Voltage gain of two stage amplifier\n",
      "print '%s %.f %s' %(\"Voltage gain of two stage amplifier=\",Am2,\"\\n\");\n",
      "R_=prll(rd,Rd)+prll(Rg,rin);\n",
      "f1=1./(2.*math.pi*Cc*R_);      #lower cutoff frequency\n",
      "f1_=f1/(math.sqrt(math.sqrt(2.)-1.));\n",
      "f2=1./(2.*math.pi*Csh*Req);      #upper cutoff frequency\n",
      "f2_=f2*(math.sqrt(math.sqrt(2.)-1.));\n",
      "BW=f2_-f1_;\n",
      "print '%s %.f %s' %(\"Bandwidth=\",BW/1000.,\"kHz\\n\");\n",
      "#There is a slight error in f1 due to use of R'(here R_)=479 kohm and in f2 due to approaximation of Req there is a slight variation\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gain of two stage amplifier= 324 \n",
        "\n",
        "Bandwidth= 115 kHz\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 298"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the midband voltage gain and bandwidth of cascade amplifier\n",
      "#given\n",
      "import math\n",
      "Am=8.##midband voltage gain of individual MOSFET\n",
      "BW=500.*10.**3.#Hz\n",
      "f2=BW#\n",
      "n=4.#\n",
      "A2m=Am**n#\n",
      "f2_=f2*(math.sqrt((2.**(1./n))-1.))#\n",
      "print '%s %.f %s' %(\"Midband voltage gain =\",A2m,\"\\n\")#\n",
      "print '%s %.1f %s' %(\"Overall Bandwidth =\",f2_/1000,\"kHz\")#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Midband voltage gain = 4096 \n",
        "\n",
        "Overall Bandwidth = 217.5 kHz\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 298"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the input and output impedance and voltage gain\n",
      "#FUNCTIONS\n",
      "\n",
      "def  prll(r1,r2):\n",
      "\tz=r1*r2/(r1+r2)#\n",
      "\treturn z\n",
      "\n",
      "import math\n",
      "hie=1.1*10.**3.;#ohm=rin\n",
      "hfe=120.;#=B\n",
      "#the values of Rac2, Zi, Zo are as per diagram\n",
      "Rac2=prll(3.3*10**3,2.2*10**3);\n",
      "Rac1=prll(6.8*10**3,prll(56*10**3,prll(5.6*10**3,1.1*10**3)));\n",
      "Zi=prll(5.6*10**3,prll(56*10**3,1.1*10**3));\n",
      "Zo=prll(3.3*10**3,2.2*10**3);\n",
      "print '%s %.3f %s %s %.2f %s' %(\"Input Resistance =\",Zi/1000,\"kohm\\n\",\"\\nOutput Resistance =\",Zo/1000,\"kohm\");\n",
      "Am2=-hfe*Rac2/(hie);\n",
      "Am1=-hfe*Rac1/(hie);\n",
      "Am=Am1*Am2;\n",
      "Am=20.*math.log10(Am);\n",
      "print '%s %.2f %s' %(\"\\nThe Overall Voltage gain is\",Am,\"dB\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input Resistance = 0.905 kohm\n",
        " \n",
        "Output Resistance = 1.32 kohm\n",
        "\n",
        "The Overall Voltage gain is 81.97 dB\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}