{
 "metadata": {
  "name": "",
  "signature": "sha256:b257ecc13b812bf0b848ecef8624701db73088f3de1f9b82ca153fc8113f8c8b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "     Chapter 4:           SMALL SIGNAL AMPLIFIERS-FREQUENCY RESPONSE"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1,Page number 217"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vs=1.               #source voltage(V)\n",
      "C=100*10**-6        #value of capacitance(uF)  \n",
      "r1=1                #resistance 1(k ohms)\n",
      "r2=4                #resistance 2(k ohms)\n",
      "R=5                 #total resistance,R=r1+r2\n",
      "\n",
      "#Calculations\n",
      "Imax=Vs/(r1+r2)*10**3        #maximum current(uA)\n",
      "fc=1/(2*(math.pi)*C*R)        #critical frequency(Hz) \n",
      "                             #As w*C*R=1 and w=2*pi*f\n",
      "f=10*fc                      #lowest frequency(Hz)\n",
      "\n",
      "#Results\n",
      "print\"maximum current\",Imax,\"uA\"\n",
      "print\"critical frequency\",round((fc/1E+3),3),\"Hz\"\n",
      "print\"lowest frequency\",round((f/1E+3),2),\"Hz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "maximum current 200.0 uA\n",
        "critical frequency 0.318 Hz\n",
        "lowest frequency 3.18 Hz\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2,Page number 218"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "C=100*10**-6     #capacitance(uF)\n",
      "Rg=1.            #galvanometer resistance(k oms)\n",
      "Rl=4.            #load resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Rth=(Rg*Rl)/(Rg+Rl)      #thevinine's equivalent resistance\n",
      "fc=1/(2*(math.pi)*C*Rth)  #critical frequency(Hz)\n",
      "f=fc*C                    #lowest frequency(Hz)\n",
      "\n",
      "#Results\n",
      "print\"lowest frequency at which the point A gets grounded is\",round((f/1E-2),1),\"Hz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "lowest frequency at which the point A gets grounded is 19.9 Hz\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3,Page number 220"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "rpi=600               #dynamic junction resistance(ohms)\n",
      "beta=100              #common emitter current gain\n",
      "Vs=5.                 #source voltage(V)\n",
      "Rs=400                #source resistance(ohms)\n",
      "R=10                  #resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Ib=Vs/(Rs+rpi)       #base current(uA)  \n",
      "Vo=R*beeta*Ib        #output voltage(V)\n",
      "Rin=rpi              #input resistance(ohms)\n",
      "Rout=R               #output ewsistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"output voltage is\",Vo,\"V\"\n",
      "print\"input resistance\",Rin,\"ohms\"\n",
      "print\"output resistance\",Rout,\"k ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output voltage is 5.0 V\n",
        "input resistance 600 ohms\n",
        "output resistance 10 k ohms\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4,Page number 220"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "gm=1.                    #transconductance(mS)\n",
      "rd=40                    #dynamic drain resistance(k ohms)  \n",
      "Rd1=40                   #JFET 1 drain resistance(k ohms) \n",
      "Rd2=10                   #JFET 2 drain resistance(k ohms) \n",
      "\n",
      "#Calculations\n",
      "Avo=(-gm*((rd*Rd1)/(rd+Rd1)))*(-gm*((rd*Rd2)/(rd+Rd2)))             #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"Avo is\",Avo"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Avo is 160.0\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5,Page number 222"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=125           #common emitter current gain\n",
      "rpi=2.5            #dynamic junction resistance(k ohms)\n",
      "rd=40              #dynamic drain resistance(k ohms)   \n",
      "gm=2               #transconductance(mS) \n",
      "Vs=1               #assume,source voltage(V)\n",
      "Rs=10              #source resistance(k ohms)\n",
      "Rc=1               #collector resistance(k ohms)\n",
      "rb=2               #resistance(k ohms)\n",
      "Vgs=1              #gate to source voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "R=(rd*Rs)/(rd+Rs)      #equivalent resistance(k ohms)\n",
      "Ib=gm*Vgs*(R/(rpi+R))  #base current(mA)\n",
      "Vo=beeta*Ib*Rc         #output voltage(V)   \n",
      "Avo=Vo                 #voltage gain\n",
      "\n",
      "#Part b\n",
      "Ib1=Vs/(rb+rpi)        #base current(mA) after interchanging stages of JFET and BJT  \n",
      "Vgs1=beeta*Ib1*Rc      #gate to source voltage(V) after interchanging stages of JFET and BJT\n",
      "Vo1=gm*Vgs1*R          #output voltage(V) after interchanging stages of JFET and BJT\n",
      "Avo1=Vo1               #voltage gain after interchanging stages of JFET and BJT\n",
      "\n",
      "#Results\n",
      "print\"Avo is\",round(Avo,1)\n",
      "print\"Avo1 when BJT and FET stages are reversed is\",round(Avo1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Avo is 190.5\n",
        "Avo1 when BJT and FET stages are reversed is 444.0\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6,Page number 226"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Cc1=1*10**-6                 #coupling capacitor 1(uF)\n",
      "Cc2=1*10**-6                 #coupling capacitor 2 (uF)  \n",
      "Rs=10**3                     #source resistance(k ohms)\n",
      "rpi=2*10**3                  #dynamic junction resistance(k ohms)\n",
      "Rc=4500                      #collector resistance(ohms)\n",
      "Rl=9*10**3                   #load resistance(k ohms)\n",
      "w=100                        #corner frequency(rad/s)\n",
      "\n",
      "#Calculations\n",
      "w11=1/(Cc1*(Rs+rpi))                    #corner frequency input circuit (rad/s)\n",
      "w12=1/(Cc2*(Rc+Rl))                     #corner frequency output circuit(rad/s)\n",
      "f=w11/(2*(math.pi))                     #lower cutoff frequency(Hz)\n",
      "Zin=complex((Rs+rpi),-(1/(w*Cc1)))      #input impedance(k ohms)   \n",
      "Zout=complex(Rc,-(1/(w*Cc2)))           #output impedance(k ohms)   \n",
      "\n",
      "#Results\n",
      "print\"lower cut-off freq is\",round(f),\"Hz\"\n",
      "print\"Zin\",Zin,\"ohms\"\n",
      "print\"Zout\",Zout,\"ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "lower cut-off freq is 53.0 Hz\n",
        "Zin (3000-10000j) ohms\n",
        "Zout (4500-10000j) ohms\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7,Page number 229"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Re=Rc=1.5*10**3              #collector resistance(ohms)\n",
      "Rs=600                       #source resistance(ohms)\n",
      "Rl=2*10**3                   #load resistance(ohms)  \n",
      "beeta=100                     #common emitter current gain \n",
      "rpi=1*10**3                  #dynamic junction resistance(ohms)\n",
      "f=50                         #frequency(Hz)\n",
      "\n",
      "#Calculations\n",
      "w=2*f*(math.pi)              #corner frequency(rad/s)\n",
      "CE=1/(w*(Rs+rpi))            #capacitance(uF)\n",
      "Ce=CE*(beeta+1)              #capacitance(uF)\n",
      "w11=w/10                     #corner frequency input circuit (rad/s)\n",
      "w12=w11/20                   #corner frequency output circuit(rad/s)\n",
      "Cc1=1/(w11*(Rs+rpi))         #coupling capacitor 1(uF)  \n",
      "Cc2=1/(w12*(Rc+Rl))          #coupling capacitor 2 (uF)  \n",
      "\n",
      "#Results\n",
      "print\"Ce is\",round(Ce/1E-6),\"uF\"\n",
      "print\"Cc1 is\",round(Cc1/1e-6,1),\"uF\"\n",
      "print\"Cc2 is\",round((Cc2/1E-5),2),\"uF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ce is 201.0 uF\n",
        "Cc1 is 19.9 uF\n",
        "Cc2 is 18.19 uF\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8,Page number 235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "gm=2.5*10**-3            #transconductance(mS) \n",
      "Rd=6*10**3               #drain resistance(ohms)\n",
      "rd=200*10**3             #dynamic drain resistance(ohms)   \n",
      "Cc1=Cc2=0.12*10**-6      #coupling capacitors(uF)\n",
      "Rs=1*10**3               #source resistance(ohms)\n",
      "Rg=0.1*10**6             #R1||R2  \n",
      "Cgs=12*10**-9            #gate to source capacitor(pF) \n",
      "Cgd=2*10**-9             #gate to drain capacitor(pF)    \n",
      "Co1=10                   # as Co1=Cl+Cw=10\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Ro=(rd*Rd)/(rd+Rd)                  #equivalent resistance of rd and Rd(ohms)\n",
      "Vo=-gm*((rd*Rd)/(rd+Rd))            #as Vgs=Vs\n",
      "Avo=Vo                              #Avo=Vo/Vs=(-gm*Vs*((rd*Rd)/(rd+Rd)))/Vs=Vo  \n",
      "    \n",
      "#Part b\n",
      "f11=1/(2*(math.pi)*Cc1*(Rs+Rg))\n",
      "\n",
      "#Part c\n",
      "Ceq=Cgs+(Cgd*(1+gm*Ro))                    #on application of miller theorem\n",
      "Co=Co1+Cgd*(1+(1/(gm*Ro)))                 #output capacitance(pF)\n",
      "f21=1/(2*(math.pi)*Ceq*((Rs*Rg)/(Rs+Rg)))  #input circuit cutoff frequency(MHz)\n",
      "f22=1/(2*(math.pi)*Co*Ro)*10**3            #output circuit cutoff frequency(MHz)\n",
      "fH=f22                                     #cutoff frequency of high frequency band(MHz)\n",
      "\n",
      "#Results\n",
      "print\"a)mid freq gain is\",round(Avo,1)\n",
      "print\"b)input circuit cut-off is\",round(f11,1),\"Hz\"\n",
      "print\"c)high freq input cutoff is\",round((f21/1E+3),2),\"and output cutoff is\",round((f22/1E-3),2),\"MHz\"\n",
      "print\"high freq cut-off is\",round((fH/1E-3),2),\"MHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)mid freq gain is -14.6\n",
        "b)input circuit cut-off is 13.1 Hz\n",
        "c)high freq input cutoff is 3.73 and output cutoff is 2.73 MHz\n",
        "high freq cut-off is 2.73 MHz\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9,Page number 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "beta=50.              #common emitter current gain \n",
      "R1=11.5              #resistance(k ohms)\n",
      "R2=41.4              #resistance(k ohms)  \n",
      "Vcc=10.               #supply voltage to collector(V)\n",
      "Rc=5.                 #collector resistance(k ohms)\n",
      "Re=1.                 #emitter resistance(k ohms)\n",
      "Rs=1.                 #source resistance(k ohms)\n",
      "Vbe=0.7              #base emitter voltage(V)\n",
      "Rl=10.                #load resistance(k ohms)\n",
      "Cc1=Cc2=20*10**-6.    #coupling capacitors(uF)\n",
      "Ce=150*10**-6.        #emitter capacitor(uF)  \n",
      "Cpi=100       \n",
      "Cu=5.\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Rb=(R1*R2)/(R1+R2)                 #R1||R2(k ohms)\n",
      "Vbb=Vcc*(R1/(R1+R2))               #suply voltage to base(V)\n",
      "Ib=(Vbb-Vbe)/(Rb+(Rs*(1+beta)))   #base current(mA)\n",
      "Ic=beta*Ib                        #collector current(mA)  \n",
      "Vce=Vcc-(Ic*Rc)-(Ic+Ib)*Re         #collector to emitter voltage(V) \n",
      "rpi=(25*beta)*10**-3/Ic                  #dynamic junction resistance(K ohms) \n",
      "    \n",
      "#Part b\n",
      "rpi=1                              #dynamic junction resistance(K ohms)  \n",
      "R=(rpi*Rb)/(rpi+Rb)                #equivalent resistance(rpi||Rb) \n",
      "Vbe=(R*Rs)/(R+Rs)                  #base to emitter voltage(V)\n",
      "Ib1=Vbe/rpi                        #base current(mA)\n",
      "Ro=(Rc*Rl)/(Rc+Rl)                 #Rc||Rl(k ohms)   \n",
      "Vo=-(beta*Ib1*Ro)                 #output voltage(V)\n",
      "Avo=Vo                             #voltage gain\n",
      "\n",
      "#Part c\n",
      "r1=(Rs*Rb)/(Rs+Rb)                #Rs||Rb(k ohms) \n",
      "w11=1/(Cc1*(Rs+R))                #low freq cutoff(rad/s)\n",
      "w12=1/(Cc2*(Rc+Rl))               #high freq cutoff(rad/s) \n",
      "w1p=1/((Ce/(beta+1))*(r1+rpi))   #low cutoff freq(rad/s)\n",
      "\n",
      "#Part d\n",
      "Co1=5                          #as Co1=Cw+Cl\n",
      "gm=beta/rpi                    #transconductance(mS)    \n",
      "Ceq=Cpi+(Cu*(1+(gm*Ro)))   #equivalent capacitance(pF)\n",
      "Rs1=(Rb*Rs)/(Rb+Rs)            #Rb||Rs(k ohms)\n",
      "r2=(Rs1*rpi)/(Rs1+rpi)         #Rs1||rpi(k ohms)\n",
      "w21=10**12/(Ceq*r2*10**3)                 #low freq cutoff(MHz) \n",
      "\n",
      "#Results\n",
      "print\"a)dc bias values are Vbb:\",round(Vbb,2),\"V, Ib:\",round(Ib,4),\"mA, Ic:\",round(Ic,2),\"mA, Vce:\",round(Vce,3),\"V, rpi:\",rpi,\"k ohms\"\n",
      "print\"mid freq gain is\",round(Avo,2)\n",
      "print\"low freq cut-off is\",round(w1p/1E+3),\"rad/s\"\n",
      "print\"high cut-off freq is\",round((w21/1E+6),2),\"*10**6 rad/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)dc bias values are Vbb: 2.17 V, Ib: 0.0246 mA, Ic: 1.23 mA, Vce: 2.606 V, rpi: 1 k ohms\n",
        "mid freq gain is -78.95\n",
        "low freq cut-off is 179.0 rad/s\n",
        "high cut-off freq is 2.25 *10**6 rad/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10,Page number 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Qcoil=75.               #coil inductance\n",
      "f=200.                  #frequency(Hz) \n",
      "BW=4.                   #bandwidth(kHz)\n",
      "C=470*10**-9.           #capacitance(pF) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Qcircuit=f/BW                     #circuit inductance\n",
      "L=1/(((2*(math.pi)*f)**2)*C)      #inductance(mH)  \n",
      "\n",
      "#Part b\n",
      "R=Qcircuit*2*(math.pi)*f*L        #resistance(k ohms)\n",
      "\n",
      "#Part c\n",
      "r=(2*(math.pi)*f*L)/Qcoil         #internal resistance(ohms)\n",
      "req=(Qcoil**2)*r                  #equivalent resistance(k ohms)\n",
      "ro=(R*req)/(req-R)                #output resistance(k ohms)\n",
      "\n",
      "#Part d\n",
      "BW=5                               #bandwidth(kHz)\n",
      "Qcircuit=f/BW                      #circuit inductance \n",
      "Req=Qcircuit*2*(math.pi)*f*L       #equivalent resistance(k ohms) \n",
      "Rl=(Req*R)/(R-Req)                 #load resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"a)coil inductance is\",round(L,2),\"mH\"\n",
      "print\"b)circuit output impedance atresonant freq is\",round((R/1E+3),2),\"K ohms\"\n",
      "print\"c)internal resistance ro is\",round((ro/1E+3),2),\"k ohms\"\n",
      "print\"d)value of load resistance is\",round((Rl/1E+3),2),\"k ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)coil inductance is 1.35 mH\n",
        "b)circuit output impedance atresonant freq is 84.66 K ohms\n",
        "c)internal resistance ro is 253.97 k ohms\n",
        "d)value of load resistance is 338.63 k ohms\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.11,Page number 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "fo=50                           #output frequency(KHz)\n",
      "L=10**-3                        #inductance(H)  \n",
      "ro=100                          #output resistance(k ohms)\n",
      "Q=80                            #coil inductance\n",
      "Ri=10                           #input resistance(k ohms)\n",
      "beta=125                        #common emitter current gain \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "C =1/(((2*(math.pi)*fo)**2)*L)   #tunning capacitance(nF)\n",
      "r=(2*(math.pi)*fo*L)/Q           #internal resistance(k ohms)\n",
      "req=(Q**2)*r                     #equivalent resistance(k ohms) \n",
      "R=(ro*req)/(ro+req)              #ro||req(k ohms)\n",
      "Avo=-(beta*R)/Ri                 #voltage gain\n",
      "\n",
      "#Part b\n",
      "Qcircuit=R/(2*(math.pi)*fo*L)    #circuit inductance\n",
      "BW=fo/Qcircuit                   #bandwidth\n",
      "\n",
      "#Results\n",
      "print\"a)value of capacitance is\",round(C/1E-3),\"nF\"\n",
      "print\"  gain is\",round(Avo,1)\n",
      "print\"b)bandwidth is\",round(BW/1E-3),\"Hz\",\"(value used for beta in texbook is wrong in the solution)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)value of capacitance is 10.0 nF\n",
        "  gain is -251.1\n",
        "b)bandwidth is 782.0 Hz (value used for beta in texbook is wrong in the solution)\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.12,Page number 248"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "\n",
      "f=1*10**6                  #radio frequency(Hz)\n",
      "beta=50                    #common emitter current gain \n",
      "fT=5*10**6                 #short circuit current gain bandwidth product(Hz)\n",
      "\n",
      "#Calculations\n",
      "betaf=fT/f                 #measurement of short circuit current gain\n",
      "fbeta=fT/beta              #frequency at beta(Hz)\n",
      "\n",
      "#Results\n",
      "print\"frequency is\",fbeta,\"Hz\"\n",
      "if fbeta<1*10**6:\n",
      "    print\"transistor is not suitable for 1Mhz amplifier as fbeta is less than 1Mhz\"\n",
      "else:\n",
      "    print\"transistor is suitable for 1Mhz amplifier\"\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "frequency is 100000 Hz\n",
        "transistor is not suitable for 1Mhz amplifier as fbeta is less than 1Mhz\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.13,Page number 249"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "rpi=2                     #dynamic junction resistance(K ohms)  \n",
      "beta=50.                   #common emitter current gain \n",
      "f=1                        #frequency(MHz)\n",
      "beta1=2.5                  #common emitter current gain \n",
      "f1=20*10**6                #frequency(Hz)\n",
      "\n",
      "#Calculations\n",
      "fT=beta1*f1                  #short circuit current gain bandwidth product(Hz)\n",
      "fbeta=fT/beta                #frequency at beta(Hz)\n",
      "Cpi=1/(2*(math.pi)*fbeta*rpi)   #dynamic capacitance(pF)\n",
      "\n",
      "#Results\n",
      "print\"fT is\",round(fT/1e+6),\"MHz\"\n",
      "print\"fB is\",round(fbeta/1e+6),\"MHz\"\n",
      "print\"Cpi is\",round(Cpi/1e-9),\"pF\"   "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fT is 50.0 MHz\n",
        "fB is 1.0 MHz\n",
        "Cpi is 80.0 pF\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.14,Page number 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R1=60                 #resistance(k ohms)\n",
      "R2=140                #resistance(k ohms)\n",
      "Rs=4                  #source resistance(k ohms)\n",
      "Re=3                  #emitter resistance(k ohms)\n",
      "Rc=4                  #collector resistance(k ohms)\n",
      "Vcc=10                #supply voltage to collector(V)\n",
      "Vbe=0.7               #base to emitter voltage(V)\n",
      "beta=100              #common emitter current gain \n",
      "Avo=-30               #voltage gain \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Rb=(R1*R2)/(R1+R2)                  #R1||R2(k ohms)\n",
      "Vth=(Vcc*R1)/(R1+R2)                #thevinine's voltage(V)\n",
      "Ib=(Vth-Vbe)/(Rb+(beta+1)*Re)       #base current(uA)\n",
      "Ic=Ib*beta                          #collector current(mA) \n",
      "Vce=Vcc-(Rc*Ic)-((beta+1)*Ib*Re)    #collector to emitter voltage(V)\n",
      "\n",
      "#Part b\n",
      "rpi=((25*beta)/Ic)*10**-3         #dynamic junction resistance(k ohms)\n",
      "r=(Rb*rpi)/(Rb+rpi)               #resistance across Vs\n",
      "Ib1=r/((Rs+r)*rpi)                #base current(mA)\n",
      "Rl=(-Rc*Avo)/(Avo+(beta*Ib1*Rc))  #load resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"value of Ic and Vce are\",round(Ic,3),\"mA and\",round(Vce,2),\"V\"\n",
      "print\"Rl is\",round(Rl,2),\"k ohms\"    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ic and Vce are 0.667 mA and 5.31 V\n",
        "Rl is 6.21 k ohms\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.15,Page number 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R1=25.                      #resistances(k ohms)\n",
      "R2=100.                     #resistances(k ohms)\n",
      "Re=2.                       #emitter resistance(k ohms) \n",
      "Vcc=10.                     #supply voltage to collector\n",
      "Vbe=0.7                    #base to emitter voltage(V)\n",
      "beta=100.                   #common emitter current gain\n",
      "Avo=160                    #voltage gain\n",
      "Rs=1                       #source resistance(k ohms)\n",
      "Vs=1                       #source voltage(V) \n",
      "Rl=12.5                    #load resistance(k ohms)\n",
      "Rc1=20.                     #collector resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Rb=(R1*R2)/(R1+R2)              #R1||R2\n",
      "Vth=(Vcc*R1)/(R1+R2)            #thevinines voltage(V)\n",
      "Ib=(Vth-Vbe)/(Rb+(beta+1)*Re)   #base current(uA)\n",
      "Ic=Ib*beta                      #collector current(mA)\n",
      "rpi=(25*beta)*10**-3/Ic                #dynamic junction resistance(k ohms)\n",
      "\n",
      "#Part b\n",
      "Ib1=1/rpi                       #small signal analysis \n",
      "Rc=-Avo/(-beta*Ib1)             #collector resistance() \n",
      "\n",
      "#Part c\n",
      "r=(Rc1*rpi)/(Rc1+rpi)              #Rc1||rpi1(k ohms) \n",
      "Ib2=(Vs*r)/((1+r)*rpi)               #base curret(mA)\n",
      "Rc2=6.84                             #collector resistance(k ohms)                                      \n",
      "Avo=-(beta*Ib2)*((Rl*Rc2)/(Rl+Rc2))  #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"value of Ic\",round(Ic,3),\"mA and rpi is\",round(rpi,2),\"k ohms\"  \n",
      "print\"Rc is\",round(Rc,2),\"k ohms\"\n",
      "print\"Avo is\",round(Avo,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ic 0.586 mA and rpi is 4.27 k ohms\n",
        "Rc is 6.83 k ohms\n",
        "Avo is -80.6\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.16,Page number 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R1=12.                 #resistance(k ohms)\n",
      "R2=100.                #resistance(k ohms)\n",
      "Rc=2                   #collector resistance(k ohms)\n",
      "Ic=1.2                 #collector current(mA)\n",
      "beta=60                #common emitter current gain\n",
      "Ib1=1                  #(say)\n",
      "Rs=1                   #source resistance(k ohms)\n",
      "Vs=1                   #source vcoltage(say)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "rpi=((25*beta)/Ic)*10**-3     #dynamic junction resistance(k ohms)\n",
      "Rb=(R1*R2)/(R1+R2)            #R1||R2(k ohms)\n",
      "r=(Rb*rpi)/(Rb+rpi)           #Rb||rpi(k ohms)\n",
      "Ro1=(Rc*rpi)/(Rc+rpi)         #Rc||rpi(k ohms)\n",
      "Vo1=Vbe2=-(beta*Ib1*Ro1)      #base to emitter voltage(V)\n",
      "Ib2=Vo1/rpi                   #base current(mA)\n",
      "Ai=Ib2/Ib1                    #current gain \n",
      "\n",
      "#Part b\n",
      "Ib11=(Rs*r)/((Rs+r)*rpi)          #base currents(mA)\n",
      "Ib21=Ib11*Ai                #base current(mA)\n",
      "Avo1=Vo1=Ib21*rpi           #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"current gain is\",round(Ai,2)\n",
      "print\"overall voltage gain is\",round(Avo1,2),\"(solution in the textbook is incorrect)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "current gain is -36.92\n",
        "overall voltage gain is -19.5 (solution in the textbook is incorrect)\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.17,Page number 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=50.                 #common emitter current gain\n",
      "R1=25.                   #resistance(k ohms)\n",
      "R2=75.                   #resistance(k ohms)\n",
      "Ic=1.25                  #collector current(mA)\n",
      "Vcc=10                   #supply voltage to collector(V)\n",
      "s=10*10**-3              #signal strength(V)\n",
      "Rs=0.5                  #output impedance(k ohms)\n",
      "Vo=1                    #output voltage(V)\n",
      "Vs=1.                    #source voltage(V) \n",
      "Vl=12                   #load at output terminal(Vl)\n",
      "Vbe=0.7                 #base to emitter voltage(V)\n",
      "Rl=12\n",
      "\n",
      "#Calculations\n",
      "rpi=((25*beeta)/Ic)              #dynamic junction resistance(k ohms)\n",
      "Rb=(R1*R2)/(R1+R2)               #R1||R2(k ohms)\n",
      "r=(Rb*rpi*10**-3)/(Rb+rpi*10**-3)              #Rb||rpi(k ohms)\n",
      "Avo=((Vo*rpi)/Vcc)                     #voltage gain\n",
      "Ib=(r*Vs)/(Rs+r)*Vs                    #base current(mA)\n",
      "Rc=(Rl*Avo)/(beeta*Ib*Rl-Avo)          #collector resistance(k ohms)\n",
      "Vth=(Vcc*R1)/(R1+R2)                   #thevinine's voltage(V)\n",
      "Ib1=Ic/beeta                           #base current(mA)\n",
      "Re=(Vth-Vbe-(Rb*Ib1))/((beeta+1)*Ib1)    #emitter resistance(k ohms) \n",
      "\n",
      "#Results\n",
      "print\"value of Rc is\",round(Rc,2),\"and Re is\",round(Re,2),\"k ohms (Vth value is wrong substituted in the book)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Rc is 4.1 and Re is 1.04 k ohms (Vth value is wrong substituted in the book)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.18,Page number 260"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Cpi=20*10**-9           #opening capacitor(F)\n",
      "Cu=5*10**-9  \n",
      "C=50*10**-9             #here C=Cl+Cw\n",
      "rpi=3.75*10**3          #dynamic drain resistance(ohms)\n",
      "r1=4*10**3              #resistance(ohms)\n",
      "r2=42*10**3             #resistance(ohms)\n",
      "r3=303*10**3            #resistance(ohms)\n",
      "f=20                    #frequency(Hz)\n",
      "beeta=100               #common emitter current gain\n",
      "Rl=10*10**3             #load resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Req=(((r1*r2)/(r1+r2)+rpi)*r3)/(((r1*r2)/(r1+r2)+rpi)+r3)    #equivalent resistance(ohms)\n",
      "Ce=(beeta+1)/(2*(math.pi)*f*Req)                             #emitter capacitance(uF)\n",
      "\n",
      "#Part b\n",
      "gm=beeta/rpi                   #transconductance\n",
      "Ro=(Rl*r1)/(r1+Rl)             #output resistance(k ohms)\n",
      "Ceq=Cpi+(Cu*(1+gm*Ro))         #equivalent capacitance(pF)\n",
      "Co=C+(Cu*(1+(1/(gm*Ro))))      #output capacitance(pF)\n",
      "r=(rpi*r1)/(rpi+r1)            #rpi||r1\n",
      "w21=1/(Ceq*r)                  #lower cutoff frequency(MHz)\n",
      "w22=1/(Co*Ro)                  #higher cutoff frequenct(MHz)\n",
      "\n",
      "#Part c\n",
      "Ceqnew=Cpi+(Cu*(1+(0.75*(gm*Ro))))           #as gain is reduced to 75% of original value\n",
      "wHnew=(10**12)/(Ceqnew*r)                    #corner value of high frequency(Mrad/s)  \n",
      "fHnew=wHnew/(2*(math.pi))                    #new value of higher frequency cutoff(KHz)\n",
      "\n",
      "#Results\n",
      "print\"a)value of bypass capacitor Ce is\",round(Ce/1E-6),\"uF\"\n",
      "if w21>w22:\n",
      "       print\"higher frequency is w21\"\n",
      "else:\n",
      "    print\"higher frequency is w22\"\n",
      "\n",
      "print\"b)high frequency cut-off is\",round((w22/1E+3),2),\"Mrad/s\"\n",
      "print\"c)high frequency cut-off is\",fHnew,\"Hz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)value of bypass capacitor Ce is 111.0 uF\n",
        "higher frequency is w22\n",
        "b)high frequency cut-off is 6.36 Mrad/s\n",
        "c)high frequency cut-off is 2.64660617737e+14 Hz\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.19,Page number 262"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vcc=3.                     #supply voltage to collector(V)\n",
      "Vee=-3.                    #supply voltage to emitter(V)\n",
      "r1=40.                     #resistance(ohms) \n",
      "r2=25.                     #resistance(ohms)\n",
      "r3=1.56                    #resistance(ohms)\n",
      "Vs=3.                      #source voltage(V)\n",
      "beeta=200                  #common emitter current gain\n",
      "r4=0.6                     #resistance(ohms)\n",
      "r5=0.15                    #resistance(ohms)\n",
      "Vbe=0.7                    #base to emitter voltage\n",
      "r=0.5                      #resistance(k ohms)\n",
      "fL=20                      #frequency(Hz)\n",
      "Req1=24.24                 #solving r||(Rth+rpi+R)||Re\n",
      "f=2                        #non dominant cutoff freq is fL/10 i.e 20/10\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vth=Vs-(((Vcc-Vee)/(r1+r2))*r1)             #thevinine's voltage(V)\n",
      "Rth=(r1*r2)/(r1+r2)                         #thevinine's voltage(V)\n",
      "Ib=(Vth-Vbe+Vcc)/(Rth+((r4+r5)*(beeta+1)))  #base current(mA)\n",
      "Ic=Ib*beeta                                 #Collector current(mA)  \n",
      "Vo=Vcc-(r3*Ic)                              #output voltage(V)\n",
      "\n",
      "#Part b\n",
      "rpi=(25*beeta)/Ic                          #dynamic drain resistance(ohms)\n",
      "R=r4*(beeta+1)                             #resistance(k ohms)\n",
      "ro=(rpi*R)/(rpi+R)                         #rpi||R(k ohms)\n",
      "Req=r+((Rth*ro)/(Rth+ro))                  #equivalent resistance(k ohms) \n",
      "Cc1=1/(Req*2*(math.pi)*fL)                 #coupling capacitor(uF)\n",
      "\n",
      "#Part c\n",
      "Ce=1/(2*(math.pi)*fL*Req1)                #emitter capacitance(uF)\n",
      "CE=beeta*Ce                               #emitter capacitance(uF) after current gain\n",
      "\n",
      "#Part d\n",
      "Ce1=1/(2*(math.pi)*f*Req1)              #emitter capacitance(uF)\n",
      "CE1=beeta*Ce1                           #emitter capacitance(uF) after current gain\n",
      "Csum=Cc1+CE1                            #total capacitance(uF)\n",
      "\n",
      "#Results\n",
      "print\"a)Ic and Vo are\",round(Ic,2),\"mA and\",round(Vo),\"V\"\n",
      "print\"b)Cc1 is\",round((Cc1/1E-3),3),\"uF\"\n",
      "print\"c)Ce is\",round((CE/1E-3),1),\"uF\"\n",
      "print\"d)Csum is\",round((Csum/1E-2),3),\"uF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Ic and Vo are 1.94 mA and -0.0 V\n",
        "b)Cc1 is 0.565 uF\n",
        "c)Ce is 65.7 uF\n",
        "d)Csum is 65.715 uF\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.21,Page number 265"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "gm=2                   #transconductance\n",
      "rd=200*10**3           #dynamic drain resistance(ohms)\n",
      "Cgs=10                 #gate to source capacitance(pF)\n",
      "Cgd=0                  #gate to drain capacitance(pF)\n",
      "Rs=1*10**3             #source resistance(ohms)\n",
      "Rg=1*10**6             #Rg=R1||R2\n",
      "Rd=5*10**3             #drain resistance(ohms) \n",
      "Rs1=2                  #resistance(k ohms) \n",
      "Cc1=Cc2=0.1*10**-6     #coupling capacitors(F)\n",
      "Co=10*10**-12          #output capacitance(F)\n",
      "Vgs=1                  #gate to source voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "R=(Rd*rd)/(Rd+rd)     #Rd||rd(k ohms)\n",
      "Avo=Vo=-Vgs*gm*R      #voltage gain\n",
      "\n",
      "#Part b\n",
      "w11=1/(Cc1*(Rs*Rg))           #corner freq(rad/s)\n",
      "wL=w11                        #input circuit corner freq(rad/s)\n",
      "\n",
      "#Part c\n",
      "w22=10**12/((Cgs*R)*10**3)     #output circuit corner frequency(rad/s)\n",
      "wH=w22/(2*math.pi)                          \n",
      "\n",
      "#Part d\n",
      "G=-Avo*wH                         #gain bandwidth product\n",
      "\n",
      "#Part e\n",
      "Rd=4*10**3                      #drain resistance reduced(ohms) \n",
      "Rnew=(Rd*rd)/(Rd+rd)            #new resistance(ohms)\n",
      "Avo1=-Vgs*gm*Rnew               #new voltage gain\n",
      "BWnew=(10**8/Rnew)/(2*math.pi)                #new bandwidth(Mrad/s)\n",
      "Gnew=-Avo1*BWnew                 #gain bandwidth product new\n",
      "\n",
      "#Results\n",
      "print\"a)Avo is\",round((Avo/1E+3),2)\n",
      "print\"b)wL is\",round((wL/1E-3),2),\"rad/s\"\n",
      "print\"c)wH is\",round((wH/1E+3),1),\"MHz\"\n",
      "print\"d)G is\",round((G/1E+6),2),\"MHz\"\n",
      "print\"e)Gnew is\",round((Gnew/1E+6),1),\"MHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Avo is -9.76\n",
        "b)wL is 10.0 rad/s\n",
        "c)wH is 3.3 MHz\n",
        "d)G is 31.83 MHz\n",
        "e)Gnew is 31.8 MHz\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.23,Page number 268"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "gm=1                    #transconductance\n",
      "rd=40                   #dynamic drain resistance(k ohms) \n",
      "Cgs=5                   #gate to source capacitance(pF)\n",
      "Cgd=1                   #gate to drain capacitance(pF)\n",
      "Cds=1                   #drain to source capacitance(pF)\n",
      "Avo1=20.                #voltage gain of JFET 1\n",
      "Avo2=8.                 #voltage gain of JFET 2 \n",
      "R1=5                    #resistance(k ohms)\n",
      "R2=20                   #resistance(k ohms)\n",
      "R3=8                    #resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Avo=Avo1*Avo2               #voltage gain\n",
      "Ceq1=Cgs+Cgd*(1+Avo1)       #input crcuit for first JFET\n",
      "Co1=Cds+(Cgd*(1+(1/Avo1)))  #output crcuit for first JFET\n",
      "Ceq2=Cgs+Cgd*(1+Avo2)       #input crcuit for second JFET\n",
      "Co2=Cds+(Cgd*(1+(1/Avo2)))  #output crcuit for second JFET\n",
      "\n",
      "#Part b\n",
      "w21=1/(R1*Ceq1)             #input circuit frequency\n",
      "w2=10**12/(R2*10**3*(Co1+Ceq2))        #common circuit frequency\n",
      "w22=1/(R3*Co2)              #output circuit frequency\n",
      "\n",
      "\n",
      "#Results\n",
      "print\"a)Avo is\",Avo\n",
      "print\"b)w21,w2,w22 are\",round((w21/1E-3),2),\"Mrad/sec,\",round((w2/1E+6),2),\"Mrad/sec and\",round((w22/1E-3),2),\"Mrad/sec\"\n",
      "print\"nondominant corner freq is\",round((w2/1E+6),2),\"Mrad/sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Avo is 160.0\n",
        "b)w21,w2,w22 are 7.69 Mrad/sec, 3.12 Mrad/sec and 58.82 Mrad/sec\n",
        "nondominant corner freq is 3.12 Mrad/sec\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}