{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "CHAPTER 18 OPERATIONAL AMPLIFIERS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-1, Page 672"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vout=13.5                       #As per figure 18-7b(V)\n",
      "Aov=100000                       #open loop voltage gain\n",
      "\n",
      "V2=Vout/Aov                      #required input voltage(V)\n",
      "\n",
      "print 'Required input voltage V2 = ',V2*10**6,'uV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required input voltage V2 =  135.0 uV\n"
       ]
      }
     ],
     "prompt_number": 71
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-2, Page 672"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "CMRR_dB=40                          #As per figure 18-7a at 100KHz(dB)\n",
      "\n",
      "CMRR=10**(CMRR_dB/20)\n",
      "\n",
      "print 'Common-mode rejection ratio = ',CMRR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Common-mode rejection ratio =  100\n"
       ]
      }
     ],
     "prompt_number": 76
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-3, Page 673"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "Av1=1000                        #Voltage gain as per figure 18-7c for 1KHZ\n",
      "Av10=100                        #Voltage gain as per figure 18-7c for 10KHZ\n",
      "Av100=10                        #Voltage gain as per figure 18-7c for 100KHZ\n",
      "\n",
      "print 'Voltage gain for 1KHZ = ',Av1\n",
      "print 'Voltage gain for 1KHZ = ',Av10\n",
      "print 'Voltage gain for 1KHZ = ',Av100"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gain for 1KHZ =  1000\n",
        "Voltage gain for 1KHZ =  100\n",
        "Voltage gain for 1KHZ =  10\n"
       ]
      }
     ],
     "prompt_number": 77
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-4, Page 673"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vout=0.25                         #output changes in 0.1us (V)\n",
      "t=0.1                             #time for output change(us) \n",
      "\n",
      "SR=Vout/t                         #slew rate(V/us)\n",
      "\n",
      "print 'Slew rate SR = ',SR,'V/us'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Slew rate SR =  2.5 V/us\n"
       ]
      }
     ],
     "prompt_number": 79
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-5, Page 673"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "SR=15                             #slew rate(V/us)\n",
      "Vp=10                             #Peak output voltage(V)\n",
      "\n",
      "fmax=1000*SR/(2*math.pi*Vp)        #power bandwidth (KHz) \n",
      "\n",
      "print 'Power bandwidth = ',round(fmax),'KHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power bandwidth =  239.0 KHz\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-6, Page 673"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "SR1=0.5                           #Slew rate1(V/us)\n",
      "SR2=5                             #Slew rate2(V/us)\n",
      "SR3=50                            #Slew rate3(V/us)\n",
      "Vp=8                              #peak voltage(V)\n",
      "\n",
      "fmax1=1000*SR1/(2*math.pi*Vp)        #power bandwidth1 (KHz) \n",
      "fmax2=1000*SR2/(2*math.pi*Vp)        #power bandwidth2 (KHz) \n",
      "fmax3=SR3/(2*3*math.pi*Vp)             #power bandwidth3 (MHz) \n",
      "\n",
      "print 'Power bandwidth1 = ',math.ceil(fmax1),'KHz'\n",
      "print 'Power bandwidth2 = ',math.ceil(fmax2),'KHz'\n",
      "print 'Power bandwidth3 = ',math.ceil(fmax3),'MHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power bandwidth1 =  10.0 KHz\n",
        "Power bandwidth2 =  100.0 KHz\n",
        "Power bandwidth3 =  1.0 MHz\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-7, Page 678"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=10                            #input voltage(mV)\n",
      "Rf=75                             #feedback path resistance Rf (KOhm)\n",
      "R1=1.5                            #inverting input resistance R1(KOhm)\n",
      "Funity=1                          #Funity (MHz)\n",
      "\n",
      "Av_CL=-Rf/R1                       #closed loop voltage gain\n",
      "f2_CL1=Funity/-Av_CL               #closed loop bandwidth1(KHz)\n",
      "Vout1=Av_CL*Vin                    #output voltage1(mV)\n",
      "Vout2=-Vin                         #output voltage2(mV)\n",
      "\n",
      "print 'Output voltage for 1KHz = ',Vout1,'mVpp'\n",
      "print 'Output voltage for 1MHz = ',Vout2,'mVpp'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage for 1KHz =  -500.0 mVpp\n",
        "Output voltage for 1MHz =  -10 mVpp\n"
       ]
      }
     ],
     "prompt_number": 90
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-8, Page 679"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=10                            #input voltage(mV)\n",
      "Rf=75                             #feedback path resistance Rf (KOhm)\n",
      "R1=1.5                            #inverting input resistance R1(KOhm)\n",
      "Iinb=80*10**-9                    #bias current(A)\n",
      "Iino =20*10**-9                   #Iin(off)  (A) \n",
      "Vino=2.0                          #Vin(off) (mV)\n",
      "Av=50                             #voltage gain \n",
      "RB1=0                             #resistance at noninverting input(KOhm) \n",
      "\n",
      "RB2=R1*Rf/(Rf+R1)                            #thevenin resistance at inverting input(KOhm) \n",
      "V1err=(RB1-RB2)*Iinb*10**6                   #dc error input1 (mV)\n",
      "V2err=(RB1+RB2)*(Iino/2)*10**6               #dc error input2 (mV)\n",
      "V3err=Vino                                   #dc error input3 (mV)\n",
      "Verror=Av*(abs(V1err)+V2err+V3err)           #output error voltage(mV)\n",
      "\n",
      "print 'output error voltage Verror = ',round(Verror,2),'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output error voltage Verror =  106.62 mV\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-9, Page 679"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=10                             #input voltage(mV)\n",
      "Rf=75                              #feedback path resistance Rf (KOhm)\n",
      "R1=1.5                             #inverting input resistance R1(KOhm)\n",
      "Iinb=500*10**-9                    #bias current(A)\n",
      "Iino =200*10**-9                   #Iin(off)  (A) \n",
      "Vino=6.0                           #Vin(off) (mV)\n",
      "Av=50                              #voltage gain \n",
      "RB1=0                              #resistance at noninverting input(KOhm) \n",
      "\n",
      "RB2=R1*Rf/(Rf+R1)                            #thevenin resistance at inverting input(KOhm) \n",
      "V1err=(RB1-RB2)*Iinb*10**6                   #dc error input1 (mV)\n",
      "V2err=(RB1+RB2)*(Iino/2)*10**6               #dc error input2 (mV)\n",
      "V3err=Vino                                   #dc error input3 (mV)\n",
      "Verror=Av*(abs(V1err)+V2err+V3err)           #output error voltage(mV)\n",
      "\n",
      "print 'output error voltage Verror = ',round(Verror,2),'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output error voltage Verror =  344.12 mV\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-10, Page 683"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "Vin=50                            #input voltage(mV)\n",
      "Rf=3.9*10**3                      #feedback path resistance Rf (Ohm)\n",
      "R1=100                            #inverting input resistance R1(Ohm)\n",
      "Funity=1*10**6                    #Funity (Hz)\n",
      "\n",
      "Av_CL=1+(Rf/R1)                    #closed loop voltage gain\n",
      "f2_CL1=Funity/Av_CL                #closed loop bandwidth1(KHz)\n",
      "Av_CL1=math.ceil(10**(12/20.0))    #Av for 12 dB at 250 KHz               \n",
      "Vout=Av_CL1*Vin                    #output voltage(mV)\n",
      "\n",
      "print 'Output voltage for 250KHz = ',Vout,'mVpp'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage for 250KHz =  200.0 mVpp\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-11, Page 684"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=10                             #input voltage(mV)\n",
      "Rf=3.9*10**3                       #feedback path resistance Rf (Ohm)\n",
      "R1=100                             #inverting input resistance R1(Ohm)\n",
      "Iinb=500*10**-9                    #bias current(A)\n",
      "Iino =200*10**-9                   #Iin(off)  (A) \n",
      "Vino=6.0*10**-3                    #Vin(off) (V)\n",
      "Av=40                              #voltage gain \n",
      "RB1=0                              #resistance at noninverting input(KOhm) \n",
      "\n",
      "RB2=R1*Rf/(Rf+R1)                            #thevenin resistance at inverting input(KOhm) \n",
      "V1err=(RB1-RB2)*Iinb                         #dc error input1 (mV)\n",
      "V2err=(RB1+RB2)*(Iino/2)                     #dc error input2 (mV)\n",
      "V3err=Vino                                   #dc error input3 (mV)\n",
      "Verror=Av*(abs(V1err)+V2err+V3err)           #output error voltage(mV)\n",
      "\n",
      "print 'output error voltage Verror = ',Verror*1000,'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output error voltage Verror =  242.34 mV\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-12, Page 687"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin1=100*10**-3                            #input voltage1(V)\n",
      "Vin2=200*10**-3                            #input voltage2(V)\n",
      "Vin3=300*10**-3                            #input voltage3(V)\n",
      "Rf=100.0                                   #feedback path resistance Rf (KOhm)\n",
      "R1=20.0                                    #inverting input resistance R1(KOhm)\n",
      "R2=10.0                                    #inverting input resistance R2(KOhm)\n",
      "R3=50.0                                    #inverting input resistance R3(KOhm)\n",
      "\n",
      "Av1_CL=-Rf/R1                              #closed loop voltage gain\n",
      "Av2_CL=-Rf/R1                              #closed loop voltage gain\n",
      "Av3_CL=-Rf/R1                              #closed loop voltage gain\n",
      "Vout=Av1_CL*Vin1+Av2_CL*Vin2+Av3_CL*Vin3   #output voltage1(mV)\n",
      "RB2=(R1**-1+R2**-1+R3**-1+Rf**-1)**-1      #thevenin resistance at inverting input(KOhm) \n",
      "\n",
      "print 'Output voltage = ',Vout,'Vpp'\n",
      "print 'thevenin resistance at inverting input RB2 = ',round(RB2,2),'KOhm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage =  -3.0 Vpp\n",
        "thevenin resistance at inverting input RB2 =  5.56 KOhm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-13, Page 688"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=10                             #ac voltage source (mVpp)\n",
      "Av=1                               #voltage gain\n",
      "Funity=1                           #unity frequency (MHz) \n",
      "\n",
      "Vout=Av*Vin                        #output voltage(V) \n",
      "f2_CL=Funity                       #bandwidth(MHz) \n",
      "\n",
      "print 'Output voltage = ',Vout,'mVpp'\n",
      "print 'Bandwidth f2(CL) = ',f2_CL,'MHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage =  10 mVpp\n",
        "Bandwidth f2(CL) =  1 MHz\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18-14, Page 688"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "RL=1.0                             #load resistance(Ohm)\n",
      "Vout=9.99                          #load voltage(mV)\n",
      "Vz=0.01                            #voltage across Zout(CL) (mV)\n",
      "\n",
      "iout=Vout/RL                           #load current(mA)\n",
      "Zout_CL=Vz/iout                        #output impedance(Ohm)\n",
      "\n",
      "print 'Load current iout = ',iout,'mA'\n",
      "print 'closed loop output impedance Zout(CL) = ',round(Zout_CL,3),'Ohm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load current iout =  9.99 mA\n",
        "closed loop output impedance Zout(CL) =  0.001 Ohm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}