{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 11: Sinusoidal Oscillators and Multivibrators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1, Page 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "L=50*10**-3#L=primary inductance of a transformer in henry\n",
      "C=(200*10**-12)#C=capacitor connected across transformer in farad\n",
      "R=50#dc resistance of primary coil in ohm\n",
      "hie=2000#hie=input impedance in ohm\n",
      "hre=10**(-4)#hre=reverse voltage amplification factor\n",
      "hfe=98#hfe=current gain\n",
      "hoe=(0.5*10**(-4))#hoe=output impedance in mho\n",
      "RB=50000#RB=resistance\n",
      "\n",
      "#Calculations\n",
      "f=1/(2*math.pi*math.sqrt(L*C))#f=frequency of oscillation\n",
      "g=((hie*hoe)-(hfe*hre))#g=dhe=delta he\n",
      "#M=mutual inductance in henry between the transformer primary and the secondary coils for sustained oscillations\n",
      "M=((RB/hfe)*((C*R)+(hoe*L)))+((C*R*hie)/hfe)+((L*g)/hfe)\n",
      "\n",
      "#Results\n",
      "print \"Frequency of oscillation is = %.1f kHz\"%(f/10**3)#f is converted in terms of kHz\n",
      "print \"Mutual inductance is = %.2f mH\"%(M/10**-3)#M is converted in terms of mH"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillation is = 50.3 kHz\n",
        "Mutual inductance is = 1.33 mH\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, Page 264"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "from numpy.linalg import inv\n",
      "\n",
      "#Variable declaration\n",
      "#L1 and L2=inductances in henry in a Hartley oscillator\n",
      "#Suppose L1=a\n",
      "#L2=b\n",
      "f=60*10**3#f=frequency in Hz\n",
      "C=400*10**(-12)#C=capacitance in Farad\n",
      "\n",
      "#Calculations\n",
      "#Also tuning capacitance varies from 100 pF to 400 pF\n",
      "#f=1/(2*%pi*sqrt((L1+L2)*C)) where f=frequency of a Hartley oscillator which varies from 60 kHz to 120 kHz\n",
      "#d=L1+L2=a+b\n",
      "#d=1/(((2*%pi*f)**2)*C)\n",
      "d=1/(((2*math.pi*f)**2)*C)#.......(1)\n",
      "#e=L2/L1=hfe/dhe\n",
      "hfe=90#hfe=current gain\n",
      "dhe=0.2#dhe=delta he\n",
      "e=hfe/dhe#..........(2)\n",
      "#From equation (1) and (2)\n",
      "#L*x=y\n",
      "x=np.matrix([[1, 1], [e, -1]])\n",
      "y=np.matrix([[d],[0]])\n",
      "L=inv(x)*y\n",
      "\n",
      "#Results\n",
      "print \"Inductance L1 is = %.f uH\"%((L[0])/10**-6)#converting L(1) in terms of micro Henry\n",
      "print \"Inductance L2 is = %.2f mH\"%((L[1])/10**-3)#converting L(2) in terms of mH\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Inductance L1 is = 39 uH\n",
        "Inductance L2 is = 17.55 mH\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, Page 264"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "L=20*10**-3#L=inductance in henry\n",
      "C1=(200*10**(-12))#C1=capacitance in farad\n",
      "C2=(300*10**(-12))#C2=capacitance in farad\n",
      "\n",
      "#Calculations\n",
      "Cs=((C1*C2)/(C1+C2))\n",
      "f=1/(2*math.pi*math.sqrt(L*Cs))\n",
      "\n",
      "#Result\n",
      "print \"Frequency of oscillation is = %.f kHz\"%(f/10**3)#converting f in terms of kHz"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillation is = 103 kHz\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, Page 264"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R=4700#R=resistance in a phase-shift oscillator in ohm\n",
      "C=(0.01*10**(-6))#C=capacitance in a phase-shift oscillator in farad\n",
      "\n",
      "#Calculations\n",
      "f=1/(2*math.pi*math.sqrt(10)*R*C)\n",
      "\n",
      "#Result\n",
      "print \"Frequency of oscillation f is = %.2f kHz\"%(f/10**3)#converting f in terms of kHz"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillation f is = 1.07 kHz\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, Page 265"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "f=30#f=frequency of oscillation of a Wien-bridge oscillator in Hz\n",
      "C=(500*10**(-12))#C=capacitance in farad\n",
      "\n",
      "#Calculations&Results\n",
      "#f=1/2*math.pi*R*C#R=resistance in ohm\n",
      "R=1/(2*math.pi*f*C)\n",
      "print \"Resistance needed to span the frequency range,R=%.1f Mohms\"%(R/10**6)#converting R in terms of Mega ohms\n",
      "#C1=50pF C2=500pF where C1,C2 are variable capacitances in a Wien bridge oscillator\n",
      "#ratio of capacitance=(1:10)\n",
      "#frequency range is 30 Hz to 300 Hz with R=10.6 Megaohms\n",
      "#for the next frequency range from 300 Hz to 3 kHz ,new R=(10.6/10)=1.06 Megaohm\n",
      "#for frequency range 3 kHz to 30kHz,R=1.06/10=106 Kilo-ohm\n",
      "#So,three values of R are 10.6 Megaohm,1.06 Megaohm,106 Kilo ohm\n",
      "A=6#A=gain of amplifier\n",
      "#R2/(R1+R2)=(1/3)-(1/A)=(1/3)-(1/6)\n",
      "#1+(R1/R2)=6\n",
      "#Hence R1/R2=5\n",
      "#R3=(R1/R2)\n",
      "R3=\"5:1\"\n",
      "print \"The ratio of the resistances in the other arms of the bridge,R1/R2 is =\",R3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance needed to span the frequency range,R=10.6 Mohms\n",
        "The ratio of the resistances in the other arms of the bridge,R1/R2 is = 5:1\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, Page 265"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "#Q=Quality factor\n",
      "L=3.5#L=inductance in henry\n",
      "f=450000#f=frequency in Hz\n",
      "R=9050#R=resistance in ohm\n",
      "\n",
      "#Calculations\n",
      "Q=(2*math.pi*f*L)/R\n",
      "\n",
      "#Result\n",
      "print \"Quality factor is %.f\"%Q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality factor is 1093\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}