{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13: Field-Effect Transistors"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1, Page 317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "ND=2*10**21#ND=donor concentration in m**-3 of an n-channel silicon JFET\n",
      "e=1.6*10**-19#e=charge of an electron\n",
      "E=12*8.854*10**-12#E=permittivity of the material where 12=dielectric constant of silicon(given)\n",
      "a=(4*10**-6)/2#2*a=channel width in metres and 2*a=4*10**-6\n",
      "\n",
      "#Calculations&Results\n",
      "Vp=(e*ND*(a**2))/(2*E)\n",
      "print \"The pinch-off voltage is = %.2f V\"%Vp\n",
      "VGS=-2#VGS=gate source voltage\n",
      "#Vp=VDsat-VGS where VDsat=saturation voltage\n",
      "VDsat=Vp+VGS\n",
      "print \"The saturation voltage is = %.2f V\"%VDsat"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pinch-off voltage is = 6.02 V\n",
        "The saturation voltage is = 4.02 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, Page 317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "VGS=-1.5#VGS=gate-to-source voltage of a JFET\n",
      "IDsat=5*10**-3#IDsat=drain saturation current in Ampere\n",
      "\n",
      "#Calculations\n",
      "RS=(abs(VGS))/(abs(IDsat))#RS=resistance to be calculated=|VGS| / |IDsat|\n",
      "\n",
      "#Result\n",
      "print \"Resistance to be calculated is = %.f ohm\"%RS "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance to be calculated is = 300 ohm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, Page 317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "VGS1=-1\n",
      "VGS2=-1.5#VGS1,VGS2=change in VGS(gate-to-source voltage) from VGS1 to VGS2 keeping VDS(drain-to-source voltage) constant\n",
      "ID1=7.*10**-3\n",
      "ID2=5*10**-3#ID1,ID2=change in ID(drain current) in Ampere from ID1 to ID2\n",
      "\n",
      "#Calculations&Results\n",
      "#gm=(id/vgs)|VDS=constant where gm=transconductance\n",
      "id=ID1-ID2\n",
      "vgs=VGS1-VGS2\n",
      "gm=id/vgs\n",
      "print \"The transconductance of the FET is = %.f mA/V\"%(gm*10**3)\n",
      "rd=200*10**3#rd=ac drain resistance in ohms\n",
      "u=rd*gm#u=amplification factor\n",
      "print \"The amplification factor of the FET is = %.f\"%u"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The transconductance of the FET is = 4 mA/V\n",
        "The amplification factor of the FET is = 800\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, Page 217"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "RL=250*10**3#RL=load resistance in ohms in a FET amplifier\n",
      "rd=100*10**3#rd=ac drain resistance in ohms\n",
      "gm=0.5*10**-3#gm=transconductance in A/V\n",
      "\n",
      "#Calculations&Results\n",
      "u=rd*gm#u=amplification factor\n",
      "AV=-(u*RL)/(rd+RL)#AV=voltage gain\n",
      "print \"The voltage gain of FET amplifier is = %.2f\"%AV\n",
      "print \"The output resistance excluding RL is rd=%.f kohm\"%(rd/1000)\n",
      "ro=(rd*RL)/(rd+RL)#ro=output resistance including RL\n",
      "print \"Including RL,the output resistance is=%.f k ohms\"%(ro/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage gain of FET amplifier is = -35.71\n",
        "The output resistance excluding RL is rd=100 kohm\n",
        "Including RL,the output resistance is=71 k ohms\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, Page 318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#For n-channel JFET \n",
      "IDSS=12*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V\n",
      "Vp=-4#Vp=pinch-off voltage\n",
      "VGS=-2#VGS=gate-to-source voltage\n",
      "\n",
      "#Calculations&Results\n",
      "#By Shockley's equation\n",
      "IDS=IDSS*(1-(VGS/Vp))**2#IDS=saturation drain current to be calculated for given value of VGS\n",
      "print \"The drain current for given value of VGS is=%.f mA\"%(IDS/10**-3)\n",
      "gmo=4*10**-3#gmo=transconductance in A/V of a JFET when VGS=0V\n",
      "#gmo=-(2*IDSS)/Vp\n",
      "Vp=-(2*IDSS)/gmo#Vp=pinch-off voltage to be calculated for given value of transconductance\n",
      "print \"The pinch-off voltage for given value of gmo is = %.f V\"%Vp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The drain current for given value of VGS is=12 mA\n",
        "The pinch-off voltage for given value of gmo is = -6 V\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, Page 318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "IDSS=12*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V\n",
      "Vp=-4#Vp=pinch-off voltage\n",
      "VDD=30#VDD=drain supply voltage\n",
      "RL=5*10**3#RL=load resistance in ohms\n",
      "Rs=600#Rs=resistance connected to source terminal in ohms\n",
      "Rg=1.5*10**6#Rg=resistance connected to gate terminal in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "#By Shockley's equation\n",
      "#IDS=IDSS*(1-(VGS/Vp))**2 where IDS=saturation drain current to be calculated for given value of VGS\n",
      "#Substituting VGS=(-ID*Rs) we get ID=IDS\n",
      "#ID=IDSS*(1+((ID*Rs)/Vp))**2\n",
      "#ID=12*(1+((0.6*ID)/-4))**2 where ID is obtained in mA\n",
      "#(0.27*ID**2)-(4.6*ID)+12=0.........(1)\n",
      "ID1=(4.6+math.sqrt((4.6**2)-(48*0.27)))/(2*0.27)\n",
      "ID2=(4.6-math.sqrt((4.6**2)-(48*0.27)))/(2*0.27)#ID1,ID2 are the 2 roots of the above equation (1)\n",
      "print \"ID1=%.2f mA\"%ID1\n",
      "print \"ID2=%.2f mA\"%ID2\n",
      "if (ID1>(IDSS/10**-3)):#IDSS is converted in terms of mA\n",
      "    print \"As ID1>IDSS ,the value rejected is ID1=%.2f mA\"%ID1\n",
      "\n",
      "if (ID2>(IDSS/10**-3)):#IDSS is converted in terms of mA\n",
      "    print \"As ID2>IDSS ,the value rejected is ID2=%.2f mA\"%ID2\n",
      "\n",
      "print \"Therefore,the drain current is = %.2f mA\"%ID2\n",
      "ID=ID2*10**-3#converting ID2 in terms of Ampere\n",
      "VDS=VDD-ID*(RL+Rs)#VDS=drain-to-source voltage\n",
      "print \"The value of drain-to-source voltage VDS is = %.f V\"%VDS\n",
      "VGS=-ID*Rs#VGS=gate-to-source voltage\n",
      "print \"The value of gate-to-source voltage VGS is=%.2f V\"%VGS\n",
      "if(Vp<0 and VDS>(VGS-Vp)):\n",
      "    print \"As Vp=(-4)<VGS<0V and VDS=12V>(VGS-Vp),it is verified that the JFET is in the saturation region of the drain characteristics\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ID1=13.82 mA\n",
        "ID2=3.22 mA\n",
        "As ID1>IDSS ,the value rejected is ID1=13.82 mA\n",
        "Therefore,the drain current is = 3.22 mA\n",
        "The value of drain-to-source voltage VDS is = 12 V\n",
        "The value of gate-to-source voltage VGS is=-1.93 V\n",
        "As Vp=(-4)<VGS<0V and VDS=12V>(VGS-Vp),it is verified that the JFET is in the saturation region of the drain characteristics\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7, Page 319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V\n",
      "Vp=-2#Vp=pinch-off voltage\n",
      "VDD=20#VDD=drain supply voltage\n",
      "RL=1*10**3#RL=load resistance in ohms\n",
      "Rs=2*1000#Rs=resistance connected to source terminal in ohms\n",
      "R1=12*10**6#R1=resistance in the voltage divider network in ohms\n",
      "R2=8*10**6#R2=resistance in the voltage divider network in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "VT=(R2/(R1+R2))*VDD#VT=Thevenin voltage\n",
      "#VGS=VT-(ID*Rs)\n",
      "#By Shockley's equation\n",
      "#IDS=IDSS*(1-(VGS/Vp))**2 where IDS=saturation drain current to be calculated for given value of VGS\n",
      "#Substituting VGS=(VGS-ID*Rs) we get ID=IDS\n",
      "#(10*ID**2)-(101*ID)+250=0.........(1)where ID is obtained in mA\n",
      "ID1=(101+math.sqrt((101**2)-(40*250)))/(2*10)\n",
      "ID2=(101-math.sqrt((101**2)-(40*250)))/(2*10)#ID1,ID2 are the 2 roots of the above equation (1)\n",
      "print \"ID1=%.2f mA\"%ID1\n",
      "print \"ID2=%.2f mA\"%ID2\n",
      "#For ID1\n",
      "VGS=VT-(ID1*Rs)#VGS=gate-to-source voltage calculated for ID1\n",
      "if (Vp>VGS):\n",
      "    print \"As Vp>(VGS calculated using ID1), the value rejected is ID1=%.2f mA\"%ID1\n",
      "\n",
      "print \"Therefore,the drain current is = %.2f mA\"%ID2\n",
      "ID=ID2*10**-3#converting ID2 in terms of Amperes\n",
      "VGS=VT-(ID*Rs)#VGS=gate-to-source voltage\n",
      "print \"VGS=%.2f V\"%VGS\n",
      "VDS=VDD-(ID*(RL+Rs))#VDS=drain-to-source voltage\n",
      "print \"VDS=%.f V\"%VDS\n",
      "if(Vp<VGS and VDS>(VGS-Vp)):\n",
      "    print \"As Vp=(-2)<(VGS=-0.68V) and VDS=7V>(VGS-Vp),it is checked that the JFET operates in the saturation region \"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ID1=5.76 mA\n",
        "ID2=4.34 mA\n",
        "As Vp>(VGS calculated using ID1), the value rejected is ID1=5.76 mA\n",
        "Therefore,the drain current is = 4.34 mA\n",
        "VGS=-8.68 V\n",
        "VDS=7 V\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8, Page 319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#For a n-channel JFET\n",
      "IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V\n",
      "Vp=(-4)#Vp=pinch-off voltage\n",
      "VGS=(-2.5)#VGS=gate-to-source voltage\n",
      "\n",
      "#Calculations&Results\n",
      "#By Shockley's equation\n",
      "IDS=IDSS*(1-(VGS/Vp))**2#IDS=saturation drain current to be calculated for given value of VGS\n",
      "print \"The drain current for given value of VGS is=%.1f mA\"%(IDS/10**-3)#converting IDS in terms of mA\n",
      "VDSmin=VGS-Vp#VDSmin=minimum value of drain-to-source voltage for the onset of the saturation region\n",
      "print \"The minimum value of VDS for saturation is=%.1f V\"%VDSmin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The drain current for given value of VGS is=1.4 mA\n",
        "The minimum value of VDS for saturation is=1.5 V\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9, Page 319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "VDD=20#VDD=drain supply voltage\n",
      "IDS=0.9#IDS=drain saturation current in terms of mA\n",
      "Vp=-3.#Vp=pinch-off voltage\n",
      "IDSS=8#IDSS=saturation drain current in mA when VGS(gate-to-source voltage)=0V\n",
      "\n",
      "#Calculations&Results\n",
      "#By Shockley's equation\n",
      "#IDS=IDSS*(1-(VGS/Vp))^2\n",
      "VGS=Vp*(1-math.sqrt(IDS/IDSS))#VGS=gate-to-source voltage\n",
      "print \"The gate-to-source voltage VGS is=%.f V\"%VGS\n",
      "#gm=(dIDS/dVGS)|VDS=constant where gm=transconductance\n",
      "gm=-((2*IDSS)/Vp)*(1-(VGS/Vp))\n",
      "print \"The value of transconductance is=%.2f mS\"%gm\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The gate-to-source voltage VGS is=-2 V\n",
        "The value of transconductance is=1.79 mS\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10, Page 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "IDS=-15.#IDS=drain saturation current in terms of mA\n",
      "Vp=5#Vp=pinch-off voltage\n",
      "IDSS=-40#IDSS=saturation drain current in mA when VGS(gate-to-source voltage)=0V\n",
      "\n",
      "#Calculations\n",
      "#By Shockley's equation\n",
      "#IDS=IDSS*(1-(VGS/Vp))^2\n",
      "VGS=Vp*(1-math.sqrt(IDS/IDSS))#VGS=gate-to-source voltage\n",
      "\n",
      "#Result\n",
      "print \"The gate-to-source voltage VGS is=%.2f V\"%VGS"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The gate-to-source voltage VGS is=1.94 V\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11, Page 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "IDSS=10*10**-3#IDSS=saturation drain current in Ampere when VGS(gate-to-source voltage)=0V\n",
      "Vp=-5.#Vp=pinch-off voltage\n",
      "VDD=24.#VDD=drain supply voltage\n",
      "VDS=8#VDS=drain-to-source voltage\n",
      "ID=4.*10**-3#ID=drain current in Ampere\n",
      "R1=2.*10**6#R1=resistance in the voltage divider network in ohms\n",
      "R2=1*10**6#R2=resistance in the voltage divider network in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "VT=(R2/(R1+R2))*VDD#VT=Thevenin voltage\n",
      "#By Shockley's equation\n",
      "#ID=IDS=IDSS*(1-(VGS/Vp))**2\n",
      "VGS=Vp*(1-math.sqrt(ID/IDSS))#VGS=gate-to-source voltage\n",
      "#VGS=VT-(ID*Rs) where Rs=resistance connected at the source terminal\n",
      "Rs=(VT-VGS)/ID\n",
      "print \"The value of Rs = %.2f k ohm\"%(Rs/10**3)#converting Rs in terms of kilo-ohm\n",
      "Rch=VDS/ID#Rch=channel resistance at the Q-point\n",
      "print \"The channel resistance at the Q-point is=%.f k ohm\"%(Rch/10**3)#converting Rch in terms of kilo-ohm"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rs = 2.46 k ohm\n",
        "The channel resistance at the Q-point is=2 k ohm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12, Page 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "ID=5#ID=saturation drain current in terms of mA in an n-channel enhancement mode MOSFET\n",
      "VGS=8.#VGS=gate-to-source voltage\n",
      "VT=4#VT=Threshold voltage\n",
      "VGS2=10#VGS2=gate-to-source voltage for which saturation drain current is to be calculated\n",
      "\n",
      "#Calculations&Results\n",
      "#ID=K*(VGS-VT)**2 where K=(IDSS/(Vp**2)) and Vp=pinch-off voltage ,IDSS=drain saturation current for VGS=0 V\n",
      "K=ID/((VGS-VT)**2)\n",
      "ID1=K*(VGS2-VT)**2#ID1=The saturation drain current for gate-source voltage of 10V i e VGS2\n",
      "\n",
      "\n",
      "print \"The saturation drain current for gate-source voltage of 10V is = %.1f mA\"%ID1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The saturation drain current for gate-source voltage of 10V is = 11.2 mA\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13, Page 321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#For n-channel enhancement mode MOSFET operating in active region\n",
      "VT=2#VT=Threshold voltage\n",
      "K=0.5#K=(IDSS/(Vp**2)) in terms of mA/V**2\n",
      "VDD=15#VDD=drain supply voltage\n",
      "RL=1#RL=load resistance in kilo ohm\n",
      "R1=200*10**3#R1=resistance in the voltage divider network in terms of ohms\n",
      "R2=100.*10**3#R2=resistance in the voltage divider network in terms of ohms\n",
      "\n",
      "#Calculations&Results\n",
      "VGS=(R2/(R1+R2))*VDD#VGS=gate-to-source voltage\n",
      "print \"Threshold voltage is = %.f V\"%VT\n",
      "print \"The gate-to-source voltage VGS is = %.f V\"%VGS\n",
      "ID=K*(VGS-VT)**2#ID=drain current in mA\n",
      "print \"The value of drain current ID is = %.1f mA\"%ID\n",
      "VDS=VDD-(ID*RL)#VDS=drain-to-source voltage\n",
      "print \"The value of drain-to-source voltage VDS is=%.1f V\"%VDS\n",
      "if (VDS>(VGS-VT)):\n",
      "    print \"As VDS>(VGS-VT),(i.e. 10.5>(5-2)),the operation is indeed in the active region \"\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Threshold voltage is = 2 V\n",
        "The gate-to-source voltage VGS is = 5 V\n",
        "The value of drain current ID is = 4.5 mA\n",
        "The value of drain-to-source voltage VDS is=10.5 V\n",
        "As VDS>(VGS-VT),(i.e. 10.5>(5-2)),the operation is indeed in the active region \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14, Page 321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#For n-channel MOSFET operating in the depletion mode\n",
      "VDD=18#VDD=drain supply voltage\n",
      "VGS=0#VGS=gate-to-source voltage\n",
      "RL=600#RL=load resistance in ohms\n",
      "IDSS=18.#IDSS=drain saturation current in mA for gate-to-source voltage (VGS)=0V\n",
      "Vp=-5#Vp=pinch-off voltage\n",
      "\n",
      "#Calculations&Results\n",
      "#Assuming that the operation is in the active region\n",
      "#ID=IDS=IDSS*(1-(VGS/Vp))**2\n",
      "#ID=(IDSS/Vp**2)(VGS-Vp)**2\n",
      "K=IDSS/(Vp**2)\n",
      "print \"The value of K is = %.2f mA/V^2\"%K\n",
      "ID=IDSS#ID=drain current \n",
      "print \"Since VGS=0,the value of ID=IDSS is=%.f mA\"%ID\n",
      "VDS=VDD-(ID*(RL/10**3))#VDS=drain-to-source voltage and also converting RL in terms of kilo ohm\n",
      "print \"The value of VDS is = %.f V\"%VDS\n",
      "print \"Pinch off voltage Vp is = %.f V\"%Vp\n",
      "print \"Gate to source voltage VGS is = %.f V\"%VGS\n",
      "if (VDS>(VGS-Vp)):\n",
      "    print \"As VDS>(VGS-Vp),(i.e.7.5>(0-(-5))),the MOSFET is actually in the active region \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of K is = 0.72 mA/V^2\n",
        "Since VGS=0,the value of ID=IDSS is=18 mA\n",
        "The value of VDS is = 18 V\n",
        "Pinch off voltage Vp is = -5 V\n",
        "Gate to source voltage VGS is = 0 V\n",
        "As VDS>(VGS-Vp),(i.e.7.5>(0-(-5))),the MOSFET is actually in the active region \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15, Page 321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "#r given in textbook is taken as rd afterwards.Hence r=rd\n",
      "rd=100*10**3#rd=drain resistance in ohms\n",
      "gm=3500*10**-6#gm=transconductance in terms of A/V (or S)\n",
      "RL=5*10**3#RL=load resistance in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "u=rd*gm#u=amplification factor\n",
      "AV=(u*RL)/(((u+1)*RL)+rd)#AV=voltage gain\n",
      "print \"The voltage gain is=%.3f\"%AV\n",
      "Ro=rd/(u+1)#Ro=output resistance excluding RL\n",
      "print \"The output resistance excluding RL is = %.f ohm\"%Ro\n",
      "Ro1=(rd*RL)/(rd+((u+1)*RL))#Ro1=Ro'=output resistance including RL\n",
      "print \"The output resistance including RL is=%.f ohm\"%(math.floor(Ro1))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage gain is=0.943\n",
        "The output resistance excluding RL is = 285 ohm\n",
        "The output resistance including RL is=269 ohm\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16, Page 322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#In a FET used in a CS amplifier\n",
      "IDSS=4.#IDSS=drain saturation current in mA for gate-to-source voltage (VGS)=0V\n",
      "Vp=-3#Vp=pinch-off voltage\n",
      "RL=10#RL=load resistance in kilo ohms\n",
      "VGS=-0.7#VGS=gate-to-source voltage\n",
      "\n",
      "#Calculations\n",
      "gmo=-(2*IDSS)/Vp#gmo=transconductance in A/V of a JFET when VGS=0V\n",
      "gm=gmo*(1-(VGS/Vp))#gm=transconductance\n",
      "AV=-gm*RL#AV=the small signal voltage gain\n",
      "\n",
      "#Result\n",
      "print \"The small signal voltage gain is = %.1f\"%AV\n",
      "#Decimal term in the answer displayed in textbook is incorrect as 2.04*10=20.4 and not 20.04."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The small signal voltage gain is = -20.4\n"
       ]
      }
     ],
     "prompt_number": 22
    }
   ],
   "metadata": {}
  }
 ]
}