summaryrefslogtreecommitdiff
path: root/Linear_Integrated_Circuit_by_M._S._Sivakumar/Ch5.ipynb
blob: 648c07398eb4a615eb25897afe54086b89949c63 (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
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
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 Characteristic of Operational Amplifier"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.1 Pg 110"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = 404.00  mV \n",
      " the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 75.00  mV \n",
      " the total offset voltage (Vo) of an op-amp circuit is = 479.00  mV \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# find the total offset voltage of feedback op-amp\n",
    "\n",
    "Vos = 4 # #mV  # input offset volt\n",
    "Ios = 150*10**-3 # # input offset current\n",
    "R1 = 5 # #kilo ohm  # input resistance\n",
    "R2 = 500 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = %0.2f'%Vo1,' mV '#\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "Vo2 = R2*Ios #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.2f'%Vo2,' mV '#\n",
    "\n",
    "# the total offset voltage is\n",
    "Vo = Vo1+Vo2 #\n",
    "print ' the total offset voltage (Vo) of an op-amp circuit is = %0.2f'%Vo,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.2 Pg 111"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = 52.00  mV \n",
      " the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 5.00  mV \n",
      " the total offset voltage (Vo) of an op-amp circuit is = 57.00  mV \n"
     ]
    }
   ],
   "source": [
    "# find the total offset voltage of feedback op-amp\n",
    "\n",
    "Vos = 2 # #mV  # input offset volt\n",
    "Ios = 20*10**-3 # # input offset current\n",
    "R1 = 10 # #kilo ohm  # input resistance\n",
    "R2 = 250 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = %0.2f'%Vo1,' mV '#\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "Vo2 = R2*Ios #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.2f'%Vo2,' mV '#\n",
    "\n",
    "# the total offset voltage is\n",
    "Vo = Vo1+Vo2 #\n",
    "print ' the total offset voltage (Vo) of an op-amp circuit is = %0.2f'%Vo,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.3 Pg 111"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the input offset voltage (Vos) of an op-amp circuit is = 1.187  mV \n"
     ]
    }
   ],
   "source": [
    "# find the input offset voltage of an op-amp circuit\n",
    "\n",
    "Vo = 90.2 # #mV  # output voltage\n",
    "R1 = 2 # #kilo ohm  # input resistence\n",
    "R2 = 150 # #kilo ohm  # feedback resistence\n",
    "\n",
    "# the input offset voltage (Vos) of an op-amp circuit is defined as\n",
    "Vos = ((R1)/(R1+R2)*Vo) #\n",
    "print 'the input offset voltage (Vos) of an op-amp circuit is = %0.3f'%Vos,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.4 Pg 112"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage due to the input offset voltage  is = 36.00  mV \n"
     ]
    }
   ],
   "source": [
    "# find the output voltage of an op-amp circuit\n",
    "\n",
    "Vos = 1 # #mV  # input offset volt\n",
    "R1 = 10 # #kilo ohm  # input resistance\n",
    "R2 = 350 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage due to the input offset voltage of the op-amp circuit is defined by\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print 'the output voltage due to the input offset voltage  is = %0.2f'%Vo1,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.5 Pg 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage of the circuit due to bias current is = 0.11  V \n",
      "Bias compensated resistor is = 9.09  kilo ohm \n",
      "Bias compensated output voltage is = 0.01  V \n"
     ]
    }
   ],
   "source": [
    "# Determine the bias current effect with and without current compensation method\n",
    "\n",
    "R1 = 10 # #kilo ohm\n",
    "R2 = 100 # #kilo ohm\n",
    "Ib1 = 1.1*10**-3 #\n",
    "Ib2 = 1*10**-3 # \n",
    "# the output voltage of the circuit due to bias current is\n",
    "Vo = Ib1*R2 #\n",
    "print 'the output voltage of the circuit due to bias current is = %0.2f'%Vo,' V '#\n",
    "\n",
    "#Bias compensated resistor is given by\n",
    "R3 = (R1*R2)/(R1+R2) #\n",
    "print 'Bias compensated resistor is = %0.2f'%R3,' kilo ohm '#\n",
    "\n",
    "#Bias compensated output voltage is given by\n",
    "Vo = R2*(Ib1-Ib2)#\n",
    "print 'Bias compensated output voltage is = %0.2f'%Vo,' V '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.6 Pg 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 80 nA \n"
     ]
    }
   ],
   "source": [
    "# find the input offset current of an op-amp circuit\n",
    "\n",
    "Vo = 12*10**-3# # V  # output voltage\n",
    "R1 = 2*10**3 # # ohm  # input resistence\n",
    "R2 = 150*10**3# # ohm  # feedback resistence\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "# Vo = R2*Ios #\n",
    "Ios = Vo/R2 *1e9 # nA\n",
    "print 'the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.f'%Ios,'nA '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.7 Pg 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current in the inverting input terminal is = 27.50  nA \n",
      "The current in the non-inverting input terminal is= 32.50  nA \n"
     ]
    }
   ],
   "source": [
    "# Determine the bias current of inverting and non-inverting\n",
    "Ios = 5 # #nA # input offset current\n",
    "Ib = 30 # #nA # input bias current\n",
    "\n",
    "# the input bias current of an op-amp is \n",
    "\n",
    "#Ib =(Ib1+Ib2)/(2)#\n",
    "\n",
    "# the offset current Ios is define as\n",
    "\n",
    "#Ios = abs(Ib1-Ib2) #\n",
    "\n",
    "Ib1=Ib-(Ios/2)#\n",
    "print 'The current in the inverting input terminal is = %0.2f'%Ib1,' nA '#\n",
    "\n",
    "Ib2 =Ib+(Ios/2)#\n",
    "print 'The current in the non-inverting input terminal is= %0.2f'%Ib2,' nA '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.8 Pg 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Feedback transfer function is = 0.01 \n",
      "OR 1/Beta  is = 100.10 \n",
      "Feedback transfer function is = -0.01 \n",
      "OR 1/Beta  is = -100.10 \n"
     ]
    }
   ],
   "source": [
    "#determine the feedback transfer function of an op-amp for the following condition\n",
    "# a) When open loop gain of 10**5 and the closed loop gain of 100\n",
    "A = 10**5 # # open loop gain\n",
    "Af = 100 # #closed loop gain\n",
    "# Feedback transfer function is\n",
    "beta =(1/Af)-(1/A)#\n",
    "print 'Feedback transfer function is = %0.2f'%beta,''#\n",
    "beta = 1/beta #\n",
    "print 'OR 1/Beta  is = %0.2f'%beta,''#\n",
    "\n",
    "# For an open loop gain of -10**5 and closed loop gain of -100\n",
    "A = -10**5 # # open loop gain\n",
    "Af = -100 # #closed loop gain\n",
    "# Feedback transfer function is\n",
    "beta =(1/Af)-(1/A)#\n",
    "print 'Feedback transfer function is = %0.2f'%beta,''#\n",
    "beta = 1/beta #\n",
    "print 'OR 1/Beta  is = %0.2f'%beta,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.9 Pg 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "open loop gain is = 2000.00\n"
     ]
    }
   ],
   "source": [
    "#to determine open loop gain\n",
    "beta = 0.0120 # # Feedback transfer function\n",
    "Af = 80 # #closed loop gain\n",
    "A = (Af)/(1-beta*Af) #\n",
    "print 'open loop gain is = %0.2f'%A"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.10 Pg 116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "close loop gain dAf is = 49.78\n",
      "the percent change of closed loop gain dAf is = 0.45 %\n"
     ]
    }
   ],
   "source": [
    " # To Determine the percent of change in the closed loop gain Af of feedback op-amp circuit\n",
    "A = 10**5 #  # open loop gain\n",
    "Af = 50 #  # close loop gain\n",
    "beta = 0.01999 #  # feedback transfer function\n",
    "dA = 10**4 #  # the change in the open llop gain \n",
    "\n",
    "# close loop gain\n",
    "dAf = ((dA)/(1+dA*beta))#\n",
    "print 'close loop gain dAf is = %0.2f'%dAf\n",
    "\n",
    "# the percent change of closed loop gain \n",
    "dAf = (((Af-dAf)/(Af))*100)#\n",
    "print 'the percent change of closed loop gain dAf is = %0.2f'%dAf,'%'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.11 Pg 116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the feedback transfer function beta is = 0.0199\n",
      "the closed loop bandwidth wfH is = 125600\n"
     ]
    }
   ],
   "source": [
    "# To Determine the bandwidth of feedback amplifier\n",
    "A = 10**4 #  # open loop gain\n",
    "Af = 50 #  # close loop gain\n",
    "wH = 628 # #(2*pi*100)  # rad/sec # open loop bandwidth\n",
    "\n",
    "# close loop gain of an op-amp is defined as\n",
    "# Af = ((A)/(1+A*beta))# \n",
    "\n",
    "# the feedback transfer function is given as\n",
    "beta = (1/Af)-(1/A) #\n",
    "print 'the feedback transfer function beta is = %0.4f'%beta\n",
    "\n",
    "# closed loop bandwidth\n",
    "wfH = wH*(1+beta*A)#\n",
    "print 'the closed loop bandwidth wfH is = %0.f'%wfH"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.12 Pg 117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity gain bandwidth is = 1e+06 Hz\n",
      "the maximum close loop gain ACL is = 50.00 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# To calculate unity gain bandwidth and maximum close loop gain\n",
    "A = 10**5 #  # open loop gain\n",
    "fo = 10 # # Hz  # dominant pole frequency\n",
    "fdb = 20*10**3 # #Hz  # 3-db frequency\n",
    "\n",
    "# the unity gain bandwidth\n",
    "f1 = fo*A #\n",
    "print 'the unity gain bandwidth is = %0.e'%f1,'Hz'#\n",
    "\n",
    "# the maximum close loop gain\n",
    "ACL = (f1/fdb) #\n",
    "print 'the maximum close loop gain ACL is = %0.2f'%ACL,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.13 Pg 117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity gain bandwidth is = 60 kHz\n",
      "the maximum close loop gain ACL is = 5.00 \n"
     ]
    }
   ],
   "source": [
    "# To calculate unity gain bandwidth and maximum close loop gain\n",
    "A = 10**3 #  # open loop gain\n",
    "fo = 60 # # Hz  # dominant pole frequency\n",
    "fdb = 12*10**3 # #Hz  # 3-db frequency\n",
    "\n",
    "# the unity gain bandwidth\n",
    "f1 = fo*A #\n",
    "print 'the unity gain bandwidth is = %0.f'%(f1/1e3),'kHz'#\n",
    "\n",
    "# the maximum close loop gain\n",
    "ACL = (f1/fdb) #\n",
    "print 'the maximum close loop gain ACL is = %0.2f'%ACL,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.14 Pg 118"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the dominant pole frequency (fPD) of an op-amp is = 2.5 kHz\n"
     ]
    }
   ],
   "source": [
    "# To determine the dominant pole frequency of an op-amp\n",
    "Ao = 2*10**5 #  # low frequency open loop gain\n",
    "f = 5*10**6 # # Hz  # pole frequency\n",
    "ACL = 100 #  # low frequency closed lkoop gain\n",
    "p_margin = 80 # \n",
    "\n",
    "# the dominant pole frequency of an op-amp\n",
    "fPD = (ACL)*(f/Ao)/1e3\n",
    "print 'the dominant pole frequency (fPD) of an op-amp is = %0.1f'%fPD,'kHz'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.15 Pg 118"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 6.37  KHz \n",
      "Acom =  [ magnitude = 6.3*10**-3   angle = -89.6 degree ]\n",
      "Ac =  [ magnitude = 0.68   angle = 0.4 degree ]\n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "C = 0.0025*10**-6 # # farad\n",
    "R = 10*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 100 #  \n",
    "angle1 = 90 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "# After putting value of F ,FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(158.7))#  #  1+%j(158.7)  Rectangular Form   where real part is 1 and imaginary part is 158.7\n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 6.3*10**-3   angle = -89.6 degree ]'#\n",
    "\n",
    "#   Ac = Ac1*Acom #         equation 1\n",
    "\n",
    "# after putting Ac1 and Acom value in equation 1  we get   Ac1 = 100 angle 90  and Acom = 6.3*10**-3  angle = -89.6    \n",
    "\n",
    "print 'Ac =  [ magnitude = 0.68   angle = 0.4 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.16 Pg 119"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 1.1  KHz \n",
      "Acom =  [ magnitude = 0.68   angle = -47.7 degree ]\n"
     ]
    }
   ],
   "source": [
    "# Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.01*10**-6 # # farad\n",
    "R = 15*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.1f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "# After putting value of F ,FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(0.9))#  #  1+%j(0.9)  Rectangular Form   where real part is 1 and imaginary part is 0.9\n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 0.68   angle = -47.7 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.17 Pg 120"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 4.25  KHz \n",
      "Acom for F = 0 KHz =   [ magnitude = 150   angle = 85 degree ]\n",
      "Acom for F = 2 KHz=  [  magnitude = 136.4   angle = 64.5 degree ]\n",
      "Acom for F = 4 KHz = [ magnitude = 107.14   angle = 41.7 degree ]\n",
      "Acom for F = 6 KHz =  [ magnitude = 88.24   angle = 30.25 degree ]\n",
      "Acom for F = 8 KHz  =  [ magnitude = 71.4   angle = 23 degree ]\n",
      "Acom  for F = 10 KHz =   [ magnitude = 58.59  angle = 18 degree ]\n",
      "Acom for F = 20 KHz =  [ magnitude = 31.12   angle = 7 degree ]\n",
      "Acom  for F = 40 KHz =  [ magnitude = 15.9   angle = 1.1 degree ]\n",
      "Acom for F = 80 KHz =  [ magnitude = 7.9  angle = -2 degree ]\n",
      "Acom for F = 100 KHz =  [ magnitude = 6.4   angle = -2.6 degree ]\n",
      "Acom for F = 200 KHz =  [ magnitude = 3.18  angle = -3.8 degree ]\n",
      "Acom for F = 400 KHz =  [ magnitude = 1.59   angle = -4.4 degree ]\n",
      "Acom for F = 800 KHz =  [ magnitude = 0.79   angle = -4.7 degree ]\n",
      "Acom for F = 1 MHz =  [ magnitude = 0.64   angle = -4.7 degree ]\n",
      "Acom for F = 1.2 MHz =  [ magnitude = 0.52   angle = -4.7 degree ]\n",
      "Acom for F = 1.4 MHz =  [ magnitude = 0.45   angle = -4.7 degree ]\n",
      "Acom for F = 1.6 MHz =  [ magnitude = 0.4   angle = -4.7 degree ]\n"
     ]
    }
   ],
   "source": [
    "# Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.5*10**-6 # # farad\n",
    "R = 75 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 150 #  \n",
    "angle1 = 85 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "\n",
    "# After putting value of  FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(F/4.24*10**3))#       equation 1\n",
    "\n",
    "# As F is unknown in above equation 1 \n",
    "#  by putting different value of F we get Acom for different frequency\n",
    "\n",
    "\n",
    "# If F = 0 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(0/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 0 KHz =   [ magnitude = 150   angle = 85 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 2 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(2*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 2 KHz=  [  magnitude = 136.4   angle = 64.5 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 4 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(4*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 4 KHz = [ magnitude = 107.14   angle = 41.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 6 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(6*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 6 KHz =  [ magnitude = 88.24   angle = 30.25 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 8 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(8*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 8 KHz  =  [ magnitude = 71.4   angle = 23 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 10 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(10*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom  for F = 10 KHz =   [ magnitude = 58.59  angle = 18 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 20 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(20*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 20 KHz =  [ magnitude = 31.12   angle = 7 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 40 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(40*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom  for F = 40 KHz =  [ magnitude = 15.9   angle = 1.1 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 80 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(80*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 80 KHz =  [ magnitude = 7.9  angle = -2 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 100 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(100*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 100 KHz =  [ magnitude = 6.4   angle = -2.6 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 200 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(200*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 200 KHz =  [ magnitude = 3.18  angle = -3.8 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 400 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(400*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 400 KHz =  [ magnitude = 1.59   angle = -4.4 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 800 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(800*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 800 KHz =  [ magnitude = 0.79   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1 MHz =  [ magnitude = 0.64   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1.2 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.2*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.2 MHz =  [ magnitude = 0.52   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 1.4 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.4*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.4 MHz =  [ magnitude = 0.45   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1.6 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.6*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.6 MHz =  [ magnitude = 0.4   angle = -4.7 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.18 Pg 123"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The compensating resistor value is = 15.92  ohm \n"
     ]
    }
   ],
   "source": [
    "# to design compensating network\n",
    "fp = 500*10**3 #  # pole frequency\n",
    "C = 0.02*10**-6 # # F  # we choose\n",
    "# loop gain of compensated network\n",
    "\n",
    "# ACom =(1)/(1+j(f/fp))\n",
    "# fp = (1/2*pie*R*C)\n",
    "R = (1/(2*3.14*C*fp))#\n",
    "print 'The compensating resistor value is = %0.2f'%R,' ohm '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.19 Pg 123"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FH = 6.37  KHz \n",
      "FL = 2.12  KHz \n",
      "Acom =  [ magnitude = 0.34   angle = -0.24 degree ]\n",
      "Ac = [ magnitude = 34   angle = 89.76 degree ]\n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.0025*10**-6 # # farad\n",
    "R1 = 10*10**3 # #  ohm\n",
    "R2 = 20*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 100 #  \n",
    "angle1 = 90 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "FH = 1/(2*3.14*R1*C)#\n",
    "print 'FH = %0.2f'%(FH/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "FL = 1/(2*3.14*(R1+R2)*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "# After putting value of FH ,FL we get\n",
    "\n",
    "#  Acom = (1+%j(158.7))/(1+%j(471.7) \n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 0.34   angle = -0.24 degree ]'#\n",
    "\n",
    "#   Ac = Ac1*Acom #         equation 1\n",
    "\n",
    "# after putting Ac1 and Acom value in equation 1  we get   Ac1 = 100 angle 90  and Acom = 0.34  angle = -0.24    \n",
    "\n",
    "print 'Ac = [ magnitude = 34   angle = 89.76 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.20 Pg 124"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FH = 1.59  KHz \n",
      "FL = 0.64  KHz \n",
      "Acom =   [magnitude = 0.4]  \n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "C = 0.01*10**-6 # # farad\n",
    "R1 = 10*10**3 # #  ohm\n",
    "R2 = 15*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "FH = 1/(2*3.14*R1*C)#\n",
    "print 'FH = %0.2f'%(FH/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "FL = 1/(2*3.14*(R1+R2)*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "# After putting value of FH ,FL we get\n",
    "\n",
    "#  Acom = (1+%j(658.9))/(1+%j(1.56*10**3) \n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =   [magnitude = 0.4]  '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.21 Pg 125"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The compensating first resistor R1 value is = 0.80  K ohm \n",
      "The compensating second resistor R2 value is = 7.17  K ohm \n"
     ]
    }
   ],
   "source": [
    "# to design compensating network\n",
    "fH = 10 # #k ohm # break frequency initiated by a zero\n",
    "fL = 1 #  #k ohm # break frequency initiated by a pole\n",
    "C = 0.02# # uF  # we choose\n",
    "# loop gain of compensated network\n",
    "\n",
    "# ACom =(1+j(f/fH))/(1+j(f/fL))\n",
    "# fH = (1/2*pie*R1*C)\n",
    "# fL = (1/2*pie*(R1+R2)*C)\n",
    "R1 = (1/(2*3.14*C*fH))#\n",
    "print 'The compensating first resistor R1 value is = %0.2f'%R1,' K ohm '#\n",
    "R2 = ((1)/(2*3.14*C*fL))-(R1)#\n",
    "print 'The compensating second resistor R2 value is = %0.2f'%R2,' K ohm '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.22 Pg 126"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input miller capacitance Cin value is = 10.10 uF \n",
      "The output miller capacitance Cout value is = 0.10 uF \n"
     ]
    }
   ],
   "source": [
    "# To determine input output miller capacitances\n",
    "A = 100 # #gain\n",
    "Cm = 0.1 #  # uF # compensated capacitor\n",
    "\n",
    "# the input output miller capacitance are defined as\n",
    "Cin = Cm*(A+1)#\n",
    "print 'The input miller capacitance Cin value is = %0.2f'%Cin,'uF '#\n",
    "Cout = (Cm*((A+1)/A))# \n",
    "print 'The output miller capacitance Cout value is = %0.2f'%Cout,'uF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.23 Pg 127"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input miller capacitance Cin value is = 3.02 uF \n",
      "The output miller capacitance Cout value is = 0.02 uF \n",
      "The initiated frequency of miller compensating network by pole is = 7.96  KHz \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "# To determine input output miller capacitances\n",
    "A = 150 # #gain\n",
    "Cm = 0.02 #  # uF # compensated capacitor\n",
    "\n",
    "# the input output miller capacitance are defined as\n",
    "Cin = Cm*(A+1)#\n",
    "print 'The input miller capacitance Cin value is = %0.2f'%Cin,'uF '#\n",
    "Cout = (Cm*((A+1)/A))# \n",
    "print 'The output miller capacitance Cout value is = %0.2f'%Cout,'uF '#\n",
    "\n",
    "# In the miller compensating network input capacitance introduce a pole . The initiated frequency of miller compensating network by pole is define as\n",
    "\n",
    "# fp = 1/(2*pi*R*Cin)#\n",
    "R = 1 # # K ohm\n",
    "fp = 1/(2*pi*R*Cout)#\n",
    "print 'The initiated frequency of miller compensating network by pole is = %0.2f'%fp,' KHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.24 Pg 128"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the slew rate of an op-amp is = 17.58  V/u sec \n",
      "The compansated capacitance value is = 1.12 pF \n"
     ]
    }
   ],
   "source": [
    "# To determine the slew rate of an op-amp\n",
    "f = 1 # # MHz # unity frequency\n",
    "Ic = 1*10**-6 #  # uA # capacitor current\n",
    "Vt = 0.7 # # V  # threshold voltage\n",
    "\n",
    "# the slew rate of an op-amp is defined as\n",
    "# Slew rate = (dVo/dt)\n",
    "Slewrate = 8*3.14*Vt*f #\n",
    "print 'the slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec '#\n",
    "\n",
    "# The compansated capacitance Cm is\n",
    "gm = (Ic/Vt)#\n",
    "Cm = (gm/4*3.14*f)*1e6 # pF\n",
    "print 'The compansated capacitance value is = %0.2f'%Cm,'pF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.25 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cut -off frequency of an op-amp is = 5.00  Hz \n"
     ]
    }
   ],
   "source": [
    " # To determine the cut off frequency of an op-amp\n",
    "f = 1*10**3 # # Hz # unity frequency\n",
    "Av = 200 # # V/mV  # dc gain\n",
    "\n",
    "# the unity gain frequency of an op-amp is defined as\n",
    "# f = Av*fc #\n",
    "\n",
    "# cut off frequency\n",
    "fc = (f/Av)#\n",
    "print 'Cut -off frequency of an op-amp is = %0.2f'%fc,' Hz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.26 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the closed loop gain ACL is = 35.00  \n",
      "The output gain factor K is = 0.88  V\n",
      "The maximum frequency of an op-amp fmax = 145.59  KHz\n"
     ]
    }
   ],
   "source": [
    "# To find the maximum frequency of input signal in op-amp circuit\n",
    "Vin = 25*10**-3 # # V  # input voltage\n",
    "Slewrate = 0.8/10**-6 #  # V/uV   # Slew rate of an op-amp\n",
    "R2 = 350*10**3 #  #  ohm  # feedback resistance\n",
    "R1 = 10*10**3 #  # ohm  # input resistance\n",
    "\n",
    "# the closed loop gain\n",
    "# ACL = (mod (Vo/Vin)) = (mod(R2/R1))#\n",
    "ACL = abs(R2/R1)#\n",
    "print 'the closed loop gain ACL is = %0.2f'%ACL,' '#\n",
    "\n",
    "# the output gain factor K is given as\n",
    "K = ACL*Vin #\n",
    "print 'The output gain factor K is = %0.2f'%K,' V'#\n",
    "\n",
    "# the maximum frequency of an op-amp is\n",
    "wmax = (Slewrate/K)#\n",
    "fmax = wmax/(2*3.14)#\n",
    "print 'The maximum frequency of an op-amp fmax = %0.2f'%(fmax/1000),' KHz'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.27 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the closed loop gain ACL is = 24.00  \n",
      "The output gain factor K is = 0.36  V\n",
      "The wmax is = 2.22 *10**6 rad/sec\n"
     ]
    }
   ],
   "source": [
    "# To find the maximum frequency of op-amp circuit\n",
    "Vin = 0.015 # # V  # input voltage\n",
    "Slewrate = 0.8 #  # V/uV   # Slew rate of an op-amp\n",
    "R2 = 120*10**3 #  #  ohm  # feedback resistance\n",
    "R1 = 5*10**3 #  # ohm  # input resistance\n",
    "\n",
    "# the closed loop gain\n",
    "# ACL = (mod (Vo/Vin)) = (mod(R2/R1))#\n",
    "ACL = abs(R2/R1)#\n",
    "print 'the closed loop gain ACL is = %0.2f'%ACL,' '#\n",
    "\n",
    "# the output gain factor K is given as\n",
    "K = ACL*Vin #\n",
    "print 'The output gain factor K is = %0.2f'%K,' V'#\n",
    "\n",
    "# the maximum frequency of an op-amp is\n",
    "wmax = (Slewrate/K)#\n",
    "print 'The wmax is = %0.2f'%wmax,'*10**6 rad/sec'# # *10**6 because Slewrate is V/uV \n",
    "\n",
    "# the signal frequency may be w = 500*10**3 rad/sec  that is less than the maximum frequency value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.28 Pg 130"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity frequency f is = 568.70 kHz \n",
      "The compansated capacitance Cm value is = 0.2 nF \n"
     ]
    }
   ],
   "source": [
    " # To determine the compensated capacitance of an op-amp\n",
    "Slewrate = 10 # # V/u sec\n",
    "Ic = 1*10**-3 #  # mA # capacitor current\n",
    "Vt = 0.7 # # V  # threshold voltage\n",
    "\n",
    "# the slew rate of an op-amp is defined as\n",
    "# Slew rate = (dVo/dt)\n",
    "# the unity frequency f is\n",
    "f =(Slewrate/(8*3.14*Vt))#\n",
    "f = f*10**6#  # *10**6 because Slew rate is V/uV \n",
    "print 'the unity frequency f is = %0.2f'%(f/1e3),'kHz '#\n",
    "\n",
    "# The compansated capacitance Cm is\n",
    "gm = (Ic/Vt)#\n",
    "Cm = (gm)/(4*3.14*f)*1e9 #\n",
    "print 'The compansated capacitance Cm value is = %0.1f'%Cm,'nF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.29 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.50  V/u sec\n"
     ]
    }
   ],
   "source": [
    " # To find Slew rate of an op-amp\n",
    "Iq = 15 # # uA  # bias current\n",
    "Cm = 30  # # pF  # internal frequency compensated capacitor\n",
    "Slewrate = (Iq/Cm)\n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.30 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.68  V/u sec\n"
     ]
    }
   ],
   "source": [
    "# To find Slew rate of an op-amp\n",
    "Iq = 21 # # uA  # bias current\n",
    "Cm = 31  # # pF  # internal frequency compensated capacitor\n",
    "Slewrate = (Iq/Cm)#\n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.31 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The full power bandwidth FPBW is = 8.12 kHz \n",
      "The 3-db frequency or small signal band width f3db is = 10 kHz \n"
     ]
    }
   ],
   "source": [
    " # To determine full power and small signal bandwidth of an op-amp with unity gain\n",
    "f = 100*10**6 # # Hz  unity gain bandwidth\n",
    "ACL = 10**4 # # maximum closed loop gain\n",
    "Slewrate = 0.51 # # V/u sec\n",
    "Vp = 10 # # V peak volt\n",
    "\n",
    "# The full power bandwidth\n",
    "FPBW = (Slewrate/(2*3.14*Vp))#\n",
    "FPBW = FPBW*10**6 #  # *10**6 because Slew rate is V/uV \n",
    "print 'The full power bandwidth FPBW is = %0.2f'%(FPBW/1e3),'kHz '#\n",
    "\n",
    "# the 3-db frequency or small signal band width \n",
    "f3db = (f/ACL)#\n",
    "print 'The 3-db frequency or small signal band width f3db is = %0.f'%(f3db/1e3),'kHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.32 Pg 132"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The full power bandwidth FPBW is = 8.12 kHz \n",
      "The 3-db frequency or small signal band width f3db is = 10 kHz \n"
     ]
    }
   ],
   "source": [
    "# To determine full power and small signal bandwidth of an op-amp with unity gain\n",
    "f = 100*10**6 # # Hz  unity gain bandwidth\n",
    "ACL = 10**4 # # maximum closed loop gain\n",
    "Slewrate = 0.51 # # V/u sec\n",
    "Vp = 10 # # V peak volt\n",
    "\n",
    "# The full power bandwidth\n",
    "FPBW = (Slewrate/(2*3.14*Vp))#\n",
    "FPBW = FPBW*10**6 #  # *10**6 because Slew rate is V/uV \n",
    "print 'The full power bandwidth FPBW is = %0.2f'%(FPBW/1e3),'kHz '#\n",
    "\n",
    "# the 3-db frequency or small signal band width \n",
    "f3db = (f/ACL)#\n",
    "print 'The 3-db frequency or small signal band width f3db is = %0.f'%(f3db/1e3),'kHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.33 Pg 132"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.31  V/u sec \n",
      "The closed loop gain ACL is = 83.33  \n"
     ]
    }
   ],
   "source": [
    "# To find Slew rate and closed loop gain of an op-amp\n",
    "fu = 1*10**6 # # Hz  # unity gain bandwidth\n",
    "fmax = 5*10**3 # # KHz  # full power bandwidth\n",
    "F3db = 12*10**3 # # Hz  # small signal bandwidth\n",
    "Vp = 10 # # V  # peak volt\n",
    "\n",
    "# the full power bandwidth of an op-amp\n",
    "# fmax=FPBW = (Slew rate/2*3.14*Vp)#\n",
    "Slewrate = 2*3.14*Vp*fmax#\n",
    "Slewrate = Slewrate*(10**-6)#  # *10**-6 because Slewrate is V/u \n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec '#\n",
    "\n",
    "# # the 3-db frequency or small signal band width \n",
    "#f3db = (f/ACL)#\n",
    "#the closed loop gain ACL\n",
    "ACL = fu/F3db #\n",
    "print 'The closed loop gain ACL is = %0.2f'%ACL,' '#"
   ]
  }
 ],
 "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
}