{
 "metadata": {
  "name": "",
  "signature": "sha256:22a4fbff9c8897e342a78bd9c8e48f9f093d2131b002f5667d92f4929ec8b5e4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter14:Operational Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 474"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate voltage gain and input and output resistance\n",
      "#given\n",
      "R1=20.*10.**3.;#ohm\n",
      "Rf=2000.*10.**3.;#ohm\n",
      "Acl=-Rf/R1;\n",
      "Ricl=R1;\n",
      "Ro=0;\n",
      "print '%s %.f %s' %(\"The voltage gain =\",Acl,\"\\n\");\n",
      "print '%s %.f %s' %(\"The input resistance =\",R1/1000,\"kohm\\n\");\n",
      "print '%s %.f %s' %(\"The output resistance =\",Ro,\"ohm\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage gain = -100 \n",
        "\n",
        "The input resistance = 20 kohm\n",
        "\n",
        "The output resistance = 0 ohm\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 474"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Find the output voltage\n",
      "#given\n",
      "R1=20.*10.**3.;#ohm\n",
      "Rf=2000.*10.**3.;#ohm\n",
      "v1=4.;#V\n",
      "v2=3.8;#V\n",
      "vo=v2*(1.+Rf/R1)-(Rf/R1)*v1;\n",
      "print '%s %.1f %s' %(\"The output voltage =\",vo,\"V\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage = -16.2 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 475"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Design an adder circuit using an op amp\n",
      "#given\n",
      "#Vo=-(V1+10*V2+100*V3)\n",
      "Rf=100.*10.**3.;#ohm\n",
      "C1=1.;#coefficient of V1\n",
      "C2=10.;#coefficient of V2\n",
      "C3=100.;#coefficient of V3\n",
      "R1=Rf/C1;\n",
      "R2=Rf/C2;\n",
      "R3=Rf/C3;\n",
      "print '%s %.f %s' %(\"R1 =\",R1/1000,\"kohm\\n\");\n",
      "print '%s %.f %s' %(\"R2 =\",R2/1000,\"kohm\\n\");\n",
      "print '%s %.f %s' %(\"R3 =\",R3/1000,\"kohm\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R1 = 100 kohm\n",
        "\n",
        "R2 = 10 kohm\n",
        "\n",
        "R3 = 1 kohm\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 484"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate CMRR in dB\n",
      "#given\n",
      "import math\n",
      "Ad=100.;#differential mode gain\n",
      "Ac=0.01;#common mode gain\n",
      "CMRR=20.*math.log10(Ad/Ac);\n",
      "print '%s %.f %s' %(\"The CMRR in dB =\",CMRR,\"dB\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The CMRR in dB = 80 dB\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 484"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the output voltage\n",
      "#given\n",
      "Ad=2000.;#differential mode gain\n",
      "CMRR=10000.;\n",
      "V1=10.**-3.;#V\n",
      "V2=0.9*10.**-3.;#V\n",
      "Vd=V1-V2;\n",
      "Vc=(V1+V2)/2.;\n",
      "Vo=Ad*Vd*(1.+Vc/(CMRR*Vd));\n",
      "print '%s %.2f %s' %(\"The output voltage is =\",Vo*1000,\"mV\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage is = 200.19 mV\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}