summaryrefslogtreecommitdiff
path: root/Electronic_Communication_Systems_by_Roy_Blake/Chapter12.ipynb
blob: f84049116fbf354a824361ed09186dac90c8cade (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 12 : Digital Modulation and Modems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 : pg 407"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a)The theoretical max data rate is 50.278 kb/s\n",
      "b)The data rate for 4 states is 40.0 kb/s\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 407\n",
    "# prob no 12_1\n",
    "#calculate the data rate and theoretical max\n",
    "#A radio channel with BW=10KHz and SNR=15 dB\n",
    "from math import log\n",
    "#given\n",
    "B=10.*10**3;\n",
    "snr=15.;\n",
    "#calculations and results\n",
    "#converting dB in power ratio\n",
    "SNR=10**(snr/10);\n",
    "#a)Determination of theoretical max data rate\n",
    "C1=B*log(1+SNR) /log(2);\n",
    "print 'a)The theoretical max data rate is',round(C1/1000,3),'kb/s'\n",
    "#b)Determination of data rate with 4 states i.e M=4\n",
    "M=4.;\n",
    "C2=2*B*log(M) / log(2);\n",
    "print 'b)The data rate for 4 states is',C2/1000,'kb/s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 : pg 408"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The baud rate is  10.0 kbaud\n",
      "The bit rate is  60.0 kb/s\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 408\n",
    "# prob no 12_2\n",
    "#calculate the baud and bit rates\n",
    "from math import log\n",
    "#A modulator transmit symbol with symbol rate=10k/sec with 64 states\n",
    "#given\n",
    "M=64.;\n",
    "S=10000.;\n",
    "#calculations and results\n",
    "#Baud rate is simply symbol rate\n",
    "print 'The baud rate is ',S/1000,'kbaud'\n",
    "#Determination of bit rate\n",
    "C=S*log(64) / log(2);\n",
    "print 'The bit rate is ',C/1000,'kb/s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 : pg 411"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a)The frequency shift is 135416.5 Hz\n",
      "b)The maximum frequency is 880067708.25 Hz\n",
      "The minimum frequency is 879932291.75 Hz\n",
      "The bandwidth efficiency in b/s/Hz is 1.354 b/s/Hz\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 411\n",
    "# prob no 12_3\n",
    "#calculate the frequency shift, max, min frequency\n",
    "#given\n",
    "f=200.*10**3;\n",
    "fb=270.833 *10**3;\n",
    "data_rate=270.833 *10**3\n",
    "fc=880*10**6;\n",
    "bandwidth=200*10**3;\n",
    "#calculations and results\n",
    "freq_shift=0.5*fb;\n",
    "print 'a)The frequency shift is',freq_shift,'Hz'\n",
    "# The shift each way from the carrier frequency is half the freq_shift\n",
    "f_max=fc+0.25*fb;\n",
    "print 'b)The maximum frequency is',round(f_max,3),'Hz'\n",
    "f_min=fc-0.25*fb;\n",
    "print 'The minimum frequency is',round(f_min,3),'Hz'\n",
    "bandwidth_efficiency=data_rate/bandwidth;\n",
    "print 'The bandwidth efficiency in b/s/Hz is',round(bandwidth_efficiency,3),'b/s/Hz'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 : pg 412"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The channel data rate is 48.6 kb/s\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 412\n",
    "# prob no 12_4\n",
    "#calculate the channel data rate\n",
    "#given\n",
    "baud_rate=24.3;# in kilobaud\n",
    "#calculations\n",
    "# In this problem dibit system is used.\n",
    "#Therefore symbol_rate=baud_rate=0.5*bit_rate\n",
    "bit_rate=2*baud_rate;\n",
    "#results\n",
    "print 'The channel data rate is',bit_rate,'kb/s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 : pg 413"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The no. of bits per symbol is 6.0\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 413\n",
    "# prob no 12_5\n",
    "#calculate the no. of bits per symbol\n",
    "from math import log\n",
    "#given\n",
    "no_of_phase_angles=16;\n",
    "no_of_amplitudes=4;\n",
    "#calculations\n",
    "no_of_states_per_symbol=no_of_phase_angles*no_of_amplitudes;\n",
    "bit_per_symbol=log(no_of_states_per_symbol)/ log(2);\n",
    "#results\n",
    "print 'The no. of bits per symbol is',bit_per_symbol"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 : pg 415"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shannon limit 29901.68 b/s\n"
     ]
    }
   ],
   "source": [
    " \n",
    "# page no 415\n",
    "# prob no 12_6\n",
    "#calculate the shannon limit\n",
    "from math import log\n",
    "#given\n",
    "B=3.*10**3;SNR_dB=30.;\n",
    "#calculations\n",
    "SNR_power=10**(30./10);\n",
    "C=B*log(1+SNR_power)/ log(2);\n",
    "print 'Shannon limit',round(C,2),'b/s'"
   ]
  }
 ],
 "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
}