{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch-18 : Rectifiers and Power Supplies"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 548 Example 18.1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Peak value of current,  Im = Vm / rf+RL = 295.45 mA\n",
      "    Average current,  Id.c. = Im / pi = 94.04 mA\n",
      "    RMS value of current,  Irms = Im / 2 = 147.72 mA\n",
      "(b) D.C. power output,  Pd.c. = (Id.c.)**2 * RL = 8.84 W\n",
      "(c) AC input power,  Pac = (Irms)**2 * (rf+RL) = 24.00 \n",
      "(d) Efficiency of rectification,  eta = Pdc / Pac = 36.85 %\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "im=325./(100+1000)  # in A\n",
    "x1=im*10**3  # in mA\n",
    "print \"(a) Peak value of current,  Im = Vm / rf+RL = %0.2f mA\"%x1\n",
    "idc=295.45/pi # in mA\n",
    "print \"    Average current,  Id.c. = Im / pi = %0.2f mA\"%idc\n",
    "irms=295.45/2  # in mA\n",
    "print \"    RMS value of current,  Irms = Im / 2 = %0.2f mA\"%irms\n",
    "pdc=((94.046*10**-3)**2)*1000  # in W\n",
    "print \"(b) D.C. power output,  Pd.c. = (Id.c.)**2 * RL = %0.2f W\"%pdc\n",
    "pac=((147.725*10**-3)**2)*1100 # in W\n",
    "print \"(c) AC input power,  Pac = (Irms)**2 * (rf+RL) = %0.2f \"%pac\n",
    "eta=(8.845/24)*100  # in percentage\n",
    "print \"(d) Efficiency of rectification,  eta = Pdc / Pac = %0.2f %%\"%eta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 548 Example 18.2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Average value of load current,  Id.c.= Vdc / RL = 48.00 mA\n",
      "Maximum value of load current,  Im= pi * Idc = 150.80 mA\n",
      "Therefore, maximum ac voltage required at the input,\n",
      "      Vm = Im * (rf+RL) = 82.94 V\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "icd=(24./500)*10**3  # in mA\n",
    "print \"Average value of load current,  Id.c.= Vdc / RL = %0.2f mA\"%icd\n",
    "im=pi*48 # in mA\n",
    "print \"Maximum value of load current,  Im= pi * Idc = %0.2f mA\"%im\n",
    "print \"Therefore, maximum ac voltage required at the input,\"\n",
    "vm=550*150.8*10**-3 # in V\n",
    "print \"      Vm = Im * (rf+RL) = %0.2f V\"%vm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 549 Example 18.3."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) The transformer secondary voltage = 46.00 V\n",
      "    Maximum value of secondary voltage,  Vm = 65.05 V\n",
      "    Therefore, d.c. output voltage,  Vd.c. = Vm / pi = 20.69 V\n",
      "(b) PIV of a diode  = Vm = 65 V\n",
      "(c) Maximum value of load current,  Im= Vm / RL = 0.22 A\n",
      "    Therefore, maximum value of power delivered to the load,\n",
      "           Pm = Im**2 * RL = 14.13 W\n",
      "(d) The average value of load current,  Id.c.(A) = Vdc / RL = 0.07 A\n",
      "    Therefore, average value of power delivered to the load,\n",
      "        Pd.c. = (Idc)**2 * RL = 1.43 W\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "x1=230./5 # in V\n",
    "vm=sqrt(2) * 46  # in V\n",
    "vdc=65./pi  # in V\n",
    "im=65./300  # in A\n",
    "pm=0.217**2 * 300  # in W\n",
    "idc=20.7/300 # in A\n",
    "pdc=(0.069**2)*300 # in W\n",
    "print \"(a) The transformer secondary voltage = %0.2f V\"%x1\n",
    "print \"    Maximum value of secondary voltage,  Vm = %0.2f V\"%vm\n",
    "print \"    Therefore, d.c. output voltage,  Vd.c. = Vm / pi = %0.2f V\"%vdc\n",
    "print \"(b) PIV of a diode  = Vm = 65 V\"\n",
    "print \"(c) Maximum value of load current,  Im= Vm / RL = %0.2f A\"%im\n",
    "print \"    Therefore, maximum value of power delivered to the load,\"\n",
    "print \"           Pm = Im**2 * RL = %0.2f W\"%pm\n",
    "print \"(d) The average value of load current,  Id.c.(A) = Vdc / RL = %0.2f A\"%idc\n",
    "print \"    Therefore, average value of power delivered to the load,\"\n",
    "print \"        Pd.c. = (Idc)**2 * RL = %0.2f W\"%pdc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 550 Example 18.4."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage across the two ends of secondary(in V) = 230 / 5 = 46.00 V\n",
      "Voltage from center tapping to one end, Vrms = 23.00 V\n",
      "(a) d.c. voltage across the load,  Vdc = 2Vm / pi = 20.71 V\n",
      "(b) d.c. current flowing through the load,\n",
      "      Idc = Vdc / (rs+rf+RL) = 20.70 mA\n",
      "(c) d.c. power delivered to the load,\n",
      "      Pdc = (Idc)**2 * RL = 0.39 W\n",
      "(d) PIV across each diode = 2Vm = 65.05 W\n",
      "(e) Ripple voltage,  Vr,rms = sqrt(Vrms**2 - Vdc**2) = 10.03 V\n",
      "    Frequency of ripple voltage = 120.00 Hz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "x1=230./5  # in V\n",
    "vrms=46./2 # in V\n",
    "vdc=(2.*23*sqrt(2))/pi # in V\n",
    "idc=(20.7/1000)*10**3 # in mA\n",
    "pdc=((20.7*10**-3)**2)*900  # in W\n",
    "piv=2*23*sqrt(2)  # in V\n",
    "vrrms=sqrt(23**2 - 20.7**2)  # in V\n",
    "f=2*60  # in Hz\n",
    "print \"The voltage across the two ends of secondary(in V) = 230 / 5 = %0.2f V\"%x1\n",
    "print \"Voltage from center tapping to one end, Vrms = %0.2f V\"%vrms\n",
    "print \"(a) d.c. voltage across the load,  Vdc = 2Vm / pi = %0.2f V\"% vdc\n",
    "print \"(b) d.c. current flowing through the load,\"\n",
    "print \"      Idc = Vdc / (rs+rf+RL) = %0.2f mA\"%idc\n",
    "print \"(c) d.c. power delivered to the load,\"\n",
    "print \"      Pdc = (Idc)**2 * RL = %0.2f W\"%pdc\n",
    "print \"(d) PIV across each diode = 2Vm = %0.2f W\"%piv\n",
    "print \"(e) Ripple voltage,  Vr,rms = sqrt(Vrms**2 - Vdc**2) = %0.2f V\"%vrrms\n",
    "print \"    Frequency of ripple voltage = %0.2f Hz\"%f"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 552 Example 18.5."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Therefore,  Imax = 320.00 mA\n",
      "The maximum value of the secondary voltage,\n",
      "      Vm = 141.42 V\n",
      "Therefore, the value of load resistor that gives the largest d.c. power output\n",
      "      RL = Vm / Imax = 441.88 ohm\n",
      "(b) D.C.(load) voltage,  Vdc(V) = (2*141.4)/pi = 90.02 V\n",
      "    D.C. load current,  Idc = Vdc / RL = 0.20 A\n",
      "(c) PIV of each diode  = 2Vm = 282.8 V\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "imax=0.8*400  # in mA\n",
    "print \"Therefore,  Imax = %0.2f mA\"%imax \n",
    "print \"The maximum value of the secondary voltage,\"\n",
    "vm=sqrt(2)*100  # in V\n",
    "print \"      Vm = %0.2f V\"%vm\n",
    "print \"Therefore, the value of load resistor that gives the largest d.c. power output\"\n",
    "RL=141.4/(320*10**-3)\n",
    "print \"      RL = Vm / Imax = %0.2f ohm\"%RL\n",
    "vdc=(2*141.4)/pi\n",
    "print \"(b) D.C.(load) voltage,  Vdc(V) = (2*141.4)/pi = %0.2f V\"%vdc\n",
    "idc=90./442\n",
    "print \"    D.C. load current,  Idc = Vdc / RL = %0.2f A\"%idc\n",
    "print \"(c) PIV of each diode  = 2Vm = 282.8 V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 553 Example 18.6."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D.C. power delivered to the load,\n",
      "            Pdc = Vdc**2 / RL\n",
      "Therefore,  Vdc = sqrt(Pdc*RL) = 100.00 V\n",
      "The ripple factor,  gamma = Vac / Vdc\n",
      "i.e.                 0.01 = Vac / 100\n",
      "Therefore, the ac ripple voltage across the load, Vac = 1 V\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "print \"D.C. power delivered to the load,\"\n",
    "print \"            Pdc = Vdc**2 / RL\"\n",
    "vdc=sqrt(50.*200)\n",
    "print \"Therefore,  Vdc = sqrt(Pdc*RL) = %0.2f V\"%vdc\n",
    "print \"The ripple factor,  gamma = Vac / Vdc\"\n",
    "print \"i.e.                 0.01 = Vac / 100\"\n",
    "print \"Therefore, the ac ripple voltage across the load, Vac = 1 V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 554 Example 18.7. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) The rms value of the transformer secondary voltage,\n",
      "      Vrms = 57.50 V\n",
      "    The maximum value of the secondary voltage\n",
      "      Vm = 81.32 V Therefore, d.c. output voltage,  Vdc = 2Vm / pi = 51.76 V\n",
      "(b) D.C. power delivered to the load,\n",
      "      Pd.c. = (Vdc)**2 / RL = 2.70 W\n",
      "(c) PIV across each diode = Vm = 81.3 V\n",
      "(d) Output frequency = 2 x 50 = 100 Hz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "Vrms=230./4  # in V\n",
    "vm=sqrt(2)*57.5  # in V\n",
    "vdc=(2*81.3)/pi  # in V\n",
    "pdc=52.**2/1000  # in W\n",
    "print \"(a) The rms value of the transformer secondary voltage,\"\n",
    "print \"      Vrms = %0.2f V\"%Vrms\n",
    "print \"    The maximum value of the secondary voltage\"\n",
    "print \"      Vm = %0.2f V\"%vm,\n",
    "print \"Therefore, d.c. output voltage,  Vdc = 2Vm / pi = %0.2f V\"%vdc\n",
    "print \"(b) D.C. power delivered to the load,\"\n",
    "print \"      Pd.c. = (Vdc)**2 / RL = %0.2f W\"%pdc\n",
    "print \"(c) PIV across each diode = Vm = 81.3 V\"\n",
    "print \"(d) Output frequency = 2 x 50 = 100 Hz\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 556 Example 18.8."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "We know that the ripple factor for inductor filter is gamma = RL / 3*sqrt(2)*omega*L\n",
      "Therefore,    L = 1.56 Henry\n"
     ]
    }
   ],
   "source": [
    "L=0.0625/0.04 # in H\n",
    "print \"We know that the ripple factor for inductor filter is gamma = RL / 3*sqrt(2)*omega*L\"\n",
    "print \"Therefore,    L = %0.2f Henry\"%L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 558 Example 18.9."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "We know that the ripple factor for capacitor filter is\n",
      "    gamma = 1 / 4*sqrt(3)*f*C*RL\n",
      "Therefore,    C = 72.20 pF\n"
     ]
    }
   ],
   "source": [
    "print \"We know that the ripple factor for capacitor filter is\"\n",
    "print \"    gamma = 1 / 4*sqrt(3)*f*C*RL\"\n",
    "c=(0.722)/0.01  # in pF\n",
    "print \"Therefore,    C = %0.2f pF\"%c"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 560 Example 18.10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The effective load resistance  RL = 50.00 ohm\n",
      "We know that the ripple factor,  gamma = 1.194 / LC\n",
      "i.e.      LC = 59.70 \n",
      "Critical value of L(mH) = RL / 3*omega = 50 / 3*2*pi*f = 53mH\n",
      "Taking L = 60 mH (about 20% higher), C will be about 1000 uF\n"
     ]
    }
   ],
   "source": [
    "rl=10./(200*10**-3)  # in ohm\n",
    "lc=1.194/0.02  \n",
    "print \"The effective load resistance  RL = %0.2f ohm\"%rl\n",
    "print \"We know that the ripple factor,  gamma = 1.194 / LC\"\n",
    "print \"i.e.      LC = %0.2f \"%lc\n",
    "print \"Critical value of L(mH) = RL / 3*omega = 50 / 3*2*pi*f = 53mH\"\n",
    "print \"Taking L = 60 mH (about 20% higher), C will be about 1000 uF\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 561 Example 18.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    RL = 50.00 ohm\n",
      "    0.02 = 5700 / L*C1*C2*50 = 114 / L*C1*C2\n",
      "If we assume L = 10 mH and  C1 = C2 = C, we have\n",
      "    0.02 = 114 / L*C**2 = 11.4 / C**2\n",
      "    C**2 = 570.00 \n",
      "therefore, C = 23.87 uF\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "rl=(10./(200*10**-3))  # in ohm\n",
    "c2=11.4/0.02\n",
    "c=sqrt(570.)  # in uF\n",
    "print \"    RL = %0.2f ohm\"%rl\n",
    "print \"    0.02 = 5700 / L*C1*C2*50 = 114 / L*C1*C2\"\n",
    "print \"If we assume L = 10 mH and  C1 = C2 = C, we have\"\n",
    "print \"    0.02 = 114 / L*C**2 = 11.4 / C**2\"\n",
    "print \"    C**2 = %0.2f \"%c2\n",
    "print \"therefore, C = %0.2f uF\"%c"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 562 Example 18.12."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    Pz = Vz * Iz_max = 0.40 W\n",
      "Hence a 0.5Z 10 zener can be selected\n",
      "Value of load resistance, RL\n",
      "  RL_min = Vo / IL_max = 200.00 ohm\n",
      "  RL_max = Vo / IL_min = 333.33 ohm\n",
      "Value of input resistance, R\n",
      "  Rmax = Vin(max)-Vo / ILmin+IZmax = 285.71 ohm\n",
      "142.857142857   Rmax(ohm) = Vin(min)-Vo / ILmax+IZmin =\n",
      "  R = Rmax+Rmin / 2 = 214.50 ohm\n"
     ]
    }
   ],
   "source": [
    "pz=10.*40*10**-3  # in W\n",
    "print \"    Pz = Vz * Iz_max = %0.2f W\"%pz\n",
    "print \"Hence a 0.5Z 10 zener can be selected\"\n",
    "print \"Value of load resistance, RL\"\n",
    "rlmin=10./(50*10**-3)  # in ohm\n",
    "print \"  RL_min = Vo / IL_max = %0.2f ohm\"%rlmin\n",
    "rlmax=10./(30*10**-3)  # in ohm\n",
    "print \"  RL_max = Vo / IL_min = %0.2f ohm\"%rlmax\n",
    "print \"Value of input resistance, R\"\n",
    "rmax=(30.-10)/((30+40)*10**-3)  # in ohm\n",
    "print \"  Rmax = Vin(max)-Vo / ILmin+IZmax = %0.2f ohm\"%rmax\n",
    "rmin=(20.-10)/((50+20)*10**-3)  # in ohm\n",
    "print rmin,\"  Rmax(ohm) = Vin(min)-Vo / ILmax+IZmin =\"\n",
    "r=(286+143.)/2\n",
    "print \"  R = Rmax+Rmin / 2 = %0.2f ohm\"%r  # answer in textbook is wrong"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 563 Example 18.13."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    RL = Vo / IL = 250.00 ohm\n",
      "Hence, the series resistance  R(ohm) = Vi(min)-Vo / IZ(min)+IL = 120.00 ohm\n",
      "The various values are given in the Zener regulator shown in Fig. 18.19\n"
     ]
    }
   ],
   "source": [
    "rl=5./(20*10**-3)  # in ohm\n",
    "print \"    RL = Vo / IL = %0.2f ohm\"%rl\n",
    "r=(8.-5)/((5.+20)*10**-3)  # in ohm\n",
    "print \"Hence, the series resistance  R(ohm) = Vi(min)-Vo / IZ(min)+IL = %0.2f ohm\"%r\n",
    "print \"The various values are given in the Zener regulator shown in Fig. 18.19\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 564 Example 18.14."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) Let IZ = IZ(min) and IL = 0\n",
      "    The total current  I = IL + IZ = 10 mA\n",
      "    Therefore,  R = 1000.00 ohm\n",
      "(ii) For IZ = IZ(max) = 100 mA and IL = 20 mA\n",
      "     I = IL + IZ = 120.00 mA\n",
      "     Therefore,  R = 83.33 ohm\n",
      "(iii) The range of R varies from 83.33 ohm to 1000 ohm\n"
     ]
    }
   ],
   "source": [
    "print \"(i) Let IZ = IZ(min) and IL = 0\"\n",
    "print \"    The total current  I = IL + IZ = 10 mA\"\n",
    "r=10./(10*10**-3)  # in ohm\n",
    "print \"    Therefore,  R = %0.2f ohm\"%r\n",
    "print \"(ii) For IZ = IZ(max) = 100 mA and IL = 20 mA\"\n",
    "i=20+100.  # in mA\n",
    "print \"     I = IL + IZ = %0.2f mA\"%i\n",
    "r=10./(120*10**-3)\n",
    "print \"     Therefore,  R = %0.2f ohm\"%r\n",
    "print \"(iii) The range of R varies from 83.33 ohm to 1000 ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 565 Example 18.15."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Here, load resistance is RL = Vo / IL = 500.00 ohm\n",
      "Maximum Zener Current Iz_max = 80.00 mA\n",
      "The minimum input voltage required will be when Iz = 0. Under this condition,\n",
      "    I = IL = 10 mA\n",
      "Minimum input voltage  Vi_min = Vo + IR\n",
      "Hence,    Vi_min = 8.00 V\n",
      "or    8 = 5 + (10*10**-3)R\n",
      "Therefore,  Rmax = 300.00 ohm\n",
      "Now, maximum input voltage, Vi_max = 5 + [(80+10)10**-3]R\n",
      "    Rmin = 77.78 ohm\n",
      "The value of R is chosen between 77.77 ohm and 300 ohm\n"
     ]
    }
   ],
   "source": [
    "rl=5./(10*10**-3)  # in ohm\n",
    "print \"Here, load resistance is RL = Vo / IL = %0.2f ohm\"%rl\n",
    "iz=400./5  # in mA\n",
    "print \"Maximum Zener Current Iz_max = %0.2f mA\"%iz\n",
    "print \"The minimum input voltage required will be when Iz = 0. Under this condition,\"\n",
    "print \"    I = IL = 10 mA\"\n",
    "print \"Minimum input voltage  Vi_min = Vo + IR\"\n",
    "vi=10.-2  # in V\n",
    "print \"Hence,    Vi_min = %0.2f V\"%vi\n",
    "print \"or    8 = 5 + (10*10**-3)R\"\n",
    "rmax=3./(10*10**-3)  # in ohm\n",
    "print \"Therefore,  Rmax = %0.2f ohm\"%rmax\n",
    "print \"Now, maximum input voltage, Vi_max = 5 + [(80+10)10**-3]R\"\n",
    "rmin=7./(90*10**-3)  # in ohm\n",
    "print \"    Rmin = %0.2f ohm\"%rmin\n",
    "print \"The value of R is chosen between 77.77 ohm and 300 ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 566 Example 18.16."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The load current,  IL( = Vo / RL = 20.00 mA\n",
      "Max. Zener current,  Iz_max = 25.00 mA\n",
      "  Rmax(ohm) = Vi-Vo / IL_min+IZ_max = 177.78 ohm\n"
     ]
    }
   ],
   "source": [
    "il=(24./1200)*10**3  # in mA\n",
    "print \"The load current,  IL( = Vo / RL = %0.2f mA\"%il\n",
    "iz=600./24  # in mA\n",
    "print \"Max. Zener current,  Iz_max = %0.2f mA\"%iz\n",
    "rmax=(32.-24)/((20+25)*10**-3)  # in ohm\n",
    "print \"  Rmax(ohm) = Vi-Vo / IL_min+IZ_max = %0.2f ohm\"%rmax"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 567 Example 18.17."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to fig.18.24. We know that\n",
      "    Vi_min(V) = Vo + 3V = 18.00 V\n",
      "Assuming the ripple voltage Vr = 2V(max), the input voltage is\n",
      "  Vi = Vi(min) + Vr/2 = 19.00 V\n",
      "Then    Vz = Vi /2 = 9.50 V           (use the zener diode 1N758 for 10V)\n",
      "Therefore,  Vz = 10 V\n",
      "            Iz = 20 mA\n",
      "    R1 = Vi-Vz / Iz = 450.00 ohm\n",
      "Let    I2 = IB(max) = 50 uA\n",
      "    R2 = Vo-Vz / I2 = 100.00 kohm\n",
      "    R3 = Vz / I2 = 200.00 kohm\n",
      "Select    C1 = 50 uF\n",
      "Specification of transistor Q1\n",
      "    VCE_max = Vi_max(V) = Vi + Vr/2 = 20.00 V\n",
      "    IE = IL = 50 mA\n",
      "    P = VCE*IL = (Vi-Vo) * IL = 200.00 mW\n",
      "Use the transistor 2N718 for Q1\n"
     ]
    }
   ],
   "source": [
    "vi=15.+3   # in V\n",
    "print \"Refer to fig.18.24. We know that\"\n",
    "print \"    Vi_min(V) = Vo + 3V = %0.2f V\"%vi\n",
    "vi=18.+1  # in V\n",
    "print \"Assuming the ripple voltage Vr = 2V(max), the input voltage is\"\n",
    "print \"  Vi = Vi(min) + Vr/2 = %0.2f V\"%vi\n",
    "vz=19./2  # in V\n",
    "print \"Then    Vz = Vi /2 = %0.2f V           (use the zener diode 1N758 for 10V)\"%vz\n",
    "print \"Therefore,  Vz = 10 V\"\n",
    "print \"            Iz = 20 mA\"\n",
    "r1=(19.-10)/(20*10**-3)  # in ohm\n",
    "print \"    R1 = Vi-Vz / Iz = %0.2f ohm\"%r1\n",
    "print \"Let    I2 = IB(max) = 50 uA\"\n",
    "r2=((15.-10)/(50*10**-6))*10**-3  # in k-ohm\n",
    "print \"    R2 = Vo-Vz / I2 = %0.2f kohm\"%r2\n",
    "r3=(10./(50*10**-6))*10**-3  # in k-ohm\n",
    "print \"    R3 = Vz / I2 = %0.2f kohm\"%r3\n",
    "print \"Select    C1 = 50 uF\"\n",
    "print \"Specification of transistor Q1\"\n",
    "vce=19.+1  # in V\n",
    "print \"    VCE_max = Vi_max(V) = Vi + Vr/2 = %0.2f V\"%vce\n",
    "print \"    IE = IL = 50 mA\"\n",
    "p=((19.-15)*50)  # in mW\n",
    "print \"    P = VCE*IL = (Vi-Vo) * IL = %0.2f mW\"%p\n",
    "print \"Use the transistor 2N718 for Q1\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 568 Example 18.18."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Selection of Zener diode\n",
      "  RLmin = Vo / ILmax = 400.00 ohm\n",
      "  Vz = Vo / 2 = 10.00 V\n",
      "The current flowing through the Zener,\n",
      "  Iz = IE2 + IR1 = 20.00 mA\n",
      "  Pz = Vz*Iz = 0.20 W\n",
      "Selection of transistor Q1\n",
      "  IE1 = IR1 + IR2 + IL = 70.00 mA\n",
      "  Vi(max) - Vo = 30 -20 = 10 V\n",
      "For transistor SL100, the rating are\n",
      "    IC(max) = 500 mA\n",
      "   VCE(max) = 50 V\n",
      "        hre = 50 - 280\n",
      "Hence, SL100 can be chosen for Q1\n",
      "\n",
      "Selection of transistor Q2\n",
      "  Therefore,  VCE2_max = (Vo + VBE1) - Vz = 10.60 V\n",
      "For transistor BC107, the rating are\n",
      "    VCEO(max) = 45 V\n",
      "      IC(max) = 200 mA\n",
      "          hFE = 125 - 300\n",
      "Hence, transistor BC107 is selected for Q2\n",
      "Selection of resistor R1, R2 and R3\n",
      "  VR1 = Vo - Vz = 10.00 V\n",
      "  R1 = VR1 / IR1 = 1.00 kohm\n",
      "  VR2 = Vo - VR3 = 9.40 V\n",
      "  R2 = VR2 / IR2 = 940.00 ohm\n",
      "  VR3 = Vz + VBE2(sat) = 10.60 V\n",
      "  R3 = VR3 / IR3 = 1060.00 ohm\n",
      "Selection of resistor R4\n",
      "  VB1 = VC2(V) = Vo + VBE1 = 20.60 V\n",
      "  IB1 = IC1 / beta = 1.40 mA\n",
      "  IR4 = IB1 + IC2 = 11.40 mA\n",
      "  R4_max = VR4(max) / IR4 = Vi(max)-VB1 / IR4 = 824.56 ohm\n",
      "  R4_min = VR4(min) / IR4 = Vi(min)-VB1 / IR4 = 122.81 ohm\n",
      "  R4 = R4(max)+R4(min) / 2 = 474.00 ohm\n"
     ]
    }
   ],
   "source": [
    "rlmin=20./(50*10**-3)  # in ohm\n",
    "print \"Selection of Zener diode\"\n",
    "print \"  RLmin = Vo / ILmax = %0.2f ohm\"%rlmin\n",
    "vz=20./2  # in V\n",
    "print \"  Vz = Vo / 2 = %0.2f V\"%vz\n",
    "print \"The current flowing through the Zener,\"\n",
    "iz=10.+10  # in mA\n",
    "print \"  Iz = IE2 + IR1 = %0.2f mA\"%iz\n",
    "pz=10.*20*10**-3  # in W\n",
    "print \"  Pz = Vz*Iz = %0.2f W\"%pz  # > 0.5 W\n",
    "print \"Selection of transistor Q1\"\n",
    "ie1=10.+10+50  # in mA\n",
    "print \"  IE1 = IR1 + IR2 + IL = %0.2f mA\"%ie1\n",
    "print \"  Vi(max) - Vo = 30 -20 = 10 V\"\n",
    "print \"For transistor SL100, the rating are\"\n",
    "print \"    IC(max) = 500 mA\"\n",
    "print \"   VCE(max) = 50 V\"\n",
    "print \"        hre = 50 - 280\"\n",
    "print \"Hence, SL100 can be chosen for Q1\"\n",
    "print \"\"\n",
    "print \"Selection of transistor Q2\"\n",
    "vce2=20.6-10  # in V\n",
    "print \"  Therefore,  VCE2_max = (Vo + VBE1) - Vz = %0.2f V\"%vce2\n",
    "print \"For transistor BC107, the rating are\"\n",
    "print \"    VCEO(max) = 45 V\"\n",
    "print \"      IC(max) = 200 mA\"\n",
    "print \"          hFE = 125 - 300\"\n",
    "print \"Hence, transistor BC107 is selected for Q2\"\n",
    "print \"Selection of resistor R1, R2 and R3\"\n",
    "vr1=20-10.  # in V\n",
    "print \"  VR1 = Vo - Vz = %0.2f V\"%vr1\n",
    "r1=10./(10)  # in k-ohm\n",
    "print \"  R1 = VR1 / IR1 = %0.2f kohm\"%r1\n",
    "vr2=20.-10.6  # in V\n",
    "print \"  VR2 = Vo - VR3 = %0.2f V\"%vr2\n",
    "r2=9.4/(10*10**-3)  # in ohm\n",
    "print \"  R2 = VR2 / IR2 = %0.2f ohm\"%r2\n",
    "vr3=10+0.6  # in V\n",
    "print \"  VR3 = Vz + VBE2(sat) = %0.2f V\"%vr3\n",
    "r3=10.6/(10*10**-3)  # in ohm\n",
    "print \"  R3 = VR3 / IR3 = %0.2f ohm\"%r3\n",
    "print \"Selection of resistor R4\"\n",
    "vb1=20+0.6  # in V\n",
    "print \"  VB1 = VC2(V) = Vo + VBE1 = %0.2f V\"%vb1\n",
    "ib1=70./50  # in mA\n",
    "print \"  IB1 = IC1 / beta = %0.2f mA\"%ib1\n",
    "ir4=11.4  # in mA\n",
    "print \"  IR4 = IB1 + IC2 = %0.2f mA\"%ir4\n",
    "r4max=(30-20.6)/(11.4*10**-3)  # in ohm\n",
    "print \"  R4_max = VR4(max) / IR4 = Vi(max)-VB1 / IR4 = %0.2f ohm\"%r4max\n",
    "r4min=(22-20.6)/(11.4*10**-3)  # in ohm\n",
    "print \"  R4_min = VR4(min) / IR4 = Vi(min)-VB1 / IR4 = %0.2f ohm\"%r4min\n",
    "r4=(825.+123)/2  # in ohm\n",
    "print \"  R4 = R4(max)+R4(min) / 2 = %0.2f ohm\"%r4"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 569 Example 18.19."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A bridge rectifier or full wave rectifier is used to get the pulsating d.c. output.\n",
      "  RL = Vdc / TL = 90.00 ohm\n",
      "A capacitor filter is used to remove the ripple and get a smooth output.\n",
      "    Ripple factor gamma = 1 / 4*sqrt(3)*f*C*RL\n",
      "Assume the ripple factor to be 0.03\n",
      "  C = 1069.17 uF\n",
      "The short circuit resistance Rsc connected with the series pass transistor is\n",
      "  Rsc = VBE / Ilim_it = 4.67 ohm\n",
      "Assume 7.6 V Zener diode in series with 1.5 k-ohm\n",
      "The designed circuit is shown in fig.18.32.\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "print \"A bridge rectifier or full wave rectifier is used to get the pulsating d.c. output.\"\n",
    "rl=9./(100*10**-3)  # in ohm\n",
    "print \"  RL = Vdc / TL = %0.2f ohm\"%rl\n",
    "print \"A capacitor filter is used to remove the ripple and get a smooth output.\"\n",
    "print \"    Ripple factor gamma = 1 / 4*sqrt(3)*f*C*RL\"\n",
    "print \"Assume the ripple factor to be 0.03\"\n",
    "c=(1./(4*sqrt(3)*50*0.03*90))*10**6  # in uF\n",
    "print \"  C = %0.2f uF\"%c  # = 1000 uF\n",
    "print \"The short circuit resistance Rsc connected with the series pass transistor is\"\n",
    "rsc=0.7/(150*10**-3)  # in ohm\n",
    "print \"  Rsc = VBE / Ilim_it = %0.2f ohm\"%rsc\n",
    "print \"Assume 7.6 V Zener diode in series with 1.5 k-ohm\"\n",
    "print \"The designed circuit is shown in fig.18.32.\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
