{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 :Selected applications of Op Amps"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1 Page No 120"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Ei = 0.5         #Input voltage\n",
      "Ri = 1*10**3     #Input resistance in ohm\n",
      "\n",
      "#Calculation\n",
      "Im = Ei / Ri     #Meter Current\n",
      "\n",
      "#Result\n",
      "print\"Meter Current = \", Im*1000,\"mA\"  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Meter Current =  0.5 mA\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2 Page No 120"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Efs = 5.0       #Full scale Voltage\n",
      "Ifs = 50*10**-6 #Full scale Meter Current\n",
      "#Calculation\n",
      "Ri = Efs / Ifs  # Input Resistance\n",
      "\n",
      "#Result\n",
      "print\" Input Resistance =\", Ri/1000,\"Kohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Input Resistance = 100.0 Kohm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3 Page No 122"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Edc = 5.0\n",
      "Erms = 5.0\n",
      "Epeak = 5.0\n",
      "Eptop = 5.0      # Voltages of meters \n",
      "Ifs = 50*10**-6  # Full scale Meter Current\n",
      "\n",
      "#Calculation\n",
      "Ri1 = Edc / Ifs               # DC Voltmeter\n",
      "Ri2 = 0.90 * (Erms / Ifs )    # Rms ac voltmeter ( math.sine wave only )\n",
      "Ri3 = 0.636 * (Epeak / Ifs )  #Peak Reading Voltmeter ( math.sine wave only )\n",
      "Ri4 = 0.318 * (Eptop / Ifs )  #Peak-to-Peak ac Voltmeter(math.sine wave only)\n",
      "\n",
      "#Result\n",
      "print\" Ri1 \", Ri1/1000,\"kohm\"\n",
      "print\" Ri2 =\",Ri2/1000 ,\"kohm\"\n",
      "print\" Ri3 = \", Ri3/1000,\"kohm\"\n",
      "print\" Ri4 = \", Ri4/1000,\"kohm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Ri1  100.0 kohm\n",
        " Ri2 = 90.0 kohm\n",
        " Ri3 =  63.6 kohm\n",
        " Ri4 =  31.8 kohm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4 Page No 123"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Vo = 10.3         #Voltage across the load resistor\n",
      "Ei = 5.0          #Input voltage\n",
      "Ri = 1*10**3      #Input Resistance\n",
      "\n",
      "#calculation\n",
      "I = Ei / Ri  #Zener Current\n",
      "Vt = Vo - Ei  #Zener Voltage\n",
      "\n",
      "#Result\n",
      "print\" Zener Current = \", I,\"A\"\n",
      "print\" Zener Voltage = \", Vt ,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Zener Current =  0.005 A\n",
        " Zener Voltage =  5.3 V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5 Page No 124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Ei = 1.0        #Reference voltage\n",
      "Ri = 1*10**3    #Input Resistance\n",
      "Vo = 0.6       #Outpur Voltage\n",
      "\n",
      "#Calculation\n",
      "I = Ei / Ri   #Diode Current\n",
      "Vdiode = Vo \n",
      "\n",
      "#Result\n",
      "print\" Diode Current = \", I*1000 ,\"mA\"\n",
      "print\" Voltage drop across the diode = \", Vdiode,\"V\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Diode Current =  1.0 mA\n",
        " Voltage drop across the diode =  0.6 V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6 Page No 127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "R = 10*10**3     #Resistance\n",
      "E2 = 0           #Source across negative terminal\n",
      "Rl = 5*10**3     # Load Resistance\n",
      "E1 = 5.0           # source across positive terminal\n",
      "\n",
      "#calculation\n",
      "Il = (E1 - E2)/R  #Load Current\n",
      "Vl = Il * Rl  # Voltage across Rl \n",
      "Vo = (2*Vl)-E2  #Output voltage\n",
      "\n",
      "#Result\n",
      "print\"(a) Load current across Rl = \" , Il*1000 ,\"mA\"\n",
      "print\"(b) Voltage across load resistance = \" , Vl,\"V\"\n",
      "print\"(c) Output Voltage = \", Vo ,\"V\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Load current across Rl =  0.5 mA\n",
        "(b) Voltage across load resistance =  2.5 V\n",
        "(c) Output Voltage =  5.0 V\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7 Page No 127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "R = 10*10**3      #Resistance\n",
      "E2 = 5.0          #Source across negative terminal\n",
      "Rl = 5*10**3      # Load Resistance\n",
      "E1 = 0            # source across positive terminal\n",
      "\n",
      "#Calculation\n",
      "Il = (E1 - E2)/R  #Load Current\n",
      "Vl = Il * Rl      # Voltage across Rl \n",
      "Vo = (2*Vl)-E2    #Output voltage\n",
      "\n",
      "#Result\n",
      "print\"(a) Load current across Rl =  \" , Il*1000,\"mA\"\n",
      "print\"(b) Voltage across load resistance = \" , Vl,\"V\"\n",
      "print \"(c) Output Voltage = \", Vo ,\"V\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Load current across Rl =   -0.5 mA\n",
        "(b) Voltage across load resistance =  -2.5 V\n",
        "(c) Output Voltage =  -10.0 V\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8 Page No 132"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Vo = 5.0         #Output Voltage\n",
      "Rf = 100*10**3   #Feedback Resistance\n",
      "\n",
      "#calculation\n",
      "Isc = Vo / Rf    #Short Circuit Current\n",
      "\n",
      "#Result\n",
      "print\" Short Circuit Current = \" , Isc*10**6,\"microA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Short Circuit Current =  50.0 microA\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9 Page No  132"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given \n",
      "Rf = 10*10**3      #Feedback Resistance\n",
      "I = 10*10**-6      #Current through Photo Detector\n",
      "\n",
      "#calculation\n",
      "Vo = Rf * I       #Vo for Dark Condition\n",
      "I1 = 1*10**-3     #Current in presence of sunlight\n",
      "Vo1 = Rf * I1     #output voltage in light condition\n",
      "\n",
      "#Result\n",
      "print\"(a)Output Voltage for dark Condition =  \", Vo,\"V\"\n",
      "print\"(b) Output voltage in light condition =  \", Vo1,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Output Voltage for dark Condition =   0.1 V\n",
        "(b) Output voltage in light condition =   10.0 V\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10 Page No 133"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Rf = 100*10**3 #Feedback Resistance\n",
      "Il1 = 1*10**-6  #Load current 1\n",
      "\n",
      "#calculation\n",
      "Vo1 = Rf * Il1  #Output voltage in photo detector\n",
      "Il2 = 50*10**-6  # Load  current 2\n",
      "Vo2 = Rf * Il2  #Output Voltage in photo detector\n",
      "\n",
      "#Result\n",
      "print\" (a)Output Voltage in photo detector for Il1 =  \",Vo1 ,\"V\"\n",
      "print \" (b)Output Voltage in photo detector for Il2 =  \",Vo2 ,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " (a)Output Voltage in photo detector for Il1 =   0.1 V\n",
        " (b)Output Voltage in photo detector for Il2 =   5.0 V\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11 Page No 134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "R = 1*10**3\n",
      "R1 = 99*10**3  \n",
      "\n",
      "#calculation\n",
      "m = R1 / R        #multiplier\n",
      "Isc = 10*10**-6   #Current on short-circuit condition\n",
      "Il = (1 + m)*Isc \n",
      "\n",
      "#result\n",
      "print\" Load current = \", Il*1000,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Load current =  1.0 mA\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12 Page No 136"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Im = 100*10**-6     #Meter current \n",
      "Isc = 0.5           # Current in short-circuit condition\n",
      "Rf = 20             # Feedback resistance\n",
      "Rm = 0.8*10**3     #Meter resistance\n",
      "\n",
      "#calculation\n",
      "d = Isc / Im      #Current divider\n",
      "R1 = d * Rf \n",
      "Rscale = R1 - Rm \n",
      "\n",
      "#Result\n",
      "print\" Resistance dRf = \", R1/1000 ,\"kohm\"\n",
      "print\" Rscale = \", Rscale/1000,\"kohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Resistance dRf =  100.0 kohm\n",
        " Rscale =  99.2 kohm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13 Page No 138"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "f = 10**3  #Frequency of Ei in Hz\n",
      "Ci = 0.01*10**-6  \n",
      "\n",
      "#Calculation\n",
      "import math\n",
      "m = math.tan(math.pi/4)\n",
      "Ri = m / (2*math.pi*f*Ci)\n",
      "\n",
      "#result\n",
      "print\" Value of Ri = \",round(Ri/1000,1),\"kohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Value of Ri =  15.9 kohm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.14 Page No 138"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "f = 10**3 \n",
      "Ri = 100*10**3  \n",
      "Ci = 0.01*10**-6\n",
      "\n",
      "#calculation\n",
      "import math\n",
      "phaseangle = 2*math.atan(2*math.pi*f*Ri*Ci)\n",
      "\n",
      "#result\n",
      "print\" Phase angle  =\", round(phaseangle*180/3.14,2),\"degree\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Phase angle  = 162.0 degree\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.15 Page no 143"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#From fig 5-14(a) and b\n",
      "Ei=2      #V, voltage\n",
      "Vf=4      #Vf force\n",
      "\n",
      "#Calculation\n",
      "Vo=-2*Ei     #Vo forces\n",
      "Vcap=3*Ei\n",
      "\n",
      "#Result\n",
      "print\"Vo is\",Vo,\"V\"\n",
      "print\"Vcap is\",Vcap,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vo is -4 V\n",
        "Vcap is 6 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.16 Page no 144"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Ei=4    #V\n",
      "Vo=8    #V\n",
      "\n",
      "#Calculation\n",
      "Vr=-Vo\n",
      "Vcap=Ei+Vo\n",
      "\n",
      "#Result\n",
      "print\"Vcap is\",Vcap,\"V\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vcap is 12 V\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.17 Page no 144"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Ri=1*10**5\n",
      "C=10**-6\n",
      "\n",
      "#Calculation\n",
      "T=3*Ri*C\n",
      "Et=5*T\n",
      "\n",
      "#Result\n",
      "print\"Equilibrium Time is\",Et,\"s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium Time is 1.5 s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.18 Page no 146"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given\n",
      "Ci=0.1*10**-6      #capacitance, farady\n",
      "Ci_=0.1            #microF\n",
      "f=1000             #frequency\n",
      "#Calculation\n",
      "import math\n",
      "Ri=1/(2*math.pi*f*Ci)\n",
      "Rf=20/(2*math.pi*f*Ci)\n",
      "Cf=1/(2*math.pi*f*Rf)\n",
      "#a=0.4*math.sin(2*math.pi*1000*t)\n",
      "#Vo=-Cf*Ci*a\n",
      "\n",
      "from sympy import *\n",
      "import numpy as np\n",
      "t = Symbol('t')\n",
      "y = -Rf*Ci_/10**6*0.4*sin(2*math.pi*1000*t)\n",
      "y_ = y.diff(t)\n",
      "\n",
      "#Reslt\n",
      "print Ci_\n",
      "print\"a)Rf is \",round(Rf/1000,1),\"kohm\"\n",
      "print\"Cf is \",round(Cf*10**6,9),\"microF\"\n",
      "print\"(b)Output voltage is \",y_,\"V\"\n",
      "\n",
      "#NOTE: Answer is same .In the book it is written 2*math.pi*1000  ."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.1\n",
        "a)Rf is  31.8 kohm\n",
        "Cf is  0.005 microF\n",
        "(b)Output voltage is  -8.0*cos(6283.18530717959*t) V\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}