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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 7 : Active Filters"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.1 Page No.269"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"import math\n",
"# Given Data\n",
"fh = 10**3\n",
"C = 0.1*10**-6\n",
"Rf = 5.86*10**3\n",
"Ri = 10**4\n",
"\n",
"# Solution \n",
"\n",
"R = 1/(2*np.pi*C*fh)\n",
"Ao = (1 + Rf/Ri)\n",
"\n",
"a = np.array([100, 200, 500, 1000, 5000, 10000])\n",
"print \" The value of R is =\",round(R/1000,1),\"Kilo ohms\"\n",
"print \" The value of Ao =\",Ao\n",
"print \" Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)\"\n",
"print \" ========================================================\" \n",
"for i in a:\n",
"\n",
" val = round(20 * math.log10(Ao/(math.sqrt(1 + (i/fh)**4))),3)\n",
" print i,\" || \",val\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of R is = 1.6 Kilo ohms\n",
" The value of Ao = 1.586\n",
" Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)\n",
" ========================================================\n",
"100 || 4.006\n",
"200 || 4.006\n",
"500 || 4.006\n",
"1000 || 0.996\n",
"5000 || -23.96\n",
"10000 || -35.994\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.2 Page No.270"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Design of a 4th order Butter worth Low pss filter \n",
"\n",
"fh = 10**3\n",
"C = 0.1*10**-6\n",
"a1 = 0.765\n",
"a2 = 1.848\n",
"\n",
"Ao1 = 3 - a1\n",
"Ao2 = 3 - a2\n",
"\n",
"# let Rf1 = 12.35 kilo Ohm and Rf2 = 15.2 kilo ohm finding the Ri1 and Ri2 \n",
"\n",
"Rf1 = 12.35*10**3\n",
"Rf2 = 15.2*10**3\n",
"\n",
"Ri1 = Rf1/(Ao1 - 1)\n",
"Ri2 = Rf2/(Ao2 - 1)\n",
"\n",
"print \" The value of Ao1 = \",Ao1\n",
"print \" The value of Ao2 = \",Ao2\n",
"print \" The value of Rf1 = \",Rf1/1000,\"Kilo Ohm\"\n",
"print \" The value of Rf2 = \",Rf2/1000,\"Kilo Ohm\"\n",
"print \" The value of Ri1 = \",int(Ri1/1000),\"Kilo Ohm\"\n",
"print \" The value of Ri2 = \",int(Ri2/1000),\"Kilo Ohm\"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of Ao1 = 2.235\n",
" The value of Ao2 = 1.152\n",
" The value of Rf1 = 12.35 Kilo Ohm\n",
" The value of Rf2 = 15.2 Kilo Ohm\n",
" The value of Ri1 = 10 Kilo Ohm\n",
" The value of Ri2 = 100 Kilo Ohm\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.3 Page No.271 "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Solution to fing out the value of n or order\n",
"\n",
"# We know the equation is 20 log|(H(jw)| = 20 log (Ao/(math.sqrt(1+(w/wh)**n))\n",
"# putig the values into the equation we will get 0.01**2 = 1/(1 + 2**2*n)\n",
"# solving the equation to get the value of n\n",
"\n",
"# 2**(2*n) = 1/(1 + (0.01)**2)\n",
"# taking log to the base 2 on both sides\n",
"n = math.log(((10**4)-1),2)/2\n",
"\n",
"print \" The order of the filter will be =\",int(math.ceil(n))\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The order of the filter will be = 7\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.4 Page No.272"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"import math\n",
"# Given Data\n",
"fl = 10**3\n",
"C = 0.1*10**-6\n",
"Rf = 5.86*10**3\n",
"Ri = 10**4\n",
"\n",
"# Solution \n",
"\n",
"R = 1/(2*np.pi*C*fl)\n",
"Ao = (1 + Rf/Ri)\n",
"\n",
"a = np.array([100, 200, 500, 1000, 5000, 10000])\n",
"print \" The value of R is =\",round(R/1000,1),\"Kilo ohms\"\n",
"print \" The value of Ao =\",Ao\n",
"print \" Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)\"\n",
"print \" ========================================================\" \n",
"for i in a:\n",
"\n",
" val = round(Ao/math.sqrt(1 + (fl/i)**4),3)\n",
" print i,\" || \",val\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of R is = 1.6 Kilo ohms\n",
" The value of Ao = 1.586\n",
" Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)\n",
" ========================================================\n",
"100 || 0.016\n",
"200 || 0.063\n",
"500 || 0.385\n",
"1000 || 1.121\n",
"5000 || 1.586\n",
"10000 || 1.586\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.5 Page No.276"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Given Data \n",
"\n",
"fl = 400\n",
"fh = 2*10**3\n",
"Ao = 4\n",
"\n",
"# For design top get Ao = 2 the values of Rf = Ri\n",
"\n",
"Rf = Ri = 10*10**3\n",
"\n",
"# for LPF \n",
"\n",
"C1 = 0.01*10**-6\n",
"R1 = 1/(2*math.pi*fh*C1)\n",
"\n",
"# for HPF \n",
"\n",
"C2 = 0.01*10**-6\n",
"R2 = 1/(2*math.pi*fl*C2)\n",
"\n",
"fo = math.sqrt(fh*fl)\n",
"Q = fo/(fh - fl)\n",
"\n",
"print \"The value of c1 =\",C1*10**6,\"uF\"\n",
"print \"The value of R1 =\",round(R1/1000,1),\"kilo Ohms\"\n",
"print \"The value of c2 =\",C2*10**6,\"uF\"\n",
"print \"The value of R2 =\",round(R2/1000,1),\"Kilo Ohms\"\n",
"print \"The value of Q =\",round(Q,2)\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of c1 = 0.01 uF\n",
"The value of R1 = 8.0 kilo Ohms\n",
"The value of c2 = 0.01 uF\n",
"The value of R2 = 39.8 Kilo Ohms\n",
"The value of Q = 0.56\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.6 Page No.279"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"\n",
"# Given Data \n",
"\n",
"fo = 50\n",
"C = 0.1*10**-6\n",
"\n",
"# Solution \n",
"\n",
"R = 1/(2*math.pi*fo*C)\n",
"\n",
"print \"The value of Capasitor = \",C*10**6,\"uF\"\n",
"print \"The value of Resistor = \",round(R/1000,1),\"Kilo Ohm\"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of Capasitor = 0.1 uF\n",
"The value of Resistor = 31.8 Kilo Ohm\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.7 Page No.280"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Given Data \n",
"\n",
"fl = 400\n",
"fh = 2*10**3\n",
"Ao = 4\n",
"\n",
"# For design top get Ao = 2 the values of Rf = Ri\n",
"\n",
"Rf = Ri = 10*10**3\n",
"\n",
"# for LPF \n",
"\n",
"C1 = 0.1*10**-6\n",
"R1 = 1/(2*math.pi*fh*C1)\n",
"\n",
"# for HPF \n",
"\n",
"C2 = 0.1*10**-6\n",
"R2 = 1/(2*math.pi*fl*C2)\n",
"\n",
"fo = math.sqrt(fh*fl)\n",
"Q = fo/(fh - fl)\n",
"\n",
"print \"The value of c1 =\",C1*10**6,\"uF\"\n",
"print \"The value of R1 =\",round(R1/1000,1),\"kilo Ohms\"\n",
"print \"The value of c2 =\",C2*10**6,\"uF\"\n",
"print \"The value of R2 =\",round(R2/1000),\"Kilo Ohms\"\n",
"print \"The value of Q =\",round(Q,2)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of c1 = 0.1 uF\n",
"The value of R1 = 0.8 kilo Ohms\n",
"The value of c2 = 0.1 uF\n",
"The value of R2 = 4.0 Kilo Ohms\n",
"The value of Q = 0.56\n"
]
}
],
"prompt_number": 17
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 7.10 Page No.298 "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# given data \n",
"\n",
"fc = 400\n",
"Ao = -2\n",
"Vcc = 5\n",
"R1 = 10*10**3\n",
"HoLP = 2\n",
"\n",
"R2 = HoLP * R1 \n",
"\n",
"# for second order butterworth filter Q = 0.707\n",
"Q = 0.707\n",
"R3 = Q * R2\n",
"\n",
"fclock = 50 * fc\n",
"\n",
"# Dispalying the outputs \n",
"\n",
"print \"The value of R1 =\",R1/1000,\"Ohms\"\n",
"print \"The value of R2 =\",R2/1000,\"Kilo Ohms\"\n",
"print \"The value of R3 =\",R3/1000,\"Kilo Ohms\"\n",
"print \"The value of clock frequency =\",fclock/1000,\"Kilo Hertz\"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of R1 = 10 Ohms\n",
"The value of R2 = 20 Kilo Ohms\n",
"The value of R3 = 14.14 Kilo Ohms\n",
"The value of clock frequency = 20 Kilo Hertz\n"
]
}
],
"prompt_number": 18
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
|