{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Measurement Of Resistance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.1\n",
      " : Page No - 5.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "Rh = 1000 # in ohm\n",
      "Rm = 50 # in ohm\n",
      "V = 3 # in V\n",
      "Ifsd = 1 # in mA\n",
      "Ifsd = Ifsd * 10**-3 # in A\n",
      "R1 = Rh - ( (Ifsd*Rm*Rh)/V ) # in ohm\n",
      "print \"The value of R1 = %0.2f \u03a9 \" %R1\n",
      "R2 = (Ifsd*Rm*Rh)/(V-(Ifsd*Rh)) # in ohm\n",
      "print \"The value of R2 = %0.f \u03a9 \" %R2\n",
      "# Due to 5 % drop in battery voltage, the voltage becomes\n",
      "V = V - (0.05*V) # in V\n",
      "R2 = (Ifsd*Rm*Rh)/(V-(Ifsd*Rh)) # in ohm\n",
      "print \"Maximum value of R2 = %0.3f \u03a9 \" %R2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 983.33 \u03a9 \n",
        "The value of R2 = 25 \u03a9 \n",
        "Maximum value of R2 = 27.027 \u03a9 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.2\n",
      " : Page No - 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 10 #resistance in k ohm\n",
      "R2 = 2 #resistance in k ohm\n",
      "R3 = 5 #resistance in k ohm\n",
      "Rx = (R1/R2)*R3 #value of unknown resistance in  k ohm\n",
      "print \"The value of unknown resistance = %0.F k\u03a9 \" %Rx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of unknown resistance = 25 k\u03a9 \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.3\n",
      " : Page No - 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "# Values of resistances of the circuit\n",
      "R1 = 7 # in k ohm\n",
      "R2 = 2 # in k ohm\n",
      "R3 = 4 # in k ohm\n",
      "R4 = 20 # in k ohm\n",
      "Rg = 300 # in ohm\n",
      "E = 8 # in V\n",
      "#Use Thevenin's equivalent for Ig,  V_TH=V_BD=V_AD-V_AB=( ((E/(R3+R4))*R4) - ((E/(R1+R2))*R1) ) \n",
      "V_TH = ( ((E/(R3+R4))*R4) - ((E/(R1+R2))*R1) ) # in V\n",
      "Req = ((R1*R2)/(R1+R2)) + ((R3*R4)/(R3+R4)) # in k ohm\n",
      "# Current through galvanometer \n",
      "Ig = V_TH/((Req*10**3)+Rg) # in A\n",
      "Ig = Ig * 10**6 # in \u00b5A\n",
      "print \"The current through galvanometer = %0.2F \u00b5A \" %Ig"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current through galvanometer = 85.65 \u00b5A \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.4\n",
      " : Page No - 5.27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R3 = 100.03 #standard resistance in \u00b5ohm\n",
      "R3 = R3 * 10**-6 # in ohm\n",
      "R2 = 100.24 #outer ratio arms resistance in ohm\n",
      "R1 = 200 #outer ratio arms resistance in ohm\n",
      "b = 100.31 # in ohm\n",
      "a = 200 # in ohm\n",
      "Ry = 700 # in \u00b5ohm\n",
      "Ry = Ry * 10**-6 # in ohm\n",
      "Rx = ((R1*R3)/R2) + ( ((b*Ry)/(Ry+a+b)) * ((R1/R2) - (a/b)) ) # in ohm\n",
      "Rx = Rx * 10**6 #unknown resistance in \u00b5ohm\n",
      "print \"The unknown resistance = %0.3F \u00b5\u03a9 \" %Rx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unknown resistance = 199.907 \u00b5\u03a9 \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.5\n",
      " : Page No - 5.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data'\n",
      "R1 = 100 # in ohm\n",
      "R2 = 1000 # in ohm\n",
      "R3 = 200 # in ohm\n",
      "R4 = 2000 # in ohm\n",
      "Rg = 200 # in ohm\n",
      "S = 12 # in mm/\u00b5A\n",
      "R = 5 # in ohm\n",
      "R4 = R4 + R # in ohm\n",
      "E = 10 # in V\n",
      "# By Thevenin's equivalent\n",
      "V_TH = E*( (R3/(R1+R3)) - (R4/(R2+R4)) ) # in V\n",
      "Req = ((R1*R3)/(R1+R3)) + ((R2*R4)/(R2+R4)) # in ohm\n",
      "Ig = abs(V_TH)/(Req+Rg) # in A\n",
      "Ig = Ig * 10**6 # in \u00b5A\n",
      "# S =D/I \n",
      "D = S*Ig #deflection of the galvanomter  in mm\n",
      "print \"The deflection of the galvanomter = %0.2f mm \" %D\n",
      "\n",
      "# Note:In the book the calculated value of V_TH is not correct. Correct value of V_TH is -5.546312 mV not -5.213 mV, \n",
      "#  So there is some difference between coding and the answer of the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The deflection of the galvanomter = 71.27 mm \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.6\n",
      " : Page No - 5.29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 1000 # in ohm\n",
      "R2 = 1000 # in ohm\n",
      "R3 = 121 # in ohm\n",
      "R4 = 119 # in ohm\n",
      "Rg = 200 # in ohm\n",
      "E = 5 # in V\n",
      "S = 1 # in mm/\u00b5A\n",
      "# Calculation of Thevenin's equivalent due to change in R3 and R4\n",
      "V_TH = E*( (R3/(R3+R1)) - (R4/(R4+R2)) ) # in V\n",
      "Req = ((R1*R3)/(R1+R3)) + ((R2*R4)/(R2+R4)) # in ohm\n",
      "Ig = V_TH/(Req+Rg) # in A \n",
      "Ig = Ig * 10**6 # in \u00b5A\n",
      "# S = D/I \n",
      "D = S*Ig #deflection of the galvanometer  in mm\n",
      "print \"The deflection of the galvanometer = %0.2f mm \" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The deflection of the galvanometer = 19.24 mm \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.7\n",
      " : Page No - 5.31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R = 500 # in ohm\n",
      "del_r = 20 # in ohm\n",
      "E = 10 # in V\n",
      "Rg = 125 # in ohm\n",
      "V_TH = (E*del_r)/(4*R) # in V\n",
      "Req = R # in ohm\n",
      "# The current through the galvanometer \n",
      "Ig = V_TH/(Req+Rg) # in A\n",
      "Ig = Ig * 10**6 # in \u00b5A\n",
      "print \"The current through the galvanometer = %0.f \u00b5A \" %Ig"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current through the galvanometer = 160 \u00b5A \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.8\n",
      " : Page No - 5.31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "# Rx/R2 = Rb/Ra = 1/1200 \n",
      "R1 = 10 # in ohm\n",
      "# Rx/R2= Rb/Ra= 1/1200\n",
      "R2 = R1/0.5 # in ohm\n",
      "Rx = R2/1200 #unknown resistance in ohm\n",
      "print \"The value of unknown resistance = %0.4f \u03a9 \" %Rx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of unknown resistance = 0.0167 \u03a9 \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.9\n",
      " : Page No - 5.32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 10 # in k ohm\n",
      "R2 = 10 # in k ohm\n",
      "R3 = 10 # in k ohm\n",
      "E = 10 # in V\n",
      "# R2/R_V = R1/R3 \n",
      "R_V = (R2*R3)/R1 # in k ohm\n",
      "T=80 # in \u00b0C\n",
      "Rv=9 # in k\u03a9\n",
      "# Evaluation of error voltage by Thevenin's equivalent voltage\n",
      "e = E*( (R3/(R1+R3)) - (Rv/(R2+Rv)) ) # in V\n",
      "# Evaluation of error voltage by approximation of slightly unbalanced bridge\n",
      "del_r = R_V-Rv # in k ohm\n",
      "errorVoltage = (E*del_r)/(4*R1) # in V\n",
      "print \"The temperature at which the bridge is balanced = %0.f \u00b0C \" %T\n",
      "print \"The error voltage at 60 \u00b0C by Thevenin''s voltage = %0.3f volts \" %e\n",
      "print \"The error voltage at 60 \u00b0C by approximation of slightly unbalanced bridge = %0.2f Volts is \" %errorVoltage"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The temperature at which the bridge is balanced = 80 \u00b0C \n",
        "The error voltage at 60 \u00b0C by Thevenin''s voltage = 0.263 volts \n",
        "The error voltage at 60 \u00b0C by approximation of slightly unbalanced bridge = 0.25 Volts is \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.10\n",
      " : Page No - 5.33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 120 # in ohm\n",
      "R2 = 120 # in ohm\n",
      "R3 = 120 # in ohm\n",
      "R_V = 121 # in ohm\n",
      "E_TH = 10 # in mV\n",
      "E_TH = E_TH * 10**-3 # in V\n",
      "# E_TH = E * ( (R3/(R3+R1)) - (R_V/(R_V+R2)) ) \n",
      "E = E_TH/((R3/(R3+R1)) - (R_V/(R_V+R2))) #required supply voltage  in V\n",
      "print \"The required supply voltage = %0.2f V \" %E\n",
      "R = 120 # in ohm\n",
      "del_r = R_V-R # in ohm\n",
      "# E_TH = (E*del_r)/(4*R) \n",
      "E = E_TH*4*R #The approximation of slightly unbalanced bridge  in V\n",
      "print \"The approximation of slightly unbalanced bridge = %0.1f V \" %E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required supply voltage = -4.82 V \n",
        "The approximation of slightly unbalanced bridge = 4.8 V \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.11\n",
      " : Page No - 5.35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 1000 # in ohm\n",
      "R2 = 100 # in ohm\n",
      "R3 = 4 # in k ohm\n",
      "R3 = R3*10**3 # in ohm\n",
      "#At bridge balance, R1*R3 = R2*R4 \n",
      "R4 = (R1*R3)/R2 # in ohm\n",
      "R4= R4*10**-3 #maximum unknown resistance in k ohm\n",
      "print \"The maximum unknown resistance = %0.f k\u03a9 \" %R4\n",
      "R4= R4*10**3 # in ohm\n",
      "R_TH = ((R1*R2)/(R1+R2)) + ((R3*R4)/(R3+R4)) # in ohm\n",
      "Si = 70 # in mm/\u00b5A\n",
      "Si = Si * 10**6 # in mm/A\n",
      "theta = 3 # in mm\n",
      "E = 10 # in V\n",
      "Rg = 80 # in ohm\n",
      "# theta = (Si*E*R3*del_R)/((R_TH+Rg)*((R3+R4)**2)) \n",
      "del_R = (theta*((R_TH+Rg)*((R3+R4)**2)))/(Si*E*R3) # in ohm\n",
      "print \"The value of del_R = %0.4f \u03a9 \" %del_R\n",
      "print \"This much unbalance is necessary to cause the deflection of 3 mm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum unknown resistance = 40 k\u03a9 \n",
        "The value of del_R = 7.8974 \u03a9 \n",
        "This much unbalance is necessary to cause the deflection of 3 mm\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.12\n",
      " : Page No - 5.36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#Given data\n",
      "P = 0.4 #power dissipation in each arm in W\n",
      "Rarm = 150 # in ohm\n",
      "#P = (I**2)*Rarm \n",
      "I = sqrt(P/Rarm) # in A\n",
      "#Apply KVL to the loop ABCEFA,  (-I*Rarm) - (I*Rarm) - (2*I) + 25 - (2*I*R) = 0 \n",
      "R = ((-I*Rarm) - (I*Rarm) - (2*I) + 25)/(2*I) #required series resistance in ohm\n",
      "print \"The required series resistance = %0.4f \u03a9 \" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required series resistance = 91.0615 \u03a9 \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.13\n",
      " : Page No - 5.37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 100 # in ohm\n",
      "R2 = 1000 # in ohm\n",
      "R3 = 0.00377 #standard resistance in ohm\n",
      "a = 99.92 # in ohm\n",
      "b = 1000.6 # in ohm\n",
      "Ry = 0.1 #resistance of link in ohm\n",
      "Rx =R1*R3/R2+b*Ry/(Ry+a+b)*(R1/R2-a/b) #unknown resistance in ohm\n",
      "Rx = Rx * 10**3 # in mohm\n",
      "print \"The value of unknown resistance = %0.4f m\u03a9 \" %Rx\n",
      "\n",
      "# Note: The answer will be in m\u03a9 not M\u03a9."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of unknown resistance = 0.3897 m\u03a9 \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.14\n",
      " : Page No - 5.37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "P = 10 # in ohm\n",
      "Q = 10 # in ohm\n",
      "S = 10 # in ohm\n",
      "# For first balance\n",
      "p = 30000 # in ohm\n",
      "q = 25000 # in ohm\n",
      "R_AB = (P*p)/(P+p) # in ohm\n",
      "R_BC = (Q*q)/(Q+q) # in ohm\n",
      "# R_AB*R = R_BC*S \n",
      "R = (R_BC/R_AB)*S # in ohm\n",
      "print \"The value of R for first balance = %0.3f \u03a9 \" %R\n",
      "# For second balance\n",
      "p = 15000 # in ohm\n",
      "q = 40000 # in ohm\n",
      "R_AB = (P*p)/(P+p) # in ohm\n",
      "R_BC = (Q*q)/(Q+q) # in ohm\n",
      "# R_AB*S = R_BC*R \n",
      "R = (R_AB/R_BC)*S # in ohm\n",
      "print \"The value of R for second balance = %0.4f \u03a9 \" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R for first balance = 9.999 \u03a9 \n",
        "The value of R for second balance = 9.9958 \u03a9 \n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.15\n",
      " : Page No - 5.39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "P = 1000 # in ohm\n",
      "Q = 1000 # in ohm\n",
      "p = 1000 # in ohm\n",
      "q = 1000 # in ohm\n",
      "S = 0.001 # in ohm\n",
      "R = (P/Q)*S # in ohm\n",
      "print \"The value of unknown resistance = %0.3f \u03a9 \" %R\n",
      "Rb = 5 # in ohm\n",
      "V = 100 # in V\n",
      "I = V/(Rb+R+S) # in A\n",
      "print \"The current through the unknown resistance = %0.2f A \" %I\n",
      "# Vac = ( (R+r+S)/(Rb+R+r+S) )*V \n",
      "Vac = ((R+S)/(Rb+R+S))*V # in V \n",
      "Vab = (P/(P+Q))*Vac # in V\n",
      "Vab = Vab * 10**3 # in mV\n",
      "# Vamd = (R + (Pr/(p+q+r)))/(R+S+(((p+q)*r)/(p+q+r))) \n",
      "Vamd = (R/(R+S))*Vab*10**-3 # in V\n",
      "Vamd = Vamd * 10**3 # in mV\n",
      "Vout = Vab - Vamd #output voltage in mV\n",
      "Vout = Vout*10**-3 # in V\n",
      "print \"The output voltage = %0.5f V \" %Vout\n",
      "\n",
      "# Note : The value of Vout in the book is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of unknown resistance = 0.001 \u03a9 \n",
        "The current through the unknown resistance = 19.99 A \n",
        "The output voltage = 0.01000 V \n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 5.16\n",
      " : Page No - 5.40 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R = 1000 # in ohm\n",
      "E = 20 # in V\n",
      "Ig = 0.1 # in nA\n",
      "Ig = Ig * 10**-9 # in A\n",
      "Req = R # in ohm\n",
      "#For small change in resistance, Thevenin's voltage,  V_TH = (E*del_r)/(4*R) \n",
      "# Ig = V_TH/Req \n",
      "del_r =  (Ig*4*R*R)/E #smallest change in resistance in ohm\n",
      "del_r= del_r*10**6 # in \u00b5\u03a9\n",
      "print \"The smallest change in resistance = %0.f \u00b5\u03a9 \" %del_r"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The smallest change in resistance = 20 \u00b5\u03a9 \n"
       ]
      }
     ],
     "prompt_number": 33
    }
   ],
   "metadata": {}
  }
 ]
}