{
 "metadata": {
  "name": "",
  "signature": "sha256:784ed0940f5ca0d7641a379ee4884ada589406f7ce20917d271026274ac607a6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9: Analog Signals"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.1, Page 235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "\n",
      "Bs=4.2  #Signal Bandwidth(MHz)\n",
      "delf=2.56  #Deviation Ratio\n",
      "\n",
      "#Calculation\n",
      "\n",
      "delF=Bs*delf  #Peak Deviation(MHz)\n",
      "BIF=2*(delF+Bs)  #Signal Bandwidth(MHz)\n",
      "BIF=round(BIF,1)\n",
      "#Results\n",
      "\n",
      "print \"The peak deviation is:\" , delF,\"MHz\"\n",
      "print \"Signal Bandwidth is\" , BIF,\"MHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The peak deviation is: 10.752 MHz\n",
        "Signal Bandwidth is 29.9 MHz\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.2, Page 236"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "\n",
      "delF=200 #Peak Deviation(kHz)\n",
      "f=0.8    #Test tone frequency (kHz)\n",
      "\n",
      "#Calculation\n",
      "\n",
      "m=delF/f  #Modualtion index\n",
      "B=2*(delF+f)  #Bandwidth of the signal(kHz)\n",
      "\n",
      "#Results\n",
      "\n",
      "print \"The modulation index is\" , m\n",
      "print \"Bandwidth of the signal is\", B,\"kHz\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The modulation index is 250.0\n",
        "Bandwidth of the signal is 401.6 kHz\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3, Page 236"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "\n",
      "Bs1=4.2  #Signal Bandwidth(MHz) of Example 9.1\n",
      "delf=2.56  #Deviation Ratio of Example 9.1\n",
      "\n",
      "delF2=200 #Peak Deviation(kHz) of Example 9.2\n",
      "Bs2=0.8    #Test tone frequency (kHz) of Example 9.2\n",
      "\n",
      "#Calculation\n",
      "\n",
      "delF1=Bs1*delf  #Peak Deviation(MHz) of Example 9.1\n",
      "\n",
      "BIF1=2*(delF1+2*Bs1)  #Signal Bandwidth(MHz) of Example 9.1 according to Carson's rule\n",
      "BIF1=round(BIF1,1)\n",
      "BIF2=2*(delF2+2*Bs2)  #Signal Bandwidth(kHz) of Example 9.2 according to Carson's rule.\n",
      "\n",
      "#Results\n",
      "\n",
      "print \"Signal Bandwidth of Example 9.1 by Carson's rule is\",BIF1,\"MHz\"\n",
      "\n",
      "print \"Signal Bandwidth of Example 9.2 by Carson's rule is\",BIF2,\"kHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Signal Bandwidth of Example 9.1 by Carson's rule is 38.3 MHz\n",
        "Signal Bandwidth of Example 9.2 by Carson's rule is 403.2 kHz\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4, Page 241"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "\n",
      "delf=5 #Deviation frequency (kHz)\n",
      "Bs=1   #Test Tone Frequency (kHz)\n",
      "CNR=30  #Carrier to noise ration(dB)\n",
      "\n",
      "#Calculation\n",
      "\n",
      "m=delf/Bs  #Modulation Index\n",
      "Gp=3*(m**2)*(m+1)  #Processing gain for sinusoidal modulation\n",
      "Gp=10*math.log10(Gp) #Converting Gp into dB\n",
      "SNR=CNR+Gp\n",
      "\n",
      "Gp=round(Gp,1)\n",
      "SNR=round(SNR,1)\n",
      "\n",
      "#Results\n",
      "\n",
      "print \"The receiver processing gain is\",Gp,\"dB\"\n",
      "print \"The Signal to noise ratio is\", SNR,\"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The receiver processing gain is 26.5 dB\n",
        "The Signal to noise ratio is 56.5 dB\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.5, Page 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "\n",
      "n=24  #Number of channels\n",
      "g=13.57  #Peak/rms factor(dB)\n",
      "b=3.1  #Channel Bandwidth(kHz)\n",
      "P=4     #Emphasis improvement (dB)\n",
      "W=2.5   #Noise weighting improvement(dB)\n",
      "CNR=25  #Carrier to noise ratio (dB)\n",
      "delFrms=35  #rms value of Peak Deviation(kHz)\n",
      "fm=108    #Baseband frequency (kHz)\n",
      "#Calculation\n",
      " \n",
      "L=10**((-1+4*math.log10(n))/20)\n",
      "g=10**(g/20)  #Converting process gain to ratio\n",
      "delF=g*delFrms*L  #Peak Deviation(Hz)\n",
      "BIF=2*(delF+fm)   #Signal Bandwidth(kHz) by Carson's rule\n",
      "Gp=(BIF/b)*((delFrms/float(fm))**2)  #Processing Gain\n",
      "Gp=10*math.log10(Gp)  #Converting Gp to dB\n",
      "SNR=CNR+Gp+P+W  #Signal to noise ratio for top channel in 24-channel FDM basseband signal\n",
      "SNR=round(SNR,1)\n",
      "#Results\n",
      "\n",
      "print \"Signal to noise ratio for top channel in 24-channel FDM Baseband signal is\", SNR,\"dB\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Signal to noise ratio for top channel in 24-channel FDM Baseband signal is 45.7 dB\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.6, Page 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Variable Declaration\n",
      "\n",
      "delF=9  #Peak Deviation (MHz) \n",
      "fm=4.2  #Baseband frequency(MHz)\n",
      "SNR=62  #Signal to noise ration(dB)\n",
      "M=11.8  #Noise weighing(P)+emphasis improvement(W)-implementation margin(IMP)\n",
      "\n",
      "#Calculation\n",
      "\n",
      "D=delF/fm  #Modulation Index\n",
      "GPV=12*(D**2)*(D+1)  #Processing Gain for TV\n",
      "GPV=10*math.log10(GPV)  #Converting GPV into dB\n",
      "CNR=SNR-GPV-M   #carrier to noise ratio(dB)\n",
      "CNR=round(CNR,1)\n",
      "#Results\n",
      "\n",
      "print \"The Carrier to noise ratio required at the input of FM detector is\",CNR,\"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Carrier to noise ratio required at the input of FM detector is 27.8 dB\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}