{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "CHAPTER 23 OSCILLATORS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-1, Page 897  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "R1=100.0*10**3                        #non-inverting input resistance wiper R1(Ohm)\n",
      "R2=1.0*10**3                          #non-inverting input resistance R2(Ohm)\n",
      "C=0.01*10**-6                         #capacitance at non-inverting input(F)\n",
      "\n",
      "R=R1+R2                                         #max. total resistance(Ohm)\n",
      "fr1=(2*math.pi*R*C)**-1                          #minimum frequency(Hz)\n",
      "R=R2                                            #min. total resistance(Ohm)\n",
      "fr2=(2*math.pi*R*C)**-1                          #maximum frequency(Hz)\n",
      "\n",
      "print 'minimum frequency fr = ',round(fr1,2),'Hz'\n",
      "print 'maximum frequency fr = ',round((fr2/1000),2),'KHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "minimum frequency fr =  157.58 Hz\n",
        "maximum frequency fr =  15.92 KHz\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-2, Page 897"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Rf=2                         #feedback resistance(KOhm)\n",
      "Rl=1                         #lamp resistance(KOhm)\n",
      "Vl=2                         #lamp voltage(V)\n",
      "\n",
      "Il=Vl/Rl                     #lamp current(mA)\n",
      "Vout=Il*(Rf+Rl)              #output voltage of oscillator(V)\n",
      "\n",
      "print 'Lamp current = ',Il,'mA'\n",
      "print 'output voltage of oscillator = ',Vout,'Vrms'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lamp current =  2 mA\n",
        "output voltage of oscillator =  6 Vrms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-3, Page 904"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "C1=0.001*10**-6                     #capacitance in oscillator(F)\n",
      "C2=0.01*10**-6                      #capacitance in oscillator(F)\n",
      "L=15*10**-6                         #inductance(H)\n",
      "\n",
      "C=C1*C2/(C1+C2)                    #equivalent capacitance(F)\n",
      "fr=(2*math.pi*((L*C)**0.5))**-1     #oscillation frequency(Hz)\n",
      "B=C1/C2                            #feedback fraction\n",
      "Av_min=C2/C1                       #minimum voltage gain\n",
      "\n",
      "print 'feedback fraction B = ',B\n",
      "print 'oscillation frequency fr = ',round((fr*10**-6),2),'MHz'\n",
      "print 'minimum voltage gain Av(min) = ',Av_min"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "feedback fraction B =  0.1\n",
        "oscillation frequency fr =  1.36 MHz\n",
        "minimum voltage gain Av(min) =  10.0\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-4, Page 908"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "C1=0.001*10**-6                     #capacitance in oscillator(F)\n",
      "C2=0.01*10**-6                      #capacitance in oscillator(F)\n",
      "C3=50.0*10**-12                     #capacitance in oscillator(F)\n",
      "L=15*10**-6                         #inductance(H)\n",
      "\n",
      "C=(C1**-1+C2**-1+C3**-1)**-1                  #equivalent capacitance(F)\n",
      "fr=(2*math.pi*((L*C)**0.5))**-1                #oscillation frequency(Hz)\n",
      "\n",
      "print 'oscillation frequency fr = ',round((fr*10**-6),2),'MHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "oscillation frequency fr =  5.97 MHz\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-5, Page 912"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "Cs=0.05*10**-12                       #series capacitance in oscillator(F)\n",
      "Cm=10.0*10**-12                       #capacitance in oscillator(F)\n",
      "R=2.0*10**3                           #resistance in oscillator(Ohm)\n",
      "L=3                                   #inductance(H)\n",
      "\n",
      "fs=(2*math.pi*((L*Cs)**0.5))**-1                #series resonant frequency(Hz)\n",
      "Cp=Cs*Cm/(Cs+Cm)                               #equvalent parallel capacitance(F)\n",
      "fp=(2*math.pi*((L*Cp)**0.5))**-1                #parallel resonant frequency(Hz)\n",
      "\n",
      "print 'series resonant frequency fs = ',math.ceil(fs*10**-3),'KHz'\n",
      "print 'parallel resonant frequency fp = ',math.ceil(fp*10**-3),'KHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "series resonant frequency fs =  411.0 KHz\n",
        "parallel resonant frequency fp =  412.0 KHz\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-6, Page 918"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                              #given supply voltage(V)\n",
      "R=33*10**3                            #given resistance(Ohm)\n",
      "C=0.47*10**-6                         #given capacitance(F)\n",
      "\n",
      "LTP=VCC/3                             #trip point LTP (V)\n",
      "UTP=2*LTP                             #trip point UTP (V)\n",
      "W=1.1*R*C                             #pulse width of output(s)\n",
      "\n",
      "print 'trigger voltage LTP = ',LTP,'V'\n",
      "print 'trigger voltage UTP = ',UTP,'V'\n",
      "print 'pulse width W = ',W*10**3,'ms'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "trigger voltage LTP =  4.0 V\n",
        "trigger voltage UTP =  8.0 V\n",
        "pulse width W =  17.061 ms\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-7, Page 919"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R=10*10**6                            #given resistance(Ohm)\n",
      "C=470*10**-6                          #given capacitance(F)\n",
      "\n",
      "W=1.1*R*C                             #pulse width of output(s)\n",
      "\n",
      "print 'pulse width W = ',W,'s = ',round((W/3600),2),'hours'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pulse width W =  5170.0 s =  1.44 hours\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-8, Page 922"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R1=75.0*10**3                            #given resistance1(Ohm)\n",
      "R2=30.0*10**3                            #given resistance2(Ohm)\n",
      "C=47.0*10**-9                            #given capacitance(F)\n",
      "\n",
      "f=1.44/((R1+(2*R2))*C)                 #frequency (Hz)\n",
      "D=(R1+R2)/(R1+(2*R2))                  #duty cycle     \n",
      "\n",
      "print 'frequency f = ',round(f,2),'Hz' \n",
      "print 'duty cycle D = ',round((D*100),2),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "frequency f =  226.95 Hz\n",
        "duty cycle D =  77.78 %\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-9, Page 923"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "VCC=12.0                                 #given supply voltage(V)\n",
      "R1=75.0*10**3                            #given resistance1(Ohm)\n",
      "R2=30.0*10**3                            #given resistance2(Ohm)\n",
      "C=47.0*10**-9                            #given capacitance(F)\n",
      "Vcon1=11                                 #given Vcon(V)     \n",
      "Vcon2=1                                  #given Vcon(V)     \n",
      "\n",
      "W1=-(R1+R2)*C*(math.log((VCC-Vcon1)/(VCC-(0.5*Vcon1))))     #pulse width(s)\n",
      "T1=W1+(0.693*R2*C)                                          #period(s)\n",
      "D1=W1/T1                                                    #duty cycle\n",
      "f1=1/T1                                                     #frequency(Hz)\n",
      "W2=-(R1+R2)*C*(math.log((VCC-Vcon2)/(VCC-(0.5*Vcon2))))     #pulse width(s)\n",
      "T2=W2+(0.693*R2*C)                                          #period(s)\n",
      "D2=W2/T2                                                    #duty cycle\n",
      "f2=1/T2                                                     #frequency(Hz)\n",
      "\n",
      "print 'For Vcon = 11V,'\n",
      "print 'frequency f = ',round(f1,2),'Hz'\n",
      "print 'duty cycle D = ',round((D1*100),2),'%'\n",
      "print 'For Vcon = 1V,'\n",
      "print 'frequency f = ',round(f2,2),'Hz'\n",
      "print 'duty cycle D = ',round((D2*100),2),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For Vcon = 11V,\n",
        "frequency f =  97.9 Hz\n",
        "duty cycle D =  90.43 %\n",
        "For Vcon = 1V,\n",
        "frequency f =  835.77 Hz\n",
        "duty cycle D =  18.33 %\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-10, Page 927"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                                 #given supply voltage(V)\n",
      "R=9.1*10**3                              #given resistance(Ohm)\n",
      "C=0.01*10**-6                            #given capacitance(F)\n",
      "f=2.5*10**3                              #given frequency(Hz)\n",
      "Vmod=2                                   #peak value of modulating signal(V)                         \n",
      "\n",
      "T=1/f                                    #period of output pulse(s)\n",
      "W=1.1*R*C                                #pulse width(s)\n",
      "UTP_max=(2*VCC/3)+Vmod                   #maximum UTP(V)\n",
      "UTP_min=(2*VCC/3)-Vmod                   #minimum UTP(V)\n",
      "Wmin=-R*C*(math.log(1-(UTP_min/VCC)))    #minimum pulse width(s)\n",
      "Wmax=-R*C*(math.log(1-(UTP_max/VCC)))    #maximum pulse width(s)\n",
      "Dmin=Wmin/T                              #minimum duty cycle\n",
      "Dmax=Wmax/T                              #maximum duty cycle\n",
      "\n",
      "print 'period of output pulse T = ',T*10**6,'us'\n",
      "print 'Quiscent pulse width W = ',W*10**6,'us'\n",
      "print 'minimum UTP = ',UTP_min,'V'\n",
      "print 'maximum UTP = ',UTP_max,'V'\n",
      "print 'minimum pulse width W(min) = ',round((Wmin*10**6),2),'us'\n",
      "print 'maximum pulse width W(max) = ',round((Wmax*10**6),2),'us'\n",
      "print 'minimum duty cycle D(min) = ',round((Dmin*100),2),'%'\n",
      "print 'maximum duty cycle D(max) = ',round((Dmax*100),2),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "period of output pulse T =  400.0 us\n",
        "Quiscent pulse width W =  100.1 us\n",
        "minimum UTP =  6.0 V\n",
        "maximum UTP =  10.0 V\n",
        "minimum pulse width W(min) =  63.08 us\n",
        "maximum pulse width W(max) =  163.05 us\n",
        "minimum duty cycle D(min) =  15.77 %\n",
        "maximum duty cycle D(max) =  40.76 %\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 23-11, Page 928"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                                 #given supply voltage(V)\n",
      "R1=3.9*10**3                             #given resistance(Ohm)\n",
      "R2=3*10**3                               #given resistance(Ohm)\n",
      "C=0.01*10**-6                            #given capacitance(F)\n",
      "Vmod=1.5                                 #peak value of modulating signal(V)                         \n",
      "\n",
      "W=0.693*(R1+R2)*C                                              #pulse width(s)\n",
      "T=0.693*(R1+(2*R2))*C                                          #period of output pulse(s)\n",
      "UTP_max=(2*VCC/3)+Vmod                                         #maximum UTP(V)\n",
      "UTP_min=(2*VCC/3)-Vmod                                         #minimum UTP(V)\n",
      "Wmin=-(R1+R2)*C*(math.log((VCC-UTP_min)/(VCC-(0.5*UTP_min))))  #minimum pulse width(s)\n",
      "Wmax=-(R1+R2)*C*(math.log((VCC-UTP_max)/(VCC-(0.5*UTP_max))))  #minimum pulse width(s)\n",
      "Tmin=Wmin+(0.693*R2*C)                                         #minimum period(s)\n",
      "Tmax=Wmax+(0.693*R2*C)                                         #maximum period(s)\n",
      "s=0.693*R2*C                                                   #space(s)\n",
      "\n",
      "print 'period of output pulse T = ',T*10**6,'us'\n",
      "print 'Quiscent pulse width W = ',W*10**6,'us'\n",
      "print 'minimum UTP = ',UTP_min,'V'\n",
      "print 'maximum UTP = ',UTP_max,'V'\n",
      "print 'minimum pulse width W(min) = ',round((Wmin*10**6),2),'us'\n",
      "print 'maximum pulse width W(max) = ',round((Wmax*10**6),2),'us'\n",
      "print 'minimum period T(min) = ',round((Tmin*10**6),2),'us'\n",
      "print 'maximum period T(max) = ',round((Tmax*10**6),2),'us'\n",
      "print 'space = ',round((s*10**6),2),'us'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "period of output pulse T =  68.607 us\n",
        "Quiscent pulse width W =  47.817 us\n",
        "minimum UTP =  6.5 V\n",
        "maximum UTP =  9.5 V\n",
        "minimum pulse width W(min) =  32.04 us\n",
        "maximum pulse width W(max) =  73.47 us\n",
        "minimum period T(min) =  52.83 us\n",
        "maximum period T(max) =  94.26 us\n",
        "space =  20.79 us\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-12, Page 929"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                                 #given supply voltage(V)\n",
      "C=100*10**-9                             #given capacitance(F)\n",
      "Ic=1*10**-3                              #collector current (A)\n",
      "\n",
      "S=Ic/C                               #slope(V/s)             \n",
      "V=2*VCC/3                            #peak value(V)\n",
      "T=V/S                                #duration of ramp(s)     \n",
      "\n",
      "print 'slope is ',S/1000,'V/ms'\n",
      "print 'Peak value V = ',V,'V'\n",
      "print 'duration of ramp = ',T*10**3,'ms'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "slope is  10.0 V/ms\n",
        "Peak value V =  10.0 V\n",
        "duration of ramp =  1.0 ms\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-13, Page 938"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R=10*10**3                                #given resistance(Ohm)\n",
      "C=0.01*10**-6                             #given capacitance(F)\n",
      "\n",
      "f0=(R*C)**-1                              #output frequency(Hz)\n",
      "\n",
      "print 'output frequency f0 = ',f0/1000,'KHz' "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output frequency f0 =  10.0 KHz\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23-14, Page 938"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R1=1.0*10**3                                #given resistance(Ohm)\n",
      "R2=2.0*10**3                                #given resistance(Ohm)\n",
      "C=0.1*10**-6                                #given capacitance(F)\n",
      "\n",
      "f=(2/C)*((R1+R2)**-1)                     #output frequency(Hz)\n",
      "D=R1/(R1+R2)                              #duty cycle\n",
      "\n",
      "print 'output frequency f = ',round((f/1000),2),'KHz' \n",
      "print 'duty cycle = ',round((D*100),2),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output frequency f =  6.67 KHz\n",
        "duty cycle =  33.33 %\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}