From f270f72badd9c61d48f290c3396004802841b9df Mon Sep 17 00:00:00 2001 From: kinitrupti Date: Fri, 12 May 2017 18:53:46 +0530 Subject: Removed duplicates --- .../Chapter8.ipynb | 737 +++++++++++++++++++++ 1 file changed, 737 insertions(+) create mode 100755 Analog_and_digital_communication_by_S_Sharma/Chapter8.ipynb (limited to 'Analog_and_digital_communication_by_S_Sharma/Chapter8.ipynb') diff --git a/Analog_and_digital_communication_by_S_Sharma/Chapter8.ipynb b/Analog_and_digital_communication_by_S_Sharma/Chapter8.ipynb new file mode 100755 index 00000000..ada93f19 --- /dev/null +++ b/Analog_and_digital_communication_by_S_Sharma/Chapter8.ipynb @@ -0,0 +1,737 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:40e21dfb7d9d57e8191a618fb51fc2251d54b9cc53424ce90fa65f1447f5fe95" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8 - Waveform coding techniques" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2 - pg 386" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the transmission bandwidth and final bit rate\n", + "import math\n", + "from math import log10\n", + "#given\n", + "f_m = 4.2*10**6#bandwidth of television signal\n", + "q = 512. #quantization levels\n", + "\n", + "#calculations\n", + "#number of bits and quantization levels are related in binary PCM as q = 2^v \n", + "#where v is code word length\n", + "v = (log10(q)/log10(2));#code word length\n", + "BW = v*f_m#transmission channel bandwidth which is greater than or equal to obtained value\n", + "f_s = 2*f_m#sampling frequency which is greater than or equal to obtained value\n", + "r = v*f_s#signaling rate of final bit rate\n", + "SbyN_dB = 4.8 + 6*v#output signal to noise ratio which is less than or equal to obtained value\n", + "\n", + "#results\n", + "print \"i. Code word length (bits) = \",v\n", + "print \"ii. Transmission bandwidth (MHz) = \",round(BW/10**6,1)\n", + "print \"iii.Final bit rate (bits/sec) = \",r\n", + "print \"iv.Output signal to quantization noise ratio (dB) = \",SbyN_dB\n", + "print \"Note:There is misprint in the question i.e TV signal bandwidth \"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i. Code word length (bits) = 9.0\n", + "ii. Transmission bandwidth (MHz) = 37.8\n", + "iii.Final bit rate (bits/sec) = 75600000.0\n", + "iv.Output signal to quantization noise ratio (dB) = 58.8\n", + "Note:There is misprint in the question i.e TV signal bandwidth \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3 - pg 387" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the number of bits required, bandwidth required and signalling rate\n", + "import math\n", + "#given\n", + "f_m = 4.*10**3#maximum frequency or bans\n", + "x_max = 3.8#maximun input signal\n", + "P = 30.*10**-3#average power of signal\n", + "SbyN_dB= 20.#signal to noise ratio in db\n", + "\n", + "#calculations\n", + "SbyN = math.exp((SbyN_dB/10)*math.log(10));\n", + "v = round((math.log10((SbyN*(x_max)**2)/(3*P))/math.log10(2.)/2.));#number of bits required per sample\n", + "BW = 30*v*f_m#transmission channel bandwidth which is greater than or equal to obtained value\n", + "r=BW*2#wkt signalling rate is two times the transmission bandwidth\n", + "\n", + "#resulta\n", + "print \"i.Number of bits required (bits) = \",round(v,2)\n", + "print \"ii.Bandwidth required for 30 PCM coders (kHz) = \",round(BW/1000.,0)\n", + "print \"iii.Signalling rate (bitspersecond) = \",round(r/1000.,0)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Number of bits required (bits) = 7.0\n", + "ii.Bandwidth required for 30 PCM coders (kHz) = 840.0\n", + "iii.Signalling rate (bitspersecond) = 1680.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4 - pg 388" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the minumum sampling rate and minumum bit rate required\n", + "import math\n", + "#given\n", + "e_max = .001#maximum quantization error\n", + "x_max = 10.#maximum amplitude\n", + "x_min = -10.#minumum amplitude\n", + "f_m = 100.#bandwidth of ;input signal\n", + "\n", + "#calculations\n", + "delta = 2*e_max#step size\n", + "q = (2*x_max)/delta#quantization levels\n", + "f_s = 2*f_m#sampling frequency\n", + "v = math.ceil(math.log10(q) /math.log10(2));#number of bits in the PCM word\n", + "r = v * f_s#bit rate required in the PCM signal which is greater than or equal to obtained value\n", + "BW = .5*r#transmission channel bandwidth which is greater than or equal to obtained value\n", + "\n", + "#results\n", + "print \"i.Minimum sampling rate required (Hz) = \",f_s\n", + "print \"ii.Number of bits in each PCM word (bits) = \",round(v,2)\n", + "print \"iii.Minimum bit rate required in the PCM signal (bits/sec) = \",round(r,0)\n", + "print \"iv.Transmission bandwidth (Hz) = \",round(BW,0)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Minimum sampling rate required (Hz) = 200.0\n", + "ii.Number of bits in each PCM word (bits) = 14.0\n", + "iii.Minimum bit rate required in the PCM signal (bits/sec) = 2800.0\n", + "iv.Transmission bandwidth (Hz) = 1400.0\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5 - pg 389" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the transmission bandwidth and sampling frequency\n", + "#given\n", + "f_m = 3.4*10**3#maximum frequency in the signal\n", + "N =24.#number of voice signals\n", + "r = 1.5*10**6#signaling rate\n", + "v = 8.#bits of encoder\n", + "\n", + "#calculations\n", + "BW = N * f_m#transmission bandwidth\n", + "r_1 = r/N#bit rate for one channel\n", + "f_s = r_1/v#sampling frquency\n", + "\n", + "#results\n", + "print \"i.Transmission bandwidth (kHz) = \",BW/1000.\n", + "print \"ii.Sampling frequency (Hz or samples per second) = \",f_s\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Transmission bandwidth (kHz) = 81.6\n", + "ii.Sampling frequency (Hz or samples per second) = 7812.5\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6 - pg 389" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the maximum message bandwidth and signal to noise ratio\n", + "\n", + "#given\n", + "v = 7.#bits of encoder\n", + "r = 50.*10**6#bit rate of the system\n", + "\n", + "#calculations\n", + "f_m = r/(2*v)#maximum message bandwidth which is less than or equal to obtained value\n", + "SbyN_dB = 1.8 + 6*v#signal to noise ratio in dB\n", + "\n", + "#results\n", + "print \"i.Maximum message bandwidth (Hz) = \",round(f_m/10**6,2)\n", + "print \"ii.Signal to noise ratio when modulating frquency is 1MHz applied (dB) = \",SbyN_dB\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Maximum message bandwidth (Hz) = 3.57\n", + "ii.Signal to noise ratio when modulating frquency is 1MHz applied (dB) = 43.8\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7 - pg 390" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the Minimum sampling rate and bit transmission rate\n", + "import math\n", + "from math import log\n", + "#given\n", + "f_m = 3*10**3#maximum frequency\n", + "M = 16.#number of quantization levels\n", + "q = M #number of quantization levels\n", + "\n", + "#calculations\n", + "v = log(q)/log(2);#number of bits\n", + "f_s = 2*f_m#sampling frequency or rate which is greater than or equal to obtained value\n", + "r = v*f_s#bit transmission rate which is greater than or equal to obtained value\n", + "\n", + "#results\n", + "print \"i.Number of bits in a codeword (bits) = \",v\n", + "print \"ii.Minimum sampling rate (kHz) = \",f_s/1000.\n", + "print \"iii.Bit transmission rate (bits/sec) = \",r\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Number of bits in a codeword (bits) = 4.0\n", + "ii.Minimum sampling rate (kHz) = 6.0\n", + "iii.Bit transmission rate (bits/sec) = 24000.0\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8 - pg 391" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the signal to noise ratio\n", + "import math\n", + "from math import log10\n", + "#given\n", + "f_m = 3.5*10**3#maximum frequency\n", + "r = 50*10**3#bit rate \n", + "v_rms = .2#rms value of input signal\n", + "R = 1#resistance\n", + "x_max = 2#maximum peak voltage\n", + "\n", + "#calculations\n", + "f_s = 2*f_m;#sampling frequency\n", + "v = math.ceil(r/f_s);#number of bits\n", + "P = v_rms**2 / R#Normalized signal power\n", + "SbyN = ((3*P) * 2**(2*v)) /(x_max**2);#signal to noise ratio\n", + "SbyN_dB = 10*log10(SbyN)#signal to noise ratio in dB\n", + "\n", + "#results\n", + "print \"i.Signal to noise ratio in dB = \",round(SbyN_dB,0)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Signal to noise ratio in dB = 33.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 10 - pg 392" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the signal to noise ratio and number of bits needed\n", + "import math\n", + "#given\n", + "#x(t) = 3*cos(500*%pi*t)\n", + "v = 10.#number of bits\n", + "A_m = 3.#peak voltage\n", + "SbyN_2 = 40.#signal to noise to noise ratio in second condition\n", + "\n", + "#calculations\n", + "SbyN = 1.8 +6*v#signal to noise ratio in dB\n", + "v_2 = (40 - 1.8)/6#number of bits needed for SbyN = 40\n", + "\n", + "#results\n", + "print \"i.Signal to noise to ratio in dB \",SbyN\n", + "print \"ii.Number of bits needed for noise ratio 40 (bits) = \",math.ceil(v_2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Signal to noise to ratio in dB 61.8\n", + "ii.Number of bits needed for noise ratio 40 (bits) = 7.0\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11 - pg 393" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the maximum frequency\n", + "\n", + "#given\n", + "v = 7.#number of bits\n", + "r = 56*10**3#signaling rate\n", + "\n", + "#calculations\n", + "SbyN = 1.8 +6*v#signal to noise ratio in dB\n", + "f_s = r/v#sampling frequency\n", + "f_m = f_s/2#maximum frequency which is less than or equal to obtained value\n", + "\n", + "#results\n", + "print \"Maximum frequency (Hz) = \",f_m\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum frequency (Hz) = 4000.0\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 13 - pg 404" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the maximum amplitude\n", + "import math\n", + "#given\n", + "f_m = 3.*10**3#bandwidth or maximum frequency\n", + "n = 5.#system operation times\n", + "delta = 250.*10**-3#step size in volts\n", + "f_m1 = 2.*10**3#given maximum frequency to calculate amplitude\n", + "\n", + "#calculations\n", + "NR = 2 * f_m#nyquist rate\n", + "f_s = n * NR#sampling frequency\n", + "T_s = 1/f_s#sampling interval\n", + "A_m =(delta/(2 * math.pi * f_m1* T_s))#Maximum amplitude\n", + "\n", + "#result\n", + "print \"Maximum amplitude for 2KHz input sinusoid (V) = \",round(A_m,1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum amplitude for 2KHz input sinusoid (V) = 0.6\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 14 - pg 406" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the signalling rate\n", + "import math\n", + "from math import log\n", + "#given\n", + "f_s = 8*10**3#sampling rate\n", + "q = 64.#quantization levels\n", + "delta = 31.25#step size\n", + "\n", + "#calculations\n", + "v = log(q)/log(2);#no fo bits in the PC\n", + "f_s= (2*math.pi*3*10**3)/delta#signalling rate which should be greater than the obtaining value\n", + "\n", + "#results\n", + "print \"Signalling rate (kHz) = \",round(f_s,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signalling rate (kHz) = 603.19\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 15 - pg 407" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the signal to noise ratio\n", + "import math\n", + "#given\n", + "f_m = 2.*10**3#maximum frequency\n", + "f_s = 64.*10**3#sampling frequency\n", + "f_M = 4.*10**3#cut off frequency of low pass filter\n", + "\n", + "#calculation\n", + "SNR_0 = (3 * f_s**3) /(8 * math.pi**2 * f_m**2 * f_M);#signal to noise ratio of linear delta modulation system\n", + "SNR_dB = 10*math.log10(SNR_0);#SNR in dB\n", + "\n", + "#result\n", + "print \"Signal to noise ratio of linear delta modulation system (dB) = \",round(SNR_dB,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signal to noise ratio of linear delta modulation system (dB) = 27.94\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 16 - pg 407" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the signal to noise ratio\n", + "\n", + "#given\n", + "r = 64.*10**3#data rate\n", + "f_s = 8.*10**3#sampling frequency\n", + "N = 8.#number of samples\n", + "\n", + "#calcualtion\n", + "SNR_q = 1.8 + 6*N#signal to noise ratio\n", + "\n", + "#result\n", + "print \"Signla to noise ratio (dB) = \",SNR_q\n", + "print \"The SNR of a DM system is 27.94dB which is too poor as \\ncompared to 49.8db of an 8 bit PCM system. Thus, for all\\n the simplicity of Dm,it cannot perform as well as an\\n 8 bit PCM\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signla to noise ratio (dB) = 49.8\n", + "The SNR of a DM system is 27.94dB which is too poor as \n", + "compared to 49.8db of an 8 bit PCM system. Thus, for all\n", + " the simplicity of Dm,it cannot perform as well as an\n", + " 8 bit PCM\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 17 - pg 413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the sampling frequency and quantizing level\n", + "import math\n", + "#given\n", + "r = 36000.#bit rate of a channel\n", + "f_m = 3.2*10**3#maximum frequency\n", + "\n", + "#calculations\n", + "f_s = 2*f_m#sampling frequency\n", + "v = math.floor(r/f_s)#number of binary digits\n", + "q = 2**v#quantizing level\n", + "f_s2=r/v\n", + "#results\n", + "print \"i.Sampling frequency (Hz) = \",f_s\n", + "print \"ii.Number of binary digits = \",round(v,1)\n", + "print \"iii.Quantizing level = \",round(q,0)\n", + "print \"iv. Sampling rate (Hz) = \",f_s2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.Sampling frequency (Hz) = 6400.0\n", + "ii.Number of binary digits = 5.0\n", + "iii.Quantizing level = 32.0\n", + "iv. Sampling rate (Hz) = 7200.0\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 20 - pg 415" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the number of required levels and output signal to quantizing noise ratio\n", + "import math\n", + "from math import log, exp, sqrt\n", + "#given\n", + "SbyN_0dB = 40.#signal to noise ratio in dB\n", + "SbyN_0 = exp((SbyN_0dB/10)*log(10))#signal to noise ratio\n", + "q = sqrt((2. / 3) * (SbyN_0));#quantizing level\n", + "v = math.ceil(log(q)/log(2.))#number of binary bits\n", + "q_1 = 2**v#number of levels required \n", + "SbyN_dB1 = 1.76 + 6.02*v#output signal-to-quantizing noise ratio in dB\n", + "\n", + "#results\n", + "print \"Number of required levels = \",v\n", + "print \"Output signal-to-quantizing noise ratio (dB) = \",SbyN_dB1\n", + "print \"Note : In the textbook they took number of levels as approximation so we get change\\n in SbyN\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of required levels = 7.0\n", + "Output signal-to-quantizing noise ratio (dB) = 43.9\n", + "Note : In the textbook they took number of levels as approximation so we get change\n", + " in SbyN\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 21 - pg 416" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the minimum number of quantizing levels and bits, bandwidth required\n", + "import math\n", + "from math import log,exp,sqrt\n", + "#given\n", + "SbyN_dB = 30.#signal to noise ratio\n", + "f_s = 8000.#sampling rate\n", + "\n", + "#calculations\n", + "#for Sbyn_dB = 1.76 + 20*logq\n", + "x1 = (1./ 20)*(SbyN_dB - 1.76)\n", + "q1 = exp(x1*log(10))#quantizing level for first case\n", + "v1 = math.ceil(log(q1)/log(2))# number of bits for first case\n", + "f_PCM1 = (v1 / 2) * f_s#minimum required bandwidth for first case\n", + "#for SbyN = 20logq - 10.1\n", + "x2 = (1./20) * (SbyN_dB + 10.1)\n", + "q2 = exp(x2*log(10))#quantizing level for second case\n", + "v2 = math.ceil(log(q2)/log(2))# number of bits for second case\n", + "f_PCM2 = (v2 / 2) * f_s#minimum required bandwidth for second case\n", + "\n", + "#results\n", + "print \"i.a.Minimum number of quantizing levels for first case = \",round(q1,2)\n", + "print \" b.Number of bits for first case = \",v1\n", + "print \" c.Minimum system bandwidth required for first case (kHz) = \",f_PCM1/1000.\n", + "print \"ii.a.Minimum number of quantizing levels for second case = \",round(q2,1)\n", + "print \" b.Number of bits for second case = \",v2\n", + "print \" c.Minimum system bandwidth required for second case (kHz) = \",f_PCM2/1000.\n", + "print \"Note:In the text book they took approximation in\\nquantization levels and number bits\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i.a.Minimum number of quantizing levels for first case = 25.82\n", + " b.Number of bits for first case = 5.0\n", + " c.Minimum system bandwidth required for first case (kHz) = 20.0\n", + "ii.a.Minimum number of quantizing levels for second case = 101.2\n", + " b.Number of bits for second case = 7.0\n", + " c.Minimum system bandwidth required for second case (kHz) = 28.0\n", + "Note:In the text book they took approximation in\n", + "quantization levels and number bits\n" + ] + } + ], + "prompt_number": 19 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit