{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter-7 : Oscillators (Sinusoidal As Well As Non-Sinusoidal)"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.1 - Page No 232"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from numpy import pi\n",
      "from math import sqrt\n",
      "# Given data\n",
      "f=200 # in Hz\n",
      "# Let us take\n",
      "C=0.1 # in micro F\n",
      "C=C*10**-6 # in F\n",
      "R=1/(2*pi*f*C*sqrt(6)) # in ohm\n",
      "R=R*10**-3 # in k ohm\n",
      "# R1>=10*R, Let\n",
      "R1=10*R # in kohm\n",
      "R_f= 29*R1 # in k ohm\n",
      "R_f=R_f*10**-3  # in M ohm\n",
      "R_f=math.ceil(R_f) \n",
      "print \"Resistor of phase-shift oscillator = %0.f Mohm\" %R_f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistor of phase-shift oscillator = 1 Mohm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.2 - Page No 232"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "f=1 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "V_CC= 10 # in volt\n",
      "I_B_max= 500 # in nA (for 741 IC op-amp)\n",
      "I_B_max= I_B_max*10**-9 # in A\n",
      "I1= 100*I_B_max # in A\n",
      "V_out= (V_CC-1) # in volt\n",
      "V_in= V_out/29 \n",
      "R1= V_in/I1 # in ohm\n",
      "R1=R1*10**-3 #in k ohm\n",
      "# 5.6 k ohm resistor may be used for R1, being standard value resistor\n",
      "R1=5.6 # in k ohm (standard value)\n",
      "A=29 \n",
      "R_f= A*R1 \n",
      "# 180 k ohm resistor may be used to provide A > 29\n",
      "R_f=180 # in k ohm (standard value)\n",
      "R_comp= R_f \n",
      "R=R1 # in k ohm\n",
      "R=R*10**3 # in ohm\n",
      "C=1/(2*pi*f*R*sqrt(6)) # in F\n",
      "C=C*10**6 # in micro F\n",
      "print \"Value of R_comp = R_f = %0.f kohm\" %R_comp\n",
      "print \"Value of R = R1 = %0.1f in kohm\" %(R*10**-3)\n",
      "print \"Value of capacitor = %0.2f micro F\" %C"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of R_comp = R_f = 180 kohm\n",
        "Value of R = R1 = 5.6 in kohm\n",
        "Value of capacitor = 0.01 micro F\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.3 - Page No 235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "f=10 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "I_Bmax= 500 # in nA\n",
      "I_Bmax= I_Bmax*10**-9 # in amphere\n",
      "# Let current through resistor R1 be equal to 100 times I_Bmax, so\n",
      "I_1= 100*I_Bmax # in amp\n",
      "Vcc= 10 # in volt\n",
      "Vout= Vcc-1 # in volt\n",
      "Addition_RfR1= Vout/(500*10**-6) # value of Rf+R1 in ohm\n",
      "Addition_RfR1=Addition_RfR1*10**-3 # in kohm\n",
      "# Rf= 2*R1, So\n",
      "R1= Addition_RfR1/3 # (used 5.6 kohm Standard value resistor)\n",
      "print \"Value of R1 = %0.f kohm (Standard value 5.6 k ohm)\" %R1\n",
      "R1= 5.6 # in kohm     (used 5.6 kohm Standard value resistor)\n",
      "Rf= 2*R1 # in kohm# (used 12 kohm standard value resistor)\n",
      "print \"Value of Rf = %0.1f kohm (Standard value 12 k ohm)\" %Rf\n",
      "Rf= 12 # k ohm (used 12 kohm standard value resistor)\n",
      "R=R1 # in kohm\n",
      "C= 1/(2*pi*f*R) # in F (Used 2700pF standard value)\n",
      "C=2700 # in pF \n",
      "print \"Value of R  = %0.1f kohm\" %R\n",
      "print \"Value of C  = %0.f pF\" %C"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of R1 = 6 kohm (Standard value 5.6 k ohm)\n",
        "Value of Rf = 11.2 kohm (Standard value 12 k ohm)\n",
        "Value of R  = 5.6 kohm\n",
        "Value of C  = 2700 pF\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.4 - Page No 235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R= 1 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "C= 4.7 # in micro F\n",
      "C=C*10**-6 # in F\n",
      "omega=1/(R*C) # in radians/second\n",
      "f=omega/(2*pi) # in Hz\n",
      "print \"Frequency of the oscillation of the circuit = %0.2f Hz\" %f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of the oscillation of the circuit = 33.86 Hz\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.6 - Page No 236"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R= 10 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "C= 100 # in pF\n",
      "C=C*10**-12 # in F\n",
      "f=1/(2*pi*R*C) # in Hz\n",
      "print \"Frequency of the oscillation of the circuit = %0.2f kHz\" %(f*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of the oscillation of the circuit = 159.15 kHz\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.7 - Page No 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "fo= 318 # in Hz\n",
      "C= 0.015 # in microF\n",
      "C=C*10**-6 # in F\n",
      "R=0.159/(fo*C) # in ohm\n",
      "R=R*10**-3 # in kohm\n",
      "R=int(R) \n",
      "print \"Value of C1 = C2 = C3 = %0.3f micro F\" %(C*10**6)\n",
      "print \"Value of R1 = R2 = R3 = %0.f in kohm\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of C1 = C2 = C3 = 0.015 micro F\n",
        "Value of R1 = R2 = R3 = 33 in kohm\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.8 - Page No 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "fo= 1.5 # in kHz\n",
      "fo=fo*10**3 # in Hz\n",
      "C= 0.01 # in microF\n",
      "C=C*10**-6 # in F\n",
      "R=0.159/(fo*C) # in ohm\n",
      "R=R*10**-3 # in kohm\n",
      "R=int(R) \n",
      "print \"Value of C1 = C2 = C3 = %0.2f micro F\" %(C*10**6)\n",
      "print \"Value of R1 = R2 = R3 = %0.f in kohm\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of C1 = C2 = C3 = 0.01 micro F\n",
        "Value of R1 = R2 = R3 = 10 in kohm\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.9 - Page No 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C= 0.1 # in microF\n",
      "C=C*10**-6 # in F\n",
      "R=12 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "R1=120 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "Rf=1 # in Mohm\n",
      "Rf=Rf*10**6 # in ohm\n",
      "V_sat= 10 # in volt\n",
      "# Part(i)\n",
      "f=Rf/(4*R1*R*C) #in Hz\n",
      "print \"(i)   : Signal Frequency = %0.3f kHz\" %(f*10**-3)\n",
      "\n",
      "# Part(ii)\n",
      "Vp_p= float(2*R1*V_sat)/Rf # in Vp_p\n",
      "\n",
      "print \"(ii)  : Amplitude of the triangular wave = %0.1f Vp_p\" %Vp_p\n",
      "\n",
      "# Part(iii)\n",
      "Vp_p= (V_sat)-(-V_sat) \n",
      "print \"(iii) : Amplitude of the square wave = %0.f Vp_p\" %Vp_p"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   : Signal Frequency = 1.736 kHz\n",
        "(ii)  : Amplitude of the triangular wave = 2.4 Vp_p\n",
        "(iii) : Amplitude of the square wave = 20 Vp_p\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.11 - Page No 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C1= 0.01 # in microF\n",
      "C1=C1*10**-6 # in F\n",
      "R1=120 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=1.2 # in kohm\n",
      "R2=R2*10**3 # in ohm\n",
      "R3=6.8 # in kohm\n",
      "R3=R3*10**3 # in ohm\n",
      "V_sat= 15 # in volt\n",
      "# Part(a)\n",
      "Vp_p= 2*(R2/R3)*V_sat #in volt\n",
      "print \"(a) : Peak to peak amplitude of triangular wave = %0.3f volt\" %Vp_p\n",
      "\n",
      "# Part(b)\n",
      "fo= R3/(4*R1*C1*R2) #in Hz\n",
      "print \"(b) : Frequency of triangular wave = %0.2f kHz\" %(fo*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) : Peak to peak amplitude of triangular wave = 5.294 volt\n",
        "(b) : Frequency of triangular wave = 1.18 kHz\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 7.12 - Page No 249"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "# Given data\n",
      "T= 100 # in micro sec\n",
      "T=T*10**-6 #in se\n",
      "V_sat= 12 # in volt\n",
      "V1= 0.7 # in volt\n",
      "V= 0.7 # in volt\n",
      "V_D1= V \n",
      "V_D2=V_D1 \n",
      "C1= 0.1 # in microF\n",
      "C1=C1*10**-6 # in F\n",
      "Bita1= 0.1 \n",
      "# Formula T= R3*C1*log((1+V1/V_sat)/(1-Bita1))\n",
      "R3= T/(C1*log((1+V1/V_sat)/(1-Bita1))) # in ohm\n",
      "print \"Value of R3 = %0.3f kohm (Standard value 6.8 kohm)\" %(R3*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of R3 = 6.171 kohm (Standard value 6.8 kohm)\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}