{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter No.2 : Operational Amplifier Fundamentals"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 2.1, Page No. 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Input bias and input offset current\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "Ib1 = 18*10**-6             # base current of transistor 1\n",
      "Ib2 = 22*10**-6             # base current of transistor 2\n",
      "\n",
      "#Calculations\n",
      "#(i)\n",
      "Ib = (Ib1+Ib2)/2\n",
      "#(ii)\n",
      "Iios = abs(Ib1-Ib2)\n",
      "\n",
      "#Result\n",
      "print(\"(i)  Input bias current = %d micro-A\\n(ii) Input offset current = %.0f micro-A\"%(Ib*10**6,Iios*10**6))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)  Input bias current = 20 micro-A\n",
        "(ii) Input offset current = 4 micro-A\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 2.2, Page No. 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Maximum frequency of operation\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "Vin = 3.0               # input voltage\n",
      "sr = 0.5*10**6          # slew rate in V/Sec\n",
      "\n",
      "#Calculations\n",
      "Vm = Vin/2\n",
      "fm = sr/(2*math.pi*Vm)\n",
      "fm = fm /1000 \n",
      "\n",
      "#Result\n",
      "print(\"Maximum frequency of operation is %.3f kHz\"%(math.floor(fm*1000)/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum frequency of operation is 53.051 kHz\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 2.3, Page No. 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Slew rate \n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "Icq = 15*10**-6         # Maximum op-amp current \n",
      "C = 35*10**-12          # equivalent capacitance\n",
      "V = 12.0                # input voltage \n",
      "\n",
      "#Calculations\n",
      "S = Icq/C\n",
      "S = S/10**6\n",
      "\n",
      "#Result\n",
      "print(\"Slew rate = %.4f V/micro-sec\"%(math.floor(S*10**4)/10**4))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Slew rate = 0.4285 V/micro-sec\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 2.4, Page No. 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Slew rate and maximum possible frequency of input\n",
      "\n",
      "import math\n",
      "# Variable declaration\n",
      "Icq = 10*10**-6             # maximum op-amp current\n",
      "C = 33*10**-12              # equivalent capacitance\n",
      "V = 12                      # peak value of input voltage\n",
      "\n",
      "\n",
      "#Calculations\n",
      "S = Icq/C\n",
      "fm = S/(2*math.pi*V)\n",
      "\n",
      "#Result\n",
      "print(\"Slew rate = %.3f V/micro-sec\\nfm        = %.3f kHz\"%(S/10**6,fm/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Slew rate = 0.303 V/micro-sec\n",
        "fm        = 4.019 kHz\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 2.5, Page No. 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Common mode rejection ratio(refere to fig 2.24)\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "R1 = 1000.0            # resistance 1\n",
      "R2_1_E = 90000.0       # resistance R2(1-E)\n",
      "R2 = 100000.0          # resistance R2\n",
      "\n",
      "#Calculations\n",
      "Aid = R2/R1\n",
      "E = 1-(R2_1_E/R2)\n",
      "Acm = R2*E/(R1+R2)\n",
      "CMRR = Aid/Acm\n",
      "CMRR = 20*math.log10(CMRR)\n",
      "\n",
      "#Result\n",
      "print(\"CMRR = %d dB\"%CMRR)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CMRR = 60 dB\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}