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
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 7 : Digital Communication"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 : pg 285"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"maximum data rate for four-level code in the available bandwidth 12.8 kb/s\n",
"maximum data rate for four-level code in the available bandwidth 37.21 kb/s\n"
]
}
],
"source": [
" \n",
"#page no 285\n",
"#prob no 7.1\n",
"#calculate the max data rate in both cases\n",
"from math import log\n",
"# In the given problem a signal is transmitted using a four level code\n",
"#given\n",
"M=4.;\n",
"B=3.2;# in KKz\n",
"SNR=35.;#in dB\n",
"#calculations and results\n",
"#By using Shannon-Hartley theorem, ignoring noise we have\n",
"c=2*B*log(M) / log(2);\n",
"print 'maximum data rate for four-level code in the available bandwidth',c,'kb/s'\n",
"#Now we have to use Shannon limit to find the maximum data rate for any code\n",
"#SNR in power ratio is \n",
"SNR1=10**(35./10.);\n",
"C=B*log(1+SNR1) /log(2);\n",
"print 'maximum data rate for four-level code in the available bandwidth',round(C,2),'kb/s'\n",
"# Both results are maxima, we have to choose lesser of the two.\n",
"# Therefore we choose c=12.8kp/s"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 : pg 289"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The audible frequency is 14.1 KHz\n"
]
}
],
"source": [
" \n",
"#page no. 289\n",
"# prob no. 7.2\n",
"# In the given problem\n",
"#calculate the audible frequency \n",
"#given\n",
"fm = 30.# in KHz\n",
"fs = 44.1#sampling rate in KHz\n",
"#calculations\n",
"fa = fs - fm# audible frequency\n",
"#results\n",
"print 'The audible frequency is',fa,'KHz'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 : pg 291"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a) The number of levels with m=8 are 256.0 levels\n",
"b) The number of levels with m=16 are 65536 levels\n"
]
}
],
"source": [
" \n",
"#page no 291\n",
"#prob no 7.3\n",
"#calculate the number of levels in both cases\n",
"#part a: no of samples,\n",
"#given\n",
"m=8.;\n",
"#calculations and results\n",
"N=2**m;# the number of levels\n",
"print 'a) The number of levels with m=8 are',N,'levels'\n",
"# part b:\n",
"m=16;\n",
"N=2**m;# the number of levels\n",
"print 'b) The number of levels with m=16 are',N,'levels'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 4 : pg 292"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Dynamic range for a linear PCM 98.08 dB\n"
]
}
],
"source": [
" \n",
"# page no 292\n",
"# prob no 7.4\n",
"#calculate the dynamic range\n",
"#In the given problem\n",
"#given\n",
"m=16.;\n",
"#calculations\n",
"DR=1.76 +6.02*m ; #Dynamic range for a linear PCM in dB\n",
"#results\n",
"print 'Dynamic range for a linear PCM',DR,'dB'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 5 : pg 295"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The minimum data rate needed to transmit audio is 560.0 Kb/s\n"
]
}
],
"source": [
" \n",
"#page no 295\n",
"# prob no 7.5\n",
"#calculate the min data rate required\n",
"# in the given problem\n",
"#given\n",
"fs=40.; m=14;\n",
"#calculations\n",
"# the minimum data rate needed to transmit audio is given by\n",
"D=fs*m;\n",
"#results\n",
"print 'The minimum data rate needed to transmit audio is ',D,'Kb/s'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6 : pg 294"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The maximum output voltage produced is 0.876 volts\n"
]
}
],
"source": [
" \n",
"# page no 294\n",
"# prob no 7.6\n",
"#calculate the max output voltage required\n",
"# In the given problem, input to a mu-law compresser is +ve,\n",
"# with its voltage one-half the max value\n",
"from math import log\n",
"#given\n",
"u=255.;\n",
"Vi=1.;#maximum input value is considered as unity volts\n",
"vi=0.5;\n",
"V0=1.;#consider maximum output voltage as unity volts\n",
"#calculations\n",
"vo=V0* log(1+u*vi/Vi)/log(1+u);\n",
"#results\n",
"print 'The maximum output voltage produced is',round(vo,3),'volts'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|