{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12: Modulation and Demodulation"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1, Page 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varibale declaration\n",
      "Vmax=8.#Vmax=maximum peak to peak value of an AM voltage\n",
      "Vmin=2.#Vmin=minimum peak to peak value of an AM voltage\n",
      "\n",
      "#Calculations&Results\n",
      "ma=(Vmax-Vmin)/(Vmax+Vmin)#ma=percentage modulation \n",
      "print \"Percentage modulation ma=%.f %%\"%(ma*100)\n",
      "#ma=(Vmax-Vmin)/(2*VC) where VC=amplitude of the unmodulated carrier\n",
      "VC=(Vmax-Vmin)/(2*ma)\n",
      "print \"Amplitude of the unmodulated carrier is VC=%.f V\"%VC\n",
      "print \"In the textbook answer given is incorrect as they have further divided by 2 which is not the part of given formula.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage modulation ma=60 %\n",
        "Amplitude of the unmodulated carrier is VC=5 V\n",
        "In the textbook answer given is incorrect as they have further divided by 2 which is not the part of given formula.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, Page 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varibale declaration\n",
      "fc=1000*(10**3)#fc=frequency of the carrier wave in Hz(hertz)\n",
      "fmin=400\n",
      "fmax=1600.#fmin and fmax represent the frequency range of audio signals by which the carrier wave is amplitude modulated.\n",
      "\n",
      "#Calculations&Results\n",
      "fs=fmax-fmin#fs=frequency span of each sideband\n",
      "print \"1.Frequency span of each sideband is %.f Hz\"%fs\n",
      "fumax=(fc+fmax)/1000#fumax=maximum upper side frequency\n",
      "print \"2.The maximum upper side frequency is %.1f kHz\"%fumax\n",
      "flmin=(fc-fmax)/1000#flmin=minimum lower side frequency\n",
      "print \"3.The minimum lower side frequency is %.1f kHz \"%flmin\n",
      "Wc=fumax-flmin#Wc=channelwidth\n",
      "print \"4.The channelwidth is %.1f kHz\"%Wc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1.Frequency span of each sideband is 1200 Hz\n",
        "2.The maximum upper side frequency is 1001.6 kHz\n",
        "3.The minimum lower side frequency is 998.4 kHz \n",
        "4.The channelwidth is 3.2 kHz\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, Page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varibale declaration\n",
      "R=100#R=load resistance in ohms\n",
      "Vc=100.#Vc=peak voltage of the carrier in volts\n",
      "ma=0.4#ma=modulation factor\n",
      "\n",
      "#Calculations&Results\n",
      "Pc=(Vc**2)/(2*R)#Pc=unmodulated carrier power developed by an AM wave\n",
      "print \"The unmodulated carrier power is Pc = %.f W\"%Pc\n",
      "Pt=Pc*(1+((ma**2)/2))#Pt=total power developed\n",
      "print \"The total power developed by the AM wave is Pt=%.f W\"%Pt\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unmodulated carrier power is Pc = 50 W\n",
        "The total power developed by the AM wave is Pt=54 W\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, Page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varibale declaration\n",
      "ma=0.5#ma=modulation factor\n",
      "Pc=20#Pc=unmodulated carrier power in kilowatts(kW)\n",
      "\n",
      "#Calculations&Results\n",
      "Ps=(1./2)*(ma**2)*Pc#Ps=total sideband power\n",
      "print \"The total sideband power is Ps=%.1f kW\"%Ps\n",
      "#modulator system efficiency is given as 70 per cent\n",
      "Pa=Ps/0.7#Pa=audio power necessary toamplitude modulate a given carrier wave\n",
      "print \"The required audio power is %.2f kW\"%Pa"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total sideband power is Ps=2.5 kW\n",
        "The required audio power is 3.57 kW\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, Page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varibale declaration\n",
      "df=30.#df=maximum frequency deviation in kilohertz(kHz)\n",
      "fm=15#fm=modulation frequency of a sinusoidal audio signal in kilohertz(kHz)\n",
      "\n",
      "#Calculations&Results\n",
      "mf=df/fm#mf=frequency modulation index\n",
      "print \"1.The modulation index is mf=%.f\"%mf\n",
      "fc=100#fc=carrier wave frequency in megahertz(MHz)\n",
      "print \"2.The three significant pairs of side frequencies are 100MHz+-15kHz(fc+-fm);100MHz+-30kHz(fc+-2fm);100MHz+-45kHz(fc+-3fm)\"\n",
      "wc=mf*3*fm#wc=channelwidth required for 3 above mentioned side frequency pairs\n",
      "print \"3.The required channelwidth is %.f kHz\"%wc\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1.The modulation index is mf=2\n",
        "2.The three significant pairs of side frequencies are 100MHz+-15kHz(fc+-fm);100MHz+-30kHz(fc+-2fm);100MHz+-45kHz(fc+-3fm)\n",
        "3.The required channelwidth is 90 kHz\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, Page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Varibale declaration\n",
      "R=0.2*(10**6)#R=load resistance in ohms in a diode detector \n",
      "C=150*(10**-12)#C=capacitance in farad in a diode detector \n",
      "\n",
      "#Calculations\n",
      "#fmh=wmh/(2*%pi)where fmh=highest modulation frequency that can be detected with tolerable distortion and wmh=corresponding angular frequency\n",
      "ma=0.5#ma=modulation factor or depth of modulation\n",
      "fmh=(1/(2*math.pi*ma*R*C))/1000\n",
      "\n",
      "#Result\n",
      "print \"The required frequency is fmh=%.2f kHz\"%fmh\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required frequency is fmh=10.61 kHz\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7, Page 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Varibale declaration\n",
      "Pc=10#Pc=unmodulated carrier power in kilowatts(kW)\n",
      "Pt=12.5#Pt=total power in kilowatts(kW)\n",
      "\n",
      "#Calculations&Results\n",
      "#Pt=Pc*(1+((ma^2)/2)) \n",
      "ma=math.sqrt(2*((Pt/Pc)-1))#ma=depth of modulation of the first signal\n",
      "print \"The depth of modulation is ma=%.3f\"%ma\n",
      "mb=0.6#mb=depth of modulation of the second signal\n",
      "PT=Pc*(1+((ma**2)/2)+((mb**2)/2))#PT=the total radiated power\n",
      "print \"The total radiated power is PT=%.1f kW\"%PT"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The depth of modulation is ma=0.707\n",
        "The total radiated power is PT=14.3 kW\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}