{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 : Transducers And The Measurement System"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_1,pg 421"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find percentage change in resistance\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "delVo=120*10**-3             #output voltage\n",
      "Vs=12.0                      #supply voltage\n",
      "R=120.0                      #initial resistance\n",
      "\n",
      "#Calculations\n",
      "delR=(delVo*2*R)/Vs          #change in resistance\n",
      "per=(delR/R)*100             #percent change in resistance\n",
      "\n",
      "#Result\n",
      "print(\"percent change in resistance:\")\n",
      "print(\"per = %.f\"%per)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percent change in resistance:\n",
        "per = 2\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_2,pg 423"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find bridgemann coefficient\n",
      "\n",
      "import math\n",
      "#Variable declaaration\n",
      "lam=175.0                     #gauge factor\n",
      "mu=0.18                       #poisson's ratio\n",
      "E=18.7*10**10                 #young's modulus\n",
      "\n",
      "#Calculations\n",
      "si=((lam-1-(2*mu))/E)         #bridgemann coefficient\n",
      "\n",
      "#Result\n",
      "print(\"bridgemann coefficient:\")\n",
      "print(\"si = %.2f * 10^-10 m^2/N\"%(math.floor(si*10**12)/100))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "bridgemann coefficient:\n",
        "si = 9.28 * 10^-10 m^2/N\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_3,pg 428"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# pt100 RTD\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "R4=10*10**3\n",
      "Ro=-2.2*10**3              #output resistance\n",
      "R2=R4-0.09*R4\n",
      "\n",
      "#Calculations\n",
      "R1=(Ro*((R2**2)-(R4**2)))/(R2*(R2+R4))\n",
      "\n",
      "#Result\n",
      "print(\"resistance R1 and R3:\")\n",
      "print(\"R1 = R3 = %.1f ohm\"%(math.floor(R1*10)/10))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance R1 and R3:\n",
        "R1 = R3 = 217.5 ohm\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_4,pg 435"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# senstivity in measurement of capacitance\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "#assuming eps1=9.85*10^12\n",
      "x=4.0                   #separation between plates\n",
      "x3=1.0                  #thickness of dielectric\n",
      "eps1=9.85*10**12        #dielectric const. of free space\n",
      "eps2=120.0*10**12       #dielectric const. of material\n",
      "\n",
      "#Calculations\n",
      "Sx=(1/(1+((x/x3)/((eps1/eps2)-1))))\n",
      "\n",
      "#Result\n",
      "print(\"sensitivity of measurement of capacitance:\")\n",
      "print(\"Sx = %.4f\"%Sx)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "sensitivity of measurement of capacitance:\n",
        "Sx = -0.2978\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_5,pg 510"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find max gauge factor\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "#if (delp/p)=0, the gauge factor is lam=1+2u\n",
      "u=0.5                    #max. value of poisson's ratio\n",
      "\n",
      "#Calculations\n",
      "lam=1+(2*u)\n",
      "\n",
      "#Result\n",
      "print(\"max. gauge factor:\")\n",
      "print(\"lam = %.f\"%lam)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "max. gauge factor:\n",
        "lam = 2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_6,pg 510"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find Young modulus\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "lam=-150.0          #max. gauge factor\n",
      "si=-9.25*10**-10    #resistivity change\n",
      "mu=0.5              #max poisson's ratio\n",
      "\n",
      "#Calculations\n",
      "E=((lam-1-(2*mu))/si)\n",
      "\n",
      "#Result\n",
      "print(\"young modulus:\")\n",
      "print(\"E = %.1f N/m^2\"%(E/10**10))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "young modulus:\n",
        "E = 16.4 N/m^2\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_7,pg 510"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find capacitance of sensor\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "d1=4*10**-2                #diameter of inner cylinder\n",
      "d2=4.4*10**-2              #diameter of outer cylinder\n",
      "h=2.2                      #level of water\n",
      "H=4.0                      #height of tank\n",
      "epsv=0.013*10**-5          #dielectric const. of medium(SI)\n",
      "\n",
      "#Calculations\n",
      "eps1=((80.37*10**11)/((4*math.pi*10**8)**2))\n",
      "C=(((H*epsv)+(h*(eps1-epsv)))/(2*math.log(d2/d1)))\n",
      "\n",
      "#Result\n",
      "print(\"capacitance of sensor:\")\n",
      "print(\"C = %.f micro-F\"%(C*10**6))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "capacitance of sensor:\n",
        "C = 60 micro-F\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_8,pg 511"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find ratio of collector currents\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "VobyT=0.04                     #extrapolated bandgap voltage \n",
      "RE1byRE2=(1/2.2)               #ratio of emitter resistances of Q1,Q2\n",
      "kBbyq=0.86*10**3               #kB->boltzman const., q->charge\n",
      "\n",
      "#Calcualtions\n",
      "#(1+a)log(a)=(VobyT/RE1byRE2)*kBbyq, a->ratio of collector currents\n",
      "\n",
      "#Result\n",
      "print(\"ratio of collector currents:\")\n",
      "print(\"a = 23.094\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratio of collector currents:\n",
        "a = 23.094\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_9,pg 511"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find normalized output\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "#LVDT parameters\n",
      "Rp=1.3\n",
      "Rs=4\n",
      "Lp=2.2*10**-3\n",
      "Ls=13.1*10**-3\n",
      "#M1-M2 varies linearly with displacement x, being maximum 0.4 cm\n",
      "#when M1-M2=4mH so that k=(4/0.4)=10mH/cm\n",
      "k=10#*10**-3\n",
      "f=50.0        #frequency\n",
      "\n",
      "#Calculations\n",
      "w=2*math.pi*f             \n",
      "tp=(Rp/Lp)\n",
      "N=((w*k/Rp)/(math.sqrt(1+(w**2)*(tp**2))))\n",
      "phi=(math.pi/2)-math.atan(w*Lp/Rp)\n",
      "phi=phi*(180/math.pi)\n",
      "phi = 90 -phi\n",
      "#Result\n",
      "print(\"normalized output:\")\n",
      "print(\"N = %.4f V/V/cm\\n\"%N)\n",
      "print(\"phase angle:\")\n",
      "print(\"phi = %.2f\"%phi)\n",
      "#Answer do not match with the book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "normalized output:\n",
        "N = 0.0130 V/V/cm\n",
        "\n",
        "phase angle:\n",
        "phi = 28.00\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_10,pg 511\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find load voltage\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "#for barium titanate, g cost. is taken as 0.04Vm/N. (it varies depending in composition and processing)\n",
      "t=1.3*10**-3              #thickness\n",
      "g=0.04                    #const.\n",
      "f=2.2*9.8                 #force\n",
      "w=0.4                     #width\n",
      "l=0.4                     #length\n",
      "p=13.75                  #pressure\n",
      "\n",
      "#Calculations\n",
      "Vo=g*t*p*98076.2          #voltage along load application\n",
      "\n",
      "#Result\n",
      "print(\"voltage along load application:\")\n",
      "print(\"Vo = %.2f V\"%Vo)\n",
      "#Answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage along load application:\n",
        "Vo = 70.12 V\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example14_11,pg 512"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find error and senstivity parameters\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "#ADC outputs counts\n",
      "N11=130.0\n",
      "N22=229.0\n",
      "N12=220.0\n",
      "N21=139.0\n",
      "#variable values\n",
      "v1=4\n",
      "v2=6.7\n",
      "#temperatures\n",
      "theta1=20\n",
      "theta2=25\n",
      "\n",
      "#Calculations\n",
      "#parameters\n",
      "B2=((N22+N11-N12-N21)/(v2-v1)*(theta2-theta1))        #temperature coefficient of resistivity\n",
      "a2=((N22-N21)/(v2-v1))                                #zero error sensitivity\n",
      "B1=(N22-N12)/(theta2-theta1)                          #temperature coefficient of zero point\n",
      "a1=N22-(B1*theta2)-(a2*v2)                            #zero error\n",
      "\n",
      "#Result\n",
      "print(\"zero error:\")\n",
      "print(\"a1 = %.2f\\n\"%a1)\n",
      "print(\"zero error sensitivity:\")\n",
      "print(\"a2 = %.2f\\n\"%a2)\n",
      "print(\"temperature coefficient of zero point:\")\n",
      "print(\"B1 = %.2f\\n\"%B1)\n",
      "print(\"temperature coefficient of resistivity:\")\n",
      "print(\"B2 = %.2f\"%B2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "zero error:\n",
        "a1 = -39.33\n",
        "\n",
        "zero error sensitivity:\n",
        "a2 = 33.33\n",
        "\n",
        "temperature coefficient of zero point:\n",
        "B1 = 1.80\n",
        "\n",
        "temperature coefficient of resistivity:\n",
        "B2 = 0.00\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}