summaryrefslogtreecommitdiff
path: root/Wireless_Communications_and_Networking_by_V._Garg/ch4.ipynb
blob: 6a6cd4166431a0676c6738782b3b8fcc1b3b1f2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
{
 "metadata": {
  "name": "",
  "signature": "sha256:d1cbcab673c40d252caf601352e39b3f6fb5df10eada02ad15211795afd1b59f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4: An Overview of Digital Communication and Transmission"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1, Page 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Fm=20;  # in KHz\n",
      "\n",
      "#Calculations\n",
      "print \"An Engineering version of the Nyquist sampling rate : fs>=2.2*fm.\"\n",
      "print 'Therefore sampling rate of >= %d ksps should be used '%(2.2*Fm); \n",
      "print \"The sampling rate for a compact disc digital audio player = 44.1 ksps and for a studio quality audio player = 48 ksps are used.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "An Engineering version of the Nyquist sampling rate : fs>=2.2*fm.\n",
        "Therefore sampling rate of >= 44 ksps should be used \n",
        "The sampling rate for a compact disc digital audio player = 44.1 ksps and for a studio quality audio player = 48 ksps are used.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2, Page 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Rt=1; #Resistance(ohm)\n",
      "#L= Number of quantization values\n",
      "L1=32;\n",
      "L2=64;\n",
      "L3=128;\n",
      "L4=256;\n",
      "\n",
      "#Calculations\n",
      "# L=2**R i.e R=math.log2(L);\n",
      "R1=math.log(L1,2);\n",
      "R2=math.log(L2,2);\n",
      "R3=math.log(L3,2);\n",
      "R4=math.log(L4,2);\n",
      "\n",
      "#P=A**2/2; #average power of signal\n",
      "#sig**2=0.333*A**2*2**(-2*Rt); #Avg quantization noise power\n",
      "#SNR=P/sig**2;\n",
      "# SNR(dB)=1.8+ 6R;\n",
      "\n",
      "SNR1=1.8+6*R1;\n",
      "SNR2=1.8+6*R2;\n",
      "SNR3=1.8+6*R3;\n",
      "SNR4=1.8+6*R4;\n",
      "\n",
      "#Result\n",
      "print 'For L=32, SNR is %.1f dB\\n '%SNR1\n",
      "print 'For L=64, SNR is %.1f dB\\n '%SNR2\n",
      "print 'For L=128, SNR is %.1f dB\\n '%SNR3\n",
      "print 'For L=256, SNR is %.1f dB\\n '%SNR4"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For L=32, SNR is 31.8 dB\n",
        " \n",
        "For L=64, SNR is 37.8 dB\n",
        " \n",
        "For L=128, SNR is 43.8 dB\n",
        " \n",
        "For L=256, SNR is 49.8 dB\n",
        " \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3, Page 99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Fs=8*10**3;  #in Hz\n",
      "Fm=3.4*10**3; # in Hz\n",
      "VCH=24; #voice channels\n",
      "SCH=1; #sunchronization channel\n",
      "PDur=1;  #extra pulse duration in microsec\n",
      "\n",
      "#Calculations&Results\n",
      "Ts=1/(Fs);\n",
      "TimeCH=Ts/(VCH+SCH)*10**6;   # in microsec\n",
      "print 'Time between the pulses is %d microsec\\n'%(TimeCH-PDur);\n",
      "#Now by using the engineering version of Nyquist rate sampling\n",
      "NyquistRate=2.2*Fm;\n",
      "Ts1_microsec=1/NyquistRate*10**6;\n",
      "Tc=round(Ts1_microsec)/(VCH+SCH);\n",
      "print \"Time between the pulses by using engineering version of Nyquist rate sampling  is %.2f microsec\\n\"%(Tc-PDur);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time between the pulses is -1 microsec\n",
        "\n",
        "Time between the pulses by using engineering version of Nyquist rate sampling  is 4.36 microsec\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4, Page 101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Fm=3000; #highest modulating frequency in signal(Hz)\n",
      "M=32; # number of pulse levels \n",
      "b=5; #bits per symbol \n",
      "p=0.01; #Quantization distortion\n",
      "\n",
      "#Calculations\n",
      "#2**R = L >= 1/2P\n",
      "# where R is the number of bits required to represent quantization levels L\n",
      "R=math.log10(1./(2*p))/math.log10(2);\n",
      "Fs=2*Fm;  # Nyquist sampling criteria (samples per second)\n",
      "fs=round(R)*Fs;\n",
      "Rs=fs/b;\n",
      "\n",
      "#Result\n",
      "print 'The minimum number of bits/sample or bits/PCM word that should be used are %d'%(round(R));\n",
      "print 'The minimum sampling rate is %d samples per second\\n '%Fs;\n",
      "print 'The resulting transmission rate is %d bps\\n '%fs;\n",
      "print 'The PCM pulse or symbol transmission rate is %d symbols/sec\\n'%Rs"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The minimum number of bits/sample or bits/PCM word that should be used are 6\n",
        "The minimum sampling rate is 6000 samples per second\n",
        " \n",
        "The resulting transmission rate is 36000 bps\n",
        " \n",
        "The PCM pulse or symbol transmission rate is 7200 symbols/sec\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5, Page 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "S_No=53.; #dB-Hz\n",
      "R=9.6*10**3; #bps\n",
      "BW=4.8*10**3; #Khz\n",
      "Pb=10**-5; #BER<=10**-5;\n",
      "\n",
      "#Calculations\n",
      "print \"Since the required data rate of 9.6 kbps is more than the available bandwidth of 4.8 kHz, the channel is bandwidth-limited.\"\n",
      "Eb_No=S_No-10*math.log10(R); #dB\n",
      "# Try for 8-PSK modulation scheme\n",
      "M=8;\n",
      "Ps=math.log(M,2)*Pb; #Max ps\n",
      "Es_No=math.log(M,2)*10**(0.1*Eb_No);\n",
      "#Ps(8)=2*Q(math.sqrt(2*Es_No)*sin(math.pi/8));\n",
      "#2*Q(math.sqrt(2*Eb_No))=erfc(math.sqrt(Eb_No));  #Refer EQn C(7) from appendix C\n",
      "\n",
      "Ps8=math.erfc(math.sqrt(Es_No)*math.sin(math.pi/8));\n",
      "\n",
      "#Result\n",
      "print 'Symbol error rate is given as %.5f \\n '%Ps\n",
      "print 'The ratio of signal energy to noise is %.2f \\n '%Es_No;\n",
      "print 'Symbol error rate for 8-PSK  is %.5f \\n '%Ps8;\n",
      "print \"As symbol error rate for 8-PSK modulation is lower than threshold value. so, We can use 8-PSK modulation.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Since the required data rate of 9.6 kbps is more than the available bandwidth of 4.8 kHz, the channel is bandwidth-limited.\n",
        "Symbol error rate is given as 0.00003 \n",
        " \n",
        "The ratio of signal energy to noise is 62.35 \n",
        " \n",
        "Symbol error rate for 8-PSK  is 0.00002 \n",
        " \n",
        "As symbol error rate for 8-PSK modulation is lower than threshold value. so, We can use 8-PSK modulation.\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6, Page 111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "SNR=48.; #dB-Hz\n",
      "BW=45.*10**3; #in Hz\n",
      "R=9.6*10**3; #bps\n",
      "Pb=10**-5; #Bit error rate\n",
      "e=2.71828; #Natural exponent e\n",
      "\n",
      "#Calculations&Results\n",
      "print \"since the available bandwidth of 45 kHz is more than adequate to support the required data rate of 9.6 kbps.\";\n",
      "print \"So, the channel is not bandwidth limited \";\n",
      "Eb_No=SNR-10*math.log10(R);\n",
      "#We try the 16-FSK modulation scheme\n",
      "M=16;\n",
      "\n",
      "Es_No=math.log(M,2)*Eb_No;\n",
      "Ps=(M-1)/2*e**(-Es_No/2);\n",
      "#For orthogonal signalling\n",
      "Ps16=(2**M-1)/(2**(M-1))*Pb;\n",
      "print \"\"\n",
      "print 'The maximum symbol error probability is %0.5f \\n '%Ps16\n",
      "print 'The symbol error probability achieved by 16-PSK is %.9f \\n '%Ps;\n",
      "print \"As achieved symbol error probability is far less than maximum tolerable value\";\n",
      "print \"So, we can meet the given speci\ufb01cations for this power-limited channel with a 16-FSK modulation scheme without any error-correction coding\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "since the available bandwidth of 45 kHz is more than adequate to support the required data rate of 9.6 kbps.\n",
        "So, the channel is not bandwidth limited \n",
        "\n",
        "The maximum symbol error probability is 0.00001 \n",
        " \n",
        "The symbol error probability achieved by 16-PSK is 0.000000553 \n",
        " \n",
        "As achieved symbol error probability is far less than maximum tolerable value\n",
        "So, we can meet the given speci\ufb01cations for this power-limited channel with a 16-FSK modulation scheme without any error-correction coding\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}