{
 "metadata": {
  "name": "",
  "signature": "sha256:a0a242a6e68dc538de9abb5ce09e495ac777f6f08436d31860a48948f4431520"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 - Ramp, Pulse and Function Generators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Design RC ramp generator\n",
      "import math\n",
      "V=5.#Output voltage(in volts)\n",
      "Vs=15.#Supply voltage(in volts)\n",
      "R=100.#Load resistance(in kilo ohm)\n",
      "v=3.#Amplitude of triggering pulse(in volts)\n",
      "vb=0.5#Bse voltage(in volts)\n",
      "p=1.2#Pulse width(in ms)\n",
      "t=0.1#Time interval(in ms)\n",
      "vbe=0.7#Base emitter voltage(in volts)\n",
      "E=0.2#Initial voltage(in volts)\n",
      "e=5.#Final voltage(in volts)\n",
      "hfe=50.\n",
      "Il=V/R\n",
      "I1=100.*Il/1000.\n",
      "R1=(Vs-V)/(I1*1000.)\n",
      "C1=p/(R1*math.log((Vs-E)/(Vs-e)))\n",
      "Ic=10.*I1\n",
      "Ib=Ic/hfe\n",
      "Rb=(Vs-vbe)/(Ib*1000.)\n",
      "Vbb=v-vbe-vb\n",
      "I=(Vs+v)/Rb\n",
      "C2=I*p/Vbb\n",
      "print '%s %.1f %s %.f %s %.1f %s %.2f' %('Components required to design circuit are resistances \\nRb(in kilo ohm)=',Rb,'\\nR1(in kilo ohm)=',R1,'\\nCapacitors \\nC1(in micro farad)=',C1,'\\nC2(in micro farad)=',C2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Components required to design circuit are resistances \n",
        "Rb(in kilo ohm)= 14.3 \n",
        "R1(in kilo ohm)= 2 \n",
        "Capacitors \n",
        "C1(in micro farad)= 1.5 \n",
        "C2(in micro farad)= 0.84\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 267"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Design a linear ramp generator\n",
      "V=5.#Output voltage(in volts)\n",
      "Vcc=15.#Supply voltage(in volts)\n",
      "Vce2=3.#Voltage(in volts)\n",
      "C1=1.#Capacitance(in micro fard)\n",
      "t=1.#pulse width(in ms)\n",
      "Vbe=0.7#Base emitter voltage(in volts)\n",
      "V3=Vcc-Vce2-5\n",
      "Ic=C1*V/t\n",
      "R3=V3/Ic\n",
      "Vb=V3+Vbe\n",
      "I1=Ic/10.\n",
      "R1=Vb/I1\n",
      "i1=Vb/R1\n",
      "V2=Vcc-Vb\n",
      "R2=V2/I1\n",
      "print '%s %.1f %s %.1f %s %.1f %s %.f' %('Components required to design the circuit are resistors \\nR1(in kilo ohm)=',13.4,'\\nR2(in kilo ohm)=',R2,'\\nR3(in kilo ohm)=',R3,'\\ncapacitance C1(in micro farad)=',C1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Components required to design the circuit are resistors \n",
        "R1(in kilo ohm)= 13.4 \n",
        "R2(in kilo ohm)= 14.6 \n",
        "R3(in kilo ohm)= 1.4 \n",
        "capacitance C1(in micro farad)= 1\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 270"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Determine Rsmax,Rsmin,and minimum drain source voltage\n",
      "I=2.#Drain Current(in mA)\n",
      "Vgsm=3.#Maximum gate source voltage(in volts)\n",
      "Vgsn=0.5#Minimum gate source voltage(in volts)\n",
      "V=6.#Peak voltage(in volts)\n",
      "Rs1=Vgsm/I\n",
      "Rs2=Vgsn*1000./I\n",
      "Vds=V-Vgsm+1.\n",
      "print '%s %.1f %s %.f %s %.f' %('Required resistances Rsmax(in kilo ohm)=',Rs1,'\\nRsmin(in ohm)=',Rs2,'\\ndrain source voltage(in volts)=',Vds)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required resistances Rsmax(in kilo ohm)= 1.5 \n",
        "Rsmin(in ohm)= 250 \n",
        "drain source voltage(in volts)= 4\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 273"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Design a UJT relaxation oscillator and find peak to peak output amplitude\n",
      "import math\n",
      "Vbb=20.#Supply voltage(in volts)\n",
      "f=5.#Frequency(in khz)\n",
      "Veb=3.#Fringe Voltage(in volts)\n",
      "Ip=2.#Fringe current(in micro ampere)\n",
      "Iv=1.#Emitter current(in mA)\n",
      "n=0.75\n",
      "Vp=3.7+(n*Vbb)\n",
      "R1x=(Vbb-Vp)/Ip\n",
      "R1n=(Vbb-Veb)/Iv\n",
      "t=1000./f\n",
      "C1=t*1443./(R1n*(math.log((Vbb-Veb)/(Vbb-Vp))))\n",
      "E=Vp-Veb\n",
      "print '%s %.1f %s %.f %s %.f' %('Peak to peak voltage(in volts)=',E,'\\nComponents for circuit are \\nresistor(in kilo ohm)=',R1n,'\\ncapacitance(in pf)=',C1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak to peak voltage(in volts)= 15.7 \n",
        "Components for circuit are \n",
        "resistor(in kilo ohm)= 17 \n",
        "capacitance(in pf)= 6603\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Design a transistor bootstrap ramp generator\n",
      "V=8.#Amplitude of output voltage(in volts)\n",
      "Vd=0.7#Forward diode voltage(in volts)\n",
      "Vce=0.2#Saturated collector emitter voltage(in volts)\n",
      "t=1.#Interval between pulses(in ms)\n",
      "Vt=3.#Triggering voltage(in volts)\n",
      "E=15.#Supply voltage(in volts)\n",
      "vbe=0.7#Base emitter voltage(in volts)\n",
      "vb=0.5#Bse voltage(in volts)\n",
      "hfe=100.\n",
      "R=1.#Load resistor(in kilo ohm)\n",
      "Ie1=E/R\n",
      "Ie2=(V-(-E))/R\n",
      "Ib1=Ie1/hfe\n",
      "Ib2=Ie2/hfe\n",
      "Ibc=Ib2-Ib1\n",
      "I1=100.*Ibc/1000.\n",
      "C1=I1*t*1000./V\n",
      "Vr1=E-Vd-Vce\n",
      "R1=Vr1/I1\n",
      "Vc3=E/100.\n",
      "C3=I1*t*1000./Vc3\n",
      "Il=V/R\n",
      "I1=100.*Il/1000.\n",
      "Ic=10.*I1\n",
      "Ib=Ic/hfe\n",
      "Rb=(E-vbe)/(Ib*12.5)\n",
      "Vbb=V-vbe-vb\n",
      "I=(E+Vt)/Rb\n",
      "C2=I*t/Vbb\n",
      "print '%s %.1f %s %.f %s %.2f %s %.f' %('Circuit components are \\nresistor Rb(in kilo ohm)=',Rb,'\\ncapacitances \\nC1(in micro farad)=',C1,'\\nC2(in micro farad)=',C2,'\\nC3(in micro farad)=',C3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Circuit components are \n",
        "resistor Rb(in kilo ohm)= 14.3 \n",
        "capacitances \n",
        "C1(in micro farad)= 1 \n",
        "C2(in micro farad)= 0.19 \n",
        "C3(in micro farad)= 53\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 284"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate drain current\n",
      "V=5.#Output peak voltage(in volts)\n",
      "p=1.#Pulse width(in ms)\n",
      "s=50.#Space width(in micro sec)\n",
      "C=0.03#Capacitance(in micro farad)\n",
      "Vp=6.#Gate source voltage(in volts)\n",
      "I1=C*V*1000./p\n",
      "Vi=Vp+1.\n",
      "R1=Vi/I1\n",
      "Id=I1*p/s\n",
      "print '%s %.f' %('Drain current(in mA)=',Id)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Drain current(in mA)= 3\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 301"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Design a pulse generator using 8038 IC\n",
      "p=200.#Pulse width(in micro sec)\n",
      "f=1.#Pulse repetition frequency(in khz)\n",
      "V=10.#Output voltage(in volts)\n",
      "I=1.#Maximum current(in mA)\n",
      "T=1000./f\n",
      "t2=T-p\n",
      "Ib=I*p/t2\n",
      "Ra=V/(5.*I)\n",
      "C=0.6*p/(Ra*1000.)\n",
      "Rb=2.*V/(5.*(I+Ib))\n",
      "Rl=V/I\n",
      "print '%s %.3f %s %.f %s %.1f %s %.f' %('Circuit components are \\nCapacitance(in micro farad)=',C,'\\nResistances Rl(in kilo ohm)=',Rl,'\\nRb(in kilo ohm)=',Rb,'\\nRa(in kilo ohm)=',Ra)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Circuit components are \n",
        "Capacitance(in micro farad)= 0.060 \n",
        "Resistances Rl(in kilo ohm)= 10 \n",
        "Rb(in kilo ohm)= 3.2 \n",
        "Ra(in kilo ohm)= 2\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 - Pg 303"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate output maximum and minimum frequencies\n",
      "V=15.#Supply voltage(in volts)\n",
      "Imin=10.#Minimum current(in micro ampere)\n",
      "Imax=1.#Maximum current(in mA)\n",
      "C=3600.#Capacitor(in pF)\n",
      "Rmax=V/(10.*Imin)\n",
      "Rmin=V/(10.*Imax)\n",
      "fmin=0.151*10.**6./(C*Rmax)\n",
      "fmax=0.15*10.**6./(C*Rmin)\n",
      "print '%s %.f %s %.f' %('minimum frequency(in hz)=',fmin,'\\nMaximum frequency(in khz)=',fmax)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "minimum frequency(in hz)= 280 \n",
        "Maximum frequency(in khz)= 28\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}