{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 7: LOW, HIGH AND PRECISE RESISTANCE MEASUREMENTS\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-1, Page Number: 165"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R= 990 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "I=0.5         #in A\n",
    "E1=500        #E+Ea in V\n",
    "Ra=10         #in ohm\n",
    "\n",
    "#Calculations\n",
    "R1=E1/I       #in ohm\n",
    "R=R1-Ra       #in ohm\n",
    "\n",
    "#Result\n",
    "print \"R=\",int(R),\"ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-2, Page Number: 166"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltmeter Reading= 495.0 V\n",
      "Ammeter Reading= 0.5 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "sensitivity=10**3                             #in ohm/V\n",
    "V=1000.0                                      #in V \n",
    "R=990.0                                       #in ohm\n",
    "Ra=10.0                                       #in ohm\n",
    "supply_voltage=500                            #in V \n",
    "\n",
    "\n",
    "#Calculations\n",
    "Rv=V*sensitivity                              #in ohm\n",
    "R1=Rv*R/(Rv+R)                                #in ohm \n",
    "voltmeter_reading=supply_voltage*R1/(Ra+R1)   #in volt  \n",
    "ammeter_reading=supply_voltage/R1             #in A\n",
    "\n",
    "#Results\n",
    "print \"Voltmeter Reading=\",round(voltmeter_reading,1),\"V\"\n",
    "print \"Ammeter Reading=\",round(ammeter_reading,1),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-3, Page Number: 166"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For V=495 V,I=0.5 A, R= 990.0 ohm\n",
      "For V=500 V,I=0.5 A, R= 1000.0 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "\n",
    "#For figure 7-1(a)\n",
    "voltmeter_reading=495                 #in V\n",
    "ammeter_reading=0.5                   #in A\n",
    "R=voltmeter_reading/ammeter_reading   #in ohm\n",
    "print \"For V=495 V,I=0.5 A, R=\",R,\"ohm\"\n",
    "\n",
    "#For figure 7-1(b)\n",
    "voltmeter_reading=500                 #in V\n",
    "ammeter_reading=0.5                   #in A\n",
    "R=voltmeter_reading/ammeter_reading   #in ohm\n",
    "\n",
    "print \"For V=500 V,I=0.5 A, R=\",R,\"ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-4, Page Number: 169"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R= 2.755 kilo ohm\n",
      "Measurement Range is 500.0 ohm to  4.0 kilo ohm\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "#Bridge Resistances\n",
    "P=3.5*10**3             #in ohm\n",
    "Q=7*10**3               #in ohm\n",
    "S=5.51*10**3            #in ohm \n",
    "\n",
    "#Calculations\n",
    "\n",
    "R=S*P/Q                  #Equation for unknown resistance in a balanced bridge(ohm)\n",
    "\n",
    "#When S=1 kilo ohm\n",
    "S=1*10**3                #in ohm\n",
    "R1=S*P/Q                 #in ohm  \n",
    "\n",
    "#When S=8 kilo ohm\n",
    "S=8*10**3                #in ohm \n",
    "R2=S*P/Q                 #in ohm\n",
    "\n",
    "print \"R=\",round(R/1000,3),\"kilo ohm\"\n",
    "print \"Measurement Range is\",round(R1),\"ohm to \",round(R2/1000),\"kilo ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-5, Page Number: 169"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Error in R=± 0.2 %\n",
      "R= 2.755 kilo ohm ± 0.2 %\n",
      "R= 2.755 kilo ohm ± 5.5 %\n",
      "R= 2.7495 kilo ohm to  2.7605 kilo ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "#Bridge Resistances\n",
    "P=3.5*10**3             #in ohm\n",
    "Q=7*10**3               #in ohm\n",
    "S=5.51*10**3            #in ohm \n",
    "R=2.755*10**3           #in ohm \n",
    "p_accuracy=0.05         #in percentage \n",
    "q_accuracy=0.05         #in percentage\n",
    "s_accuracy=0.1          #in percentage \n",
    "\n",
    "#Calculation\n",
    "error_r=p_accuracy+q_accuracy+s_accuracy     #in percentage\n",
    "Rmax=R+R*error_r/100.0                       #in ohm\n",
    "Rmin=R-R*error_r/100.0                       #in ohm  \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Error in R=±\",round(error_r,1),\"%\"\n",
    "print \"R=\",round(R/1000,3),\"kilo ohm ±\",round(error_r,1),\"%\"\n",
    "print \"R=\",round(R/1000,3),\"kilo ohm ±\",round(R*error_r/100.0,1),\"%\"\n",
    "print \"R=\",round(Rmin/1000,4),\"kilo ohm to \",round(Rmax/1000,4),\"kilo ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-6, Page Number: 172"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum Change in R is 5.9 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "P=3.5*10**3                  #in ohm\n",
    "Q=7*10**3                    #in ohm\n",
    "S=4*10**3                    #in ohm\n",
    "R=2*10**3                    #in ohm\n",
    "Eb=10\n",
    "Ig=10**-6                    #in A/mm\n",
    "Rg=2.5*10**3                  #in ohm\n",
    "\n",
    "#Calculations\n",
    "r=P*R/(P+R)+Q*S/(Q+S)        #R=P||R+Q||S in ohm\n",
    "dV=Ig*(r+Rg)                 # Smallest voltage change in V  \n",
    "\n",
    "Vr=Eb*R/(P+R)                #Voltage across R(Voltage Divider Rule), in V \n",
    "V=Vr+dV                      #in V   \n",
    "Vp=Eb-V                      #KVL                  \n",
    "Ip=Vp/P                      #Ohm's Law\n",
    "Ir=Ip                \n",
    "dR=round(V,5)/round(Ir,6)-R  #in ohm\n",
    "\n",
    "\n",
    "print \"Minimum Change in R is\",round(dR,1),\"ohm\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-7, Page Number: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R/P=S/Q=  10 / 15\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "\n",
    "#Variable Declaration\n",
    "S=0.10       #in ohm\n",
    "Q=0.15       #in ohm(Approximately equal to 0.15)\n",
    "\n",
    "#Result\n",
    "print \"R/P=S/Q= \",int(S*100),\"/\",int(Q*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7-8, Page Number: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Volume resistance= 6.7e+09 ohm\n",
      "Surface resistance= 2.9e+09 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "E=10000                     #in Volt\n",
    "Iv=1.5*10**-6               #in A\n",
    "rv=E/Iv                     #Volume resistance in ohm \n",
    "\n",
    "#Surface leakage Resistance\n",
    "\n",
    "It=5*10**-6                 #in A\n",
    "Is=It-Iv                    #KCL \n",
    "rs=E/Is                     #Surface Resistance in ohm\n",
    "\n",
    "#Results\n",
    "print \"Volume resistance=\",'%.1e' %rv,\"ohm\"\n",
    "print \"Surface resistance=\",'%.1e' %rs,\"ohm\"\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}