{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 12: INSTRUMENT CALIBRATION"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12-1, Page Number: 355"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When scale reading is 10 V and precise voltage is 9.5 V,\n",
      "Error=- -5.0 % of reading= -0.5 % of full scale\n",
      "\n",
      "When scale reading is 50 V and precise voltage is 51.7 V,\n",
      "Error= + 3.4 % of reading= + 1.7 % of full scale\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "#For Scale reading =10 V, and precise voltage=9.5 V\n",
    "scale_reading=10                                            #Scale reading is 10 V\n",
    "\n",
    "precise_reading=9.5                                         #Precise voltage is 9.5 V\n",
    "\n",
    "error=(precise_reading-scale_reading)/scale_reading*100     #Error in percentage form w.r.t reading\n",
    "\n",
    "error_fullscale=(precise_reading-scale_reading)*100/100     #Error with respect to full scale \n",
    "\n",
    "\n",
    "print \"When scale reading is 10 V and precise voltage is 9.5 V,\"\n",
    "print \"Error=-\",round(error,1),\"% of reading=\",error_fullscale, \"% of full scale\"\n",
    "\n",
    "print \n",
    "#For Scale reading =50 V, and precise voltage=51.7 V\n",
    "scale_reading=50                                            #Scale reading is 50 V\n",
    "precise_reading=51.7                                        #Precise voltage is 51.7 V\n",
    "error=(precise_reading-scale_reading)/scale_reading*100     #Error in percentage form \n",
    "error_fullscale=(precise_reading-scale_reading)*100/100\n",
    "\n",
    "print \"When scale reading is 50 V and precise voltage is 51.7 V,\"\n",
    "print \"Error= +\",round(error,1),\"% of reading= +\",error_fullscale, \"% of full scale\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12-2, Page Number: 357"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Correction figure= -6 W\n",
      "Error= -5 %\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "V=114               #Measured Voltage in V\n",
    "I=1                 #Measured Current in A\n",
    "W=120               #Full Scale wattage in W\n",
    "\n",
    "P=V*I               #Wattmeter Power\n",
    "error=P-W           #Correction figure\n",
    "print \"Correction figure=\",error,\"W\"\n",
    "\n",
    "error=error*100/W   #Error %\n",
    "\n",
    "print \"Error=\",error,\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12-3, Page Number 361"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Therefore Vo= 5 V ± 700.0 micro volt\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "R4=1125.0\n",
    "R5=4017.9\n",
    "Vz=6.4\n",
    "accuracy=100.0/10**6           #100ppm\n",
    "\n",
    "#Calculation\n",
    "#Maximum and Minimum values of resistances in ohm\n",
    "R4max=R4*(1+accuracy)        \n",
    "R4min=R4*(1-accuracy)\n",
    "R5max=R5*(1+accuracy)\n",
    "R5min=R5*(1-accuracy)\n",
    "\n",
    "#Maximum and minimum zener voltages in V\n",
    "Vzmax=Vz+Vz*0.01/100                  #Maximum voltage is Vz+0.01% of Vz\n",
    "Vzmin=Vz-Vz*0.01/100                  #Minimum voltage is Vz-0.01% of Vz\n",
    "\n",
    "#Maximum and minimum output voltages in V\n",
    "Vomax=Vzmax*(R5max/(R4min+R5max))     #Output is maximum when Vz is maximum, R5 is minimum and R4 is maximum\n",
    "Vomin=Vzmin*(R5min/(R4max+R5min))     #Output is minimum when Vzi mimimum, R5 is maximum and R4 is minimum\n",
    "Vo=Vz*(R5/(R4+R5))\n",
    "\n",
    "error=round(Vomax-Vo,4)               #Deviation of output voltage from theoretical value \n",
    "\n",
    "#Result\n",
    "print \"Therefore Vo=\",int(Vo),\"V ±\",error*10**6,\"micro volt\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 12-4, Page Number: 364"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When the potentiometer is calibrated, I= 20.0 mA\n",
      "R1= 50.0 ohm\n",
      "\n",
      "Vx= 1.886 V\n",
      "\n",
      "The value of R2 to limit standard cell current to 20 micro ampere is  200 kilo ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "Rab=100        #Resistance of wire AB, in ohm\n",
    "Vb1=3          #Battery B1, terminal voltage(V)\n",
    "Vb2=1.0190     #Standard Cell Voltage(V) \n",
    "l=50.95        #Length BC, in cm\n",
    "\n",
    "#At Calibration\n",
    "\n",
    "Vbc=Vb2                              \n",
    "volt_per_unit_length=Vbc/l        #in V/cm\n",
    "Vab=100*volt_per_unit_length      #in V \n",
    "I=Vab/Rab                         #Ohm's Law\n",
    "Vr1=Vb1-Vab                       #KVL \n",
    "R1=Vr1/I                           \n",
    "\n",
    "#At 94.3cm\n",
    "Vx=94.3*volt_per_unit_length\n",
    "\n",
    "#Worst case: Terminal voltage of B2 or B1 may be reversed\n",
    "#Total voltage producing current flow through standard cell is\n",
    "\n",
    "Vt=Vb2+Vb1\n",
    "R2=Vt/(20*10**-6)       #Value of resistance R2 to limit standard cell current to a maximum of 20 micro ampere\n",
    "\n",
    "\n",
    "print \"When the potentiometer is calibrated, I=\",I*10**3,\"mA\"\n",
    "print \"R1=\",R1,\"ohm\"\n",
    "\n",
    "print \n",
    "print \"Vx=\",round(Vx,3),\"V\"\n",
    "print \n",
    "print \"The value of R2 to limit standard cell current to 20 micro ampere is \",int(R2*10**-3),\"kilo ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 12-5, Page Number: 367"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The instrument can measure a maximum of 1.6 V\n",
      "Instrument resolution=± 0.2 mV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "R3=509.5                   #in ohm\n",
    "R4=290.5                   #in ohm\n",
    "R13=100                    #in ohm\n",
    "l=100                      #in cm\n",
    "Vb2=1.0190                 #in V(Standard Cell Voltage)\n",
    "\n",
    "Vr3=Vb2     \n",
    "I1=Vb2/R3                  #Ohm's Law \n",
    " \n",
    "#Maximum measurable voltage:\n",
    "Vae=I1*(R3+R4)             #Maximum measurable voltage in V\n",
    "\n",
    "#Resolution\n",
    "I2=Vae/(8*R13)             #in A     \n",
    "\n",
    "Vab=I2*R13\n",
    "slidewire_vper_length=Vab/l   #in V/mm\n",
    "\n",
    "instrument_resolution=slidewire_vper_length*1  #As contact can be read within 1 mm, 1 is multiplied\n",
    "\n",
    "print \"The instrument can measure a maximum of\",Vae,\"V\"\n",
    "print \"Instrument resolution=±\",instrument_resolution*10**2,\"mV\""
   ]
  }
 ],
 "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
}