{
 "metadata": {
  "name": "",
  "signature": "sha256:2fe1179f75aa385348ef5cec4f87809b650f5f51dbd7626f41d9c2f163f1cec2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter2, Gate Triggering Circuits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6.1: page 2-24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from numpy import log\n",
      "#design\n",
      "#given data :\n",
      "c1=0.1 #in micro farads\n",
      "vbb=30 #in volts\n",
      "n=0.51 #\n",
      "ip=10 #in micro amperes\n",
      "vv=3.5 #in volts\n",
      "iv=10 #in mA\n",
      "f=50 #in Hz\n",
      "w=50 #eifth in micro seconds\n",
      "vd=0.7 #in volts\n",
      "vp=n*vbb+vd #in volts\n",
      "vc=vp #in volts\n",
      "x=log(vv/(vp-vd)) #\n",
      "r1=-(w*10**-6/(c1*10**-6*x)) #\n",
      "T=(1/(f))*10**3 #in ms\n",
      "t1=T-(w*10**-3) # in ms\n",
      "r=((t1*10**-3)/(c1*10**-6*log(1/(1-n)))) #\n",
      "r2=(10**4/(n*vbb)) #in ohms\n",
      "print \"Resistance R1 = %0.f ohm\" %round(r1)\n",
      "print \"Resistance R = %0.2f kohm\" %(r*10**-3)\n",
      "print \"Resistance R2 = %0.1f ohm \" %r2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance R1 = 339 ohm\n",
        "Resistance R = 279.67 kohm\n",
        "Resistance R2 = 653.6 ohm \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.1: page 2-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import exp\n",
      "#current\n",
      "#given data :\n",
      "v=100 #in volts\n",
      "r=20 #in ohms\n",
      "t=50 #in micro seconds\n",
      "l=0.5 #in henry\n",
      "il=(v/r)*(1-exp(-t*10**-6*(r/l))) #\n",
      "print \"load current = %0.f mA \"%(il*10**3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "load current = 10 mA \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.2: page 2-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "#MINIMUM WIDTH\n",
      "#given data :\n",
      "v=100 #in volts\n",
      "r=20 #in ohms\n",
      "l=0.5 #in henry\n",
      "il=50 #in mA\n",
      "t1=log(1-((il*10**-3)/(v/r)))/(-(r/l)) #\n",
      "print \"minimum pulse width = %0.2f micro seconds \" %(t1*10**6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "minimum pulse width = 251.26 micro seconds \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.3: page 2-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "#MINIMUM WIDTH\n",
      "#given data :\n",
      "v=207 #in volts\n",
      "r=10 #in ohms\n",
      "l=1 #in henry\n",
      "il=100 #in mA\n",
      "t1=log(1-((il*10**-3)/(v/r)))/(-(r/l)) #\n",
      "print \"minimum pulse width = %0.2f micro seconds\" %(t1*10**6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "minimum pulse width = 484.26 micro seconds\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.4: page 2-34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import symbols, solve\n",
      "from numpy import round, float\n",
      "#resistance and duty cycle\n",
      "#given data :\n",
      "vr=15 #in volts\n",
      "t=20 #in micro seconds\n",
      "pd=0.3 #power dissipation in watts\n",
      "pgm=5 #peak power in watts\n",
      "Ig=symbols('Ig')\n",
      "Vg=1+10*Ig\n",
      "exp = Vg*Ig-pgm # expression for equation\n",
      "Ig = solve(exp, Ig) # solving equation for Ig\n",
      "Ig=round(float(Ig[0]),3) # A\n",
      "Vg=1+10*Ig # V\n",
      "# Vr = Vg+Ig*Rg\n",
      "Rg = (vr-Vg)/Ig\n",
      "print \"(a) print Rg =\",round(Rg,3), \"ohm\"\n",
      "d=(pd/pgm)*100 #duty cycle \n",
      "print \"(b) duty cycle = %0.f %%\" %d\n",
      "tt=(t)/(d/100) #in micro seconds\n",
      "f=(1/(tt*10**-3)) #triggering frequency in kHz\n",
      "print \"(c) triggering frequency = %0.f kHz\" %f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) print Rg = 11.244 ohm\n",
        "(b) duty cycle = 6 %\n",
        "(c) triggering frequency = 3 kHz\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.5: page 2-35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#resistance\n",
      "#given data :\n",
      "vg=15.0 #in volys\n",
      "vgk=0.7 #in volts\n",
      "pg=0.5 # in watts\n",
      "ig=pg/vgk #in amperes\n",
      "rg=(vg-vgk)/ig #in ohms\n",
      "print \"gate source resistance = %0.f ohm \" %rg"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "gate source resistance = 20 ohm \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.6: page 2-35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import log\n",
      "#resistance ,frequency\n",
      "#given data :\n",
      "li=3.7 #leakage current in mA\n",
      "c1=0.1 #in micro farads\n",
      "vp=16 #in volts\n",
      "vv=1 #in volts\n",
      "n=0.7 #\n",
      "ip=0.7 #in milli amperes\n",
      "iv=6 #in mA\n",
      "f=1000 #in Hz\n",
      "rb1=5.5 #in killo ohms\n",
      "t=(1/f)*10**3 #in ms\n",
      "tg=50 #in micro seconds\n",
      "r2=((tg*10**-6/(c1*10**-6))) # in ohms\n",
      "r1=500  #in ohms assume\n",
      "vs=(r1+(rb1*10**3)+r2)*(li*10**-3) #in volts\n",
      "r=((t*10**-3)/(c1*10**-6*log(1/(1-n))))*10**-3 #in killo ohms\n",
      "rmin=(vs-vv)/iv #minimum resistance in killo ohms\n",
      "rmax=(vs-vp)/ip #maxium resistance in killo ohms\n",
      "fmin=(1/(rmax*10**3*c1*10**-6*log(1/(1-n)))) #minimum frequency in Hz\n",
      "fmax=(1/(rmin*10**3*c1*10**-6*log(1/(1-n))))*10**-3 #minimum frequency in Hz\n",
      "print \"Voltage = %0.f V \"%vs\n",
      "print \"charging resistance = %0.3f kohm \" %r\n",
      "print \"minimum resistance = %0.3f kohm\" %rmin\n",
      "print \"maximum resistance = %0.3f kohm\"%rmax\n",
      "print \"minimum frequency = %0.1f Hz\" %fmin\n",
      "print \"maximum frequency = %0.3f kHz\" %fmax\n",
      "#mimimum frequency is calculated wrong in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage = 24 V \n",
        "charging resistance = 8.306 kohm \n",
        "minimum resistance = 3.842 kohm\n",
        "maximum resistance = 11.500 kohm\n",
        "minimum frequency = 722.2 Hz\n",
        "maximum frequency = 2.162 kHz\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.7: page 2-37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#resistance\n",
      "#given data :\n",
      "il=50 #in mA\n",
      "pw=50 #pulse width in micro seconds\n",
      "i=10 #in mA\n",
      "v=100 #in volts\n",
      "if1=50 #in mA\n",
      "rmax=(v/(if1-i)) #maximum resistance in killo ohms\n",
      "print \"maximum resistance = %0.1f kohm\"%rmax"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "maximum resistance = 2.5 kohm\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.8: page 2-38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#resistance and gate power dissipation and frequency\n",
      "#given data :\n",
      "g=16 #in volts/ampere\n",
      "vr=15 #in volts\n",
      "t=4 #in micro seconds\n",
      "ig=500 #in mA\n",
      "rg=(vr/(ig*10**-3))-g #resistance in ohms\n",
      "print \"part (a) : \"\n",
      "print \"resistance in series with SCR gate = %0.f ohm\" %rg\n",
      "ig=500 #in mA\n",
      "rg=(vr/(ig*10**-3))-g #resistance in ohms\n",
      "pg=(ig*10**-3)**2*(g) #\n",
      "print \"part (b) : \"\n",
      "print \"gate power dissipation = %0.f Watt\" %pg\n",
      "ogv=0.3 #in watts\n",
      "d=(ogv/pg)*100 #\n",
      "t1=(t)/(d/100) #in micro seconds\n",
      "f1=(1/(t1*10**-3)) #frequency in kHz \n",
      "print \"part (c) : \"\n",
      "print \"triggering frequency = %0.2f kHz\" %f1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a) : \n",
        "resistance in series with SCR gate = 14 ohm\n",
        "part (b) : \n",
        "gate power dissipation = 4 Watt\n",
        "part (c) : \n",
        "triggering frequency = 18.75 kHz\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.9: page 2-39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import symbols, solve\n",
      "from numpy import round\n",
      "#series resistance and power dissipation\n",
      "#given data :\n",
      "vr=12.0 #in volts\n",
      "t=50.0 #in micro seconds\n",
      "d=0.2 #duty cycle\n",
      "pd=5.0 #power dissipation in watts\n",
      "Ig=symbols('Ig')\n",
      "p=-5+1.5*Ig+8*Ig**2 #\n",
      "x=solve(p, Ig) #\n",
      "rg=(vr-(1.5+8*x[1]))/(x[1]) #resistance in ohms\n",
      "pg=d*pd #average power loss in watts\n",
      "print \"resistance Rg = %.f ohm\"%rg\n",
      "print \"average power loss = %0.f Watt\" %pg"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance Rg = 7 ohm\n",
        "average power loss = 1 Watt\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.10: page 2-40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import log\n",
      "#design\n",
      "#given data :\n",
      "vs=20.0 #in volts\n",
      "c1=0.1 #in micro farads\n",
      "vv=2.5 #in volts\n",
      "n=0.66 #\n",
      "ip=10.0 #in micro amperes\n",
      "iv=10.0 #in mA\n",
      "f=1.0 #in KHz\n",
      "tg=40.0 #in micro seconds\n",
      "vd=0.8 #in volts\n",
      "vp=(n*vs+vd) #in volts\n",
      "r1=((tg*10**-6/(c1*10**-6))) # in ohms\n",
      "r=((1)/(f*10**3*c1*10**-6*log(1/(1-n))))*10**-3 #in killo ohms\n",
      "rmin=(vs-vv)/iv #minimum resistance in killo ohms\n",
      "rmax=(vs-vp)/ip #maxium resistance in killo ohms\n",
      "r2=10**4/(n*vs) #in ohms\n",
      "print \"Vp = %0.f Volts\" %vp\n",
      "print \"R1 = %0.f ohm\" %r1\n",
      "print \"R = %0.3f kohm\" %r\n",
      "print \"minimum resistance = %0.2f kohm\" %rmin\n",
      "print \"maximum resistance = %0.f kohm\" %(rmax*10**3)\n",
      "print \"R2 = %0.f ohm\" %round(r2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vp = 14 Volts\n",
        "R1 = 400 ohm\n",
        "R = 9.269 kohm\n",
        "minimum resistance = 1.75 kohm\n",
        "maximum resistance = 600 kohm\n",
        "R2 = 758 ohm\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.11: page 2-41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import sqrt, degrees, asin\n",
      "#trigger angle\n",
      "#given data :\n",
      "vm=120*sqrt(2) #in volts\n",
      "vrb=0.7 #in volts\n",
      "rb=500 #in ohms\n",
      "rl=1000 #in ohms\n",
      "rmin=1000 #in ohms\n",
      "r=4000 #in ohms\n",
      "alpha=degrees(asin((0.7*(rl+rmin+r+rb))/(rb*vm))) #in degree\n",
      "print \"triggering angle = %0.2f degree \"%alpha"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "triggering angle = 3.07 degree \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.12: page 2-41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#pulse width\n",
      "#given data :\n",
      "v=200 #in volts\n",
      "il=100 #latch current in mA\n",
      "l=0.2 #inductance in henry\n",
      "dit=v/l #in amp/sec\n",
      "dt=(il*10**-3)/dit #in seconds\n",
      "print \"(a) minimum pulse width required to turn on the SCR = %0.f micro seconds\" %(dt*10**6)\n",
      "r=20 #in ohms\n",
      "x=(il*10**-3*r)/v #\n",
      "t=(log(1-x))*(-l/r) #\n",
      "print \"(b) minimum pulse width = %0.f micro seconds\"%(round(t*10**6))\n",
      "#part b answer is calculated wrong in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) minimum pulse width required to turn on the SCR = 100 micro seconds\n",
        "(b) minimum pulse width = 101 micro seconds\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7.13: 2-43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from numpy import log\n",
      "#design\n",
      "vs=30 #in volts\n",
      "n=0.51 #\n",
      "vd=0.7 #in volts\n",
      "vp=(n*vs+vd) #in volts\n",
      "c=0.1 #in micro farads(taken for design)\n",
      "vv=3.5 #in volts\n",
      "x=log(vv/(vp-vd)) #\n",
      "t2=50 #in micro seconds\n",
      "r3=-((t2*10**-6)/(x*c*10**-6)) #in ohms\n",
      "f=50 #in Hz\n",
      "t=(1/f)*10**3 #in ms\n",
      "t1=(t-(t2*10**-6)) #inms\n",
      "x1=log(1-((vp-vv)/(vs))) #\n",
      "y1=(-t1*10**-3)/(c*10**-6) #\n",
      "r1=y1/x1 #in ohms\n",
      "r2=(10**4)/(n*vs) #in ohms\n",
      "print \"R1 = %0.3f ohm\" %(r1*10**-3)\n",
      "print \"R2 = %0.1f ohm\" %r2\n",
      "print \"R3 = %0.f ohm\" %(round(r3))\n",
      "print \"capaictance = %0.1f micro Farad/40 V\"%c\n",
      "#R3 is wrong in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R1 = 371.059 ohm\n",
        "R2 = 653.6 ohm\n",
        "R3 = 339 ohm\n",
        "capaictance = 0.1 micro Farad/40 V\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}