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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Ch-6 : Frequency response, bode plots and resonance"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.1 Page No: 476"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"peak value of Vout = 6.00 volts\n",
"phase angle of Vout = 70.00 degrees\n",
"with frequency equal to = 1000.00\n"
]
}
],
"source": [
"from math import pi, cos, sin, atan, sqrt\n",
"# given V_in(t)=2*cos(2000*pi*t+A), A=40*pi/180\n",
"w=2000*pi# #omega\n",
"f=w/(2*pi)# #frequency\n",
"A=40*pi/180# #40 degrees = %0.2f radians\n",
"#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n",
"H_max=(4000-f)/1000# #magnitude of H(traansfer function)\n",
"#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n",
"H_phi=pi*f/6000# #phase angle of H\n",
"H=H_max*complex(cos(H_phi),sin(H_phi))\n",
"V_in=2*complex(cos(A),sin(A))# #input voltage phasor\n",
"V_out=H*V_in# #output voltage phasor\n",
"V_out_R=(V_out.real)# #real part\n",
"V_out_I=(V_out.imag)# #imaginary part\n",
"V_out_max=sqrt((V_out_R**2)+(V_out_I**2))# #peak value\n",
"V_out_phi=atan(V_out_I/V_out_R)\n",
"print 'peak value of Vout = %0.2f volts'%V_out_max\n",
"print 'phase angle of Vout = %0.2f degrees'%(V_out_phi*180/pi)\n",
"print 'with frequency equal to = %0.2f'%f"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.2 Page No: 477"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Output voltage is Vout1+Vout2+Vout3 where\n",
"\n",
"FOR Vout1:\n",
"peak value = 12.00 volts\n",
"phase angle = 0.00 degrees\n",
"with frequency = 0.00 hertz\n",
"\n",
"FOR Vout2:\n",
"peak value = 6.00 volts\n",
"phase angle = 30.00 degrees\n",
"with frequency = 1000.00 hertz\n",
"\n",
"FOR Vout3:\n",
"peak value = 2.00 volts\n",
"phase angle = -10.00 degrees\n",
"with frequency = 2000.00 hertz\n"
]
}
],
"source": [
"from __future__ import division\n",
"#given V_in(t)=3+2*cos(2000*pi*t)+cos(4000*pi*t-A), A=70*pi/180\n",
"#the three parts of V_in(t) are V_in_1=3, V_in_2=2*cos(2000*pi*t),V_in_3=cos(4000*pi*t-A)\n",
"\n",
"#first component V_1\n",
"V_in_1=3\n",
"f_1=0# #as omega is zero\n",
"#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n",
"H_1_max=(4000-f_1)/1000# #magnitude of H(traansfer function)\n",
"#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n",
"H_1_phi=pi*f_1/6000# #phase angle of H\n",
"H_1=H_1_max*complex(cos(H_1_phi),sin(H_1_phi))\n",
"V_out_1=H_1*V_in_1\n",
"V_out_1_R=(V_out_1).real# #real part\n",
"V_out_1_I=(V_out_1).imag# #imaginary part\n",
"V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n",
"V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n",
"\n",
"#second component V_in_2\n",
"V_in_2=2*complex(cos(0),sin(0))# #V_in_2 phasor\n",
"w=2000*pi# #omega\n",
"f_2=w/(2*pi)# #frequency\n",
"#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n",
"H_2_max=(4000-f_2)/1000# #magnitude of H(traansfer function)\n",
"#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n",
"H_2_phi=pi*f_2/6000# #phase angle of H\n",
"H_2=H_2_max*complex(cos(H_2_phi),sin(H_2_phi))\n",
"V_out_2=H_2*V_in_2\n",
"V_out_2_R=(V_out_2).real# #real part\n",
"V_out_2_I=(V_out_2).imag# #imaginary part\n",
"V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n",
"V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n",
"\n",
"#third component\n",
"A=-70*pi/180# #-70 degrees = %0.2f radians\n",
"V_in_3=complex(cos(A),sin(A))# #V_in_3 phasor\n",
"w=4000*pi# #omega\n",
"f_3=w/(2*pi)# #frequency\n",
"#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n",
"H_3_max=(4000-f_3)/1000# #magnitude of H(traansfer function)\n",
"#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n",
"H_3_phi=pi*f_3/6000# #phase angle of H\n",
"H_3=H_3_max*complex(cos(H_3_phi),sin(H_3_phi))\n",
"V_out_3=H_3*V_in_3\n",
"V_out_3_R=(V_out_3).real# #real part\n",
"V_out_3_I=(V_out_3).imag# #imaginary part\n",
"V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n",
"V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n",
"\n",
"print 'Output voltage is Vout1+Vout2+Vout3 where'\n",
"print ''\n",
"print 'FOR Vout1:'\n",
"print 'peak value = %0.2f volts'%V_out_1_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_1\n",
"print ''\n",
"print 'FOR Vout2:'\n",
"print 'peak value = %0.2f volts'%V_out_2_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_2\n",
"print ''\n",
"print 'FOR Vout3:'\n",
"print 'peak value = %0.2f volts'%V_out_3_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.3 Page No: 477"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n",
"Output voltage is Vout1+Vout2+Vout3 where\n",
"\n",
"FOR Vout1:\n",
"peak value = 4.98 volts\n",
"phase angle = -5.71 degrees\n",
"with frequency = 10.00 hertz\n",
"\n",
"FOR Vout2:\n",
"peak value = 3.54 volts\n",
"phase angle = -45.00 degrees\n",
"with frequency = 100.00 hertz\n",
"\n",
"FOR Vout3:\n",
"peak value = 0.50 volts\n",
"phase angle = -84.29 degrees\n",
"with frequency = 1000.00 hertz\n"
]
}
],
"source": [
"R=1000/(2*pi)# #resistance\n",
"C=10*10**-6# #capacitance\n",
"f_B=1/(2*pi*R*C)# #half-power frequency\n",
"#the three parts of V_in are V_1=5*cos(20*pi*t)+5*cos(200*pi*t)+5*cos(2000*pi*t)\n",
"\n",
"#first component V_in_1\n",
"V_in_1=5*complex(cos(0),sin(0))# #V_in_1 phasor\n",
"w_1=20*pi# #omega\n",
"f_1=w_1/(2*pi)# #frequency\n",
"H_1=1/(1+1J*(f_1/f_B))# #transfer function\n",
"V_out_1=H_1*V_in_1\n",
"V_out_1_R=(V_out_1).real# #real part\n",
"V_out_1_I=(V_out_1).imag# #imaginary part\n",
"V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n",
"V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n",
"\n",
"#second component V_in_2\n",
"V_in_2=5*complex(cos(0),sin(0))# #V_in_2 phasor\n",
"w_2=200*pi# #omega\n",
"f_2=w_2/(2*pi)# #frequency\n",
"H_2=1/(1+1J*(f_2/f_B))# #transfer function\n",
"V_out_2=H_2*V_in_2\n",
"V_out_2_R=(V_out_2).real #real part\n",
"V_out_2_I=(V_out_2).imag #imaginary part\n",
"V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n",
"V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n",
"\n",
"#third component V_in_3\n",
"V_in_3=5*complex(cos(0),sin(0))# #V_in_3 phasor\n",
"w_3=2000*pi# #omega\n",
"f_3=w_3/(2*pi)# #frequency\n",
"H_3=1/(1+1J*(f_3/f_B))# #transfer function\n",
"V_out_3=H_3*V_in_3\n",
"V_out_3_R=(V_out_3).real #real part\n",
"V_out_3_I=(V_out_3).imag #imaginary part\n",
"V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n",
"V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n",
"\n",
"print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n",
"print 'Output voltage is Vout1+Vout2+Vout3 where'\n",
"print ''\n",
"print 'FOR Vout1:'\n",
"print 'peak value = %0.2f volts'%V_out_1_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_1\n",
"print ''\n",
"print 'FOR Vout2:'\n",
"print 'peak value = %0.2f volts'%V_out_2_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_2\n",
"print ''\n",
"print 'FOR Vout3:'\n",
"print 'peak value = %0.2f volts'%V_out_3_max\n",
"print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n",
"print 'with frequency = %0.2f hertz'%f_3\n",
"#we can observe that there is a clear discrimination = %0.2f output signals based on frequencies i.e, lesser the frequency lesser the effect."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.4 Page No: 478"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n",
"Break frequency = 1897.37 Hz\n"
]
}
],
"source": [
"H_max=-30# #transfer function magnitude\n",
"f=60\n",
"m=20# #low-frequency asymptote slope rate = %0.2f db/decade\n",
"#f_B must be K higher than f where K is\n",
"K=abs(H_max)/m\n",
"#(base 10)log(f_B/60)=1.5 ==>\n",
"f_B=60*10**1.5\n",
"print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n",
"print 'Break frequency = %0.2f Hz'%f_B"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.5 Page No: 479"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Phasor voltage across Resistance\n",
"peak value = 1.00 volts\n",
"phase angle = 0.00 degrees\n",
"\n",
"Phasor voltage across Inductance\n",
"peak value = 10.00 volts\n",
"phase angle = 90.00 degrees\n",
"\n",
"Phasor voltage across Capacitance\n",
"peak value = 10.00 volts\n",
"phase angle = -90.00 degrees\n"
]
}
],
"source": [
"V_s=1*complex(cos(0),sin(0))\n",
"L=159.2*10**-3\n",
"R=100\n",
"C=0.1592*10**-6\n",
"f_o=1/(2*pi*sqrt(L*C))# #resonant frequency\n",
"Q_s=2*pi*f_o*L/R# #quality factor\n",
"B=f_o/Q_s# #Bandwidth\n",
"#Approximate half-power frequencies are\n",
"f_H=f_o+(B/2)\n",
"f_L=f_o-(B/2)\n",
"#At resonance\n",
"Z_L=1J*2*pi*f_o*L# #impedance of inductance\n",
"Z_C=-1J/(2*pi*f_o*C)# #impedance of capacitance\n",
"Z_s=R+Z_L+Z_C\n",
"I=V_s/Z_s# #phasor current\n",
"#voltages across diffrent elements are\n",
"#for resistance\n",
"V_R=R*I\n",
"V_R_R=(V_R).real #real part\n",
"V_R_I=(V_R).imag #imaginary part\n",
"V_R_max=sqrt((V_R_R**2)+(V_R_I**2))# #peak value\n",
"V_R_phi=atan(V_R_I/V_R_R)# #phase angle\n",
"#for inductance\n",
"V_L=Z_L*I\n",
"V_L_R=(V_L).real #real part\n",
"V_L_I=(V_L).imag #imaginary part\n",
"V_L_max=sqrt((V_L_R**2)+(V_L_I**2))# #peak value\n",
"#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n",
"if ((V_L/1J)==abs(V_L)):\n",
" V_L_phi=pi/2\n",
"elif ((V_L/1J)==-abs(V_L)):\n",
" V_L_phi=-pi/2\n",
"\n",
"\n",
"#for capacitance\n",
"V_C=Z_C*I\n",
"V_C_R=(V_C).real #real part\n",
"V_C_I=(V_C).imag #imaginary part\n",
"V_C_max=sqrt((V_C_R**2)+(V_C_I**2))# #peak value\n",
"#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n",
"if ((V_C/1J)==abs(V_C)) :\n",
" V_C_phi=pi/2\n",
"elif ((V_C/1J)==-abs(V_C)) :\n",
" V_C_phi=-pi/2\n",
"\n",
" \n",
"print 'Phasor voltage across Resistance'\n",
"print 'peak value = %0.2f volts'%V_R_max\n",
"print 'phase angle = %0.2f degrees'%(V_R_phi*180/pi)\n",
"print ''\n",
"print 'Phasor voltage across Inductance'\n",
"print 'peak value = %0.2f volts'%V_L_max\n",
"print 'phase angle = %0.2f degrees'%(V_L_phi*180/pi)\n",
"print ''\n",
"print 'Phasor voltage across Capacitance'\n",
"print 'peak value = %0.2f volts'%V_C_max\n",
"print 'phase angle = %0.2f degrees'%(V_C_phi*180/pi)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.6 Page No: 480"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Current phasor across Resistance\n",
"peak value = 0.001 amperes\n",
"phase angle = 0 degrees\n",
"\n",
"Current phasor across Inductance\n",
"peak value = 0.010 amperes\n",
"phase angle = -90.00 degrees\n",
"\n",
"current phasor across capacitance\n",
"peak value = 0.010 amperes\n",
"phase angle = 90.00 degrees\n"
]
}
],
"source": [
"R=10*10**3\n",
"f_o=1*10**6\n",
"B=100*10**3\n",
"I=10**-3*complex(cos(0),sin(0))\n",
"Q_p=f_o/B# #quality factor\n",
"L=R/(2*pi*f_o*Q_p)\n",
"C=Q_p/(2*pi*f_o*R)\n",
"#At resonance\n",
"V_out=I*R\n",
"Z_L=1J*2*pi*f_o*L\n",
"Z_C=-1J/(2*pi*f_o*C)\n",
"\n",
"#across resistance\n",
"I_R=V_out/R\n",
"I_R_R=(I_R).real# #real part\n",
"I_R_I=(I_R).imag# #imaginary part\n",
"I_R_max=sqrt((I_R_R**2)+(I_R_I**2))# #peak value\n",
"I_R_phi=atan(I_R_I/I_R_R)# #phase angle\n",
"\n",
"#across inductance\n",
"I_L=V_out/Z_L\n",
"I_L_R=(I_L).real #real part\n",
"I_L_I=(I_L).imag# #imaginary part\n",
"I_L_max=sqrt((I_L_R**2)+(I_L_I**2))# #peak value\n",
"#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n",
"if ((I_L/1J)==abs(I_L)):\n",
" I_L_phi=pi/2\n",
"elif ((I_L/1J)==-abs(I_L)) :\n",
" I_L_phi=-pi/2\n",
"\n",
"\n",
"#across capacitor\n",
"I_C=V_out/Z_C\n",
"I_C_R=(I_C).real# #real part\n",
"I_C_I=(I_C).imag# #imaginary part\n",
"I_C_max=sqrt((I_C_R**2)+(I_C_I**2))# #peak value\n",
"#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n",
"if ((I_C/1J)==abs(I_C)):\n",
" I_C_phi=pi/2\n",
"elif ((I_C/1J)==-abs(I_C)) :\n",
" I_C_phi=-pi/2\n",
"\n",
"\n",
"print 'Current phasor across Resistance'\n",
"print 'peak value = %0.3f amperes'%I_R_max\n",
"print 'phase angle = %0.f degrees'%(I_R_phi*180/pi)\n",
"print ''\n",
"print 'Current phasor across Inductance'\n",
"print 'peak value = %0.3f amperes'%I_L_max\n",
"print 'phase angle = %0.2f degrees'%(I_L_phi*180/pi)\n",
"print ''\n",
"print 'current phasor across capacitance'\n",
"print 'peak value = %0.3f amperes'%I_C_max\n",
"print 'phase angle = %0.2f degrees'%(I_C_phi*180/pi)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example: 6.7 Page No: 481"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n",
"\n",
"The required second order circuit configuration is\n",
"Inductance = 50.00 KH\n",
"Capacitance = 0.51 mF(micro Farads)\n",
"Resistance = 314.16 ohms\n"
]
}
],
"source": [
"#We need a high-pass filter\n",
"L=50*10**-3\n",
"#for the transfer function to be approximately constant = %0.2f passband area(from graph given = %0.2f the text), we choose\n",
"Q_s=1\n",
"f_o=1*10**3\n",
"C=1/(((2*pi)**2)*f_o**2*L)\n",
"R=2*pi*f_o*L/Q_s\n",
"print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n",
"print ''\n",
"print 'The required second order circuit configuration is'\n",
"print 'Inductance = %0.2f KH'%(L*10**3)\n",
"print 'Capacitance = %0.2f mF(micro Farads)'%(C*10**6)\n",
"print 'Resistance = %0.2f ohms'%R\n",
"\n"
]
}
],
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|