{
 "metadata": {
  "name": "",
  "signature": "sha256:caca8dab0d3857abcaf7d3628393a15e93a869b003e981e40fff14ea15639860"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 - Radio receivers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - pg 150"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the image frequency and rejection ratio in both cases\n",
      "import math\n",
      "from math import sqrt\n",
      "#given data\n",
      "Q = 100.#quality factor\n",
      "f_i = 455.*10**3#intermediate frequency\n",
      "\n",
      "#calculations\n",
      "#first case\n",
      "f_s = 1000.*10**3#incoming frequecy of first case\n",
      "f_si = f_s + 2*f_i#image frequency of first case\n",
      "p = (f_si/f_s) - (f_s/f_si);\n",
      "alpha = sqrt(1+(Q**2*p**2))#rejection ratio of first case\n",
      "#second case\n",
      "f_s1 = 25.*10**6#incoming frequecy of second case\n",
      "f_si1 = f_s1+ 2*f_i#image frequency of second case\n",
      "p1 = ((f_si1/f_s1) - (f_s1/f_si1)); \n",
      "alpha1 = sqrt(1+(Q**2*p1**2))#rejection ratio of second  case\n",
      "\n",
      "#results\n",
      "print \"(i)a.Image frequency of first case (kHz)\",f_si/1000.\n",
      "print \"   b.Rejection ratio of first case = \",round(alpha,1)\n",
      "print \" (ii)a.Image frequency of second case (MHz) = \",round(f_si1/10**6,2)\n",
      "print \"     b.Rejection ratio of second case = \",round(alpha1,2)\n",
      "print \"Note: Their is mistake in textbook  in the calculation of rejection ratio\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)a.Image frequency of first case (kHz) 1910.0\n",
        "   b.Rejection ratio of first case =  138.6\n",
        " (ii)a.Image frequency of second case (MHz) =  25.91\n",
        "     b.Rejection ratio of second case =  7.22\n",
        "Note: Their is mistake in textbook  in the calculation of rejection ratio\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - pg 150"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the image frequency and rejection ratio in both cases\n",
      "import math\n",
      "from math import sqrt\n",
      "#given data\n",
      "Q = 90.\n",
      "f_i = 455.*10**3#intermediate frequency\n",
      "\n",
      "#calculations\n",
      "#first case\n",
      "f_s = 950.*10**3#incoming frequency of first case\n",
      "f_si = f_s + 2*f_i#image frequency of first case\n",
      "p = (f_si/f_s) - (f_s/f_si);\n",
      "alpha = sqrt(1+(Q**2*p**2))#rejection ratio of first case\n",
      "#second case\n",
      "f_s1 = 10.*10**6#incoming frequecy of second case\n",
      "f_si1 = f_s1+ 2*f_i#image frequency of second case\n",
      "p1 = ((f_si1/f_s1) - (f_s1/f_si1)); \n",
      "alpha1 = sqrt(1+(Q**2*p1**2))#rejection ratio of second  case\n",
      "\n",
      "#results\n",
      "print \"(i)a.Image frequency of first case (kHz)\",f_si/1000.\n",
      "print \"   b.Rejection ratio of first case = \",round(alpha,1)\n",
      "print \" (ii)a.Image frequency of second case (MHz) = \",round(f_si1/10**6,2)\n",
      "print \"     b.Rejection ratio of second case = \",round(alpha1,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)a.Image frequency of first case (kHz) 1860.0\n",
        "   b.Rejection ratio of first case =  130.2\n",
        " (ii)a.Image frequency of second case (MHz) =  10.91\n",
        "     b.Rejection ratio of second case =  15.73\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - pg 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the quality factor and new intermediate frequency\n",
      "#given\n",
      "import math\n",
      "from math import sqrt\n",
      "a1 = 130.5#rejection ratio\n",
      "f_s = 10.*10**3#incoming frequency\n",
      "print (\"from fig 4.8 from t/b we can write that\")\n",
      "\n",
      "#calculations\n",
      "#first case\n",
      "alpha = 130.5#from problem 4.2 of first case\n",
      "alpha2 = 15.72#from problem 4.2 of second case\n",
      "alpha1 = alpha/alpha2#rejection ratio ofgiven RF amplifer\n",
      "p1 =.174#from problem 4.2 of second case\n",
      "Q = (sqrt(alpha1**2 - 1)/p1)#quality factor\n",
      "#second case\n",
      "p2 = 1.45#from problem 4.2 of second case\n",
      "f_si =1860.*10**3#from problem 4.2 of second case\n",
      "f_i = 950.*10**3#incoming frequency\n",
      "f_i1 = 10.*10**6#good image frequency\n",
      "f_si1 = (f_si*f_i1)/f_i; #image frequency\n",
      "f_i2 = (f_si1 - f_i1)/2#new intermediate frequency\n",
      "\n",
      "#results\n",
      "print \"(i)Quality factor =  \",round(Q,2)\n",
      "print \"(ii)New intermediate frequency (MHz) = \",round(f_i2/10**6,3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from fig 4.8 from t/b we can write that\n",
        "(i)Quality factor =   47.36\n",
        "(ii)New intermediate frequency (MHz) =  4.789\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - pg 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the local oscillator frequency and image frequency rejection ratio\n",
      "import math\n",
      "from math import sqrt\n",
      "#given\n",
      "IF = 455.*10**3#intermediate frequency in hertz\n",
      "f_s = 900.*10**3#signal frequency in hertz\n",
      "Q = 80.#quality factor\n",
      "\n",
      "#calculations\n",
      "f_0 = f_s + IF#local oscillator frequency\n",
      "f_si = f_s + 2* IF#image frequency\n",
      "p = (f_si/f_s)-(f_s/f_si)\n",
      "a = sqrt(1+(Q*p)**2)#image frequency rejection ratio\n",
      "\n",
      "#results\n",
      "print \"(i)Local oscillator frequency (kHz) = \",f_0/1000.\n",
      "print \"(ii)Image frequency (kHz) = \",f_si/1000.\n",
      "print \"(iii)Image frequency rejection ratio = \",a\n",
      "print \"Note:Their is mistake in textbook in the calculation of image frequency\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)Local oscillator frequency (kHz) =  1355.0\n",
        "(ii)Image frequency (kHz) =  1810.0\n",
        "(iii)Image frequency rejection ratio =  121.114011776\n",
        "Note:Their is mistake in textbook in the calculation of image frequency\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - pg 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the image frequency, rejection ratio\n",
      "import math\n",
      "from math import sqrt\n",
      "#given\n",
      "Q = 125. #quality factor\n",
      "\n",
      "#calculations\n",
      "#first case\n",
      "IF1 = 465.*10**3#intermediate frequency\n",
      "f_s1 = 1.*10**6#incoming frequency for first case in hertz\n",
      "f_s2 = 30.*10**6#second incoming frequency for first case in hertz\n",
      "f_si1 = f_s1 + 2*IF1#image frequency for incoming frequency 1MHz for first case\n",
      "f_si2 = f_s2 + 2*IF1#image frequency for incoming frequency 30MHz for first case\n",
      "p1 = (f_si1/f_s1)-(f_s1/f_si1);\n",
      "p2 = (f_si2/f_s2)-(f_s2/f_si2);\n",
      "alpha1 = sqrt(1+(Q*p1)**2);#rejection ratio at 1MHz incoming frequency\n",
      "alpha2 = sqrt(1+(Q*p2)**2);#rejection ratio at 30MHz incoming frequency\n",
      "#second case\n",
      "f_s3 = 1.*10**6#incoming frequency for second case in hertz\n",
      "f_si3 = (f_si1*f_s2)/f_s3#image  frequency\n",
      "IF2 =  (f_si3-f_s2)/2.#intermediate frequency\n",
      "\n",
      "#results\n",
      "print \"(i)a.Image frequency for 1MHz incoming frequency (kHz) = \",f_si1/1000.\n",
      "print \"   b.Rejection ratio for 1MHz incoming frequency = \",round(alpha1,2)\n",
      "print \"   c.Image frequency for 30MHz incoming frequency (MHz) = \",f_si2/10**6\n",
      "print \"   d.Rejection ratio for 30MHz incoming frequency =\",round(alpha2,2)\n",
      "print \"(ii)intermediate frequency for second case (Hz) = \",round(IF2/10**6,1)\n",
      "print 'The answers are a bit different from textbook due to rounding off error'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)a.Image frequency for 1MHz incoming frequency (kHz) =  1930.0\n",
        "   b.Rejection ratio for 1MHz incoming frequency =  176.49\n",
        "   c.Image frequency for 30MHz incoming frequency (MHz) =  30.93\n",
        "   d.Rejection ratio for 30MHz incoming frequency = 7.7\n",
        "(ii)intermediate frequency for second case (Hz) =  13.9\n",
        "The answers are a bit different from textbook due to rounding off error\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - pg 173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the range of local oscillator frequency and image frequency\n",
      "#given\n",
      "fs1=3 #MHz\n",
      "fs2=30 #MHz\n",
      "IF=40.525 #MHZ\n",
      "#calculations\n",
      "f01=fs1+IF\n",
      "f02=fs2+IF\n",
      "fsi1=fs1+2*IF\n",
      "fsi2=fs2+2*IF\n",
      "#results\n",
      "print 'The range of local oscillator frequency is ',f01,'MHz to',f02,'MHz'\n",
      "print 'The range of image frequency is ',fsi1,'MHz to',fsi2,'MHz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The range of local oscillator frequency is  43.525 MHz to 70.525 MHz\n",
        "The range of image frequency is  84.05 MHz to 111.05 MHz\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - pg 174"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Q factor of RF amplifier\n",
      "#given\n",
      "fr=1*10**6 #Hz\n",
      "BW=10.*10**3 #Hz\n",
      "#calculations\n",
      "Q=fr/BW\n",
      "#results\n",
      "print 'Q factor = ',Q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Q factor =  100.0\n"
       ]
      }
     ],
     "prompt_number": 13
    }
   ],
   "metadata": {}
  }
 ]
}