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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
|
{
"metadata": {
"name": "",
"signature": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 1 - Operational Amplifiers"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.1 - page 11"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"G= -100 \n",
"R1= 2.2 # in kohm\n",
"R1=R1*10**3 # in ohm\n",
"# Formula G=-Rf/R1\n",
"Rf= -G*R1 \n",
"print \"The value of Rf = %0.f kohm \" %(Rf*10**-3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of Rf = 220 kohm \n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.2 - page 11"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"Rf= 200 # in kohm\n",
"R1= 2 # in kohm\n",
"vin=2.5 # in mV\n",
"vin=vin*10**-3 # in volt\n",
"G= -Rf/R1 \n",
"vo= G*vin # in V\n",
"print \"The output voltage = %0.2f Volt \" %vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The output voltage = -0.25 Volt \n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.3 - page 12"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"G=-10 \n",
"Ri= 100 # in kohm\n",
"R1= Ri # in kohm\n",
"R1=R1*10**3 # in ohm\n",
"# Formula G=-R2/R1\n",
"R2= R1*abs(G) # ohm\n",
"print \"Value of R1 = %0.f kohm \" %(R1*10**-3)\n",
"print \"and value of R2 = %0.f Mohm \" %(R2*10**-6)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Value of R1 = 100 kohm \n",
"and value of R2 = 1 Mohm \n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.4 - page 37"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"R1= 100 # in kohm\n",
"R2= 500 # in kohm\n",
"V1= 2 # in volt\n",
"Vo= (1+R2/R1)*V1 # in volt\n",
"print \"Output voltage for noninverting amplifier = %0.f Volt\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage for noninverting amplifier = 12 Volt\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.5 - page 38"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf= 1 # in Mohm\n",
"Rf=Rf*10**6 #in ohm\n",
"\n",
"# Part(a)\n",
"V1=1 #in volt\n",
"V2=2 #in volt\n",
"V3=3 #in volt\n",
"R1= 500 # in kohm\n",
"R1=R1*10**3 #in ohm\n",
"R2= 1 # in Mohm\n",
"R2=R2*10**6 #in ohm\n",
"R3= 1 # in Mohm\n",
"R3=R3*10**6 #in ohm\n",
"Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n",
"print \"(a) Output voltage = %0.f Volt \" %Vo\n",
"\n",
"# Part(b)\n",
"V1=-2 #in volt\n",
"V2=3 #in volt\n",
"V3=1 #in volt\n",
"R1= 200 # in kohm\n",
"R1=R1*10**3 #in ohm\n",
"R2= 500 # in kohm\n",
"R2=R2*10**3 #in ohm\n",
"R3= 1 # in Mohm\n",
"R3=R3*10**6 #in ohm\n",
"Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n",
"print \"(b) Output voltage = %0.f Volt\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"(a) Output voltage = -7 Volt \n",
"(b) Output voltage = 3 Volt\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.6 - page 38"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"print \"Minimum closed loop voltage gain for R2=0 and R1= 2 kohm\"\n",
"R2=0 \n",
"R1=2 # in kohm\n",
"R1=R1*10**3 # in ohm\n",
"Av_min= (1+R2/R1)\n",
"print \"Av(min) =\",Av_min\n",
"\n",
"print \"Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm\"\n",
"R2=100 # in kohm\n",
"R1=2 # in kohm\n",
"Av_max= (1+R2/R1)\n",
"print \"Av(max) =\",Av_max"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Minimum closed loop voltage gain for R2=0 and R1= 2 kohm\n",
"Av(min) = 1.0\n",
"Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm\n",
"Av(max) = 51.0\n"
]
}
],
"prompt_number": 14
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.7 - page 39"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"V1= 745 # in \u00b5V\n",
"V2= 740 # in \u00b5V\n",
"V1=V1*10**-6 # in volt\n",
"V2=V2*10**-6 # in volt\n",
"CMRR=80 # in dB\n",
"Av=5*10**5 \n",
"# (i)\n",
"# CMRR in dB= 20*log(Ad/Ac)\n",
"Ad=Av \n",
"Ac= Ad/10**(CMRR/20) \n",
"# (ii)\n",
"Vo= Ad*(V1-V2)+Ac*(V1+V2)/2 \n",
"print \"Output voltage = %0.2f Volt\" %Vo\n",
"\n",
"# Note:- In the book, there is calculation error to evaluate the value of Ac,\n",
"#so the value of Ac is wrong ans to evaluate the output voltage there is also calculation error "
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage = 2.54 Volt\n"
]
}
],
"prompt_number": 15
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.8 - page 40"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"R1= 1 # in Mohm\n",
"Ri=R1 # in Mohm\n",
"Rf=1 # in Mohm\n",
"A_VF= -Rf/R1 \n",
"print \"Voltage gain = %0.f\" %A_VF"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Voltage gain = -1\n"
]
}
],
"prompt_number": 16
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.10 - page 41"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"V1=2 # in V\n",
"V2=3 # in V\n",
"Rf=3 # in kohm\n",
"R1=1 # in kohm\n",
"Vo1= (1+Rf/R1)*V1 \n",
"print \"Output voltage when only 2V voltage source is acting is %0.f Volt\" %Vo1\n",
"Vo2= (1+Rf/R1)*V2 \n",
"print \"Output voltage due to 3V voltage source is %0.f Volt\" %Vo2\n",
"Vo= Vo1+Vo2 # in volts\n",
"print \"Total output voltage is %0.f Volts\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage when only 2V voltage source is acting is 8 Volt\n",
"Output voltage due to 3V voltage source is 12 Volt\n",
"Total output voltage is 20 Volts\n"
]
}
],
"prompt_number": 18
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.11 - page 42"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf=500 # in kohm\n",
"min_vvs= 0 # minimum value of variable resistor in ohm\n",
"max_vvs= 10 # maximum value of variable resistor in ohm\n",
"Ri_min= 10+min_vvs # in kohm\n",
"Ri_max= 10+max_vvs #in kohm\n",
"# Av= Vo/Vi= -Rf/Ri\n",
"Av=-Rf/Ri_min \n",
"print \"Closed loop voltage gain corresponding to Ri(min) is\",Av\n",
"Av=-Rf/Ri_max \n",
"print \"and closed loop voltage gain corresponding to Ri(max) is\",Av"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Closed loop voltage gain corresponding to Ri(min) is -50.0\n",
"and closed loop voltage gain corresponding to Ri(max) is -25.0\n"
]
}
],
"prompt_number": 21
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.12 - page 43"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"Rf=200 # in kohm\n",
"R1= 20 # in kohm\n",
"# Av= Vo/Vi= -Rf/Ri\n",
"Av= -Rf/R1 \n",
"Vi_min= 0.1 # in V\n",
"Vi_max= 0.5 # in V\n",
"# Vo= Av*Vi\n",
"Vo_min= Av*Vi_min # in V\n",
"Vo_max= Av*Vi_max # in V\n",
"print \"Output voltage ranges from\",Vo_min,\"V to\",Vo_max,\"V\""
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage ranges from -1.0 V to -5.0 V\n"
]
}
],
"prompt_number": 23
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.13 - page 43"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf= 250 # in kohm\n",
"# Output voltage expression, Vo= -5*Va+3*Vb\n",
"# and we know that for a difference amplifier circuit, \n",
"# Vo= -Rf/R1*Va + [R2/(R1+R2)]*[1+Rf/R1]*Vb\n",
"# Comparing both the expression, we get\n",
"# -Rf/R1*Va= -5*Va, or\n",
"R1= Rf/5 # in kohm\n",
"print \"The value of R1 = %0.2f kohm\" %R1\n",
"# and \n",
"R2= 3*R1**2/(R1+Rf-3*R1)\n",
"print \"The value of R2 = %0.2f kohm\" %R2\n",
"\n",
"# Note : Answer in the book is wrong"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of R1 = 50.00 kohm\n",
"The value of R2 = 50.00 kohm\n"
]
}
],
"prompt_number": 24
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.14 - page 44"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"Vi_1= 150 # in \u00b5V\n",
"Vi_2= 140 # in \u00b5V\n",
"Vd= Vi_1-Vi_2 # in \u00b5V\n",
"Vd=Vd*10**-6 # in V\n",
"Vc= (Vi_1+Vi_2)/2 # in \u00b5V\n",
"Vc=Vc*10**-6 # in V\n",
"# Vo= Ad*Vd*(1+Vc/(CMRR*Vd))\n",
"\n",
"# (i) For Ad=4000 and CMRR= 100\n",
"Ad=4000 \n",
"CMRR= 100 \n",
"Vo= Ad*Vd*(1+Vc/(CMRR*Vd)) # in volt\n",
"print \"(a) Output voltage = %.1f mV\" %(Vo*10**3)\n",
"\n",
"# (ii) For Ad=4000 and CMRR= 10**5\n",
"Ad=4000 \n",
"CMRR= 10**5 \n",
"Vo= Ad*Vd*(1+Vc/(CMRR*Vd)) # in volt\n",
"print \"(b) Output voltage = %0.1f mV\" %(Vo*10**3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"(a) Output voltage = 45.8 mV\n",
"(b) Output voltage = 40.0 mV\n"
]
}
],
"prompt_number": 31
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.15 - page 45"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf=470 # in kohm\n",
"R1=4.3 # in kohm\n",
"R2=33 # in kohm\n",
"R3=33 # in kohm\n",
"Vi= 80 # in \u00b5V\n",
"Vi=Vi*10**-6 # in volt\n",
"A1= 1+Rf/R1 \n",
"A2=-Rf/R2 \n",
"A3= -Rf/R3 \n",
"A=A1*A2*A3 \n",
"Vo= A*Vi # in volt\n",
"print \"Output voltage = %0.2f Volts\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage = 1.79 Volts\n"
]
}
],
"prompt_number": 33
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.16 - page 46"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import *\n",
"t = symbols('t')\n",
"# Given data\n",
"R1= 33 # in k\u03a9\n",
"R2= 10 # in k\u03a9\n",
"R3= 330 # in k\u03a9\n",
"V1 = simplify(50*sin(1000*t)) # in mV\n",
"V2 = simplify(10*sin(3000*t)) # in mV\n",
"Vo = -(R3/R1*V1+R3/R2*V2)/1000 # in V\n",
"print \"Output voltage is\",Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage is -0.5*sin(1000*t) - 0.33*sin(3000*t)\n"
]
}
],
"prompt_number": 37
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.17 - page 47"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"R1=10 # in kohm\n",
"R2=150 # in kohm\n",
"R3=10 # in kohm\n",
"R4=300 # in kohm\n",
"V1= 1 # in V\n",
"V2= 2 # in V\n",
"Vo= ((1+R4/R2)*(R3*V1/(R1+R3))-(R4/R2)*V2) \n",
"print \"Output voltage = %0.2f Volts\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage = -2.50 Volts\n"
]
}
],
"prompt_number": 39
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.18 - page 47"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"R1=12 # in kohm\n",
"Rf=360 # in kohm\n",
"V1= -0.3 # in V\n",
"Vo= (1+Rf/R1)*V1 # in V\n",
"print \"(a) Output voltage result in %0.2f Volts\" %Vo\n",
"\n",
"# Part(b)\n",
"Vo= 2.4 # in V\n",
"# We know, Vo= (1+Rf/R1)*V1\n",
"V1= Vo/(1+Rf/R1) \n",
"print \"(b) To result in an output of 2.4 Volt, Input voltage = %0.2f mV\" %(V1*10**3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"(a) Output voltage result in -9.30 Volts\n",
"(b) To result in an output of 2.4 Volt, Input voltage = 77.42 mV\n"
]
}
],
"prompt_number": 41
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.19 - page 48"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf=68 # in kohm\n",
"R1=33 # in kohm\n",
"R2=22 # in kohm\n",
"R3=12 # in kohm\n",
"V1= 0.2 # in V\n",
"V2=-0.5 # in V\n",
"V3= 0.8 # in V\n",
"Vo= -Rf/R1*V1 + (-Rf/R2)*V2 + (-Rf/R3)*V3 # in volts\n",
"print \"Output voltage = %0.3f Volts\" %Vo\n",
"#Answer in the textbook is not accurate."
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage = -3.400 Volts\n"
]
}
],
"prompt_number": 44
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.20 - page 48"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"Rf=100 # in kohm\n",
"R1=20 # in kohm\n",
"V1= 1.5 # in V\n",
"Vo1= V1 \n",
"Vo= -Rf/R1*Vo1 # in volts\n",
"print \"Output voltage = %0.2f Volts\" %Vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Output voltage = -7.50 Volts\n"
]
}
],
"prompt_number": 45
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.22 - page 50"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"# Given data\n",
"vo= -10 # in V\n",
"i_f= 1 # in mA\n",
"i_f= i_f*10**-3 #in A\n",
"# Formula vo= -i_f*Rf\n",
"Rf= -vo/i_f # in \u03a9\n",
"# The output voltage, vo= -(v1+5*v2) (i)\n",
"# vo= -Rf/R1*v1 - Rf/R2*v2 (ii)\n",
"# Comparing equations (i) and (2)\n",
"R1= Rf/1 # in \u03a9\n",
"R2= Rf/5 # in \u03a9\n",
"print \"The value of Rf = %0.2f k\u03a9\" %(Rf*10**-3)\n",
"print \"The value of R1 = %0.2f k\u03a9\" %(R1*10**-3)\n",
"print \"The value of R2 = %0.2f k\u03a9\" %(R2*10**-3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of Rf = 10.00 k\u03a9\n",
"The value of R1 = 10.00 k\u03a9\n",
"The value of R2 = 2.00 k\u03a9\n"
]
}
],
"prompt_number": 46
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.24 - page 52"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"from sympy import *\n",
"v1,v2 = symbols('v1 v2')\n",
"# Given data\n",
"R1= 9 # in k\u03a9\n",
"R2= 1 # in k\u03a9\n",
"R3= 2 # in k\u03a9\n",
"R4= 3 # in k\u03a9\n",
"# for node 1\n",
"va = R4/(R4+R3)*v1\n",
"vo1 = (1+R1/R2)*va\n",
"# for node 2\n",
"va=R3/(R3+R4)*v2\n",
"vo2 = (1+R1/R2)*va\n",
"vo = vo1+vo2\n",
"print \"Total voltage is, vo =\",vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Total voltage is, vo = 6.0*v1 + 4.0*v2\n"
]
}
],
"prompt_number": 60
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.25 - page 54"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"from sympy import *\n",
"v1,v2,v3 = symbols('v1 v2 v3')\n",
"# Given data\n",
"R1= 9 # in k\u03a9\n",
"R2= 1 # in k\u03a9\n",
"R3= 2 # in k\u03a9\n",
"R4= 3 # in k\u03a9\n",
"# Voltage at node 1\n",
"va= R4*v1/(R3+R4)\n",
"vo1= (1+R1/R2)*va\n",
"# Voltage at node 2\n",
"va= R3*v2/(R3+R4)\n",
"# From (i) and (ii)\n",
"vo2= (1+R1/R2)*va\n",
"# Voltage at node 3\n",
"va= R3*v2/(R3+R4)\n",
"vo3= (-R1/R2)*v3\n",
"vo = vo1+vo2+vo3\n",
"print \"Total voltage is\",vo"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Total voltage is 6.0*v1 + 4.0*v2 - 9.0*v3\n"
]
}
],
"prompt_number": 67
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.26 - page 55"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Given data\n",
"import numpy as np\n",
"from __future__ import division\n",
"# omega_t= Ao*omega_b\n",
"# 2*pi*f_t = Ao*2*pi*f_b\n",
"# f_t= Ao*f_b\n",
"# Part (i)\n",
"Ao1= 10**5 \n",
"f_b1= 10**2 # in Hz\n",
"f_t1= Ao1*f_b1 # in Hz\n",
"row1 = np.array([Ao1,f_b1,f_t1])\n",
"# Part (ii)\n",
"Ao2= 10**6 \n",
"f_t2= 10**6 # in Hz\n",
"f_b2= f_t2/Ao2 # in Hz\n",
"row2 = np.array([Ao2,f_b2,f_t2])\n",
"# Part (iii)\n",
"f_b3= 10**3 # in Hz\n",
"f_t3= 10**8 # in Hz\n",
"Ao3= f_t3/f_b3 \n",
"row3 = np.array([Ao3,f_b3,f_t3])\n",
"# Part (iv)\n",
"f_b4= 10**-1 # in Hz\n",
"f_t4= 10**6 # in Hz\n",
"Ao4= f_t4/f_b4 \n",
"row4 = np.array([Ao4,f_b4,f_t4])\n",
"# Part (v)\n",
"Ao5= 2*10**5 \n",
"f_b5= 10 # in Hz\n",
"f_t5= Ao5*f_b5 # in Hz\n",
"row5 = np.array([Ao5,f_b5,f_t5])\n",
"print \"-\"*33\n",
"print \"Ao fb(Hz) ft(Hz)\"\n",
"print \"-\"*33\n",
"print \"%.e %.e %.e\" %(row1[0], row1[1], row1[2])\n",
"print \"%.e %.f %.e\" %(row2[0], row5[1], row2[2])\n",
"print \"%.e %.e %.e\" %(row3[0], row3[1], row3[2])\n",
"print \"%.e %.e %.e\" %(row4[0], row4[1], row4[2])\n",
"print \"%.e %.f %.e\" %(row5[0], row5[1], row5[2])\n",
"# Answer for f_b2 is wrong in the textbook."
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"---------------------------------\n",
"Ao fb(Hz) ft(Hz)\n",
"---------------------------------\n",
"1e+05 1e+02 1e+07\n",
"1e+06 10 1e+06\n",
"1e+05 1e+03 1e+08\n",
"1e+07 1e-01 1e+06\n",
"2e+05 10 2e+06\n"
]
}
],
"prompt_number": 37
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.27 - page 56"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"from numpy import sqrt\n",
"# Given data\n",
"Ao= 86 # in dB\n",
"A= 40 # in dB\n",
"f=100 # in kHz\n",
"f=f*10**3 # in Hz\n",
"# From 20*log(S) = 20*log(Ao/A), where S, stands for sqrt(1+(f/fb)**2)\n",
"S= 10**((Ao-A)/20) \n",
"# S= sqrt(1+(f/fb)**2)\n",
"fb= f/sqrt(S**2-1) # in Hz\n",
"Ao= 10**(Ao/20) \n",
"ft= Ao*fb # in Hz\n",
"print \"The value of Ao = %0.3e\" %Ao\n",
"print \"The value of fb = %0.f Hz\" %fb\n",
"print \"The value of ft = %0.f MHz\" %round(ft*10**-6)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The value of Ao = 1.995e+04\n",
"The value of fb = 501 Hz\n",
"The value of ft = 10 MHz\n"
]
}
],
"prompt_number": 43
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Exa 1.28 - page 56"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from __future__ import division\n",
"from numpy import pi, sqrt\n",
"# Given data\n",
"Ao= 10**4 # in V/V\n",
"f_t= 10**6 # in Hz\n",
"R2byR1= 20 \n",
"omega_t= 2*pi*f_t \n",
"omega_3dB= omega_t/(1+R2byR1) \n",
"f3dB= omega_3dB/(2*pi) # in Hz\n",
"print \"3-dB frequency of the closed loop amplifier is %0.1f kHz\" %(f3dB*10**-3)\n",
"f3dB= 0.1*f3dB # in Hz\n",
"voBYvi= -R2byR1/sqrt(1+(2*pi*f3dB/omega_3dB)**2) \n",
"voBYvi= abs(voBYvi) # in v/v\n",
"print \"Gain = %0.1f v/v\" %(voBYvi)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"3-dB frequency of the closed loop amplifier is 47.6 kHz\n",
"Gain = 19.9 v/v\n"
]
}
],
"prompt_number": 48
}
],
"metadata": {}
}
]
}
|