{
 "metadata": {
  "name": "Rijwan",
  "signature": "sha256:ccfeb26b31d807a5210cb280c22c39e23c0906566f59b1bedfeb5dfebe856c36"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ch-8 Oscillators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.1, page 272 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "A=50  #unitless\n",
      "criteria =  \"Barkhausen criterion for oscillator : Beta*A=1\"\n",
      "Beta=1/A  #unitless\n",
      "print criteria,\"\\nFeedback Factor for oscillator : \",Beta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Barkhausen criterion for oscillator : Beta*A=1 \n",
        "Feedback Factor for oscillator :  0.02\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.2, page 279"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "from math import pi\n",
      "#Given data\n",
      "L=100  #in uH\n",
      "L=L*10**-6  #in H\n",
      "f1=500  #in kHz\n",
      "f1=f1*10**3  #in Hz\n",
      "f2=1500  #in kHz\n",
      "f2=f2*10**3  #in Hz\n",
      "#Formula : f=1/(2*%pi*sqrt(L*C))\n",
      "C1=1/(4*pi**2*f1**2*L)  #in F\n",
      "C2=1/(4*pi**2*f2**2*L)  #in F\n",
      "C1*=10**12  #pF\n",
      "C2*=10**12  #pF\n",
      "print \"Range of capacitor : %0.2f pf to %0.2f pf\" %(C2, C1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Range of capacitor : 112.58 pf to 1013.21 pf\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.3, page 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "from math import pi  \n",
      "#Given data\n",
      "R=100  #in kOhm\n",
      "R=R*10**3  #in Ohm\n",
      "C=0.01  #in uF\n",
      "C=C*10**-6  #in F\n",
      "fo=sqrt(6)/(2*pi*R*C)  #in Hz\n",
      "print \"Frequency of oscillation is %0.3f Hz\" %fo"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillation is 389.848 Hz\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.4, page 288"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "from math import sqrt\n",
      "#Given data\n",
      "assumed = \"Assume alfa=sqrt(6) to find the gain.\"\n",
      "alfa=sqrt(6)  #unitless\n",
      "Beta=1/(1-5*alfa**2)  \n",
      "criteria = \"Barkhausen critera : A*|Beta|>=1\"\n",
      "Beta=-Beta  #\n",
      "A=1/Beta  #unitless\n",
      "print assumed,\"\\n\",criteria,\"\\nMinimum Gain of Amplifier must be \",A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Assume alfa=sqrt(6) to find the gain. \n",
        "Barkhausen critera : A*|Beta|>=1 \n",
        "Minimum Gain of Amplifier must be  29.0\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.6, page 289"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "from math import pi, sqrt\n",
      "#Given data :\n",
      "R1=50  #in kohm\n",
      "R1=R1*10**3  #in ohm\n",
      "C1=0.001  #in uF\n",
      "C1=C1*10**-6  #in F\n",
      "R2=1  #in kohm\n",
      "R2=R2*10**3  #in ohm\n",
      "C2=0.01  #in uF\n",
      "C2=C2*10**-6  #in F\n",
      "#Part (i)\n",
      "#Formula : f=1/(2*pi*sqrt(C1*C2*R1*R2))\n",
      "f=1/(2*pi*sqrt(C1*C2*R1*R2))  #in Hz\n",
      "f/=1000  #kHz\n",
      "print \"(i) Frequency of oscillations is %0.3f kHz\" %f\n",
      "#Part (ii)\n",
      "CurrentGain=1+C2/C1+R1/R2  #unitless\n",
      "print \"(ii) Current Gain : \",CurrentGain"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Frequency of oscillations is 7.118 kHz\n",
        "(ii) Current Gain :  61.0\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 8.7, page 295"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "from __future__ import division\n",
      "from math import sqrt, pi\n",
      "#Given data :\n",
      "fmin=20  #in Hz\n",
      "fmax=20  #in kHz\n",
      "Cmin=30  #in pF\n",
      "Cmax=300  #in pF\n",
      "#Formula : fo=1/(2*pi*R*C))\n",
      "R=1/(2*pi*fmin*Cmax*10**-12) # ohm\n",
      "R/=10**6  # Mohm\n",
      "print \"Required resistance is %0.3f Mohm\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required resistance is 26.526 Mohm\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}