{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 6: DIGITAL VOLTMETERS AND FREQUENCY METERS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Example 6-1, Page Number: 139"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum time t1 for the digital voltmeter is 1.33 ms\n",
      "Ramp Generator Frequency can be 600 Hz\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "f=1.5*10**6                  #Clock frequency in Hz\n",
    "N=1999                       #Maximum count\n",
    "\n",
    "#Calculations\n",
    "clock_time_period=1/f        #Clock time period in s\n",
    "t1=N*clock_time_period       #Maximum time in s\n",
    "t2=0.25*t1                   #Select t2=0.25*t1\n",
    "t=t1+t2                      #in s\n",
    "fr=1/t                       #in Hz \n",
    "\n",
    "#Results\n",
    "print \"Maximum time t1 for the digital voltmeter is\",round(t1*10**3,2),\"ms\"\n",
    "print \"Ramp Generator Frequency can be\",int(fr),\"Hz\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6-2, Page Number: 149"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For the analog meter,\n",
      "Voltage Error=± 0.5 V\n",
      "Error=± 2.5 %\n",
      "\n",
      "For the digital meter,\n",
      "Voltage Error=± 0.22 V\n",
      "Error=± 1.1 %\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "V=20                                             #Voltage to be measured in V\n",
    "analog_range=25                                  #Range of analog meter in V\n",
    "analog_accuracy=2.0/100                          #Accuracy of analog meter at FSD    \n",
    "\n",
    "#Calculations\n",
    "\n",
    "#Analog Instrument:\n",
    "voltage_error=analog_accuracy*analog_range        #in V\n",
    "\n",
    "error=voltage_error*100/V                         #in percentage\n",
    "\n",
    "print \"For the analog meter,\"\n",
    "print \"Voltage Error=±\",round(voltage_error,1),\"V\"\n",
    "print \"Error=±\",round(error,1),\"%\"\n",
    "\n",
    "#Digital Instrument:\n",
    "\n",
    "#For 20 V displayed on a 3 1/2 digit display\n",
    "digit=0.1                                         #in V\n",
    "digital_accuracy=0.6/100                     \n",
    "voltage_error=digital_accuracy*V+digit            #in V  \n",
    "error=voltage_error*100/V                         #in percentage \n",
    "print\n",
    "print \"For the digital meter,\"\n",
    "print \"Voltage Error=±\",round(voltage_error,2),\"V\"\n",
    "print \"Error=±\",round(error,1),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6-3, Page Number: 153"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When 6 decade counters are used,f= 1.512 kHz\n",
      "When 4 decade counters are used,f= 1.5 kHz\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "ft=1.0*10**6                  #Clock generator frequency in Hz\n",
    "fi=1.512*10**3              #Input frequency in Hz\n",
    "\n",
    "#Calculations\n",
    "#Using 6 decade counters\n",
    "d=6                         #No. of decade counters used\n",
    "f1=ft/10**d                 #Time base frequency in Hz\n",
    "t1=1/f1                     #Time period in s  \n",
    "n1=fi*t1                    #No. of cycles counted \n",
    "f=n1/t1\n",
    "\n",
    "print \"When 6 decade counters are used,f=\",round(f/1000,3),\"kHz\"\n",
    "\n",
    "#Using 4 decade counters\n",
    "d=4                         #No.of decade counters used\n",
    "f2=ft/10**d                 #Time base frequency in Hz\n",
    "t2=1/f2                     #Time period in s   \n",
    "n2=fi*t2                    #No. of cycles counted\n",
    "f=n2/t2\n",
    "\n",
    "print \"When 4 decade counters are used,f=\",round(f/1000,1),\"kHz\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6-4, Page Number: 154"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "At f=100 Hz,\n",
      "error=± 1.0 count\n",
      "%error=± 1.0 %\n",
      "\n",
      "At f=1 MHz\n",
      "error=± 2.0 count\n",
      "%error=±  2.0e-04 %\n",
      "\n",
      "At f=100 MHz,\n",
      "error=± 101.0 count\n",
      "%error=± 1.01e-04 %\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "accuracy=10**-6                                #Accuracy\n",
    "\n",
    "#At f=100 Hz\n",
    "\n",
    "f=100                                          #Frequency in Hz\n",
    "error=1+f*accuracy                             #in terms of counts\n",
    "percentage_error=error*100/f                   #in percentage\n",
    "\n",
    "print \"At f=100 Hz,\"\n",
    "print \"error=±\",round(error),\"count\"\n",
    "print \"%error=±\",round(percentage_error),\"%\"\n",
    "print\n",
    "#At f=1 MHz,\n",
    "\n",
    "f=1*10**6                                       #Frequency in Hz\n",
    "error=1+f*accuracy                              #in terms of counts\n",
    "percentage_error=error*100/f                    #in percentage\n",
    "\n",
    "print \"At f=1 MHz\"\n",
    "print \"error=±\",round(error),\"count\"\n",
    "print \"%error=± \",'%.1e' % percentage_error,\"%\"\n",
    "print\n",
    "\n",
    "#At f=100 MHz\n",
    "\n",
    "f=100*10**6                                     #Frequency in Hz \n",
    "error=1+f*accuracy                              #in terms of counts  \n",
    "percentage_error=error*100/f                    #in percentage\n",
    "print \"At f=100 MHz,\"\n",
    "print \"error=±\",round(error),\"count\"\n",
    "print \"%error=±\",'%.2e' % percentage_error,\"%\"\n",
    "print"
   ]
  }
 ],
 "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
}