{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "CHAPTER 5 SPECIAL-PURPOSE DIODES"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-1, Page 146"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vsmin=20             #Source voltage minimum(V)\n",
      "Vsmax=40             #Source voltage maximum(V)\n",
      "Vbd=10               #Breakdown voltage(V)\n",
      "R=0.82               #Resistance(KOhm)\n",
      "\n",
      "Vr1=Vsmin-Vbd        #voltage across resistor(V)\n",
      "Is1=Vr1/R            #Minimum current(mA)\n",
      "Vr2=Vsmax-Vbd        #voltage across resistor(V)\n",
      "Is2=Vr2/R            #Maximum current(mA)\n",
      "\n",
      "print 'Ideally, zener diode acts as a battery(of breakdown voltage = 10V) shown in figure 5-4b'\n",
      "print 'Minimum current Is1=',round(Is1,2),'mA'\n",
      "print 'Maximum current Is1=',round(Is2,2),'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ideally, zener diode acts as a battery(of breakdown voltage = 10V) shown in figure 5-4b\n",
        "Minimum current Is1= 12.2 mA\n",
        "Maximum current Is1= 36.59 mA\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-2, Page 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vs=18                 #supply voltage(V)\n",
      "Rs=0.27               #source resistance(KOhm)\n",
      "RL=1                  #Load resistance(KOhm)\n",
      "Vz=10                 #Zener voltage(V)\n",
      "\n",
      "VTH=(RL/(Rs+RL))*Vs    #Thevenin voltage(V)\n",
      "\n",
      "print 'Thevenin voltage VTH = ',round(VTH,2),'V'\n",
      "print 'Thevenin voltage is greater than zener voltage, zener diode is operating in breakdown region.'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thevenin voltage VTH =  14.17 V\n",
        "Thevenin voltage is greater than zener voltage, zener diode is operating in breakdown region.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-3, Page 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vs=18                 #supply voltage(V)\n",
      "Rs=0.27               #source resistance(KOhm)\n",
      "RL=1                  #Load resistance(KOhm)\n",
      "Vbd=10                #Zener voltage(V)\n",
      "\n",
      "Vr=Vs-Vbd            #voltage across resistor(V)\n",
      "Is=Vr/Rs              #Current(mA)\n",
      "IL=Vbd/RL            #Current(mA)\n",
      "Iz=Is-IL             #Zener current(mA)\n",
      "\n",
      "print 'Load current IL = ',IL,'mA'\n",
      "print 'Zener current Iz = ',round(Iz,2),'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load current IL =  10 mA\n",
        "Zener current Iz =  19.63 mA\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-7, Page 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Iz=20                    #zener current(mA)\n",
      "Rz=8.5                   #zener resistance(Ohm)\n",
      "Vbd=10                   #Zener voltage(V)\n",
      "\n",
      "DVL=Iz*Rz/1000           #change in load voltage(V)\n",
      "VL=Vbd+DVL               #Load voltage(V)\n",
      "\n",
      "print 'Change in load voltage DVL =',DVL,'V'\n",
      "print 'Load voltage with second approx., VL =',VL,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in load voltage DVL = 0.17 V\n",
        "Load voltage with second approx., VL = 10.17 V\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-8, Page 154"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Rs=270                   #Source resistance (Ohm)\n",
      "Rz=8.5                   #zener resistance(Ohm)\n",
      "VRin=2                   #Zener voltage(V)\n",
      "\n",
      "VRout=(Rz/Rs)*VRin*1000  #Load ripple voltage(V)\n",
      "\n",
      "print 'Load ripple voltage VRout=',round(VRout,2),'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load ripple voltage VRout= 62.96 mV\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-10, Page 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vil=22                 #input voltage range low(V)\n",
      "Vih=30                 #input voltage range high(V)\n",
      "Vz=12                  #regulated output voltage(V)\n",
      "Rl=140                 #Load resistance low(KOhm)\n",
      "Rh=10                  #Load resistance high(KOhm)\n",
      "\n",
      "RSmax=Rl*(float(Vil)/float(Vz)-1)  #Maximum series resistance\n",
      "\n",
      "print 'Maximum series resistance RSmax =',round(RSmax,2),'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum series resistance RSmax = 116.67 V\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-11, Page 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "Vil=15                     #input voltage range low(V)\n",
      "Vih=20                     #input voltage range high(V)\n",
      "Vz=6.8                     #regulated output voltage(V)\n",
      "Il=5                       #Load current low(mA)\n",
      "Ih=20                      #Load current high(mA)\n",
      "\n",
      "RSmax=(Vil-float(Vz))/Ih*1000  #Maximum series resistance\n",
      "\n",
      "print 'Maximum series resistance RSmax =',RSmax,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum series resistance RSmax = 410.0 V\n"
       ]
      }
     ],
     "prompt_number": 69
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-12, Page 168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vi=50                    #voatage supply(V)\n",
      "Rs=2.2                   #series resistance(KOhm)\n",
      "Vf=2                     #forward approx. voltage\n",
      "                    \n",
      "Is=(Vi-Vf)/Rs\n",
      "\n",
      "print 'LED current Is =',round(Is,2),'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "LED current Is = 21.82 mA\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-13, Page 168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vs=9                     #voatage supply(V)\n",
      "Rs=470.0                 #series resistance(Ohm)\n",
      "Vf=2                     #forward approx. voltage\n",
      "                    \n",
      "Is=(Vs-Vf)/Rs\n",
      "\n",
      "print 'LED current Is =',round((Is*1000),2),'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "LED current Is = 14.89 mA\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-14, Page 169"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "Vac=20                   #AC voatage supply(V)\n",
      "Rs=680.0                 #series resistance(KOhm)\n",
      "                    \n",
      "Vacp=1.414*Vac            #peak source voltage(V)\n",
      "Is1=(Vacp/Rs)*1000        #approx. peak current(mA)\n",
      "Is2=Is1/math.pi              #average of half-wave current through LED(mA)\n",
      "P=(Vac)**2/Rs             #Power dissipation(W)\n",
      "\n",
      "print 'approx. peak LED current Is1 =',round(Is1,2),'mA'\n",
      "print 'average of half-wave current through LED Is2 =',round(Is2,2),'mA'\n",
      "print 'Power dissipation P =',round(P,2),'W'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "approx. peak LED current Is1 = 41.59 mA\n",
        "average of half-wave current through LED Is2 = 13.24 mA\n",
        "Power dissipation P = 0.59 W\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-15, Page 170"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "Vs=120                   #AC voatage supply(V)\n",
      "f=60                     #frequency(Hz)\n",
      "C=0.68                   #series resistance(KOhm)\n",
      "                    \n",
      "Xc=1/(2*math.pi*f*C)*1000    #capacitive reactance(KOhm)\n",
      "Vacp=Vs*1.414\n",
      "Is1=(Vacp/Xc)             #approx. peak current(mA)\n",
      "Is2=Is1/math.pi              #average current through LED(mA)\n",
      "\n",
      "print 'Capacitance reactance Xc = ',round(Xc,2),'KOhm'\n",
      "print 'approx. peak LED current Is1 =',round(Is1,2),'mA'\n",
      "print 'average current through LED Is2 =',round(Is2,2),'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance reactance Xc =  3.9 KOhm\n",
        "approx. peak LED current Is1 = 43.5 mA\n",
        "average current through LED Is2 = 13.85 mA\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}