{
 "metadata": {
  "name": "",
  "signature": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter6 - Oscillators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.1 - page 438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Vf= 0.0125 # in volt\n",
      "Vo= 0.5 # in volt\n",
      "Beta= Vf/Vo \n",
      "# For oscillator A*Beta= 1\n",
      "A= 1/Beta \n",
      "print \"Amplifier Should have a minimum gain of\",A,\"to provide oscillation\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier Should have a minimum gain of 40.0 to provide oscillation\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.2 - page 439"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "R1= 50 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "R3=R2 # in ohm\n",
      "C1= 60 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "C3=C2 # in F\n",
      "f= 1/(2*pi*R1*C1*sqrt(6)) \n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %( f*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 21.66 kHz\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.3 - page 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "# Given data\n",
      "f=2 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "# Let\n",
      "R= 10 # in kohm   (As R should be greater than 1 kohm)\n",
      "R=R*10**3 # in ohm\n",
      "# Formula f= 1/(2*pi*R*C)\n",
      "C= 1/(2*pi*f*R) # in F\n",
      "C= C*10**9 # in nF\n",
      "# For Bita to be 1/3, Choose\n",
      "R4= R # in ohm\n",
      "R3= 2*R4 # in ohm\n",
      "print \"Value of C = %0.2f nF\" %C\n",
      "print \"Value of R3 = %0.f kohm\" %(R3*10**-3)\n",
      "print \"Value of R4 = %0.f kohm\" %(R4*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of C = 7.96 nF\n",
        "Value of R3 = 20 kohm\n",
        "Value of R4 = 10 kohm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.4 - page 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R1= 200 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "C1= 200 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "f= 1/(2*pi*R1*C1) # in Hz\n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %(f*10**-3)\n",
      "\n",
      "# Note: Calculation to find the value of f in the book is wrong, so answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 3.98 kHz\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.5 - page 460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L= 100 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= .001 # in \u00b5F\n",
      "C1= C1*10**-6 # in F\n",
      "C2= .01 # in \u00b5F\n",
      "C2= C2*10**-6 # in F\n",
      "C= C1*C2/(C1+C2) # in F\n",
      "# (i)\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Operating frequency = %0.f kHz\" %(round(f*10**-3))\n",
      "# (ii)\n",
      "Beta= C1/C2 \n",
      "print \"Feedback fraction  = %0.1f \" %Beta\n",
      "# (iii)\n",
      "# A*Bita >=1, so Amin*Bita= 1\n",
      "Amin= 1/Beta \n",
      "print \"Minimum gain to substain oscillations is\",Amin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating frequency = 528 kHz\n",
        "Feedback fraction  = 0.1 \n",
        "Minimum gain to substain oscillations is 10.0\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.6 - page 460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L= 15 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= .004 # in \u00b5F\n",
      "C1= C1*10**-6 # in F\n",
      "C2= .04 # in \u00b5F\n",
      "C2= C2*10**-6 # in F\n",
      "C= C1*C2/(C1+C2) # in F\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Frequency of oscilltions = %0.1f kHz\" %(f*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 681.5 kHz\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.7 - page 461"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L= 0.01 # in H\n",
      "C= 10 # in pF\n",
      "C= C*10**-12 # in F\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %(f*10**-3)\n",
      "# Note: Calculation to find the value of f in the book is wrong, so answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 503.29 kHz\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.8 - page 463"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L= 0.8 # in H\n",
      "\n",
      "C= .08 # in pF\n",
      "C= C*10**-12 # in F\n",
      "C_M= 1.9 # in pF\n",
      "C_M= C_M*10**-12 # in F\n",
      "C_T= C*C_M/(C+C_M) # in F\n",
      "R=5 # in kohm\n",
      "f_s= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Series resonant frequency = %0.f kHz\" %(f_s*10**-3)\n",
      "# (ii)\n",
      "f_p= 1/(2*pi*sqrt(L*C_T)) # in Hz\n",
      "print \"Parallel resonant frequency = %0.f kHz\" %(f_p*10**-3)\n",
      "# Note: Calculation to find the value of parallel resonant frequency in the book is wrong, so answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Series resonant frequency = 629 kHz\n",
        "Parallel resonant frequency = 642 kHz\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.10 - page 466"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R1= 220 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "C1= 250 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "f= 1/(2*pi*R1*C1) \n",
      "print \"Frequency of oscilltions = %0.2f Hz\" %f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 2893.73 Hz\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.11 - page 467"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import tan\n",
      "# Given data\n",
      "R= 10 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "f=1000 \n",
      "fie= 60 # in \u00b0\n",
      "# The impedence of given circuit , Z= R+j*1/(omega*C)\n",
      "# the phase shift, tan(fie)= imaginary part/ Real part\n",
      "# tand(fie) = 1/(omega*R*C)\n",
      "C= 1/(2*pi*R*tan(fie*pi/180)) \n",
      "print \"The value of C = %0.2f pF\" %(C*10**12)\n",
      "# Note : There is an calculation error to evaluate the value of C, So the answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 9188814.92 pF\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R= 10 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "f=1000 \n",
      "fie= 60 # in \u00b0\n",
      "# The impedence of given circuit , Z= R+j*1/(omega*C)\n",
      "# the phase shift, tan(fie)= imaginary part/ Real part\n",
      "# tand(fie) = 1/(omega*R*C)\n",
      "C= 1/(2*pi*R*tan(fie*pi/180)) \n",
      "print \"The value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "# Note : There is an calculation error to evaluate the value of C, So the answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 9.19 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.12 - page 467"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L= 50 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= 300 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2= 100 # in pF\n",
      "C2= C2*10**-12 # in F\n",
      "C_eq= C1*C2/(C1+C2) # in F\n",
      "f= 1/(2*pi*sqrt(L*C_eq)) # in Hz\n",
      "print \"Frequency of oscillations = %0.1f MHz\" %(f*10**-6)\n",
      "Beta= C2/C1 \n",
      "# (iii)\n",
      "# A*Beta >=1, so A*Bita= 1  (for sustained oscillations)\n",
      "Amin= 1/Beta \n",
      "print \"Minimum gain to substain oscillations is\",Amin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillations = 2.6 MHz\n",
        "Minimum gain to substain oscillations is 3.0\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.14 - page 469"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "L1= 2 # in mH\n",
      "L1= L1*10**-3 # in H\n",
      "L2= 1.5 # in mH\n",
      "L2= L2*10**-3 # in H\n",
      "# Formula f= 1/(2*pi*sqrt((L1+L2)*C)\n",
      "# For f= 1000 kHz, C will be maximum\n",
      "f=1000 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "Cmax= 1/((2*pi*f)**2*(L1+L2)) # in F\n",
      "# For f= 2000 kHz, C will be maximum\n",
      "f=2000 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "Cmin= 1/((2*pi*f)**2*(L1+L2)) # in F\n",
      "print \"Maximum Capacitance = %0.1f pF\" %(Cmax*10**12)\n",
      "print \"Minimum Capacitance = %0.1f pF\" %(Cmin*10**12)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum Capacitance = 7.2 pF\n",
        "Minimum Capacitance = 1.8 pF\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}