{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6 - Oscilloscopes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - pg 6_53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "minimum rise time of pulse (ns) =  14.28\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_2,pg 6-53\n",
    "#calculate the rise time\n",
    "import math\n",
    "#given\n",
    "BW=25*10**6 #Hz\n",
    "Trd=20*10**-9 #s\n",
    "#calculations\n",
    "Tro=0.35/BW\n",
    "Trs=(Trd**2-Tro**2)**.5\n",
    "#results\n",
    "print\"minimum rise time of pulse (ns) = \",round(Trs*10**9,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 - pg 6_26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bandwidth of CRO (kHz) =  28.389\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_2,pg 6-26\n",
    "#calculate the bandwidth of CRO\n",
    "import math\n",
    "#given\n",
    "Trs=17*10**-6\n",
    "Trd=21*10**-6\n",
    "#calculations\n",
    "Tro=math.sqrt((Trd**2)-(Trs**2))\n",
    "BW=0.35/Tro\n",
    "#results\n",
    "print\"bandwidth of CRO (kHz) = \",round(BW/1000.,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 6_53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "minimum rise time of pulse (ns) =  5.0\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_2,pg 6-53\n",
    "#calculate the minimum rise time\n",
    "#given\n",
    "SR=200.*10**6#sampling rate\n",
    "#calculations\n",
    "trmin=1/SR\n",
    "#results\n",
    "print\"minimum rise time of pulse (ns) = \",round(trmin*10**9,0)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 - pg 6_63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "peak value of voltage (mV) =  5.2\n",
      "RMS value of voltage (mV) =  3.677\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_3,pg 6-63\n",
    "#calculate the amplitude, rms value of voltage\n",
    "#from plot 1 subdivision=0.2 units\n",
    "import math\n",
    "#given\n",
    "pp=2+3*0.2#positive peak\n",
    "np=2+3*0.2#negative peak\n",
    "Vd=2*10**-3#volts per division\n",
    "#calculations\n",
    "Nd=pp+np#no. of divisions\n",
    "Vpp=Nd*Vd\n",
    "Vm=Vpp/2\n",
    "Vrms=Vm/math.sqrt(2)\n",
    "#results\n",
    "print\"peak value of voltage (mV) = \",Vm*1000\n",
    "print\"RMS value of voltage (mV) = \",round(Vrms*1000,4)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 - pg 6_64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RMS value of voltage (V) =  2.1213\n",
      "frequency of voltage across resistor (Hz) =  250.0\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_4,pg 6-64\n",
    "#calculate the RMS value of voltage and frequency across resistor\n",
    "#given\n",
    "import math\n",
    "Vd=2.\n",
    "Tb=2.*10**-3#time base\n",
    "Vd=2.\n",
    "Nd=3.\n",
    "Hd=2#horizontal occupancy\n",
    "#calculations\n",
    "Vpp=Nd*Vd\n",
    "Vm=Vpp/2\n",
    "Vrms=Vm/math.sqrt(2)\n",
    "T=Tb*Hd\n",
    "f=1/T\n",
    "#results\n",
    "print\"RMS value of voltage (V) = \",round(Vrms,4)\n",
    "print\"frequency of voltage across resistor (Hz) = \",f\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 - pg 6_67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "phase difference (deg) =  53.13\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_5,pg 6-67\n",
    "#calculate the phase difference\n",
    "import math\n",
    "#given\n",
    "y1=8.\n",
    "y2=10.\n",
    "#calculation\n",
    "phi=math.asin(y1/y2)#phase difference\n",
    "phi=phi*(180/math.pi)\n",
    "#results\n",
    "print\"phase difference (deg) = \",round(phi,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 - pg 6_69"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "vertical signal frequency (kHz) =  2.5\n"
     ]
    }
   ],
   "source": [
    "#Chapter-6,Example6_6,pg 6-69\n",
    "#calculate the vertical signal frequency\n",
    "import math\n",
    "#given\n",
    "Nv=2.\n",
    "Nh=5.\n",
    "fh=1*10**3\n",
    "#calculations\n",
    "fv=(5./2)*fh#(fv/fh)=(Nh/Nv)=(5/2)\n",
    "#results\n",
    "print\"vertical signal frequency (kHz) = \",fv/1000."
   ]
  }
 ],
 "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
}