{
 "metadata": {
  "name": "",
  "signature": "sha256:996be6d9ddaa0bf73287e9f8387b49ed0c7806d0e7dbe4ba43b1c30f0c65dc07"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter03:Semiconductor Diodes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#find the value of threshold voltage\n",
      "#given\n",
      "t1=25.;#degrees C#initial temperature\n",
      "t2=100.;#degrees C#final temperature\n",
      "V=2.*10.**-3.;#V per celsius degree#decrease in barrier potential per degree\n",
      "V0=0.7#V#Potential at normal temperature\n",
      "Vd=(t2-t1)*V;#decrease in barrier potential\n",
      "Vt=V0-Vd;#threshold volatge at 100degree C\n",
      "print '%s %.2f %s' %(\"Threshold volatge at 100 degrees C =\",Vt,'V');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Threshold volatge at 100 degrees C = 0.55 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#detrenmine dc resistance of silicon diode\n",
      "#given\n",
      "#At Id = 2 mA\n",
      "Id=2.*10.**-3.;#Ampere#diode current\n",
      "Vd=0.5;#V#voltage(from given curve)\n",
      "Rf=(Vd/Id);\n",
      "print '%s %.f %s' %(\"The dc resistance is =\",Rf,\"ohm\\n\");\n",
      "\n",
      "#At Id = 20 mA\n",
      "Id=20.*10.**-3.;#Ampere#diode current\n",
      "Vd=0.75;#V#voltage(from given curve)\n",
      "Rf=(Vd/Id);\n",
      "print '%s %.1f %s' %(\"The dc resistance is =\",Rf,\"ohm\\n\");\n",
      "\n",
      "#At Vd = - 10 V \n",
      "Id=-2.*10.**-6.;#Ampere#diode current(from given curve)\n",
      "Vd=-10.;#V#voltage\n",
      "Rf=(Vd/Id);\n",
      "print '%s %.f %s' %(\"The dc resistance is =\",Rf/10**6,\"M ohm\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc resistance is = 250 ohm\n",
        "\n",
        "The dc resistance is = 37.5 ohm\n",
        "\n",
        "The dc resistance is = 5 M ohm\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine dc & ac resistance of silicon diode\n",
      "#given\n",
      "Id=20.*10.**-3.;#A#diode current\n",
      "Vd=0.75;#V# as given in the V-I graph\n",
      "Rf=Vd/Id;\n",
      "print '%s %.1f %s' %(\"The dc resistance of diode is =\",Rf,\"ohm\\n\");\n",
      "\n",
      "#From Graph the values of dynamic voltage and current are\n",
      "#which is equal to MN and NL repectively (in graph)\n",
      "del_Vd=(0.8-0.68);#V\n",
      "del_Id=(40-0)*10.**-3.;#A\n",
      "rf=del_Vd/del_Id;\n",
      "print '%s %.f %s' %(\"The ac resistance of the diode is =\",rf,\"ohm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc resistance of diode is = 37.5 ohm\n",
        "\n",
        "The ac resistance of the diode is = 3 ohm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine ac resistance of silicon diode\n",
      "#given\n",
      "#At Id =10mA\n",
      "Id=10.;#mA\n",
      "rf=25./Id;\n",
      "print '%s %.1f %s' %(\"The ac resistance of the diode is(At Id= 10mA) =\",rf,\"ohm\\n\")\n",
      "\n",
      "#At Id =20mA\n",
      "Id=20.;#mA\n",
      "rf=25./Id;\n",
      "print '%s %.2f %s' %(\"The ac resistance of the diode is(At Id= 20mA) =\",rf,\"ohm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ac resistance of the diode is(At Id= 10mA) = 2.5 ohm\n",
        "\n",
        "The ac resistance of the diode is(At Id= 20mA) = 1.25 ohm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Find current through diode\n",
      "#given\n",
      "Vt=0.3;#V#Threshold voltage\n",
      "rf=25.;#ohm# average resistance\n",
      "\n",
      "#assuming it to be ideal\n",
      "#from fig 3.19\n",
      "Vaa=10.;#V#supply\n",
      "R1=45.;#ohm\n",
      "R2=5.;#ohm\n",
      "Vab=Vaa*R2/(R1+R2);\n",
      "#Vab>Vt therefore diode is forward bias and no current flow through R2\n",
      "Idi=Vaa/R1;       #for ideal\n",
      "print '%s %.f %s' %(\"The diode current (for ideal) is =\",Idi*1000,\"mA\\n\");\n",
      "\n",
      "#assuming it to be real\n",
      "#Thevenins equivalent circuit parameters of fig 3.19\n",
      "Vth=Vaa*R2/(R1+R2);\n",
      "Rth=R1*R2/(R1+R2);\n",
      "Idr=(Vth-Vt)/(Rth+rf);          #for real\n",
      "print '%s %.1f %s' %(\"The diode current (for real) is =\",Idr*1000,\"mA\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The diode current (for ideal) is = 222 mA\n",
        "\n",
        "The diode current (for real) is = 23.7 mA\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Find current through resistance in given figure\n",
      "#From fig\n",
      "Vaa=20.;#V#supply\n",
      "Vt=0.7;#V#threshold voltage of diode\n",
      "rf=5.;#ohm #forward resistance\n",
      "R=90.;#ohm#given resistor\n",
      "\n",
      "#Diode D1 and D4 are forward bias and D2 and D3 are reverse biased\n",
      "\n",
      "Vnet=Vaa-Vt-Vt;\n",
      "Rt=R+rf+rf;\n",
      "I=Vnet/Rt;\n",
      "print '%s %.f %s' %(\"Current through 90 ohm resistor is =\",I*1000,\"mA\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through 90 ohm resistor is = 186 mA\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Find current drawn by the battery\n",
      "#From fig\n",
      "Vaa=10.;#V#supply\n",
      "R1=100.;#ohm\n",
      "R2=100.;#ohm\n",
      "\n",
      "#Forward Bias\n",
      "Id=Vaa/R1;\n",
      "print '%s %.1f %s' %(\"Current drawn from battery (forward bias) =\",Id,\"A\\n\");\n",
      "\n",
      "#Reverse Bias\n",
      "Rnet=R1+R2;\n",
      "Id=Vaa/Rnet;\n",
      "print '%s %.2f %s' %(\"Current drawn from battery (reverse bias) =\",Id,\"A\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current drawn from battery (forward bias) = 0.1 A\n",
        "\n",
        "Current drawn from battery (reverse bias) = 0.05 A\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine dc current through load and rectification efficiency and peak inverse voltage\n",
      "#given\n",
      "import math\n",
      "TR=31./2.;#Turn ratio of the transformer\n",
      "rf=20.;#ohm#Dynamic forward resistance\n",
      "Rl=1000.;#ohm#Load resistance\n",
      "Vt=0.66;#V#Threshold voltage of diode\n",
      "V=220.;#V#input voltage of transformer\n",
      "Vp=math.sqrt(2.)*220.#V#peak value of primary voltage\n",
      "Vm=(1./TR)*Vp;\n",
      "Im=(Vm-Vt)/(rf+Rl);\n",
      "Idc=Im/math.pi;\n",
      "n=40.6/(1.+rf/Rl);\n",
      "print '%s %.f %s' %(\"The dc current through load is =\",Idc*1000,\"mA\\n\");\n",
      "print '%s %.1f %s' %(\"The rectification efficiency is =\",n,\"percent\\n\");\n",
      "print '%s %.2f %s' %(\"Peak inverse voltage =Vm = \",Vm,\"V\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc current through load is = 6 mA\n",
        "\n",
        "The rectification efficiency is = 39.8 percent\n",
        "\n",
        "Peak inverse voltage =Vm =  20.07 V\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine dc voltage across load and peak inverse voltage across each diode\n",
      "#given\n",
      "import math\n",
      "TR=12./1.##Turn ratio of the transformer\n",
      "V=220.##V#input voltage of transformer\n",
      "Vp=math.sqrt(2.)*220.#V#peak value of primary voltage\n",
      "Vm=(1./TR)*Vp#\n",
      "Vdc=(2.*Vm)/math.pi#\n",
      "print '%s %.1f %s' %(\"The dc voltage across load =\",Vdc,\"V\\n\")#\n",
      "print '%s %.1f %s' %(\"Peak inverse voltage (for bridge rectifier) =\",Vm,\"V\\n\")#\n",
      "print '%s %.1f %s' %(\"Peak inverse voltage (for centre tap rectifier) =\",2*Vm,\"V\\n\")#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc voltage across load = 16.5 V\n",
        "\n",
        "Peak inverse voltage (for bridge rectifier) = 25.9 V\n",
        "\n",
        "Peak inverse voltage (for centre tap rectifier) = 51.9 V\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#find dc power supplied to load and efficiency and PIV rating of the diode\n",
      "#given\n",
      "import math\n",
      "rf=2.;#ohm#Dynamic forward resistance\n",
      "Rs=5.;#ohm#resistaqnce of secondary\n",
      "Rl=25.;#ohm#Load resistance\n",
      "Idc=0.1;#A#dc current to a load\n",
      "Pdc=Idc**2.*Rl;      #dc power\n",
      "n=(81.2*Rl)/(Rl+rf+Rs);        #efficiency\n",
      "Im=(math.pi*Idc)/2.;              #peak value current\n",
      "Vm=Im*(Rl+rf+Rs);              #peak voltage\n",
      "Vlm=Vm-Im*(rf+Rs);              #peak voltage across load\n",
      "PIV=Vm+Vlm;\n",
      "print '%s %.2f %s' %(\"The dc power supplied to the load is =\",Pdc,'W\\n');\n",
      "print '%s %.2f %s' %(\"Efficiency =\",n,'percent\\n');\n",
      "print '%s %.3f %s' %(\"The peak inverse voltage is =\",PIV,'V');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc power supplied to the load is = 0.25 W\n",
        "\n",
        "Efficiency = 63.44 percent\n",
        "\n",
        "The peak inverse voltage is = 8.954 V\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate output voltage and current through load and voltage across series resistor and current and power dissipated in zener diode\n",
      "#given\n",
      "Vi=110.;#V       #input voltage\n",
      "Rl=6.*10.**3.;# ohm    #load resistance\n",
      "Rs=2.*10.**3.;#ohm       #series resistance\n",
      "Vz=60.;#V        #Zener voltage\n",
      "V=Vi*Rl/(Rs+Rl);\n",
      "\n",
      "#This V>Vz therefore Zener diode is ON\n",
      "\n",
      "Vo=Vz;          #output voltage\n",
      "Il=Vo/Rl;       #Current through load resistance\n",
      "Vs=Vi-Vo;       #Voltage drop across the series resistor\n",
      "Is=Vs/Rs         #current through the series resistor\n",
      "Iz=Is-Il        #/By applying kirchhoffs law\n",
      "Pz=Vz*Iz        #Power dissipated accross zener diode\n",
      "\n",
      "print '%s %.f %s' %(\"The output voltage is =\",Vo,\"V\\n\");\n",
      "print '%s %.f %s' %(\"The current through load resistance is =\",Il*1000,\"mA\\n\");\n",
      "print '%s %.f %s' %(\"Voltage across series resistor is =\",Vs,\"V\\n\")\n",
      "print '%s %.f %s' %(\"Current in zener diode is =\",Iz*1000,\"mA\\n\")\n",
      "print '%s %.f %s' %(\"Power dissipated by zener diode =\",Pz*1000,'mW');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage is = 60 V\n",
        "\n",
        "The current through load resistance is = 10 mA\n",
        "\n",
        "Voltage across series resistor is = 50 V\n",
        "\n",
        "Current in zener diode is = 15 mA\n",
        "\n",
        "Power dissipated by zener diode = 900 mW\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Calculate max and min values of zener diode current\n",
      "#given\n",
      "Vimin=80.;#V       #minimum input voltage\n",
      "Vimax=120.;#V       #maximum input voltage\n",
      "Rl=10.*10.**3.;# ohm    #load resistance\n",
      "Rs=5.*10.**3.;#ohm       #series resistance\n",
      "Vz=50.;#V        #Zener voltage\n",
      "V=Vimin*Rl/(Rs+Rl);\n",
      "\n",
      "#This V>Vz therefore Zener diode is ON\n",
      "\n",
      "#For minimum value of zener diode\n",
      "\n",
      "Vo=Vz;          #output voltage\n",
      "Vs=Vimin-Vo;       #Voltage drop across the series resistor\n",
      "Is=Vs/Rs         #current through the series resistor\n",
      "Il=Vo/Rl;       #Current through load resistance\n",
      "Izmin=Is-Il;\n",
      "print '%s %.f %s' %(\"Minimum values of zener diode current is =\",Izmin*1000,\"mA\\n\");\n",
      "\n",
      "#For maximum value of zener diode\n",
      "\n",
      "Vo=Vz;          #output voltage\n",
      "Vs=Vimax-Vo;       #Voltage drop across the series resistor\n",
      "Is=Vs/Rs         #current through the series resistor\n",
      "Il=Vo/Rl;       #Current through load resistance\n",
      "Izmax=Is-Il;\n",
      "print '%s %.f %s' %(\"Maximum values of zener diode current is =\",Izmax*1000,\"mA\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum values of zener diode current is = 1 mA\n",
        "\n",
        "Maximum values of zener diode current is = 9 mA\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 - Pg 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine value of the series resistor and wattage rating\n",
      "#given\n",
      "Vi=12.##V       #input voltage\n",
      "Vz=7.2##V        #Zener voltage\n",
      "Izmin=10.*10.**-3.##A             #min current through zener diode\n",
      "Ilmax=100*10.**-3.##A            #max current through load\n",
      "Ilmin=12.*10.**-3.##A            #min current through load\n",
      "Vs=Vi-Vz#       #Voltage drop across the series resistor\n",
      "Is=Izmin+Ilmax#     #Current through the series resistor\n",
      "Rs=Vs/Is#\n",
      "print '%s %.1f %s' %(\"The series resistor so that 10mA current flow through zener diode is =\",Rs,\"ohm\\n\")#\n",
      "Izmax=Is-Ilmin#max zener through zener diode\n",
      "Pmax=Izmax*Vz#\n",
      "print '%s %.1f %s' %(\"The maximum wattage rating is =\",Pmax*1000,\"mW\")#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The series resistor so that 10mA current flow through zener diode is = 43.6 ohm\n",
        "\n",
        "The maximum wattage rating is = 705.6 mW\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E14 - Pg 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Find the capacitance of a varactor diode\n",
      "#given\n",
      "import math\n",
      "C=5.;#pf#capcitance of varactor diode at V=4V\n",
      "V=4.;#V\n",
      "K=C*math.sqrt(4.);\n",
      "#When bias voltage is increased upto 6 V\n",
      "Vn=6.;#V#new bias voltage\n",
      "Cn=K/(math.sqrt(Vn));\n",
      "print '%s %.3f %s' %(\"Capacitance (At 6 V ) =\",Cn,\"pf\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance (At 6 V ) = 4.082 pf\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}