{
 "metadata": {
  "name": "",
  "signature": "sha256:24c423084544eb74b3903e47cf4df50df61e5b0825c0f2f723c85cbcdae27d10"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 6: SEMICONDUCTOR DIODE"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2, Page number 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration \n",
      "Vf =20;                #Peak Input Voltage in V\n",
      "rf=10;                  #Forward Resistance in ohms\n",
      "RL=500.0;                 #Load Resistance in ohms\n",
      "V0=0.7;                  #Potential Barrier Voltage of the diodes in V\n",
      "\n",
      "#Calculation\n",
      "#(1)\n",
      "If_peak=(Vf-V0)/(rf+RL);                  #Peak current through the diode in A\n",
      "If_peak=If_peak*1000;                    #Peak current through the diode in mA\n",
      "#(2)\n",
      "V_out_peak =If_peak * RL/1000 ;               #Peak output voltage in V\n",
      "\n",
      "#For an Ideal diode\n",
      "If_peak_ideal=Vf/RL;                   #Peak current through the ideal diode in A\n",
      "If_peak_ideal=If_peak_ideal*1000;      #Peak current through the ideal diode in mA\n",
      "\n",
      "V_out_peak_ideal=If_peak_ideal * RL/1000;     # Peak output voltage in case of the ideal diode in V\n",
      "\n",
      "#Result\n",
      "print '(i) Peak current through the diode = %.1f mA '%If_peak;\n",
      "print '(ii) Peak output voltage = %.1f V'%V_out_peak;\n",
      "print '(iii) Peak current through the ideal diode = %d mA '%If_peak_ideal;\n",
      "print '(iv) Peak output voltage in case of the ideal diode = %d V'%V_out_peak_ideal;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Peak current through the diode = 37.8 mA \n",
        "(ii) Peak output voltage = 18.9 V\n",
        "(iii) Peak current through the ideal diode = 40 mA \n",
        "(iv) Peak output voltage in case of the ideal diode = 20 V\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3, Page number 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "V =10.0;                #Battery voltage in V\n",
      "R1=50.0;                  #Resistor 1's resistance in ohms\n",
      "R2=5.0;                 #Resistor 2's resistance in ohms\n",
      "\n",
      "#Calculation\n",
      "#Using Thevenin's Theorem to find current in the diode\n",
      "E0=(R2/(R1+R2))*V;          #Thevenin's Voltage in V\n",
      "R0=(R1*R2)/(R1+R2);         #Thevenin's Resistance in ohms\n",
      "\n",
      "I0=E0/R0;                   #Current through the diode in A\n",
      "I0=I0*1000;                 #Current through the diode in mA\n",
      "\n",
      "#Result\n",
      "print 'Current through the diode = %d mA '%Io;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through the diode = 200 mA \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4, Page number 82-83 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "V =10.0;                #Battery voltage in V\n",
      "R0=48.0;                  #Resistance of the resistor in ohms\n",
      "Rd=1.0;                 #Forward resistance of the diodes in ohms\n",
      "Vd=0.7;                 #Potential barrier of the diodes in V\n",
      "#Calculation\n",
      "V_net=V-Vd-Vd;        #Net voltage in the circuit in V\n",
      "R_net=R0+Rd+Rd        #Net resistance of the circuit in ohms\n",
      "I_net=V_net/R_net;    #Net current in the circuit in A\n",
      "I_net=I_net*1000;     #Net current in mA\n",
      "\n",
      "#Result\n",
      "print 'Net current in the circuit = %d mA '%I_net;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net current in the circuit = 172 mA \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5, Page number 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E1=24;           #Voltage of first source in V\n",
      "E2=4;            #Voltage of second source in V\n",
      "V0=0.7;          #Potential barrier of diodes in V\n",
      "R=2000;          #Resistance of the given resistor in ohms\n",
      "Rd=0;            #Forward resistance of the diodes in ohms\n",
      "\n",
      "#Calculation\n",
      "I=(E1-E2-V0)/(R+Rd);  #Current in the circuit in A\n",
      "I=I*1000;             #Current in the circuit in mA \n",
      "\n",
      "#Result\n",
      "print 'Current in the circuit = %.2f mA '%I;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current in the circuit = 9.65 mA \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6, Page number 83-84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "V=20;           #Voltage of source in V\n",
      "V0=0.3;         #Potential barrier of Germanium diode in V\n",
      "V0_Si=0.7;      #Potetial barrier of Silicon diode in V \n",
      "\n",
      "#Calculation\n",
      "#As only Ge diode is turned on due to less potential barrier,\n",
      "VA=V-V0;        #Voltage VA acroos resistor of 3k ohms\n",
      "\n",
      "#Result\n",
      "print 'Voltage VA = %.1f mA '%VA;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage VA = 19.7 mA \n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7, Page number 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "V=10;           #Voltage of source in V\n",
      "V0=0.7;      #Potetial barrier of Silicon diode in V \n",
      "# Resistance of all resistors in ohms\n",
      "R1=2000;\n",
      "R2=2000;\n",
      "R3=2000;\n",
      "\n",
      "#Calculation\n",
      "Id=(V-V0)/(R2+2*R3);     #Current through the diodes in A\n",
      "VQ=2*Id*R3;      #Voltage VQ across the grounded 2k ohm resistor in V\n",
      "Id=Id*1000;      #Current through the diodes in mA\n",
      "\n",
      "#Result\n",
      "print 'Voltage VQ = %.1f V '%VQ;\n",
      "print 'Current through the diodes, Id = %.2f mA '%Id;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage VQ = 6.2 V \n",
        "Current through the diodes, Id = 1.55 mA \n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8, Page number 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "V=15;           #Voltage of source in V\n",
      "V0=0.7;      #Potetial barrier of Silicon diode in V \n",
      "R=500       # Resistance of all resistors in ohms\n",
      "\n",
      "#Calculation\n",
      "I1=(V-V0)/R;      #total current in the circuit in A\n",
      "Id1=I1/2;         #current in first diode in A\n",
      "Id1=Id1*1000;     #current in first diode in mA\n",
      "Id2=Id1           #current in second diode in mA\n",
      "\n",
      "#Result\n",
      "print ('Current in first diode = %.1f mA'%Id1);\n",
      "print ('Current in second diode = %.1f mA'%Id2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current in first diode = 14.3 mA\n",
        "Current in second diode = 14.3 mA\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9, Page number 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E=20;           #Voltage of source in V\n",
      "V0_d1=0.7;      #Potetial barrier of first Silicon diode in V\n",
      "V0_d2=0.7;      #Potetial barrier of second Silicon diode in V\n",
      "R1=5600;       # Resistance of first resistor in ohms\n",
      "R2=3300;       #  Resistance of second resistor in ohms\n",
      "\n",
      "#Calculation\n",
      "I2=V0_d2/R2;                  #Current I2 through resistor R2 in A\n",
      "I2=round((I2*1000),3);                   #Current I2 through resistor R2 in mA\n",
      "I1=(E-V0_d1-V0_d2)/R1;        #Current I1 through resistor R1 in  A\n",
      "I1=round((I1*1000),2);                   #Current I1 through resistor R1 in  mA\n",
      "I3=I1-I2;                     #Current I3 through diode D2 in mA\n",
      "\n",
      "#Result\n",
      "print 'Current I1= %.2f mA'%I1;\n",
      "print 'Current I1= %.3f mA'%I2;\n",
      "print 'Current I1= %.3f mA'%I3;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current I1= 3.32 mA\n",
        "Current I1= 0.212 mA\n",
        "Current I1= 3.108 mA\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10, Page number 85-86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E=10.0;           #Voltage of source in V\n",
      "V0=0.7;      #Potetial barrier of Silicon diode in V\n",
      "R1=2000;       # Resistance of first resistor in ohms\n",
      "R2=8000;       #  Resistance of second resistor in ohms\n",
      "R3=4000;       #Resistance of third resistor in ohms\n",
      "R4=6000;       #Resistance of fourth resistor in ohms\n",
      "\n",
      "#Calculation\n",
      "#Assuming the given diode to be reverse bised and calculating voltage across it's terminals\n",
      "V1=(E/(R1+R2))*R2;      #voltage at the P side of the diode, i.e, voltage across R2 resistor,according to voltage divider rule, in V\n",
      "V2=(E/(R3+R4))*R4;      #voltage at the N side of the diode, i.e, voltage across R4 resistor,according to voltage divider rule, in V\n",
      "\n",
      "#Result\n",
      "if((V1-V2)>=V0):\n",
      "    print 'Our assumption was wrong and, the diode is forward biased';\n",
      "else:\n",
      "    print 'The diode is reverse biased';\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Our assumption was wrong and, the diode is forward biased\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11, Page number 86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=2;                              #Supply voltage in V\n",
      "V0=0.7;                           #Potential barrier voltage of the diode in V \n",
      "R1=4000.0;                        #Resistance of first resistor in \u03a9\n",
      "R2=1000.0;                        ##Resistance of second resistor in \u03a9\n",
      "\n",
      "#Calculation\n",
      "#Assuming the diode to be in ON state\n",
      "I1=((V-V0)/R1)*1000;                  #Current through resistor R1, in mA\n",
      "I2=(V0/R2)*1000;                    #Current through resistor R2, in mA\n",
      "ID=I1-I2;                           #Diode current, in  mA\n",
      "\n",
      "if(ID<0):\n",
      "    #Since the diode current is negative, the diode must be OFF \n",
      "    ID=0;                     #True value of diode current, mA\n",
      "    \n",
      "#As the diode is in OFF state it can be replaced by an open ciruit equivalent \n",
      "VD=V*R2/(R1 +R2);                #Voltage across the diode, in V\n",
      "\n",
      "#Result\n",
      "print 'ID =%d mA'%ID;\n",
      "print 'VD =%.1f V'%VD;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ID =0 mA\n",
        "VD =0.4 V\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12, Page number 89-90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "AC_Input_Power=100.0;          #Input AC Power in watts\n",
      "AC_Output_Power=40.0;          #Output AC Power in watts\n",
      "Accepted_Power=50.0;           #Power accepted by the half-wave rectifier in watt\n",
      "\n",
      "#Calculation\n",
      "R_eff=(AC_Output_Power/AC_Input_Power)*100;             #Rectification efficiency of the half-wave rectifier\n",
      "Unused_power=AC_Input_Power-Accepted_Power;       #Power not used by the half_wave rectifier due to open circuited condition of the diode in watt\n",
      "Power_dissipated=Accepted_Power-AC_Output_Power;  #Power dissipated by the diode watt\n",
      "\n",
      "#Result\n",
      "print 'The rectification efficiency of the half-wave rectifier= %d%% '%R_eff;\n",
      "\n",
      "print 'Rest 60%% of the power is the unused power and power dissipated by the diode = %d watts and %d watts' %(Unused_power ,Power_dissipated);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rectification efficiency of the half-wave rectifier= 40% \n",
        "Rest 60% of the power is the unused power and power dissipated by the diode = 50 watts and 10 watts\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.13, Page number 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "from math import sqrt\n",
      "#Variable declaration\n",
      "Vrms=230.0;                #AC supply RMS voltage in V\n",
      "Turns_Ratio=10/1;        #turn ratio of the transformer \n",
      "\n",
      "#Calculation\n",
      "Vpm=sqrt(2)*Vrms;         #Maximum primary voltage in V\n",
      "Vsm=Vpm/Turns_Ratio;     #Maximum secondary voltage in V\n",
      "#Case 1\n",
      "Vdc=Vsm/(round(pi,2));              #Output D.C voltage, which is the average voltage in V\n",
      "Vdc=round(Vdc,2);\n",
      "#Case 2\n",
      "PIV=Vsm;                 #Peak Inverse Voltage in V\n",
      "\n",
      "#Result\n",
      "print 'The output d.c voltage= %.2f V'%Vdc;\n",
      "print 'The peak inverse voltage= %.2f V'%PIV;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output d.c voltage= 10.36 V\n",
        "The peak inverse voltage= 32.53 V\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.14, Page number 90-91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "#Variable declaration\n",
      "rf=20.0;           #Internal resistance of the crystal diode in ohms\n",
      "Vm=50.0;           #Maximum applied voltage in V\n",
      "RL=800.0;          #Load Resistance in ohms\n",
      "\n",
      "#Calculation\n",
      "# 1\n",
      "Im=Vm/(rf+RL);         #Maximum current in A\n",
      "Im=Im*1000;            #Maximum current in \n",
      "Im=round(Im,0);\n",
      "Idc=Im/pi;             #Average voltage in mA\n",
      "Idc=round(Idc,1);\n",
      "Irms=Im/2;             #RMS value of the current in mA\n",
      "Irms=round(Irms,1)\n",
      "\n",
      "# 2\n",
      "AC_Input_Power=pow(Irms/1000,2)*(rf+RL);     #Input a.c power in watt\n",
      "\n",
      "DC_Output_Power=pow(Idc/1000,2)*RL;          #Output d.c power in watt\n",
      "\n",
      "# 3\n",
      "DC_Output_Voltage=(Idc/1000)*RL;               #Output d.c voltage in V\n",
      "\n",
      "# 4\n",
      "Rectifier_efficiency=(DC_Output_Power/AC_Input_Power)*100;   # Efficiency of rectification of the half-wave rectifier\n",
      "\n",
      "#Result\n",
      "print ' i:';\n",
      "print '   Im   = %d mA'%Im;\n",
      "print '   Idc  = %.1f mA'%Idc;\n",
      "print '   Irms = %.1f mA'%Irms;\n",
      "print ' ii: ';\n",
      "print '   a.c input power= %.3f watt'%AC_Input_Power;\n",
      "print '   d.c output power= %.3f watt'%DC_Output_Power;\n",
      "print ' iii: ';\n",
      "print '   d.c output voltage = %.2f volts'%DC_Output_Voltage;\n",
      "print ' iv: '\n",
      "print '   Efficiency of rectification = %.1f%%'%Rectifier_efficiency;\n",
      "\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " i:\n",
        "   Im   = 61 mA\n",
        "   Idc  = 19.4 mA\n",
        "   Irms = 30.5 mA\n",
        " ii: \n",
        "   a.c input power= 0.763 watt\n",
        "   d.c output power= 0.301 watt\n",
        " iii: \n",
        "   d.c output voltage = 15.52 volts\n",
        " iv: \n",
        "   Efficiency of rectification = 39.5%\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.15, Page number 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "#Variable declaration\n",
      "Vdc=50.0;           #Output d.c voltage in V\n",
      "rf=25;            #Diode resistance in ohm\n",
      "RL=800;           #Load resistance in ohm\n",
      "\n",
      "\n",
      "#Calculation\n",
      "Vm=(pi*(rf+RL)*Vdc)/RL;   #[ Vdc=Vm*RL/(pi*(rf+RL)) ]Maximum value of a.c voltage required to get a volatge  of Vdc from the half-wave rectifier, in V\n",
      "Vm=round(Vm,0);  \n",
      "#Result\n",
      "print 'The a.c voltage required should have maximum value of = %d V' %Vm;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The a.c voltage required should have maximum value of = 162 V\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.16, Page number 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt \n",
      "from math import pi\n",
      "#Variable declaration\n",
      "rf=20;              #Internal resistance of the diodes in ohm\n",
      "Vrms=50;            #RMS value of transformer's secondary voltage from centre tap to each end of secondary\n",
      "RL=980;             #Load resistance in ohm\n",
      "\n",
      "#Calculation\n",
      "Vm=Vrms*sqrt(2);      #Maximum a.c voltage in V\n",
      "Im=Vm/(rf+RL);        #Maximum load current in A\n",
      "Im=Im*1000;           #Maximum load current in mA\n",
      " \n",
      "# 1:\n",
      "Idc=2*Im/pi;          #Mean load current\n",
      "\n",
      "# 2:\n",
      "Irms=Im/sqrt(2);       #RMS value of load current in A\n",
      "\n",
      "#Result\n",
      "print 'i:';\n",
      "print'   The mean load current= %d mA'%Idc;\n",
      "print 'ii:';\n",
      "print '  The r.m.s value of the load current = %d mA'%Irms; "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i:\n",
        "   The mean load current= 45 mA\n",
        "ii:\n",
        "  The r.m.s value of the load current = 50 mA\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.17, Page number 95-96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt \n",
      "#Variable declaration\n",
      "RL=100;                          #Load resistance in ohm       \n",
      "rf=0;                            #Internal resistance of the diodes in ohm\n",
      "Turns_ratio=5/1;                 #Primary to secondary turns ratio of transformer \n",
      "P_Vrms=230;                      #R.M.S value of voltage in primary winding in V\n",
      "S_Vrms=P_Vrms/Turns_ratio;       #R.M.S value of voltage in secondary winding in V\n",
      "S_Vm=S_Vrms*sqrt(2);        #Maximum voltage across secondary winding in V\n",
      "Vm=S_Vm/2;                  #Maximum voltage across half seconfdary winding in V\n",
      "\n",
      "\n",
      "#Calculation\n",
      "# 1:\n",
      "Idc=2*Vm/(pi*RL);            #Average current in A\n",
      "Vdc=Idc*RL;                  #d.c output voltage in V\n",
      "\n",
      "# 2:\n",
      "PIV=S_Vm;                    #Peak Invers Voltage(= Maximum secondary voltage) in V\n",
      "\n",
      "# 3:\n",
      "Pac=pow(Vm/(RL*sqrt(2)),2)*(rf+RL);         #a.c input power in watt\n",
      "Pdc=(pow(Idc,2)*RL);                        #d.c output power in watt\n",
      "R_eff=(Pdc/Pac)*100;      #Rectification efficiency\n",
      "R_eff=round(R_eff,1);\n",
      "\n",
      "#Result\n",
      "print 'i:';\n",
      "print '   The d.c output voltage= %.1f V'%Vdc;\n",
      "print 'ii:';\n",
      "print '   The peak inverse voltage= %d V'%PIV;\n",
      "print 'iii:';\n",
      "print '   Rectification efficiency= %.1f%%'%R_eff;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i:\n",
        "   The d.c output voltage= 20.7 V\n",
        "ii:\n",
        "   The peak inverse voltage= 65 V\n",
        "iii:\n",
        "   Rectification efficiency= 81.1%\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "NOTE: The value of rectification efficiency is calculated as 81.2% in the textbook using the formula 0.812/(1 + (rf/RL)), but by calculating using the correct values in the formula we get 81.1%."
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.18, Page number 96-97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt \n",
      "#Variable declaration\n",
      "fin=50;                       #frequency of input ac source in Hz\n",
      "RL=200;                       #Load resistance in ohm\n",
      "Turns_ratio=4/1;              #Transformers turns ratio, primary to secondary.\n",
      "P_Vrms=230.0;                 #R.M.S value of voltage in primary winding in V\n",
      "S_Vrms=P_Vrms/Turns_ratio     #R.M.S value of voltage in secondary winding in V\n",
      "Vm=S_Vrms*sqrt(2);            #Maximum voltage across secondary winding in V\n",
      "\n",
      "#Calculation\n",
      "# 1:\n",
      "Idc=2*Vm/(pi*RL);           # Average current in A\n",
      "Vdc=Idc*RL;                 #Output d.c voltage in V\n",
      "Vdc=round(Vdc,0);\n",
      "# 2:\n",
      "PIV= Vm;                    #Peak Inverse Voltage(= Maximum volutage across secondary winding) in V\n",
      "\n",
      "# 3:\n",
      "fout=2*fin;                 #Output frequency in Hz\n",
      "\n",
      "#Result\n",
      "print 'i:';\n",
      "print '   The d.c output voltage = %d V' %Vdc;\n",
      "print 'ii:';\n",
      "print '   The peak inverse voltage = %.1f V'%PIV;\n",
      "print 'iii:';\n",
      "print '   The output frequency = %d Hz'%fout;\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i:\n",
        "   The d.c output voltage = 52 V\n",
        "ii:\n",
        "   The peak inverse voltage = 81.3 V\n",
        "iii:\n",
        "   The output frequency = 100 Hz\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.19, Page number 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "from math import sqrt\n",
      "\n",
      "#Variable declaration\n",
      "RL=100.0;                        #Load Resistance in ohm\n",
      "Turns_ratio=5/1;                 #Primary to secondary turns ratio of the transformer\n",
      "Vin=230.0;                       #R.M.S value of input voltage in V\n",
      "fin=50;                          #Input frequency in Hz\n",
      "\n",
      "#Calculation\n",
      "Vs_rms=Vin/Turns_ratio;          #R.M.S value of the voltage in secondary winding, in v\n",
      "Vs_max=Vs_rms*sqrt(2);           #Maximum voltage across secondary, in V\n",
      "\n",
      "# (i)\n",
      "#Case i: Centre-tap circuit\n",
      "Vm=Vs_max/2;                     #Maximum voltage across half secondary winding, in V \n",
      "Vdc=2*Vm*RL/(pi*RL);             #DC output voltage, in V \n",
      "print 'The d.c output voltage for the centre-tap circuit = %.1f V'%Vdc;\n",
      "\n",
      "#Case ii:\n",
      "Vm=Vs_max;                      #Maximum voltage across secondary, in V\n",
      "Vdc=2*Vm*RL/(pi*RL);            #DC output voltage, in V \n",
      "print 'The d.c output voltage for the bridge circuit = %.1f V'%Vdc; \n",
      "\n",
      "# ii:\n",
      "#Case i: Centre-tap circuit\n",
      "Turns_ratio=5/1;\n",
      "Vs_rms=Vin/Turns_ratio;\n",
      "Vs_max=Vs_rms*sqrt(2);\n",
      "Vm=Vs_max/2;\n",
      "PIV=2*Vm;\n",
      "print 'PIV in case of centre-tap circuit = %d V'%PIV;\n",
      "\n",
      "#Case ii: Bridge circuit\n",
      "Turns_ratio=10/1;\n",
      "Vs_rms=Vin/Turns_ratio;\n",
      "Vs_max=Vs_rms*sqrt(2);\n",
      "PIV=Vm;\n",
      "print 'PIV in case of bridge circuit = %.1f V'%PIV;\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The d.c output voltage for the centre-tap circuit = 20.7 V\n",
        "The d.c output voltage for the bridge circuit = 41.4 V\n",
        "PIV in case of centre-tap circuit = 65 V\n",
        "PIV in case of bridge circuit = 32.5 V\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.20, Page number 98"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "from math import sqrt\n",
      "#Variable declaration\n",
      "rf=1;                    #forward resistance of diodes of the rectifier in ohm\n",
      "RL=480;                  #Load resistance in ohm\n",
      "Vrms=240.0;                #a.c supply voltage in V\n",
      "Vm=Vrms*sqrt(2);         #Maximum a.c voltage in V \n",
      "\n",
      "#Calculation\n",
      "# 1:\n",
      "Rt=2*rf+RL;             #Total circuit resistance at any instance in ohm\n",
      "Im=Vm/Rt;               #Maximum load current in A\n",
      "Idc=2*Im/pi;            #Mean load current in A\n",
      "\n",
      "# 2:\n",
      "Irms=Im/2;              #R.M.S value of current  in A\n",
      "P=pow(Irms,2)*rf;       #Power dissipated in each diode in watt\n",
      "\n",
      "\n",
      "#Result\n",
      "print 'i:';\n",
      "print '   Mean load current = %.2f A'%Idc;\n",
      "print 'ii:';\n",
      "print '   Power dissipated in each diode= %.3f W'%P;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i:\n",
        "   Mean load current = 0.45 A\n",
        "ii:\n",
        "   Power dissipated in each diode= 0.124 W\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "NOTE: The value of power dissipated is approximately 0.124 W , but in the textbook it is approximated as 0.123W."
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.21, Page number 98-99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt,pi\n",
      "#Variable declaration\n",
      "RL=12000;                #Load resistance in ohm\n",
      "V0=0.7;                   #Potential barrier voltage of diodes in V\n",
      "Vrms=12;                  #R.M.S value of input a.c voltage in V\n",
      "Vs_pk=Vrms*sqrt(2);       #Peak secondary voltage in V\n",
      "\n",
      "#Calculation\n",
      "# 1:\n",
      "Vout_pk=Vs_pk-(2*V0);      #Peak output voltage in  V\n",
      "Vav=2*Vout_pk/pi;          #Average output voltage in V\n",
      "Vav=round(Vav,2);\n",
      "\n",
      "# 2:\n",
      "Iav=Vav/RL;                #Average output current in A\n",
      "Iav=Iav*pow(10,6);         #Average output current in \u03bcA\n",
      "\n",
      "\n",
      "#Result\n",
      "print 'i:';\n",
      "print '   Average output voltage=%.2f V'%Vav;\n",
      "print 'ii:';\n",
      "print '   Average output current=%.1f \u03bcA'%Iav;\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i:\n",
        "   Average output voltage=9.91 V\n",
        "ii:\n",
        "   Average output current=825.8 \u03bcA\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.22, Page number 102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vdc_A=10;                      #Supply voltage of A in V\n",
      "Vdc_B=25;                      #Supply voltage of B in V\n",
      "Vac_rms_a=0.5;                 #Ripples in power supply A in V\n",
      "Vac_rms_b=0.001;               #Ripples in power supply B in V\n",
      "\n",
      "#Calculation\n",
      "#For power supply A\n",
      "ripple_factor_A=Vac_rms_a/Vdc_A;      #Ripple factor of power supply A\n",
      "\n",
      "#For power supply B\n",
      "ripple_factor_B=Vac_rms_b/Vdc_B;      #Ripple factor of power supply B\n",
      "\n",
      "#Result\n",
      "if(ripple_factor_A<ripple_factor_B):\n",
      "    print 'Power supply A is better';\n",
      "else :\n",
      "    print 'Power supply B is better';"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power supply B is better\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.23, Page number 105-106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#Variable declaration\n",
      "RL=2200;                    #Load resistance in ohm\n",
      "C=50*pow(10,-6);            #Capacitance of the capacitor used in filter circuit in F\n",
      "V0=0.7;                     #Potential barrier voltage of the diodes of the rectifier in  V\n",
      "Vrms=115.0;                   #R.M.S value of input a.c voltage in V \n",
      "fin=60;                     #Frequency of input a.c voltage in Hz\n",
      "Turns_ratio=10/1;           #Primary to secondary, turns ratio of the transformer \n",
      "\n",
      "#Calculation\n",
      "Vp_prim=Vrms*sqrt(2);               #Peak primary voltage in V\n",
      "Vp_sec=Vp_prim/Turns_ratio;         #Peak secondary voltage in V\n",
      "Vp_in= Vp_sec - 2*V0;               #Peak full wave rectified voltage at the filter input in V\n",
      "f=2*fin;                            #Output frequency in Hz\n",
      "Vdc=Vp_in*(1-(1/(2*f*RL*C)));       #Output d.c voltage in V\n",
      "\n",
      "#Result\n",
      "print 'The output d.c voltage  is = %.1f V'%Vdc;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output d.c voltage  is = 14.3 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.24, Page number 106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "#Variable declaration\n",
      "R=25;                        #d.c resistance of the choke in ohm\n",
      "RL=750;                      #Load resistance in ohm\n",
      "Vm=25.7;                     #Maximum value of the pulsating output from the rectifier in V\n",
      "\n",
      "#Calculation\n",
      "V_dc=2*Vm/pi;                #d.c component of the pulsating output in V\n",
      "V_dc=round(V_dc,1);\n",
      "V_dc_out=(V_dc*RL)/(R+RL);   #Output d.c voltage in V\n",
      "V_dc_out=round(V_dc_out,1);\n",
      "\n",
      "#Result\n",
      "print ' The output d.c voltage accross the load resistance is = %.1f V'%V_dc_out;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The output d.c voltage accross the load resistance is = 15.9 V\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.25, Page number 113-114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ei=120.0;                   #Input Voltage in V\n",
      "Vz=50.0;                    #Zener Voltage in V\n",
      "R=5000.0;                   #Resistance of the series resistor in ohm\n",
      "RL=10000.0;                 #Load resistance in ohm\n",
      "\n",
      "#Calculation\n",
      "V=Ei*RL/(R+RL);             #Voltage across the open circuit if the zener diode is removed\n",
      "if(V>Vz):\n",
      "    #Zener diode is in ON state\n",
      "    # i:\n",
      "    Output_voltage=Vz;             #Voltage across load resistance, in V\n",
      "    #ii:\n",
      "    Voltage_R=Ei-Vz;               #Voltage across the series resistance R, in V\n",
      "    #iii:\n",
      "    IL=Vz/RL;                      #Load current through RL in A\n",
      "    IL=IL*1000;                    #Load current through RL in mA\n",
      "    I=Voltage_R/R;                 #Current through the series resistance in A\n",
      "    I=I*1000;                      #Current through the series resistance in mA\n",
      "    Iz=I-IL;                       #Applying Kirchhoff's first law, Zener current in mA\n",
      "    \n",
      "    #Result\n",
      "    print 'i)   The output voltage across the load resistance RL = %d V'%Output_voltage;\n",
      "    print 'ii)  The voltage drop across the series resistance  R = %d V'%Voltage_R;\n",
      "    print 'iii) The current through the zener diode = %d mA'%Iz;\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i)   The output voltage across the load resistance RL = 50 V\n",
        "ii)  The voltage drop across the series resistance  R = 70 V\n",
        "iii) The current through the zener diode = 9 mA\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.26, Page number 114-115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Max_V=120.0;                  #Maximum input voltage in V\n",
      "Min_V=80.0;                   #Minimum input voltage in V\n",
      "R=5000.0;                     #Series resistance in ohm\n",
      "RL=10000.0;                   #Load resistance in ohm\n",
      "Vz=50.0;                      #Zener voltage in V\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#Case i: Maximum zener current\n",
      "#Zener current will be maximum when the input voltage is maximum\n",
      "V_R_max=Max_V-Vz;                #Voltage across series resistance R, in  V\n",
      "I_max=V_R_max/R;                 #Current through series resistance R, in A\n",
      "I_max=I_max*1000;                #Current through series resistance R, in mA\n",
      "IL_max=Vz/RL;                        #Load current in A\n",
      "IL_max=IL_max*1000;                      #Load current in mA\n",
      "Iz_max=I_max-IL_max;                     #Applying Kirchhoff's first law, Zener current in mA;\n",
      "\n",
      "#Case ii: Minimum zener current\n",
      "#The zener will conduct minimum current when the input voltage is minimum\n",
      "V_R_min=Min_V-Vz;                #Voltage across series resistance R, in V\n",
      "I_min=V_R_min/R;                 #Current through series resistance R, in A\n",
      "I_min=I_min*1000;                #Current through series resistance R, in mA\n",
      "IL_min=Vz/RL;                        #Load current in A\n",
      "IL_min=IL_min*1000;                      #Load current in mA\n",
      "Iz_min=I_min-IL_min;                     #Applying Kirchhoff's first law, Zener current in mA\n",
      "\n",
      "#Result\n",
      "print 'Case i: ';\n",
      "print 'Maximum zener current = %d mA'%Iz_max;\n",
      "print 'Case ii: ';\n",
      "print 'Minimum zener current = %d mA'%Iz_min;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case i: \n",
        "Maximum zener current = 9 mA\n",
        "Case ii: \n",
        "Minimum zener current = 1 mA\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.27, Page number 115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ei=12;                      #Input voltage in V\n",
      "Vz=7.2;                     #Zener voltage in V\n",
      "E0=Vz;                      #Voltage to be maintained across the load in  V\n",
      "IL_max=0.1;                 #Maximum load current in A\n",
      "IL_min=0.012;                  #Minimum load current in A\n",
      "Iz_min=0.01;                  #Minimum zener current in A\n",
      "\n",
      "#Calculation\n",
      "#When the load current is maximum at minimum value of RL, the zener current is minimum and, as the load current decreases due to increase in value of RL\n",
      "R=(Ei-E0)/(Iz_min+IL_max);        #The value of series resistance R to maintain a voltage=E0 across load, in ohm\n",
      "\n",
      "#Result\n",
      "print 'The minimum value of series resistance R to maintain a constant value of 7.2 V is = %.1f \u03a9'%R;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The minimum value of series resistance R to maintain a constant value of 7.2 V is = 43.6 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "NOTE: The actual value of R is 43.636363 (recurring) but, in the textbook the value of R is wrongly approximated 43.5 \u03a9"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.28, Page number 115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ei_min=22;                #Minimum input voltage in V\n",
      "Ei_max=28;                #Maximum input voltage in V\n",
      "Vz=18;                   #Zener voltage in V\n",
      "E0=Vz;                    #Constant voltage maintained across the load resistance in V\n",
      "Iz_min=0.2;               #Minimum zener current in A\n",
      "Iz_max=2;                 #Maximum zener current in A\n",
      "RL=18;                    #Load resistance in \u03a9\n",
      "\n",
      "#Calculation\n",
      "IL=Vz/RL;                      #Constant value of load current in A\n",
      "#When the input voltage is minimum, the zener current will be minimum\n",
      "R=(Ei_min-E0)/(Iz_min+IL)      #The value of series resistance so that the voltage E0 across RL remains constant\n",
      "\n",
      "print 'The value of series resistance R, to maintain constant voltage E0 across RL = %.2f \u03a9.'%R;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of series resistance R, to maintain constant voltage E0 across RL = 3.33 \u03a9.\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.29, Page number 116 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vz=10                                #Zener voltage in V\n",
      "Ei_min=13;                           #Minimum input voltage in V\n",
      "Ei_max=16;                           #Maximum input voltage in V\n",
      "Iz_min=0.015;                        #Minimum zener current in A\n",
      "IL_min=0.01;                         #Minimum load current in A \n",
      "IL_max=0.085;                        #Maximum load curremt in A\n",
      "E0=Vz;                               #Constant voltage to be maintained in V \n",
      "\n",
      "#Calculation\n",
      "#The zener current will be minimum when the input voltage will be minimum  and at that time the load current will be maximum\n",
      "R=(Ei_min-E0)/(Iz_min+IL_max);       #The value of series resistance R to maintain a constant voltage across load\n",
      "\n",
      "\n",
      "#Result\n",
      "print 'The value of series resistance to maintain a constant voltage across the load resistance is = %d \u03a9'%R;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of series resistance to maintain a constant voltage across the load resistance is = 30 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.30, Page number 116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Iz=0.2;               #Current rating of each zener in A\n",
      "Vz=15;                #Voltage rating of each zener in V\n",
      "Ei=45;                #Input voltage in V\n",
      "\n",
      "#Calculation\n",
      "# i: Regulated output voltage across the two zener diodes \n",
      "E0=2*Vz;                     # V\n",
      "\n",
      "# ii: Value of series resistance \n",
      "R=(Ei-E0)/Iz;                  # \u03a9\n",
      "\n",
      "#Result\n",
      "print 'i) The regulated output voltage = %d V'%E0;\n",
      "print 'ii) The value of the series resistance = %d \u03a9'%R;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i) The regulated output voltage = 30 V\n",
        "ii) The value of the series resistance = 75 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.31, Page number 116-117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vz=10;                   #Voltage rating of each zener in V\n",
      "Iz=1;                    #Current rating of each zener in A\n",
      "Ei=45;                   #Input unregulated voltage in V\n",
      "\n",
      "#Calculation\n",
      "#Regulated output voltage across the three zener diodes\n",
      "E0=3*Vz;               # V\n",
      "\n",
      "#Value of series resistance to obtain a 30V regulated output voltage\n",
      "R=(Ei-E0)/Iz;          # \u03a9\n",
      "\n",
      "#Result\n",
      "print 'Value of series resistance to obtain a 30V regulated output voltage = %d \u03a9'%R;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of series resistance to obtain a 30V regulated output voltage = 15 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.32, Page number 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#variable declaration\n",
      "RL=2000.0;                   #Load resistance in \u03a9\n",
      "R=200.0;                     #Series resistance in \u03a9\n",
      "Iz=0.025;                  #Zener current rating in A\n",
      "E0=30.0;                     #Output regulated voltage in V \n",
      "\n",
      "#Calculation\n",
      "#Minimum input voltage will be required when Iz=0 A, and at  this condition\n",
      "IL=E0/RL;                   #Load current during Iz=0, in A\n",
      "I=IL;                       #According to Kirchhoff's law, total current, in A\n",
      "Ei_min=E0+(I*R);            #Minimum input voltage in V\n",
      "\n",
      "#The maximum input voltage required will be when Iz=0.025 A, and at that condition \n",
      "I=IL+Iz;                    #According to Kirchhoff's law, total current, in A\n",
      "Ei_max=E0+(I*R);            #maximum input voltage in V\n",
      "\n",
      "\n",
      "#Result\n",
      "print 'The required range of input voltage is from %d V to %d V'%(Ei_min,Ei_max);  \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required range of input voltage is from 33 V to 38 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.33, Page number 117-118"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ei=16;                   #Unregulated input voltage in V\n",
      "E0=12;                   #Output regulated voltage in V\n",
      "IL_min=0;                #Minimum load current in A\n",
      "IL_max=0.2;              #Maximum load current in A\n",
      "Iz_min=0;                #Minimum zener current in A\n",
      "Iz_max=0.2;              #Maximum zener current in A\n",
      "\n",
      "#Calculation\n",
      "#As the regulated voltage required across the load is 12V\n",
      "Vz=E0;                   #Voltage rating of zener diode in V\n",
      "V_R=Ei-E0;               #Constant Voltage that should remain across series resistance \n",
      "#The minimum zener current will occur when the curent in the load in maximum\n",
      "R=V_R/(Iz_min+IL_max);   #Series resistance in \u03a9\n",
      "\n",
      "Max_power_rating=Vz*Iz_max;     #Maximum power rating of zener diode in W\n",
      "\n",
      "#Result\n",
      "print 'The regulator is designed using a Seris resistance of %d \u03a9 and a zener diode of zener voltage %d V'%(R,Vz);\n",
      "print 'The maximum power rating of the zener diode is = %.1f W '%Max_power_rating;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The regulator is designed using a Seris resistance of 20 \u03a9 and a zener diode of zener voltage 12 V\n",
        "The maximum power rating of the zener diode is = 2.4 W \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.34, Page number 118"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=12;                       #Source voltage in V\n",
      "R=1000;                     #Series resistance in \u03a9\n",
      "RL=5000;                    #Load resistance in \u03a9\n",
      "Vz=6;                       #Voltage rating of zener in V\n",
      "\n",
      "#Calculation\n",
      "#Case i: zener is working properly\n",
      "#The output voltage across the load will be equal to the zener voltage.\n",
      "V0=Vz;                        # V\n",
      "\n",
      "#Result\n",
      "print 'Case i: Output voltage when zener is working properly is %d V'%V0;\n",
      "\n",
      "#Case ii: zener is shorted\n",
      "#As the zener is shorted, the potential difference across the load will be zero\n",
      "V0=0;                        #V\n",
      "\n",
      "#Result\n",
      "print 'Case ii: Output voltage when zener is short circuited is %d V'%V0;\n",
      "     \n",
      "#Case iii: zener is open circuited\n",
      "#If the zener is open circuited, the total voltage will drop across R and RL according to the voltage divider rule\n",
      "V0=V*RL/(R+RL);                      #V\n",
      "\n",
      "#Result\n",
      "print 'Case iii: Output voltage when zener is open circuited is %d V'%V0;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case i: Output voltage when zener is working properly is 6 V\n",
        "Case ii: Output voltage when zener is short circuited is 0 V\n",
        "Case iii: Output voltage when zener is open circuited is 10 V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}