{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5: Semiconductor Junction Diodes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1, Page 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "#I=Is*(exp((e*V)/kB*T)-1)\n",
      "I=50*10**(-3)#I=Forward current in ampere\n",
      "Is=5*10**(-6)#Is=Reverse saturation current in ampere\n",
      "e=1.6*10**(-19)#e=charge of electron in coulomb\n",
      "#V=voltage\n",
      "kB=1.38*10**(-23)#kB=Boltzmann's constant in Joule/kelvin\n",
      "T=300#T=Temperature in kelvin\n",
      "\n",
      "#Calculations\n",
      "a=(I/Is)+1\n",
      "#exp((e*V)/kB*T)=a\n",
      "V=((kB*T)/e)*math.log(10**4)\n",
      "\n",
      "#Result\n",
      "print \"V= %.3f V\"%V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V= 0.238 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, Page 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "e=1.6*10**-19#e=charge of an electron in C\n",
      "V1=0.06#V1=applied forward bias in V\n",
      "V2=(-0.06)#V2 =applied reverse bias in V\n",
      "kB=1.38*10**(-23)#kB=Boltzmann's constant in J/K\n",
      "T=300#T=Temperature in Kelvin\n",
      "\n",
      "#Calculations\n",
      "#Is=reverse saturation current in A\n",
      "#I1=Is*(exp((e*V1)/(kB*T))-1)#I1=current for forward bias\n",
      "#I2=Is*(exp((e*V2)/(kB*T))-1)#I2=current for reverse bias\n",
      "a=((math.exp((e*V1)/(kB*T))-1))/((math.exp((e*V2)/(kB*T))-1))#a=(I1/I2)\n",
      "\n",
      "#Result\n",
      "print \"a = %.2f\"%abs(a)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a = 10.16\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, Page 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=0.9#V=forward bias voltage\n",
      "I=60*10**(-3)#I=Current in ampere\n",
      "\n",
      "#Calculations\n",
      "rdc=(V/I)#rdc=static resistance in ohm\n",
      "n=2#n=emission coefficient\n",
      "rac=((26*n*10**(-3))/I)#rac=dynamic resistance\n",
      "\n",
      "#Results\n",
      "print \"rdc=%.f ohm\"%rdc\n",
      "print \"rac=%.2f ohm\"%rac"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rdc=15 ohm\n",
        "rac=0.87 ohm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, Page 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "e=1.6*10**(-19)#e=charge of an electron in C\n",
      "kB=1.38*10**(-23)#kB=Boltzmann's constant in J/K\n",
      "#V,V1=forward bias voltagesin V\n",
      "n=2#n=emission coefficient for silicon pn junction diode\n",
      "T=300#T=Temperature in kelvin\n",
      "\n",
      "#Calculations\n",
      "#Is=Reverse saturation current in A\n",
      "#I=Is*(exp((e*V)/(n*kB*T)))#I=current for forward bias voltage V\n",
      "#2I=Is*(exp((e*V1)/(n*kB*T)))#2I=current for forward bias voltage V1\n",
      "#exp((e*(V1-V)/(n*kB*T)))=2\n",
      "a=(((n*kB*T)/e)*math.log(2))*10**3#a=(V1-V)=increase in the bias voltage in V\n",
      "\n",
      "#Result\n",
      "print \"V1-V = %.1f mV\"%a"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V1-V = 35.9 mV\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, Page 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "e=1.6*10**(-19)#e=charge of an electron in C\n",
      "kB=1.38*10**(-23)#kB=Boltzmann's constant in J/K\n",
      "n=2#n=emission coefficient for silicon pn junction diode\n",
      "T=300#T=Temperature in kelvin\n",
      "\n",
      "#Calculations\n",
      "#Is=Reverse saturation current in A\n",
      "#V=bias voltage in V\n",
      "#I=Is*(exp((e*V)/(n*kB*T))-1)#I=reverse current in A\n",
      "#I=(-(Is/2))\n",
      "a=(((n*kB*T)/e)*math.log(1./2))*10**3#a=bias for reverse current in silicon pn junction diode \n",
      "\n",
      "#Results\n",
      "print \"V = %.1f mV\"%a\n",
      "print \"The negative sign suggests diode in reverse bias\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V = -35.9 mV\n",
        "The negative sign suggests diode in reverse bias\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, Page 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "#T1,T2=Temperature in kelvin\n",
      "#Is1=Reverse saturation current at temperature T1 in ampere\n",
      "#Is2=Reverse saturation current at temperature T2 in ampere\n",
      "#Is2=Is1*2^((T2-T1)/10)\n",
      "#((T2-T1)/10)*log(2)=log(Is2/Is1)\n",
      "#b=(Is2/Is1)\n",
      "b=50\n",
      "\n",
      "#Calculations\n",
      "a=((10*math.log(b))/math.log(2))#a=(T2-T1)=rise in temperature in degree celcius\n",
      "\n",
      "#Result\n",
      "print \"T2-T1 = %.1f C\"%a"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T2-T1 = 56.4 C\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7, Page 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V=0.6#V=cutin voltage in V\n",
      "r=150.#r=forward resistance in ohm\n",
      "P=200.0*(10**-3)#P=maximum power in Watt\n",
      "\n",
      "#Calculations&Results\n",
      "#P=(i^2)*r where i=maximum safe diode current\n",
      "i=(math.sqrt(P/r))*10**3\n",
      "print \"i=%.1f mA\"%i\n",
      "#i=((Vb/3)-V)/3 by applying KCL\n",
      "Vb=((3*i)+V)*3#Vb=maximum permissible battery voltage\n",
      "print \"Vb= %.1f V\"%Vb\n",
      "#Incorrect answers in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i=36.5 mA\n",
        "Vb= 330.4 V\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8, Page 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=15#V=supply voltage\n",
      "Vz=12#Vz=Zener voltage\n",
      "P=0.36#P=power of Zener diode\n",
      "\n",
      "#Calculations&Results\n",
      "#P=Vz*I\n",
      "I=(P/Vz)#I=maximum allowable Zener current \n",
      "print \"I= %.2f A\"%I\n",
      "Vr=V-Vz#Vr=voltage drop across series resistance R\n",
      "print \"Vr=%.f V\"%Vr\n",
      "R=Vr/I#R=series resistance\n",
      "print \"R=%.f ohm\"%R\n",
      "#I=Iz+Il\n",
      "Iz=2*(10**-3)#Iz=minimum diode current\n",
      "Il=I-Iz#Il=current through load resistance Rl\n",
      "print \"Il=%.f mA\"%(Il*10**3)\n",
      "Rlm=Vz/Il#Rlm=minimum value of Rl\n",
      "print \"Rlm=%.1f ohm\"%Rlm\n",
      "print \"The allowable range of variation of Rl is 428.6ohm<=Rl<infinite\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I= 0.03 A\n",
        "Vr=3 V\n",
        "R=100 ohm\n",
        "Il=28 mA\n",
        "Rlm=428.6 ohm\n",
        "The allowable range of variation of Rl is 428.6ohm<=Rl<infinite\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9, Page 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=15#V=supply voltage\n",
      "Vz=12.#Vz=Zener voltage\n",
      "P=0.36#P=power of Zener diode\n",
      "\n",
      "#Calculations&Results\n",
      "#P=Vz*I\n",
      "I=(P/Vz)#I=maximum allowable Zener current \n",
      "print \"I=%.2f A\"%I\n",
      "Iz=2*10**(-3)#Iz=minimum value attained by the zener current\n",
      "Rl=1000#Rl=load resistance\n",
      "i=Vz/Rl#i=load current\n",
      "print \"i=%.3f A\"%i\n",
      "Imin=Iz+i#Imin=minimum allowable value of current\n",
      "R=100#R=series resistance\n",
      "Vr=Imin*R#Vr=voltage drop across R\n",
      "print \"Vr=%.1f V\"%Vr\n",
      "Vmin=Vz+Vr#Vmin=minimum value of V\n",
      "print \"Vmin=%.1f V\"%Vmin\n",
      "I1=I+i\n",
      "print \"I1=%.f mA\"%(I1*10**3)\n",
      "VR=I1*R\n",
      "print \"VR=%.1f V\"%VR\n",
      "Vmax=Vz+VR#Vmax=maximum value of V\n",
      "print \"Vmax=%.1f V\"%Vmax\n",
      "print \"V can vary between Vmin & Vmax\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I=0.03 A\n",
        "i=0.012 A\n",
        "Vr=1.4 V\n",
        "Vmin=13.4 V\n",
        "I1=42 mA\n",
        "VR=4.2 V\n",
        "Vmax=16.2 V\n",
        "V can vary between Vmin & Vmax\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10, Page 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "from numpy.linalg import inv\n",
      "\n",
      "#Variable declaration\n",
      "Vz=3#Vz=breakdown voltage of zener diode\n",
      "Vi=12#Vi=input voltage\n",
      "V=np.matrix('12;-3')#V=[Vi:-Vz]\n",
      "R1=1000\n",
      "R2=1000\n",
      "R3=500#R1,R2,R3=resistances\n",
      "\n",
      "#Calculations&Results\n",
      "R=np.matrix([[R1+R2, -R2],[-R2, R2+R3]])\n",
      "#solving this matrix on the basis of application of KCL & KVL,we get the values of branch currents I & Iz as I1=[I;Iz]\n",
      "I1=inv(R)*V\n",
      "print \"I=%.2f mA\"%(I1[0]*10**3)\n",
      "print \"Iz=%.f mA\"%(I1[1]*10**3)\n",
      "Pz=Vz*I1[1]#Pz=power dissipated in zener diode\n",
      "print \"Pz=%.f mW\"%(Pz*10**3)\n",
      "print \"Power dissipated does not exceed the maximum power limit of 20mW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I=7.50 mA\n",
        "Iz=3 mA\n",
        "Pz=9 mW\n",
        "Power dissipated does not exceed the maximum power limit of 20mW\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11, Page 86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vs1=15\n",
      "Vs2=30.#Vs=supply voltage varying from 15(Vs1) to 30(Vs2) Volt\n",
      "Vzo=9#Vzo=knee voltage\n",
      "rZ=5.#rZ=dynamic resistance in ohms\n",
      "R=800#R=series resistance in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "Izmin=(Vs1-Vzo)/(R+rZ)#Izmin=current through zener diode when Vs is 15 V\n",
      "print \"Izmin=%.2f mA\"%(Izmin*10**3)\n",
      "Vomin=(rZ*Izmin)+Vzo#Vomin=corresponding minimum output voltage\n",
      "print \"Vomin=%.3f V\"%Vomin\n",
      "Izmax=(Vs2-Vzo)/(R+rZ)#Izmax=current through zener diode when Vs is 30 V\n",
      "print \"Izmax=%.f mA\"%(Izmax*10**3)\n",
      "Vomax=(rZ*Izmax)+Vzo#Vomax=corresponding maximum output voltage\n",
      "print \"Vomax=%.2f V\"%Vomax\n",
      "print \"Output voltage Vo varies in the range Vomin to Vomax\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Izmin=7.45 mA\n",
        "Vomin=9.037 V\n",
        "Izmax=26 mA\n",
        "Vomax=9.13 V\n",
        "Output voltage Vo varies in the range Vomin to Vomax\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12, Page 86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=35#V=supply voltage\n",
      "Iz=25*10**(-3)#Iz=diode current\n",
      "Il=5*10**(-3)#Il=load current\n",
      "Vzo=7#Vzo=knee voltage of zener diode\n",
      "rZ=6#rZ=dynamic resistance in ohms\n",
      "\n",
      "#Calculations&Results\n",
      "Vz=Vzo+(rZ*Iz)#Vz=zener voltage\n",
      "print \"Vz=%.2f V\"%Vz\n",
      "I=Iz+Il#I=current through resistance R\n",
      "print \"I=%.f mA\"%(I*10**3)\n",
      "R=(V-Vz)/I\n",
      "print \"R=%.1f ohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vz=7.15 V\n",
        "I=30 mA\n",
        "R=928.3 ohm\n"
       ]
      }
     ],
     "prompt_number": 33
    }
   ],
   "metadata": {}
  }
 ]
}