{

 "metadata": {

  "name": "",

  "signature": "sha256:b6ca6f88473b518209629b5a50e034951050cc84cc7fdfcdcdfe2cbba83ff5c4"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter03:Diodes"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.1:pg-143"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.1: Peak value of diode current and maximum reverse voltage\n",

      "#v_s is sinusoidal input voltage with peak 24V\n",

      "#battery charges to 12V\n",

      "I_d=(24-12)/100.0\n",

      "max_v_rev=24+12.0;\n",

      "print round(I_d,2),\"peak value of diode current (A)\\n\",round(max_v_rev,2),\"maximum reverse voltage acrossthe diode (V)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.12 peak value of diode current (A)\n",

        "36.0 maximum reverse voltage acrossthe diode (V)\n"

       ]

      }

     ],

     "prompt_number": 2

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.2:pg-145"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.2 : Values of Iand V for the circuit given\n",

      "print \"Consider fig 3.6(a). Assume both diodes are conducting\"\n",

      "I_D2=(10-0)/10.0;\n",

      "I=(0-(-10))/5.0-I_D2; # node eqution at B for fig 3.6(a)\n",

      "V_B=0;\n",

      "V=0;\n",

      "print I,\"= I (mA)\\n\", V,\"= V (V)\\n\" ,\"D_1 is conducting as assumed originally\"\n",

      "print \"Consider fig 3.6(a). Assume both diodes are conducting\"\n",

      "I_D2=(10-0)/5.0;\n",

      "I=(0-(-10.0))/10-2; # node eqution at B for fig 3.6(b)\n",

      "print I,\"= I (mA)\\n \", V,\"=V (V)\"\n",

      "print \"Implies assumption is wrong. lets assume D_1 is off and D_2 is on\"\n",

      "I_D2=(10-(-10))/15.0;\n",

      "V_B=-10+10.0*I_D2;\n",

      "I=0;\n",

      "print I,\"= I (mA)\\n\", round(V_B,1),\"= V (V)\\n D_1 is reverse biased\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Consider fig 3.6(a). Assume both diodes are conducting\n",

        "1.0 = I (mA)\n",

        "0 = V (V)\n",

        "D_1 is conducting as assumed originally\n",

        "Consider fig 3.6(a). Assume both diodes are conducting\n",

        "-1.0 = I (mA)\n",

        "  0 =V (V)\n",

        "Implies assumption is wrong. lets assume D_1 is off and D_2 is on\n",

        "0 = I (mA)\n",

        "3.3 = V (V)\n",

        " D_1 is reverse biased\n"

       ]

      }

     ],

     "prompt_number": 5

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.3:pg-150"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.3 : Evaluating junction scaling constant\n",

      "#i-I_S*exp(v/(n*V_T)) implies I_S=i*exp(-v/(n*V_T))\n",

      "n=1;\n",

      "i=10**-3; # (A)\n",

      "v=700; # (V)\n",

      "V_T=25; # (V)\n",

      "I_S=i*exp(-v/(n*V_T))\n",

      "print round(I_S,17),\"= I_S (A) for n=1\"\n",

      "n=2;\n",

      "I_S=i*exp(-v/(n*V_T))\n",

      "print round(I_S,11),\"= I_S (A) for n=2\"\n",

      "print \"These values implies I_S is 1000 times greater \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "6.9e-16 = I_S (A) for n=1\n",

        "8.3e-10 = I_S (A) for n=2\n",

        "These values implies I_S is 1000 times greater \n"

       ]

      }

     ],

     "prompt_number": 11

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.4:pg-154"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.4: To determine I_D and V_D\n",

      "V_DD=5; # (V)\n",

      "R=1000; # (ohm)\n",

      "I_1=1*10**-3; # (A)\n",

      "V_D=0.7; # (V)\n",

      "V_1=V_D;\n",

      "I_D=(V_DD-V_D)/R;\n",

      "I_2=I_D;\n",

      "V_2=V_1+0.1*log10(I_2/I_1);\n",

      "I_D=(V_DD-V_2)/R;\n",

      "print round(I_D*1000.0,3),\"= The diode current (mA)\"\n",

      "V_D=V_2+0.1*log10(I_D/I_2)\n",

      "print round(V_D,3),\"= The diode volage (V)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "4.237 = The diode current (mA)\n",

        "0.763 = The diode volage (V)\n"

       ]

      }

     ],

     "prompt_number": 14

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.5:pg-157"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.5 : Repeating example 3.4 using piecewise linear model\n",

      "V_D0=0.65; # (V)\n",

      "r_D=20; # (ohm)\n",

      "R=1000; # (ohm)\n",

      "V_DD=5; # (V)\n",

      "I_D=(V_DD-V_D0)/(R+r_D);\n",

      "print round(I_D*1000,2),\"= I_D (mA)\"\n",

      "V_D=V_D0+I_D*r_D;\n",

      "print round(V_D,3),\"= The diod voltage (V)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "4.26 = I_D (mA)\n",

        "0.735 = The diod voltage (V)\n"

       ]

      }

     ],

     "prompt_number": 18

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.6:pg-162"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.6 : Power supply ripple\n",

      "V_S=10; # V_S=V_+\n",

      "V_D=0.7; # (V)\n",

      "R=10*10**3; # (ohm)\n",

      "n=2;\n",

      "V_T=25*10**-3; # (V)\n",

      "V_s=1; # (V)\n",

      "I_D=(V_S - V_D)/R;\n",

      "r_D=n*V_T/I_D;\n",

      "v_d=V_s*r_D/(R+r_D);\n",

      "print round(v_d*1000,2),\"= v_d(peak (mV))\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "5.35 = v_d(peak (mV))\n"

       ]

      }

     ],

     "prompt_number": 21

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.7:pg-163"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.7 : Percentage change in regulated voltage\n",

      "V_DD=10; # (V)\n",

      "V_D=0.7*3; # string of 3 diodes provide this constant voltage\n",

      "R=1*10**3;\n",

      "I_D=(V_DD-V_D)/R;\n",

      "n=2;\n",

      "V_T= 25*10**-3; # (V)\n",

      "r_d=n*V_T/I_D; # incremental resistance \n",

      "r=3*r_d; # total incremental resistance\n",

      "deltav_O=2*r/(r+R); # deltav is peak to peak change in output voltage\n",

      "print round(deltav_O*1000,1),\"is Percentage change (mV) in regulated voltage caused by 10% change in power supply\"\n",

      "I=2.1*10**-3; # The current drawn from the diode string\n",

      "deltav_O=-I*r; # Decrease in voltage across diode string\n",

      "print round(deltav_O*1000,1),\"is Decrease in voltage across diode string (mV)\"\n",

      "# The answer in the textbook is slightly different due to approximation"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "37.3 is Percentage change (mV) in regulated voltage caused by 10% change in power supply\n",

        "-39.9 is Decrease in voltage across diode string (mV)\n"

       ]

      }

     ],

     "prompt_number": 24

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.8:pg-169"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.8 : line regulation load regulation\n",

      "\n",

      "V_Z=6.8; # (V)\n",

      "I_Z=0.005; # (A)\n",

      "r_Z=20; # (ohm)\n",

      "V=10; # V=V_+\n",

      "R=0.5*10**3; # (ohm)\n",

      "\n",

      "# 3.8a\n",

      "V_ZO=V_Z-r_Z*I_Z;\n",

      "I_Z=(V-V_ZO)/(R+r_Z)\n",

      "V_O=V_ZO+I_Z*r_Z;\n",

      "print round(V_O,2),\"= V_O (V)\"\n",

      "\n",

      "# 3.8b\n",

      "deltaV=1; # change in V is +1 and -1\n",

      "deltaV_O=deltaV*r_Z/(R+r_Z); # corresponding change in output voltage\n",

      "print round(deltaV_O*1000,1),\"= Line regulation (mV/V)\"\n",

      "\n",

      "# 3.8c\n",

      "I_L=1*10**-3; # load current\n",

      "deltaI_L=1*10**-3;\n",

      "deltaI_Z=-1*10**-3; # change in zener current\n",

      "deltaV_O=r_Z*deltaI_Z;\n",

      "print round(deltaV_O*1000),\"= Load regulation (mV/mA)\"\n",

      "\n",

      "# 3.8d\n",

      "I_L=6.8/2000; # load current with load resistance of 2000\n",

      "deltaI_Z=-I_L;\n",

      "deltaV_O=r_Z*deltaI_Z;\n",

      "print round(deltaV_O*1000,2),\"= Corresponding change in zener voltage (mV) for zener current change of -3.4mA\"\n",

      "\n",

      "# 3.8e\n",

      "R_L=0.5*10**3; # (ohm)\n",

      "V_O=V*R_L/(R+R_L);\n",

      "print V_O,\"V_O (V) for R_L=0.5K ohm\"\n",

      "\n",

      "# 3.8f\n",

      "I_Z=0.2*10**-3; # Zener t be at the edge of breakdown I_Z=I_ZK\n",

      "V_Z=6.7; # V_Z=V_ZK\n",

      "I_Lmin=(9-6.7)/0.5; # Lowest current supplied to R\n",

      "I_L=I_Lmin-I_Z; # load current\n",

      "R_L=V_Z/I_L;\n",

      "print round(R_L,1),\"= R_L (Kohm)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "6.83 = V_O (V)\n",

        "38.5 = Line regulation (mV/V)\n",

        "-20.0 = Load regulation (mV/mA)\n",

        "-68.0 = Corresponding change in zener voltage (V) for zener current change of -3.4mA\n",

        "5.0 V_O (V) for R_L=0.5K ohm\n",

        "1.5 = R_L (Kohm)\n"

       ]

      }

     ],

     "prompt_number": 29

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.9:pg-181"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.9 : Value of capacitance C that will result in peak-peak ripple of 2V\n",

      "V_P=100.0; # (V)\n",

      "V_r=2.0; # (V)\n",

      "f=60.0; # (Hz)\n",

      "R=10.0*10**3; # (ohm)\n",

      "I_L=V_P/R;\n",

      "C=V_P/(V_r*f*R);\n",

      "print round(C*1000000,1),\"= C (microF)\"\n",

      "wdeltat=math.sqrt(2*V_r/V_P);\n",

      "print wdeltat,\"= Conduction angle (rad)\"\n",

      "i_Dav=I_L*(1+math.pi*math.sqrt(2*V_P/V_r));\n",

      "print round(i_Dav*1000),\"= i_Dav (A)\"\n",

      "i_Dmax=I_L*(1+2*math.pi*math.sqrt(2*V_P/V_r));\n",

      "print round(i_Dmax*1000),\"= i_Dmax (mA)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "83.3 = C (microF)\n",

        "0.2 = Conduction angle (rad)\n",

        "324.0 = i_Dav (A)\n",

        "638.0 = i_Dmax (mA)\n"

       ]

      }

     ],

     "prompt_number": 35

    }

   ],

   "metadata": {}

  }

 ]

}