{
 "metadata": {
  "name": "",
  "signature": "sha256:5e5e30eadf8083e86f3bfcce8a26926dfce2f385a2aaffbc34c9a0019e815666"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Part B : Chapter 1 : Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1 Page no : 1.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Av = 10;\t\t\t\t#voltage gain\n",
      "Ri = 1;\t\t\t\t#kohm\n",
      "Ro = 10;\t\t\t\t#ohm\n",
      "Vs = 2;\t\t\t\t#V(Sensor voltage)\n",
      "Rs = 100;\t\t\t\t#ohm(Sensor Resistance)\n",
      "RL = 50;\t\t\t\t#ohm\n",
      "\n",
      "# Calculations\n",
      "Vi = Vs*Ri*1000./(Rs+Ri*1000);\t\t\t\t#V\n",
      "Vo = Av*Vi*RL/(Ro+RL);\t\t\t\t#V\n",
      "\n",
      "# Results\n",
      "print \"Output voltage of amplifier(V) : %.1f\"%Vo\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage of amplifier(V) : 15.2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2 Page no : 1.11\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Av = 10;\t\t\t\t#voltage gain\n",
      "Ri = 1;\t\t\t\t#kohm\n",
      "Ro = 10;\t\t\t\t#ohm\n",
      "Vs = 2;\t\t\t\t#V(Sensor voltage)\n",
      "Rs = 100;\t\t\t\t#ohm(Sensor Resistance)\n",
      "RL = 50;\t\t\t\t#ohm\n",
      "\n",
      "# Calculations\n",
      "Vi = Vs*Ri*1000./(Rs+Ri*1000);\t\t\t\t#V\n",
      "Vo = Av*Vi*RL/(Ro+RL);\t\t\t\t#V\n",
      "Av = Vo/Vi;\t\t\t\t#voltage gain of circuit\n",
      "\n",
      "# Results\n",
      "print \"Voltage gain of circuit %.2f\"%Av\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gain of circuit 8.33\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3 Page no :1.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Av = 10.;\t\t\t\t#voltage gain\n",
      "Ro = 0.;\t\t\t\t#ohm\n",
      "Vs = 2.;\t\t\t\t#V(Sensor voltage)\n",
      "Rs = 100.;\t\t\t\t#ohm(Sensor Resistance)\n",
      "RL = 50.;\t\t\t\t#ohm\n",
      "\n",
      "# Calculations\n",
      "#Vi = Vs*Ri/(Rs+Ri) leads to Vi approximately equals to Vs as Ri = %inf\n",
      "Vi = Vs;\t\t\t\t#V\n",
      "Vo = Av*Vi*RL/(Ro+RL);\t\t\t\t#V\n",
      "\n",
      "# Results\n",
      "print \"Output voltage of amplifier(V) %.2f\"%Vo\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage of amplifier(V) 20.00\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4 page no : 1.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "VOC = 10;\t\t\t\t#V(open circuit voltage)\n",
      "#VOC = source voltage here\n",
      "R = 1.;\t\t\t\t#kohm\n",
      "\n",
      "# Calculations\n",
      "ISC = VOC/R;\t\t\t\t#mA\n",
      "\n",
      "# Results\n",
      "print \"Current generated by the circuit(mA) : %.2f\"%ISC\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current generated by the circuit(mA) : 10.00\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5 page no : 1.15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Av = 10;\t\t\t\t#voltage gain\n",
      "Ri = 1;\t\t\t\t#kohm\n",
      "Ro = 10;\t\t\t\t#ohm\n",
      "Vs = 2;\t\t\t\t#V(Sensor voltage)\n",
      "Rs = 100;\t\t\t\t#ohm(Sensor Resistance)\n",
      "RL = 50;\t\t\t\t#ohm\n",
      "\n",
      "# Calculations\n",
      "Vi = Vs*Ri*1000./(Rs+Ri*1000);\t\t\t\t#V\n",
      "Vo = Av*Vi*RL/(Ro+RL);\t\t\t\t#V\n",
      "Po = Vo**2/RL;\t\t\t\t#W\n",
      "\n",
      "# Results\n",
      "print \"Output power(W) : %.2f\"%Po\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output power(W) : 4.59\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6 page no  :1.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Av = 10.;\t\t\t\t#voltage gain\n",
      "Ri = 1.;\t\t\t\t#kohm\n",
      "Ro = 10.;\t\t\t\t#ohm\n",
      "Vs = 2.;\t\t\t\t#V(Sensor voltage)\n",
      "Rs = 100.;\t\t\t\t#ohm(Sensor Resistance)\n",
      "RL = 50.;\t\t\t\t#ohm\n",
      "\n",
      "# Calculations\n",
      "Vi = Vs*Ri*1000/(Rs+Ri*1000);\t\t\t\t#V\n",
      "Vo = Av*Vi*RL/(Ro+RL);\t\t\t\t#V\n",
      "Po = Vo**2/RL;\t\t\t\t#W\n",
      "Pi = Vi**2/Ri;\t\t\t\t#mW\n",
      "Ap = Po*1000/Pi;\t\t\t\t#Power gain\n",
      "\n",
      "# Results\n",
      "print \"Power gain : %.f\"%Ap\n",
      "\n",
      "#Answer in the book is wrong.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power gain : 1389\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7 pageno : 1.19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "Ap = 1400;\t\t\t\t#Power gain\n",
      "\n",
      "# Calculations\n",
      "Ap_dB = 10*math.log10(Ap);\t\t\t\t#dB\n",
      "\n",
      "# Results\n",
      "print \"Power gain(dB) : %.2f\"%Ap_dB\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power gain(dB) : 31.46\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8 page no :1.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "Ap1 = 5;\t\t\t\t#Power gain\n",
      "\n",
      "# Calculations and Results\n",
      "Ap1_dB = 10*math.log10(Ap1);\t\t\t\t#dB\n",
      "print \"Power gain of 5 in dB : %.f\"%Ap1_dB\n",
      "Ap2 = 50;\t\t\t\t#Power gain\n",
      "Ap2_dB = 10*math.log10(Ap2);\t\t\t\t#dB\n",
      "print \"Power gain of 50 in dB : %.f \"%Ap2_dB\n",
      "Ap3 = 500;\t\t\t\t#Power gain\n",
      "Ap3_dB = 10*math.log10(Ap3);\t\t\t\t#dB\n",
      "print \"Power gain of 500 in dB : %.f\"%Ap3_dB\n",
      "Av1 = 5;\t\t\t\t#Voltage gain\n",
      "Av1_dB = 20*math.log10(Av1);\t\t\t\t#dB\n",
      "print \"Voltage gain of 5 in dB : %.f\"%Av1_dB\n",
      "Av2 = 50;\t\t\t\t#Voltage gain\n",
      "Av2_dB = 20*math.log10(Av2);\t\t\t\t#dB\n",
      "print \"Voltage gain of 50 in dB : %.f\"%Av2_dB\n",
      "Av3 = 500;\t\t\t\t#Voltage gain\n",
      "Av3_dB = 20*math.log10(Av3);\t\t\t\t#dB\n",
      "print \"Voltage gain of 500 in dB : %.f\"%Av3_dB\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power gain of 5 in dB : 7\n",
        "Power gain of 50 in dB : 17 \n",
        "Power gain of 500 in dB : 27\n",
        "Voltage gain of 5 in dB : 14\n",
        "Voltage gain of 50 in dB : 34\n",
        "Voltage gain of 500 in dB : 54\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.10  pageno  :1.25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "C = 10.;\t\t\t\t#micro F\n",
      "R = 1.;\t\t\t\t#kohm\n",
      "\n",
      "# Calculations and Results\n",
      "T = C*10**-6*R*1000;\t\t\t\t#seconds\n",
      "print \"Time constant(seconds) : %.2f\"%T\n",
      "omega_c = 1/T;\t\t\t\t#rads/s\n",
      "print \"omega_c(rads/s) : %.2f\"%omega_c\n",
      "fc = 1./2/math.pi/T;\t\t\t\t#Hz\n",
      "print \"fc(Hz) : %.2f\"%fc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time constant(seconds) : 0.01\n",
        "omega_c(rads/s) : 100.00\n",
        "fc(Hz) : 15.92\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11 pageno : 1.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#(a)\n",
      "f = 1;\t\t\t\t#kHz\n",
      "n = 1;\t\t\t\t#no. of octave(above)\n",
      "f1 = f*2**n;\t\t\t\t#Hz\n",
      "print \"(a) An octave above 1 kHz (in kHz) =  %.2f\"%f1\n",
      "#(b)\n",
      "f = 10;\t\t\t\t#Hz\n",
      "n = 3;\t\t\t\t#no. of octave(above)\n",
      "f1 = f*2**n;\t\t\t\t#Hz\n",
      "print \"(b) Three octave above 10 Hz (in Hz) =  %.2f\"%f1\n",
      "#(c)\n",
      "f = 100.;\t\t\t\t#Hz\n",
      "n = 1.;\t\t\t\t#no. of octave(below)\n",
      "f1 = f/2**n;\t\t\t\t#Hz\n",
      "print \"(c) An octave below 100 Hz (in Hz) =  %.2f\"%f1\n",
      "#(d)\n",
      "f = 20;\t\t\t\t#kHz\n",
      "n = 1;\t\t\t\t#no. of decade(above)\n",
      "f1 = f*10**n;\t\t\t\t#Hz\n",
      "print \"(d) An decade above 20 Hz (in Hz)  =  %.2f\"%f1\n",
      "#(e)\n",
      "f = 1.;\t\t\t\t#MHz\n",
      "n = 3;\t\t\t\t#no. of decade(below)\n",
      "f1 = f/10**n;\t\t\t\t#Hz\n",
      "print \"(e) Three decade below 1 MHz (in kHz)  =  %.2f\"%(f1/1000)\n",
      "#(f)\n",
      "f = 50;\t\t\t\t#kHz\n",
      "n = 2;\t\t\t\t#no. of decade(above)\n",
      "f1 = f*10**n;\t\t\t\t#Hz\n",
      "print \"(f) Two decade above 50 Hz (in kHz)  =  %.2f\"%(f1/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) An octave above 1 kHz (in kHz) =  2.00\n",
        "(b) Three octave above 10 Hz (in Hz) =  80.00\n",
        "(c) An octave below 100 Hz (in Hz) =  50.00\n",
        "(d) An decade above 20 Hz (in Hz)  =  200.00\n",
        "(e) Three decade below 1 MHz (in kHz)  =  0.00\n",
        "(f) Two decade above 50 Hz (in kHz)  =  5.00\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12 pageno : 1.30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "C = 10.;\t\t\t\t#micro F\n",
      "R = 1.;\t\t\t\t#kohm\n",
      "\n",
      "# Calculations and Results\n",
      "T = C*10**-6*R*1000;\t\t\t\t#seconds\n",
      "print \"Time constant(seconds) : %.2f\"%T\n",
      "omega_c = 1./T;\t\t\t\t#rads/s\n",
      "print \"omega_c(rads/s) : %.2f\"%omega_c\n",
      "fc = 1./2/math.pi/T;\t\t\t\t#Hz\n",
      "print \"fc(Hz) : %.2f\"%fc\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time constant(seconds) : 0.01\n",
        "omega_c(rads/s) : 100.00\n",
        "fc(Hz) : 15.92\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13 pageno : 1.38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "Vs = 2.5;\t\t\t\t#V\n",
      "Vn = 1.0;\t\t\t\t#mV\n",
      "\n",
      "# Calculations\n",
      "SNratio = 20*math.log10(Vs/(Vn/100));\t\t\t\t#dB\n",
      "\n",
      "# Results\n",
      "print \"S/N ratio(dB) : %.f\"%SNratio\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "S/N ratio(dB) : 48\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13 page no : 1.47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "G = 100.;\t\t\t\t#stable voltage gain\n",
      "A = range(100000,200000+1);\t\t\t\t#variable gain\n",
      "\n",
      "# Calculations and Results\n",
      "B = 1./G;\t\t\t\t#Unitless\n",
      "print (\"When the gain of amplifier(A) is 100000\");\n",
      "G1 = min(A)/(1+min(A)*B);\t\t\t\t#overall gain\n",
      "print \"The overall gain(G) is :%.2f\"%G1\n",
      "print (\"When the gain of amplifier(A) is 200000\");\n",
      "G2 = max(A)/(1+max(A)*B);\t\t\t\t#overall gain\n",
      "print \"The overall gain(G) is %.2f\"%G2\n",
      "change = (G2-G1)/G*100;\t\t\t\t#% Change in gain\n",
      "print (\"Effect of variable gain :\");\n",
      "print \"Corresponding to 100%% Change in gain of active amplifier, Change in overall gain is(%%) :%.2f\"%change\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "When the gain of amplifier(A) is 100000\n",
        "The overall gain(G) is :99.90\n",
        "When the gain of amplifier(A) is 200000\n",
        "The overall gain(G) is 99.95\n",
        "Effect of variable gain :\n",
        "Corresponding to 100% Change in gain of active amplifier, Change in overall gain is(%) :0.05\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14 page no : 1.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "A = 10000.;\t\t\t\t#stable voltage gain\n",
      "B = 1/A;\t\t\t\t#unitless\n",
      "#For A = 100000;\t\t\t\t#gain\n",
      "A = 100000;\t\t\t\t#gain\n",
      "\n",
      "# Calculations and Results\n",
      "G = A/(1+A*B);\t\t\t\t#overall gain\n",
      "print \"When the gain of amplifier is 100000, Overall gain will be : %.f\"%G\n",
      "A = 200000.;\t\t\t\t#gain\n",
      "G = A/(1+A*B);\t\t\t\t#overall gain\n",
      "print \"When the gain of amplifier is 200000, Overall gain will be : %.f\"%G\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "When the gain of amplifier is 100000, Overall gain will be : 9091\n",
        "When the gain of amplifier is 200000, Overall gain will be : 9524\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}