{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "CHAPTER 17 DIFFERENTIAL AMPLIFIERS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-1, Page 625"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15                           #supply voltage(V)\n",
      "RE=7.5                           #Emitter resistance(KOhm)\n",
      "\n",
      "IT=VCC/RE                         #tail current (mA)\n",
      "IE=IT/2                           #emitter current (mA)\n",
      "\n",
      "print 'tail current = ',IT,'mA'\n",
      "print 'emitter current = ',IE,'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "tail current =  2.0 mA\n",
        "emitter current =  1.0 mA\n"
       ]
      }
     ],
     "prompt_number": 94
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-2, Page 626"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15                           #supply voltage(V)\n",
      "RE=7.5                           #Emitter resistance(KOhm)\n",
      "VBE=0.7                          #base-emitter voltage(V)\n",
      "RC=5                             #collector resistance(KOhm)\n",
      "\n",
      "IT=(VCC-VBE)/RE                         #tail current (mA)\n",
      "IE=IT/2                                 #emitter current (mA)\n",
      "VC=VCC-(IE*RC)                          #collector quiescent voltage(V) \n",
      "\n",
      "print 'tail current = ',round(IT,2),'mA'\n",
      "print 'emitter current = ',round(IE,2),'mA'\n",
      "print 'collector quiescent voltage VC = ',round(VC,2),'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "tail current =  1.91 mA\n",
        "emitter current =  0.95 mA\n",
        "collector quiescent voltage VC =  10.23 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-3, Page 626"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                           #supply voltage(V)\n",
      "RE=5.0                             #Emitter resistance(KOhm)\n",
      "RC=3.0                             #collector resistance(KOhm)\n",
      "\n",
      "IT=VCC/RE                         #tail current (mA)\n",
      "IE=IT/2                           #emitter current (mA)\n",
      "VC=VCC-(IE*RC)                    #collector quiescent voltage(V) \n",
      "IT1=(VCC-VBE)/RE                          #tail current (mA)\n",
      "IE1=IT1/2                                 #emitter current (mA)\n",
      "VC1=VCC-(IE1*RC)                          #collector quiescent voltage(V) \n",
      "\n",
      "print 'tail current = ',IT,'mA'\n",
      "print 'emitter current = ',IE,'mA'\n",
      "print 'collector quiescent voltage VC = ',VC,'V'\n",
      "print 'with second approximation,'\n",
      "print 'tail current = ',IT1,'mA'\n",
      "print 'emitter current = ',IE1,'mA'\n",
      "print 'collector quiescent voltage VC = ',VC1,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "tail current =  2.4 mA\n",
        "emitter current =  1.2 mA\n",
        "collector quiescent voltage VC =  8.4 V\n",
        "with second approximation,\n",
        "tail current =  2.26 mA\n",
        "emitter current =  1.13 mA\n",
        "collector quiescent voltage VC =  8.61 V\n"
       ]
      }
     ],
     "prompt_number": 92
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-4, Page 631"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                           #supply voltage(V)\n",
      "RE=7.5                             #Emitter resistance(KOhm)\n",
      "RC=5.0                             #collector resistance(KOhm)\n",
      "IE=1                               #emitter current as per preceding example(mA)\n",
      "Vin=1                              #input ac voltage(mV)\n",
      "B=300                              #current gain\n",
      "\n",
      "re=25/IE                          #ac emitter resistance(Ohm)\n",
      "Av=1000*RC/re                     #voltage gain\n",
      "Vout=Av*Vin                       #Output voltage(mV)\n",
      "Zinb=2*B*re                       #input impedance of diff amp(Ohm)\n",
      "\n",
      "print 'voltage gain Av = ',Av\n",
      "print 'Output voltage Vout = ',Vout,'mV'\n",
      "print 'input impedance of diff amplifier, Zin(base) = ',Zinb/1000,'KOhm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain Av =  200.0\n",
        "Output voltage Vout =  200.0 mV\n",
        "input impedance of diff amplifier, Zin(base) =  15 KOhm\n"
       ]
      }
     ],
     "prompt_number": 91
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-5, Page 632"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                           #supply voltage(V)\n",
      "RE=7.5                             #Emitter resistance(KOhm)\n",
      "RC=5.0                             #collector resistance(KOhm)\n",
      "IE=0.955                           #emitter current as per previous example(mA)\n",
      "Vin=1                              #input ac voltage(mV)\n",
      "B=300                              #current gain\n",
      "\n",
      "re=25/IE                          #ac emitter resistance(Ohm)\n",
      "Av=1000*RC/re                     #voltage gain\n",
      "Vout=Av*Vin                       #Output voltage(mV)\n",
      "Zinb=2*B*re                       #input impedance of diff amp(Ohm)\n",
      "\n",
      "print 'voltage gain Av = ',Av\n",
      "print 'Output voltage Vout = ',Vout,'mV'\n",
      "print 'input impedance of diff amplifier, Zin(base) = ',round((Zinb/1000),2),'KOhm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain Av =  191.0\n",
        "Output voltage Vout =  191.0 mV\n",
        "input impedance of diff amplifier, Zin(base) =  15.71 KOhm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-6, Page 633"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=12.0                           #supply voltage(V)\n",
      "RE=7.5                             #Emitter resistance(KOhm)\n",
      "RC=5.0                             #collector resistance(KOhm)\n",
      "IE=1                               #emitter current as per preceding example(mA)\n",
      "V2=1                               #input ac voltage(mV)\n",
      "B=300                              #current gain\n",
      "\n",
      "re=25/IE                          #ac emitter resistance(Ohm)\n",
      "Av=1000*RC/re                     #voltage gain\n",
      "Vout=Av*V2                        #Output voltage(mV)\n",
      "Zinb=2*B*re                       #input impedance of diff amp(Ohm)\n",
      "\n",
      "print 'V2 input is at inverting input, So, ideally same as previous case.'\n",
      "print 'Voltage gain Av = ',Av\n",
      "print 'Output voltage Vout = ',Vout,'mV'\n",
      "print 'input impedance of diff amplifier, Zin(base) = ',Zinb/1000,'KOhm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V2 input is at inverting input, So, ideally same as previous case.\n",
        "Voltage gain Av =  200.0\n",
        "Output voltage Vout =  200.0 mV\n",
        "input impedance of diff amplifier, Zin(base) =  15 KOhm\n"
       ]
      }
     ],
     "prompt_number": 96
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-7, Page 633"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                           #supply voltage(V)\n",
      "RC=1.0**10**6                      #collector resistance(Ohm)\n",
      "RE=1.0**10**6                      #emitter resistance(Ohm)\n",
      "IE=1                               #emitter current as per preceding example(mA)\n",
      "Vin=7                              #input ac voltage(mV)\n",
      "B=300                              #current gain\n",
      "\n",
      "IT=VCC/RE                         #tail current (uA)\n",
      "IE=IT/2                           #emitter current (uA)\n",
      "re=25/IE/1000                     #ac emitter resistance(Ohm)\n",
      "Av=RC/(2*re)                      #voltage gain\n",
      "Vout=Av*Vin                       #Output voltage(V)\n",
      "Zinb=2*B*re                       #input impedance of diff amp(MOhm)\n",
      "\n",
      "print 'Voltage gain Av = ',Av\n",
      "print 'Output voltage Vout = ',Vout/1000,'V'\n",
      "print 'input impedance of diff amplifier, Zin(base) = ',Zinb,'MOhm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gain Av =  150.0\n",
        "Output voltage Vout =  1.05 V\n",
        "input impedance of diff amplifier, Zin(base) =  2.0 MOhm\n"
       ]
      }
     ],
     "prompt_number": 97
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-8, Page 639"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                           #supply voltage(V)\n",
      "RC=5.0*10**3                       #collector resistance(Ohm)\n",
      "RE=7.5*10**3                       #emitter resistance(Ohm)\n",
      "RB=1*10**3                         #base resistance(Ohm)\n",
      "Vin=10                             #input ac voltage(mV)\n",
      "Av=200                             #voltage gain\n",
      "Iinb=3*10**-6                      #bias current(A)\n",
      "Iino =0.5*10**-6                   #Iin(off)  (A) \n",
      "Vino=1.0                           #Vin(off) (mV)\n",
      "\n",
      "V1err=RB*Iinb*1000                      #dc error input1 (mV)\n",
      "V2err=RB*(Iino/2)*1000                  #dc error input2 (mV)\n",
      "V3err=Vino                              #dc error input3 (mV)\n",
      "Verror=Av*(V1err+V2err+V3err)           #output error voltage(mV)\n",
      "V1err1=0                                #dc error input1 (mV)\n",
      "V2err1=RB*Iino*1000                     #dc error input2 (mV)\n",
      "V3err1=Vino                             #dc error input3 (mV)\n",
      "Verror1=Av*(V1err1+V2err1+V3err1)       #output error voltage(mV)\n",
      "\n",
      "print 'output error voltage Verror = ',Verror,'mV'\n",
      "print 'output error voltage Verror = ',Verror1,'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output error voltage Verror =  850.0 mV\n",
        "output error voltage Verror =  300.0 mV\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-9, Page 640"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                           #supply voltage(V)\n",
      "RC=1.0*10**6                       #collector resistance(Ohm)\n",
      "RE=1.0*10**6                       #emitter resistance(Ohm)\n",
      "RB=10*10**3                        #base resistance(Ohm)\n",
      "Vin=10                             #input ac voltage(mV)\n",
      "Av=300                             #voltage gain\n",
      "Iinb=80*10**-9                     #bias current(A)\n",
      "Iino=20*10**-9                     #Iin(off)  (A) \n",
      "Vino=5.0                           #Vin(off) (mV)\n",
      "\n",
      "V1err=0                                 #dc error input1 (mV)\n",
      "V2err=RB*(Iino/2)*1000                  #dc error input2 (mV)\n",
      "V3err=Vino                              #dc error input3 (mV)\n",
      "Verror=Av*(V1err+V2err+V3err)           #output error voltage(mV)\n",
      "\n",
      "print 'output error voltage Verror = ',Verror/1000,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output error voltage Verror =  1.53 V\n"
       ]
      }
     ],
     "prompt_number": 98
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-10, Page 643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                           #supply voltage(V)\n",
      "RC=1.0*10**6                       #collector resistance(Ohm)\n",
      "RE=1.0*10**6                       #emitter resistance(Ohm)\n",
      "Vin=1                              #input ac voltage(mV)\n",
      "\n",
      "Av_CM=RC/(2*RE)                    #common mode voltage gain\n",
      "Vout=Av_CM*Vin                     #output voltage(mV) \n",
      "\n",
      "print 'common mode voltage gain : Av(CM) = ',Av_CM\n",
      "print 'Output voltage Vout = ',Vout,'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "common mode voltage gain : Av(CM) =  0.5\n",
        "Output voltage Vout =  0.5 mV\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-11, Page 643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Vin=1                              #input ac voltage(mV)\n",
      "Av=150                             #voltage gain\n",
      "Av_CM=0.5                          #common mode voltage gain\n",
      "\n",
      "Vout1=Av*Vin                       #output voltage1(mV)\n",
      "Vout2=Av_CM*Vin                       #output voltage2(mV)\n",
      "Vout=Vout1+Vout2                    #output volatge(mV)\n",
      "\n",
      "print 'output voltage Vout1 = ',Vout1,'mV'\n",
      "print 'output voltage Vout2 = ',Vout2,'mV'\n",
      "print 'output voltage Vout = ',Vout,'mV'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output voltage Vout1 =  150 mV\n",
        "output voltage Vout2 =  0.5 mV\n",
        "output voltage Vout =  150.5 mV\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-12, Page 644"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "CMRR_dB=90                               #CMRR(dB)\n",
      "Av=200000                                #voltage gain\n",
      "Vin=1*10**-6                             #input voltage(V)\n",
      "\n",
      "CMRR=10**(CMRR_dB/20.0)                 #CMRR \n",
      "Av_CM=Av/CMRR                         #common mode voltage gain   \n",
      "Vout1=Av*Vin                          #desired output: voltage1(V)\n",
      "Vout2=Av_CM*Vin                       #common mode output: voltage2(V)\n",
      "\n",
      "print 'output voltage Vout1 = ',Vout1,'V'\n",
      "print 'output voltage Vout2 = ',round((Vout2*10**6),2),'uV'\n",
      "print 'see, desired output is much larger than common mode output.'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "output voltage Vout1 =  0.2 V\n",
        "output voltage Vout2 =  6.32 uV\n",
        "see, desired output is much larger than common mode output.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-13, Page 651"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "VCC=15.0                           #supply voltage(V)\n",
      "RC=7.5*10**3                       #collector resistance(Ohm)\n",
      "RE=7.5*10**3                       #emitter resistance(Ohm)\n",
      "V1=10                              #input ac voltage(mV)\n",
      "re=25                              #as per example 17-4 (Ohm)   \n",
      "RL=15*10**3                        #load resistance(KOhm)\n",
      "\n",
      "Av=RC/re                           #voltage gain\n",
      "Vout=Av*V1/1000                    #output voltage(V) \n",
      "RTH=2*RC                           #Thevenin resistance(Ohm)\n",
      "VL=(RL/(RL+RTH))*Vout              #load voltage(V)\n",
      "\n",
      "print 'Load voltage VL = ',VL,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load voltage VL =  1.5 V\n"
       ]
      }
     ],
     "prompt_number": 67
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-14, Page 652"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "RL=15.0                            #load resistance as per previous example(Ohm)\n",
      "VL=3                               #load voltage as per previous example(V)\n",
      "\n",
      "iL=VL/RL                           #load current(mA)\n",
      "\n",
      "print 'Load current iL = ',iL,'mA'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load current iL =  0.2 mA\n"
       ]
      }
     ],
     "prompt_number": 69
    }
   ],
   "metadata": {}
  }
 ]
}