{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : Operational Amplifier Characteristics "
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1 Page No.108"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "Ri = 10*10**3\n",
      "R1 = 10*10**6\n",
      "Acl = 10\n",
      "\n",
      "# Solution \n",
      "\n",
      "Rf = Acl * R1\n",
      "Rt = 47*10**3\n",
      "Rs = (Rt**2)/(Rf - (2*Rt))\n",
      "\n",
      "# Displaying the results\n",
      "\n",
      "print \"The value of Rf = \",Rf/10**6,\"Mega Ohms\"\n",
      "print \"Thevalue of Rs  = \",Rs,\"Ohms\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rf =  100 Mega Ohms\n",
        "Thevalue of Rs  =  22 Ohms\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2 Page No.110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "\n",
      "Rf = 10*10**3\n",
      "R1 = 10**3\n",
      "Vios = 10*10**-3\n",
      "Ib = 300*10**-9\n",
      "Ios = 50*10**-9\n",
      "\n",
      "# Solution \n",
      "# Solution for part a\n",
      "Vot1 = (1 + (Rf/R1))*Vios + Rf*Ib\n",
      "# Solution for part b \n",
      "Rcomp = (Rf * R1)/(Rf + R1)\n",
      "# Solution for part c\n",
      "Vot2 = (1+(Rf/R1))*Vios + Rf*Ios \n",
      "\n",
      "# Displaying the values \n",
      "\n",
      "print \"The value of maximum output offset due to Vios and Ib    = \", int( Vot1*10**3),\"mV\"\n",
      "print \"The value of Rcomp                                       = \",Rcomp,\"Ohms\" # Given answer in the textbook is not correct please make the change \n",
      "print \"The value of maximum output offset if Rcomp is connected = \",Vot2*10**3,\"mV\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of maximum output offset due to Vios and Ib    =  113 mV\n",
        "The value of Rcomp                                       =  909 Ohms\n",
        "The value of maximum output offset if Rcomp is connected =  110.5 mV\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3 Page No.111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "Acl = 100\n",
      "Temp0 = 25\n",
      "Temp1 = 50\n",
      "Vodrift = 0.15*10**-3\n",
      "\n",
      "# Solution \n",
      "\n",
      "Vos = Vodrift * (Temp1 - Temp0)\n",
      "Vo = Vos * Acl\n",
      "\n",
      "# Displaying the results \n",
      "\n",
      "print \"The value of Input offset voltage = \",Vos*10**3,\"mV\"\n",
      "print \"The value of Ooutput voltage      = \",int(Vo*10**3),\"mV\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Input offset voltage =  3.75 mV\n",
        "The value of Ooutput voltage      =  375 mV\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4 Page No.125"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "from scipy import signal\n",
      "import matplotlib.pyplot as plt\n",
      "import numpy as np\n",
      "\n",
      "Vpp = 6.0\n",
      "Frequency = 2*10**6\n",
      "\n",
      "# Solution \n",
      "\n",
      "WL = 1.0/Frequency # Calculating the wavelength \n",
      "SR = Vpp/(WL/2)  # Calculating the slew rate\n",
      "\n",
      "# Displaying the results \n",
      "\n",
      "print \"The value of slew rate is =\",int(SR*10**-6),\"V/us\"\n",
      "\n",
      "# Ploting the result \n",
      "\n",
      "Vp = 3\n",
      "t = np.linspace(0, 1, 500)\n",
      "plt.plot(t, -Vp*abs(signal.sawtooth(2 * np.pi * 2 * t)))  # Note : Triangular wave is the absolute of sawtooth wave\n",
      "plt.ylim(-3,0)\n",
      "plt.title(\"Output wave form of example 3.4\")\n",
      "plt.ylabel(\"Amplitude (V)\")\n",
      "plt.xlabel(\"Time(t)\")\n",
      "plt.show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of slew rate is = 24 V/us\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5 Page No.126"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "# Given data \n",
      "\n",
      "Acl = 50\n",
      "Slew_rate = 0.5\n",
      "frequency = 20*10**3\n",
      "# solution \n",
      "\n",
      "Vm = round((Slew_rate * 10**6)/(2*math.pi * frequency),2)\n",
      "Vo = 2 * Vm\n",
      "Vpeak_to_peak = Vo/Acl\n",
      "\n",
      "# Displaying the outputs \n",
      "\n",
      "print \"The peak voltage is                   =\",Vm,\"V peak\"\n",
      "print \"The peak to peak voltage              =\",Vo,\"V peak to peak\"\n",
      "print \"The value of maximum input voltage is =\",int(Vpeak_to_peak*10**3),\"mVpeak to peak \" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The peak voltage is                   = 3.98 V peak\n",
        "The peak to peak voltage              = 7.96 V peak to peak\n",
        "The value of maximum input voltage is = 159 mVpeak to peak \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6 Page No.127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "Vptpi = 500*10**-3  #input peak to peak voltage \n",
      "Vptpo = 3\n",
      "Tr = 4*10**-6\n",
      "\n",
      "# Solution \n",
      "\n",
      "Vdelta  = (0.9 - 0.1) * Vptpo\n",
      "SR = (Vdelta / Tr ) * 10**-6\n",
      "\n",
      "# Display the values \n",
      "\n",
      "print \"The value of delta V  = \",Vdelta,\"V\"\n",
      "print \"The slew rate is      = \",SR,\"V/us\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of delta V  =  2.4 V\n",
        "The slew rate is      =  0.6 V/us\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}