{
 "metadata": {
  "name": "",
  "signature": "sha256:d077ff1ae1358d45f28145208de3c4ea471b35a4622d519cd3d0c3db386677a5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12 - Oscillators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 587"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex12_1 Pg-587\n",
      "#calculate Frequency of oscillations produced\n",
      "import math\n",
      "C1=0.001e-6 #capacitor c1 in farad\n",
      "C2=0.01e-6 #capacitor c2 in farad\n",
      "L=5e-6 #inductance in Henry\n",
      "print '%s' %(\"To maintain vibrations in a colpitts oscilator,\")\n",
      "print '%s' %(\"hfe >= C2/C1\")\n",
      "hfe=C2/C1 #transistor current gain\n",
      "print '%s %.f' %(\"=\",hfe)\n",
      "print '%s' %(\"So the value of hfe of transistor used must be greater than 10\")\n",
      "print '%s' %(\"Frequency of oscillations produced\")\n",
      "x=1/(C1)+1/(C2)\n",
      "y=1/(L)\n",
      "f=math.sqrt(x*y)\n",
      "print '%s %.1f' %(\"=*1e7 Hz\",f*1e-7)\n",
      "# answer in the book is wrong\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "To maintain vibrations in a colpitts oscilator,\n",
        "hfe >= C2/C1\n",
        "= 10\n",
        "So the value of hfe of transistor used must be greater than 10\n",
        "Frequency of oscillations produced\n",
        "=*1e7 Hz 1.5\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 588"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex12_2 Pg-588\n",
      "#calculate frequency of oscillations\n",
      "import math\n",
      "RL=3.3*10.**(3.) #load resistor in ohm\n",
      "R=5.6*10.**(3.) #resistor R in ohm\n",
      "C=0.001*10.**(-6.) #capacitance in farad\n",
      "print '%s' %(\"For oscillations to be maintained in a RC oscillator\")\n",
      "hfe=(23.+(29.*R/RL)+(4.*RL/R)) #transistor current gain\n",
      "print '%s %.f' %(\"=\",hfe)\n",
      "print '%s' %(\"Frequency of oscillations\")\n",
      "f=1./(2.*math.pi*C*math.sqrt((4.*R*RL)+(6.*R**2.))) \n",
      "#frequency of oscillation (textbook answer is wrong\n",
      "# because of the used of wrong value of C)\n",
      "print '%s %.1f' %(\"=Hz\",f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For oscillations to be maintained in a RC oscillator\n",
        "= 75\n",
        "Frequency of oscillations\n",
        "=Hz 9831.1\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 588"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex12_3 Pg-588\n",
      "#calculate Series resonant frequency,Q of the crystal\n",
      "import math\n",
      "L=0.33 #inductance in henry\n",
      "C=0.065*10.**(-12.) #capacitance in farad\n",
      "Cm=10.**(-12.) #capacitance in farad\n",
      "R=0.55*10.**(3.) #resistor R in ohm\n",
      "print '%s' %(\"Series resonant frequency, fs = 1/2*math.pi*math.sqrt(L*C)\")\n",
      "fs=1./(2.*math.pi*math.sqrt(L*C))\n",
      "print '%s %.2f' %(\"= MHz\",fs*1e-6)\n",
      "print '%s' %(\"Q of the crystal = 2*pi*fs*L/R\")\n",
      "Q=(2*math.pi*fs*L)/R #quality factor (textbook answer wrong)\n",
      "print '%s %.0f' %(\"=\",Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Series resonant frequency, fs = 1/2*math.pi*math.sqrt(L*C)\n",
        "= MHz 1.09\n",
        "Q of the crystal = 2*pi*fs*L/R\n",
        "= 4097\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 602"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex12_4 Pg-602\n",
      "#calculate Series resonant frequency,The equialent parallel capacitance,Parallel resonant frequency\n",
      "import math\n",
      "L=3. #inductance in henry\n",
      "Cs=0.05*10.**(-12.) #capacitance in farad\n",
      "Cm=10.*10.**(-12.) #capacitance in farad\n",
      "R=2.*10.**(3.) #resistor R in ohm\n",
      "print '%s' %(\"Series resonant frequency, fs = 1/2*pi*sqrt(LC)\")\n",
      "fs=1./(2.*math.pi*math.sqrt(L*Cs))\n",
      "print '%s %.0f' %(\"= KHz\",fs*1e-3)\n",
      "print '%s' %(\"The equialent parallel capacitance, Cp = Cm*Cs/Cm+Cs\")\n",
      "Cp=Cm*Cs/(Cm+Cs) #quality factor \n",
      "print '%s %.4f' %(\"= pF\",Cp*1e12)\n",
      "print '%s' %(\"Parallel resonant frequency, fp = 1/2*pi*sqrt(L*Cp)\")\n",
      "fp=1/(2*math.pi*math.sqrt(L*Cp))\n",
      "print '%s %.0f' %(\"= kHz\",fp*1e-3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Series resonant frequency, fs = 1/2*pi*sqrt(LC)\n",
        "= KHz 411\n",
        "The equialent parallel capacitance, Cp = Cm*Cs/Cm+Cs\n",
        "= pF 0.0498\n",
        "Parallel resonant frequency, fp = 1/2*pi*sqrt(L*Cp)\n",
        "= kHz 412\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 602"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex12_5 Pg-602\n",
      "#calculate Fundamental frequency of oscillations of crystal\n",
      "print '%s' %(\"Fundamental frequency of oscillations of crystal\")\n",
      "print '%s' %(\"fr = K/t\")\n",
      "print '%s' %(\"Let new thickness of the crystal be t''\")\n",
      "print '%s' %(\"fr''/fr = t''/t = 99/100\")\n",
      "print '%s' %(\"So, new frequency fr'' = k/t''\")\n",
      "print '%s' %(\"or fr'' = (99/100)*fr\")\n",
      "print '%s' %(\"or reduction in frequency,\")\n",
      "print '%s' %(\"fr-fr'' = fr-(99/100)*fr\")\n",
      "print '%s' %(\"= fr(1/100)\")\n",
      "print '%s' %(\"or fr-fr''/fr = 1/100  \")\n",
      "print '%s' %(\"Therefore, fr'' reduces by 1%\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fundamental frequency of oscillations of crystal\n",
        "fr = K/t\n",
        "Let new thickness of the crystal be t''\n",
        "fr''/fr = t''/t = 99/100\n",
        "So, new frequency fr'' = k/t''\n",
        "or fr'' = (99/100)*fr\n",
        "or reduction in frequency,\n",
        "fr-fr'' = fr-(99/100)*fr\n",
        "= fr(1/100)\n",
        "or fr-fr''/fr = 1/100  \n",
        "Therefore, fr'' reduces by 1%\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}