{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Chpater 3: WAVEFORM CODING TECHNIQUES

" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3,1 Page No 110" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print('This is a Theoretical example')\t" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "This is a theoretcal example\n" ] } ], "prompt_number": 104 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3,2,i, Page No 111" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math \n", "#find code word length\n", "\n", "#Variable Declaration\n", "#Given data\n", "bandwidth=4.2*10**6\n", "fm=bandwidth\n", "q=512 #Quantization levels\n", "#q=2^v\n", "\n", "#Calculation\n", "v=math.log10(512)/math.log10(2)\n", "\n", "#Result\n", "print(\"The code word legth is = %.f bits\" %v)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The code word legth is = 9 bits\n" ] } ], "prompt_number": 105 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.2.ii, Page No 111" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#find The transmission Bandwidth\n", "\n", "#Variable Declaration\n", "#Given data\n", "bandwidth=4.2*10**6\n", "fm=bandwidth\n", "q=512.0 #Quantization levels\n", "v=9.0\n", "\n", "#Calculation\n", "bw=v*fm*10**-6\n", "\n", "#Result\n", "print(\"The transmission Bandwidth is = %.1f MHz\" %bw)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The transmission Bandwidth is = 37.8 MHz\n" ] } ], "prompt_number": 106 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.2.iii, Page No 111 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#find Final Bit rate\n", "\n", "#Variable Declaration\n", "#Given data\n", "bandwidth=4.2*10**6\n", "fm=bandwidth\n", "q=512.0 #Quantization levels\n", "v=9.0\n", "\n", "#Calculation\n", "fs=2*fm\n", "r=v*fs #signaling rate\n", "\n", "#Result\n", "print(\"Final Bit rate =%.1f x 10^6 bits/sec\" %(r/(10**6)))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Final Bit rate =75.6 x 10^6 bits/sec\n" ] } ], "prompt_number": 107 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.2.iv, Page No 111" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#find Output signal to noise ratio\n", "\n", "#Variable Declaration\n", "#Given data\n", "bandwidth=4.2*10**6\n", "fm=bandwidth\n", "q=512 #Quantization levels\n", "v=9.0\n", "\n", "#Calculation\n", "sn=4.8+6*v #noise in dB\n", "\n", "\n", "print(\"Output signal to noise ratio is = %.1f dB\" %sn)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Output signal to noise ratio is = 58.8 dB\n" ] } ], "prompt_number": 108 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.3.i, Page No 112" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#find bits per sample\n", "\n", "#Variable Declaration\n", "fmax=4*10**3\n", "xmax=3.8\n", "snr=100\n", "\n", "#Calculation\n", "P=30*10**-3\n", "v=(math.log10(((snr*xmax**2)/(3*P)))/(2*math.log10(2)))\n", "\n", "#Result\n", "print(\"Number of bits required per sample are = %.2f bits\" %v)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Number of bits required per sample are = 6.98 bits\n" ] } ], "prompt_number": 109 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.3.ii, Page No 168" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Find Transmission Bandwith\n", "\n", "#Variable Declaration\n", "#Given data\n", "fm=4*10**3 #Bandwidth of PCM\n", "xmax=3.8\n", "snr=100 #Signal to Noise Ratio\n", "outputs=30.0\n", "v=7.0\n", "\n", "#Calculation\n", "bw=outputs*v*fm \n", "r=bw*2\n", "bw=bw/10**3\n", "\n", "#Result\n", "print('Transmission Bandwith R = %.f kHz' %bw)\n", "r=r/1000\n", "print('Signaling rate R = %.f bits/sec' %r)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Transmission Bandwith R = 840 kHz\n", "Signaling rate R = 1680 bits/sec\n" ] } ], "prompt_number": 110 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.4, Page No 112" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#find sampling rate,number of bits,bit rate,bandwidht\n", "\n", "#Variable Declaration\n", "#Given data\n", "emax=0.001\n", "de=2*emax\n", "fm=100.0\n", "xmax=10.0\n", "\n", "#Calculation\n", "q=(2*xmax)/de\n", "fs=2*fm\n", "v=(math.log10(q))/math.log10(2)\n", "v=math.ceil(v)\n", "r=v*fs\n", "\n", "#Result\n", "print('1. sampling Frequncy = %.f Hz ' %fs) \n", "print('2. No.of bits in PCM = %.f bits ' %v) \n", "print('3. sampling rate = %.f bits per second ' %r)\n", "r=r/2\n", "print('4. Transmission Bandwidth = %.f Hz ' %r) " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1. sampling Frequncy = 200 Hz \n", "2. No.of bits in PCM = 14 bits \n", "3. sampling rate = 2800 bits per second \n", "4. Transmission Bandwidth = 1400 Hz \n" ] } ], "prompt_number": 111 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.5, Page No 113 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Bandwidth,Sampling Rate\n", "\n", "\n", "#Variable Declaration\n", "#Given data\n", "fm=3.4*10**3\n", "N=24\n", "r=1.5*10**6\n", "encoder=8\n", "\n", "#Calculation\n", "BW=N*fm\n", "BW=BW/10**3\n", "r1=r/N\n", "fs=r1/encoder\n", "\n", "#Result\n", "print(\"i. Channel Bandwith is = %.2f kHz\" %BW)\n", "print(\"ii. Sampling frequency is = %.2f Hz or samples per second.\" %fs)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i. Channel Bandwith is = 81.60 kHz\n", "ii. Sampling frequency is = 7812.50 Hz or samples per second.\n" ] } ], "prompt_number": 112 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.6, Page No 114 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Find Signal Bandwidth,Noise Ratio\n", "\n", "#Variable Declaration\n", "#Given data\n", "v=7\n", "r=50*10**6\n", "\n", "#Calculation\n", "#fs=2*fm\n", "fm=r/(2*v)\n", "snr=1.8+(6*v);\n", "fm=fm*10**-6\n", "\n", "#Result\n", "print('i. Maximum message Bandwidth is = %.2f MHz ' %fm)\n", "print('ii. signal to quantization niose ration = %.2f dB ' %snr)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i. Maximum message Bandwidth is = 3.57 MHz \n", "ii. signal to quantization niose ration = 43.80 dB \n" ] } ], "prompt_number": 113 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.7, Page No 114" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#find i)bits per sample,ii)transmission rate\n", "\n", "#Variable Declaration\n", "#Given data\n", "fm=3*10**3\n", "q=16\n", "\n", "#Calculation\n", "v=(math.log10(q))/math.log10(2)\n", "\n", "#Result\n", "print('i) Bits in code word= %.f bits' %v)\n", "fs=2*fm\n", "r=v*fs\n", "print('ii) it trasmission rate= %.f x 10^3 bits per second' %(r/(10**3)))\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Bits in code word= 4 bits\n", "ii) it trasmission rate= 24 x 10^3 bits per second\n" ] } ], "prompt_number": 114 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.8, Page No 115" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Find signal to noise ratio\n", "\n", "#Variable Declaration\n", "#Given data\n", "fm=3.5*10**3\n", "r=50*10**3\n", "\n", "#Calculation\n", "fs=2*fm\n", "rms=0.2\n", "xmax=2\n", "v=r/fs #signaling rate r=v*fs\n", "v=math.ceil(v)\n", "P=(rms**2)/1\n", "SNR=((3*P*2**(2*v))/(xmax**2))\n", "SN=10*math.log10(SNR)\n", "SN=math.ceil(SN)\n", "\n", "#Result\n", "print(\"signal to niose ratio =%.f dB\" %SN)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "signal to niose ratio =33 dB\n" ] } ], "prompt_number": 115 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.10, Page No 117 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find i)noise ratio ii)bits\n", "\n", "#Variable Declaration\n", "#Given data\n", "Am=3.0\n", "v=10.0\n", "\n", "#Calculation\n", "SNR=1.8+6*v #noise ratio \n", "SN=40\n", "v=(SN-1.8)/6\n", "\n", "#Result\n", "print(\"i) Signal to Quantization noise ratio = %.1f dB\" %SNR)\n", "print(\"ii) Bits required to get signal to niose ratio of 40dB = %.f \" %math.ceil(v))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Signal to Quantization noise ratio = 61.8 dB\n", "ii) Bits required to get signal to niose ratio of 40dB = 7 \n" ] } ], "prompt_number": 116 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.11, Page No 117 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Maximum frequency\n", "\n", "#Variable Declaration\n", "#Given data\n", "v=7\n", "SNR=1.8+6*v\n", "r=56*10**3\n", "\n", "#Calculation\n", "fs=r/v #r=v*fs signaling rate\n", "fm=fs/2 #Nquset rate\n", "\n", "#Result\n", "fm=fm/10**3\n", "print(\"Maximum frequency is = %.f kHz\" %fm)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Maximum frequency is = 4 kHz\n" ] } ], "prompt_number": 117 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.14, Page No 129 " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Maximum Amplitude\n", "\n", "#Variable Declaration\n", "fm=3*10**3.0\n", "\n", "#Calculation\n", "Nyquistrate=2*fm #Nyquistrate\n", "fs=5*Nyquistrate #Samplingfrquency\n", "Ts=1/fs #Sampling Interval\n", "de=0.25 #step size\n", "fm1=2*10**3.0\n", "Am=de/(2*math.pi*fm1*Ts)\n", "\n", "#Result\n", "print(\"Maximum Amplitude = %.4f Volts\" %Am)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Maximum Amplitude = 0.5968 Volts\n" ] } ], "prompt_number": 118 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.16, Page No 130" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find signaling rate\n", "\n", "#Variable Declaration\n", "fs1=8*10**3.0\n", "de=31.25*10**-3\n", "q=64.0\n", "\n", "#Calculation\n", "v=math.log(q,2)\n", "r=v*fs1 #signaling rate\n", "fm=3*10**3.0\n", "A=1\n", "fs2=(2*math.pi*fm*A)/(de)\n", "\n", "#Result\n", "r=r*10**-3\n", "print(\"Signaling rate of PCM is = %.f kHz\" %r)\n", "fs2=fs2*10**-3\n", "print(\"The signaling rate of DM is = %.2f kHz\" %fs2)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Signaling rate of PCM is = 48 kHz\n", "The signaling rate of DM is = 603.19 kHz\n" ] } ], "prompt_number": 119 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.17, Page No 131" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find signal to noise ratio\n", "\n", "#Variable Declaration\n", "fs=64.0*10**3 #frequency\n", "fm=2.0*10**3 #Sinosoidal input signal sample \n", "fM=4.0*10**3 #bandwidth\n", "\n", "#Calculation\n", "SNR=(3*fs**3)/(8*math.pi**2*fm**2*fM) #Signal to noise ratio\n", "SNRO=10*math.log10(SNR)\n", "\n", "#Result\n", "print(\"Output signal to noise ratio = %.2f dB\" %SNRO)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Output signal to noise ratio = 27.94 dB\n" ] } ], "prompt_number": 120 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.18, Page No 131" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find signal to Quatization noise ratio \n", "\n", "#Variable Declaration\n", "fs=8.0*10**3 #Sampling frequency\n", "r=64.0*10**3 #Data Rate\n", "N=8 #number of bits\n", "\n", "#Calculation\n", "SNR=(1.8+6*N) #signal to Quatization noise ratio\n", "\n", "#Result\n", "print(\"Signal to Quatization noise ratio of PCM system is = %.f dB\" %SNR)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Signal to Quatization noise ratio of PCM system is = 50 dB\n" ] } ], "prompt_number": 121 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.20, Page No 149" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Find sampling rate,quantizing level\n", "\n", "#Variable Declaration\n", "r=36000\n", "fm=3.2*10**3\n", "\n", "#Calculation\n", "fs=2*fm #Nquest rate\n", "v=r/fs #r=v*fs signaling rate\n", "v=math.floor(v)\n", "q=2**v\n", "fs1=r/v\n", "\n", "#Result\n", "print(\"Quantizing level q = %.f \" %q)\n", "fs1=fs1/1000\n", "print(\"sampling rate fs = %.1f kHz \" %fs1)\n", "print(\"Number of binary digits = %.f \" %v)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Quantizing level q = 32 \n", "sampling rate fs = 7.2 kHz \n", "Number of binary digits = 5 \n" ] } ], "prompt_number": 122 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.21, Page No 149" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find time duration of 1bit binary encoded signal\n", "\n", "#Variable Declaration\n", "fs=input(\"Enter the Nyquist rate of Signal fs(Hz)=\")\n", "q=input(\"Enter the Quantization levels q =\")\n", "\n", "#Calculation\n", "v=math.log(q,2) #binary pulses transmitted per second\n", "t=1.0/(v*fs) #Nyquist interval\n", "\n", "#Result\n", "print('Time duration of binary signal t = %.4f sec ' %t)\n", "#output\n", "#Enter the Nyquist rate fs(Hz)=3\n", "#Enter the Quantization levels q =5\n", "#time duration of 1bit binary signal \n", "#t=0.1435589 sec" ], "language": "python", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter the Nyquist rate of Signal fs(Hz)=23\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter the Quantization levels q =34\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Time duration of binary signal t = 0.0085 sec \n" ] } ], "prompt_number": 123 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.23, Page No 150" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#find signal to noise ratio\n", "\n", "#Variable Declaration\n", "SNR=40\n", "SNRO=10**(SNR/10)\n", "\n", "#SNR=3(q**2)/2, Signal to Quantization noise ratio\n", "\n", "#Calculation\n", "q=math.sqrt((2*SNRO)/3)\n", "q=math.ceil(q)\n", "v=math.log(q,2) #q=2**v Quantization levels\n", "v=math.ceil(v)\n", "snr=1.76+6.02*v #output Signal to Quantization noise ratio\n", "\n", "#Result\n", "print(\"Output Signal to Quantization noise ratio = %.1f dB\" %snr)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Output Signal to Quantization noise ratio = 43.9 dB\n" ] } ], "prompt_number": 124 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.24.i, Page No 150" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Quantizing levels,minimum number of bits per sample\n", "\n", "#Variable Declaration\n", "SNRO=30.0\n", "fmin=300.0\n", "fmax=3300.0\n", "fs=80000.0\n", "\n", "#Calculation\n", "#SNRO=1.76+20log10(q)\n", "q=10**((SNRO-1.76)/20)\n", "q=math.ceil(q)\n", "v=math.log(q,2)\n", "\n", "#Result\n", "print('Quantizing levels required is =%.f' %q)\n", "print('minimum number of bits per sample are=%.1f that is approximately 5' %v)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Quantizing levels required is =26\n", "minimum number of bits per sample are=4.7 that is approximately 5\n" ] } ], "prompt_number": 125 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.24.ii, Page No 150" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find minimum required bandwidth\n", "\n", "#Variable Declaration\n", "SNRO=30.0 #Signal to quantisizing noise ratio\n", "fmin=300.0 #min frequency band\n", "fmax=3300.0 #max frequency band\n", "fs=8000.0 #Sampling rate\n", "v=5.0 #Minimum number of bits per sample\n", "\n", "#Calculation\n", "fPCM=(v*fs)/2\n", "fPCM=fPCM/1000\n", "\n", "#Result\n", "print('minimum required bandwidth =%.f kHz' %fPCM)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "minimum required bandwidth =20 kHz\n" ] } ], "prompt_number": 126 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.24.iii, Page No 150" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Quantizing levels,minimum number of bits per sample and bandwidth\n", "\n", "#Variable Declaration\n", "SNRO=30.0 #Signal to quantisizing noise ratio\n", "fmin=300.0 #min frequency band\n", "fmax=3300.0 #max frequency band\n", "fs=8000.0 #Sampling rate\n", "\n", "#Calculation\n", "q=10**((SNRO+10.1)/20)\n", "q=math.ceil(q)\n", "v=math.log(q,2)\n", "v=math.ceil(v)\n", "\n", "#Result\n", "print('Quantizing levels need is =%.f' %q)\n", "print('minimum number of bits per sample is =%.f' %v)\n", "fPCM=(v*fs)/2\n", "fPCM=fPCM/1000\n", "print('minimum required bandwidth =%.f Khz' %fPCM)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Quantizing levels need is =102\n", "minimum number of bits per sample is =7\n", "minimum required bandwidth =28 Khz\n" ] } ], "prompt_number": 127 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.27, Page No 152" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#determine the Maximum Amplitude,\n", "\n", "#Variable Declaration\n", "de=250*10**-3\n", "wm=2*math.pi*1000 \n", "fs=3*10**3\n", "Ts=1/fs\n", "\n", "#Calculation\n", "Amax=(de*3*fs*2)/(wm) #Amplitude\n", "SNR=(3.0*((3*6*(10**3))**3))/((8*(math.pi**2)*(10**3)**3))\n", "\n", "#Result\n", "print('Maximum Amplitude= %.1f mV' %(Amax*(10**2)))\n", "print('Signal to noise ratio = %.2f dB' %(10*math.log10(SNR)))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Maximum Amplitude= 71.6 mV\n", "Signal to noise ratio = 23.46 dB\n" ] } ], "prompt_number": 128 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.29, Page No 153" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of bits per sample\n", "\n", "#Variable Declaration\n", "SNR=20\n", "averagepower=30*10**-3\n", "SNRO=10**(SNR/10)\n", "A=3.8\n", "\n", "#SNRO=average signal power/Quatizing power\n", "#de=(2*A)/L\n", "\n", "#Calculation\n", "L=math.sqrt((SNRO*A**2)/(3*averagepower))\n", "n=math.log(L,2)\n", "n=math.ceil(n)\n", "\n", "#Result\n", "print('Bits required per sample =%.f' %n)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Bits required per sample =7\n" ] } ], "prompt_number": 129 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.30.i, Page No 153" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Normalized power for quantization noise\n", "\n", "#Variable Declaration\n", "fm=3.0*10.0**3\n", "v=8.0\n", "VH=5.0\n", "VL=-5.0\n", "q=2**v\n", "\n", "#Calculation\n", "de=(VH-VL)/q\n", "Nq=de**2/12.0 #quantization noise\n", "\n", "#Result\n", "print('Normalized power for quantization noise =%.2f x 10^-6 W' %(Nq*(10**6)))\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Normalized power for quantization noise =127.16 x 10^-6 W\n" ] } ], "prompt_number": 130 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.30.ii, Page No 153" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find bit transmission rate\n", "\n", "#Variable Declaration\n", "fm=3*10.0**3\n", "v=8.0\n", "VH=5.0\n", "VL=-5\n", "q=2**v\n", "\n", "#Calculation\n", "fs=2*fm #Nyquist rate\n", "r=8*fs/1000\n", "\n", "#Result\n", "print('bit transmission rate %.f K bits/s' %r)\n", " \n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "bit transmission rate 48 K bits/s\n" ] } ], "prompt_number": 131 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.30.iii, Page No 153" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Signal to quantization noise ratio\n", "\n", "#Variable Declaration\n", "Nq=127.15*10**-6\n", "Meansignal=2\n", "\n", "#Calculation\n", "P=Meansignal/1\n", "SNR=P/Nq\n", "SNRq=10*math.log10(SNR)\n", "\n", "#Result\n", "print('Signal to quantization noise ratio %.2f dB ' %SNRq)\n", " \n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Signal to quantization noise ratio 41.97 dB \n" ] } ], "prompt_number": 132 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.31, Page No 154" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find i)SNR ii)output bit rate iii)no.of bits recorded\n", "\n", "#Variable Declaration\n", "N=16.0\n", "v=16.0\n", "fs=44.1*10**3\n", "\n", "#Calculation\n", "SNR=1.76+6*N\n", "bitrate=2*v*fs\n", "outputbitrate=2*bitrate*10**-6 #including addtional 100% over head\n", "CD=outputbitrate*3600*10**-3\n", "\n", "#Result\n", "print('i)Out put signal noise ratio =%.2f dB' %SNR)\n", "print('ii)output bit rate =%.3f Mbits/sec' %outputbitrate)\n", "print('iii)no.of bits recorded in CD =%.2f gigabits' %CD)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)Out put signal noise ratio =97.76 dB\n", "ii)output bit rate =2.822 Mbits/sec\n", "iii)no.of bits recorded in CD =10.16 gigabits\n" ] } ], "prompt_number": 133 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.32, Page No 155" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find output SNR\n", "#Variable Declaration\n", "fm=1*10.0**3\n", "fs=32*10**3\n", "\n", "#Calculation\n", "FM=4*10**3 #Bandwidth\n", "SNR=(3*fs**3)/(8*math.pi**2*fm**2*FM) #SNR\n", "SNRO=10*math.log10(SNR)\n", "\n", "#Result\n", "print('Output signal to noise ratio %.2f dB' %SNRO)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Output signal to noise ratio 24.93 dB\n" ] } ], "prompt_number": 134 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.33.i, Page No 155" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find step size\n", "\n", "#Variable Declaration\n", "fs=64000.0 #samples/sec\n", "Amax=1.0 #Maximum signal amplitude\n", "fm=3500.0 #Sample Rate\n", "\n", "#Calculation\n", "de=(2*math.pi*fm*Amax)/fs*1000\n", "\n", "#Result\n", "print('Step Size %.2f mV ' %de)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Step Size 343.61 mV \n" ] } ], "prompt_number": 135 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.33ii, Page No 155" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Quantizatio noise power \n", "#Variable Declaration\n", "fs=64000.0 #sample Rate\n", "Amax=1.0 #Maximum signal Amplitude\n", "fm=3500.0\n", "\n", "#Calculation\n", "de=343.6117*10**-3 #step size\n", "Nq=de**2/3.0 #Quantizatio noise power\n", "Nqd=Nq*(fm/fs)*1000\n", "\n", "#Result\n", "print('Quantizatio noise power %.3f mW' %Nqd)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Quantizatio noise power 2.152 mW\n" ] } ], "prompt_number": 136 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.33iii, Page No 155" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find SNR\n", "\n", "#Variable Declaration\n", "fs=64000.0\n", "Amax=1.0\n", "fm=3500.0\n", "Nqd=2.1522995*10**-3\n", "\n", "#Calculation\n", "So=Amax**2/2\n", "SNR=So/Nqd\n", "SNRO=10*math.log10(SNR)\n", "\n", "#Result\n", "print('Output signal noise ratio dB %.3f dB' %SNRO)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Output signal noise ratio dB 23.661 dB\n" ] } ], "prompt_number": 137 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.34, Page No 156" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Assuming signal is sampled at the rate 20% above Nyquist rate\n", "\n", "#Variable Declaration\n", "fm=4.5*10**6\n", "q=1024.0\n", "\n", "#Calculation\n", "fs=1.2*2*fm #20% above Nyquist rate\n", "v=math.log(q,2)\n", "r=v*fs/10**6\n", "\n", "#Result\n", "print('no.of bits/sec = %.f M bit/sec' %r)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "no.of bits/sec = 108 M bit/sec\n" ] } ], "prompt_number": 138 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.35, Page No 156" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#assume bandwidth of the singal is 4kHz\n", "\n", "#Variable Declaration\n", "fs=32000.0\n", "A=2.0\n", "fm=4000.0\n", "BW=4000.0\n", "\n", "#Calculation\n", "de=(2*math.pi*fm*A)/fs\n", "Nq=de**2/3\n", "SNR=(3*fs**3)/(8*math.pi**2*fm**2*BW)\n", "\n", "#Result\n", "print('i)step size = %.3f M Volt' %de)\n", "print('ii)noise power = %.3f W' %Nq)\n", "print('iii)SNR= = %.3f ' %SNR)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)step size = 1.571 M Volt\n", "ii)noise power = 0.822 W\n", "iii)SNR= = 19.454 \n" ] } ], "prompt_number": 139 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.36, Page No 157" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#assuming signal is sampled at the rate 20% above Nyquist rate\n", "\n", "#Variable Declaration\n", "fm=15*10**3\n", "fs=1.2*2*fm\n", "q=65536\n", "\n", "#Calculation\n", "v=math.log(q,2)\n", "r=v*fs/1000\n", "BW=r/2\n", "\n", "#Result\n", "print('i)signaling rate,= %.f K bits/sec ' %r)\n", "print('ii)bandwidth BW min = %.f kHz ' %BW)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)signaling rate,= 576 K bits/sec \n", "ii)bandwidth BW min = 288 kHz \n" ] } ], "prompt_number": 140 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.37, Page No 157" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find step size,noise power\n", "\n", "#Variable Declaration\n", "fs=64*10**3\n", "fm=3500.0\n", "A=1.0\n", "\n", "#Calculation\n", "de=(2*math.pi*fm*A)/fs #step size\n", "Nq=(de**2/3)*(fm/fs) #Granular noise power\n", "\n", "#Result\n", "print('i)step size = %.3f Volts' %de)\n", "print('ii)Nq= %.5f W' %Nq)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)step size = 0.344 Volts\n", "ii)Nq= 0.00215 W\n" ] } ], "prompt_number": 141 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.40, Page No 159" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find step Nr,Transmission Bandwidth, SNR\n", "\n", "#Variable Declaration\n", "fs=4 #kHz\n", "N=12\n", "\n", "#Calculation\n", "Nr=2*fs #Nyquest rate\n", "Bt=1.0/2*N*fs #Transmission Bandwidth\n", "SNR=1.8+(6*N) \n", "\n", "\n", "#Result\n", "print('i)Nyquest rate = %.1f kHz' %Nr)\n", "print('ii)Transmission Bandwidth = %.1f kHz' %Bt)\n", "print('iii)SNR = %.1f dB' %SNR)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)Nyquest rate = 8.0 kHz\n", "ii)Transmission Bandwidth = 24.0 kHz\n", "iii)SNR = 73.8 dB\n" ] } ], "prompt_number": 142 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.41, Page No 159" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find step size,noise power\n", "\n", "#Variable Declaration\n", "fm=3.5*10**3\n", "fs=64*10**3\n", "A=2.0\n", "\n", "#Calculation\n", "de=(2*math.pi*fm*A)/fs #step size\n", "Nq=(de**2/3)*(fm/fs) #Granular noise power\n", "\n", "#Result\n", "print('i)step size = %.3f Volts' %de)\n", "print('ii)Nq= %.1f X 10^-3 W' %(Nq*10**3))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i)step size = 0.687 Volts\n", "ii)Nq= 8.6 X 10^-3 W\n" ] } ], "prompt_number": 143 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.42, Page No 159" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of binay pulse per word, Bit rate, Bandwidth\n", "\n", "#Variable Declaration\n", "W=4.5 * 10**6 #khz\n", "Nr = 2 * W #Nyquist Rate\n", "Q = 1024\n", "fs=10.8\n", "\n", "#Calculation\n", "N = math.log(Q,2) #number of binay pulse per word\n", "Br= N*fs #Bit rate\n", "Bw= 1.0/2*Br #Bandwidth\n", "\n", "#Result\n", "print('i) Number of binay pulse per word = %.1f k bits/sec' %N)\n", "print('ii) Bit rate = %.1f k bits/sec' %Br)\n", "print('iii)Bandwidth= %.1f X 10^-3 kHz' %Bw)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of binay pulse per word = 10.0 k bits/sec\n", "ii) Bit rate = 108.0 k bits/sec\n", "iii)Bandwidth= 54.0 X 10^-3 kHz\n" ] } ], "prompt_number": 144 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.43, Page No 160" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of binay pulse per word, Bit rate, Bandwidth\n", "\n", "#Variable Declaration\n", "W=15 #khz\n", "Nr = 2*W #Nyquist Rate\n", "Q = 65.53\n", "fs=44.1 # Sampling rate kHz\n", "N=16\n", "\n", "#Calculation\n", "Br= N*fs #Bit rate\n", "Bw= 1.0/2*Br #Bandwidth\n", "\n", "#Result\n", "print('i) Number of binay pulse per word = %.3f bits' %N)\n", "print('ii) Bit rate = %.1f k bits/sec' %Br)\n", "print('iii)Bandwidth= %.1f kHz' %Bw)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of binay pulse per word = 16.000 bits\n", "ii) Bit rate = 705.6 k bits/sec\n", "iii)Bandwidth= 352.8 kHz\n" ] } ], "prompt_number": 145 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.44, Page No 160" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Number of binay pulse per word\n", "\n", "#Variable Declaration\n", "W=3.3 #khz\n", "fm = 1*10**3 #kHz\n", "de = 250 #mV\n", "fs=19.8 # Sampling rate kHz\n", "\n", "#Calculation\n", "A=(de*fs)/(2*math.pi*fm)\n", "\n", "#Result\n", "print('i) Number of binay pulse per word = %.3f' %A)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of binay pulse per word = 0.788\n" ] } ], "prompt_number": 146 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.45, Page No 160" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of binay pulse per word, Signaling rate, Bandwidth\n", "\n", "#Variable Declaration\n", "W=3.3 #khz\n", "fm = 3300 #Hz\n", "Snq = 40 #dB\n", "fs= 8000 # Samples/sec\n", "\n", "#Calculation \n", "N=math.ceil((Snq-4.8)/6) # Number of bits per word\n", "Q=2**N #\n", "r=N*fs #Signaling rate k bits/sec\n", "Bw=1.0/2*r\n", "\n", "#Result\n", "print('i) Number of bits per word = %.1f' %N)\n", "print('ii) Signaling rate rate = %.1f k bits/sec' %(r/10**3))\n", "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of bits per word = 6.0\n", "ii) Signaling rate rate = 48.0 k bits/sec\n", "iii)Bandwidth= 24.0 kHz\n" ] } ], "prompt_number": 147 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.46, Page No 161" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find the maximun frequency with 1 volt amplitude\n", "\n", "#Variable Declaration\n", "de=256*10**-3 #V\n", "Ts = 10*10**-6 #kHz\n", "fm = 10 #kHz\n", "fs= 100 # kHz\n", "A=1 #V\n", "\n", "#Calculation \n", "wm=(de/A*Ts)*10**7\n", "\n", "#Result\n", "print('i) maximun frequency = %.1f X 10^3 rad/sec' %wm)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) maximun frequency = 25.6 X 10^3 rad/sec\n" ] } ], "prompt_number": 148 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.47, Page No 162" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find the Signal to noise ratio\n", "\n", "#Variable Declaration\n", "Q=256 \n", "m=255\n", "\n", "#Calculation \n", "SNR=(3*Q**2)/(math.log((1+m),math.e))**2 #dB\n", "Gc=m/(math.log(1+m)) #Companding gain\n", "Gc=20*math.log(Gc,10)\n", "\n", "#Result\n", "print('i) The Signal to noise ratio= %.1f dB' %SNR)\n", "print('ii) The Companding gain = %.1f dB' %Gc)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) The Signal to noise ratio= 6394.0 dB\n", "ii) The Companding gain = 33.3 dB\n" ] } ], "prompt_number": 149 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.48, Page No 162" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of binay pulse per word, Signaling rate, Bandwidth\n", "\n", "#Variable Declaration\n", "fm=15*10**3 #kHz\n", "Q=200\n", "fs=2*fm\n", "\n", "#Calculation \n", "N=math.ceil(math.log(Q,2))\n", "tr=N*fs #Transmission rate kbps\n", "Bw=1.0/2*tr\n", "\n", "#Result\n", "print('i) Number of bits per Samples = %.1f' %N)\n", "print('ii) Signaling rate = %.1f k bits/sec' %(tr/10**3))\n", "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of bits per Samples = 8.0\n", "ii) Signaling rate = 240.0 k bits/sec\n", "iii)Bandwidth= 120.0 kHz\n" ] } ], "prompt_number": 150 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.49, Page No 162" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find number of quantization level\n", "\n", "#Variable Declaration\n", "tr=36.0 #kbps\n", "fm=3.4 #kHz\n", "fs=8\n", "\n", "#Calculation \n", "N=math.ceil(tr/fs)\n", "Q=2**N\n", "\n", "\n", "#Result\n", "print('i) number of quantization level = %.1f' %Q)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) number of quantization level = 32.0\n" ] } ], "prompt_number": 151 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.50, Page No 162" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find delta modulation\n", "\n", "#Variable Declaration\n", "A=1 #V\n", "fm=3.4 #kHz\n", "fs=20\n", "\n", "#Calculation \n", "de=1*2*math.pi*(fm/fs)\n", "\n", "\n", "#Result\n", "print('i) delta modulation = %.2f V' %de)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) delta modulation = 1.07 V\n" ] } ], "prompt_number": 152 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.51, Page No 163" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Signal to noise ratio\n", "\n", "#Variable Declaration\n", "W=3.5 #kHz\n", "r=50.0 #kbps\n", "Vpp=4 #V\n", "fs=8\n", "\n", "#Calculation \n", "N=r/fs\n", "SNR=4.8+(6.8*N)\n", "\n", "#Result\n", "print('i) Signal to noise ratio = %.2f V' %SNR)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Signal to noise ratio = 47.30 V\n" ] } ], "prompt_number": 153 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3.52, Page No 163" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "#Find Signal to noise ratio\n", "\n", "#Variable Declaration\n", "W=1 #MHz\n", "fs1=3 #MHz\n", "fs2=2.4 #MHz\n", "Q=256\n", "m=255\n", "\n", "#Calculation \n", "SNR=((3*Q**2)/(math.log((1+m),math.e))**2)\n", "SNR1=63095.73 #SNR=38+10\n", "Q1=math.sqrt((SNR1*((math.log(256,math.e))**2))/3)\n", "N1=math.ceil(math.log(Q1,2))\n", "r=N1*fs2\n", "Bw=1.0/2*r\n", "\n", "#Result\n", "print('i) Number of bits/word = %.2f ' %N1)\n", "print('ii) Bit rate = %.1f Mb/s' %r)\n", "print('iii) Bandwidth = %.1f Mb/s' %Bw)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "i) Number of bits/word = 10.00 \n", "ii) Bit rate = 24.0 Mb/s\n", "iii) Bandwidth = 12.0 Mb/s\n" ] } ], "prompt_number": 154 } ], "metadata": {} } ] }