summaryrefslogtreecommitdiff
path: root/Electronic_devices_and_circuits_by_I.J_Nagrath/chapter3.ipynb
blob: b37b068d6c525c40b6597dfb1aa49f630e2d017e (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:cb1edbf7476adce6aba9bf1488bee35026e4b80ac8b3b01d96344eaf38909822"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "\n",
      "Chapter 3:           SMALL SIGNAL MODELS,AMPLIFICATION AND BIASING"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1,Page number 136"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100            #current gain\n",
      "Ic=2.5               #collector current(mA)\n",
      "Io=-0.5              #output current(mA) \n",
      "Rl=2.5               #load resistance(kohm)\n",
      "\n",
      "#Calculations\n",
      "rpi=beeta*(25/Ic)   #dynamic resistance(ohms)\n",
      "Ib=Io/(-beeta)      #as Io=-beeta*Ib\n",
      "Vs=rpi*Ib           #signal voltage(V)\n",
      "Vo=Rl*Io            #output voltage(V)\n",
      "Av=Vo/Vs            #voltage gain\n",
      "Ai=Io/Ib            #current gain\n",
      "\n",
      "#Results\n",
      "print\"signal voltage is\",Vs,\"mV\"\n",
      "print\"current gain is\",Ai\n",
      "print\"voltage gain is\",round(Av/1E-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "signal voltage is 5.0 mV\n",
        "current gain is -100.0\n",
        "voltage gain is -250.0\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2,Page number 139"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Id=1.6               #drain current(mA)\n",
      "Vgs=-3               #gate to source voltage(V)\n",
      "Id1=.4               #drain current(mA)\n",
      "Vgs1=-4              #gate to source voltage(V)   \n",
      "Vp=-5                #peak voltage(V) by solving equations 1.6=Idss(1+3/Vp)^2 and .4=Idss(1+4/Vp)^2\n",
      "Idss=10              #small signal drain current(mA) by solving equations 1.6=Idss(1+3/Vp)^2 and .4=Idss(1+4/Vp)^2\n",
      "                      \n",
      "#Calculations\n",
      "gmo=-(2*Idss)/Vp                #transconductance(mS)\n",
      "gm=gmo*(math.sqrt(Id/Idss))     #transconductance(uS)\n",
      "gm1=gmo*(math.sqrt(Id1/Idss))   #transconductance(uS) \n",
      "\n",
      "#Results\n",
      "print\"Idss and Vp are\",Idss,\"mA and\",Vp,\"V\"\n",
      "print\"gmo is\",gmo,\"mS\"\n",
      "print\"gm at Id is\",round(gm/1E-3),\"and gm at Id1 is\",round(gm1/1E-3),\"uS\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Idss and Vp are 10 mA and -5 V\n",
        "gmo is 4 mS\n",
        "gm at Id is 1600.0 and gm at Id1 is 800.0 uS\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3,Page number 140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "gm=1600             #gm(us)\n",
      "rd=50               #resistance(kohms)\n",
      "Rl=5                #load resistance(kohms)\n",
      "\n",
      "#Calculations\n",
      "Av=-gm*Rl           #Vgs=Vs from circuit model\n",
      "                    #Vo=-(gm*Vgs)*Rl\n",
      "                    #as Av=Vo/Vs=-gm*Rl     \n",
      "\n",
      "#Result\n",
      "print\"voltage gain of the circuit is\",round(Av/1E+3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain of the circuit is -8.0\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4,Page number 145"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=100.       #current gain\n",
      "rpi=2*10**3     #dynamic resistance(ohms)\n",
      "rx=500          #resistance(ohms)\n",
      "ro=250*10**3    #output resistance(ohms)\n",
      "R1=50*10**3     #resistance(k ohms)   \n",
      "R2=10*10**3     #resistance(k ohms)\n",
      "Rc=5*10**3      #collector current(k ohms) \n",
      "Rl=5*10**3.     #load current(k ohms)\n",
      "Rs=1*10**3      #source resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Rb=(R1*R2)/(R1+R2)               #equivalent resistance of R1 and R2(kohms)\n",
      "r=rpi+rx                         #series resistance of rpi and rx(k ohms) \n",
      "gm=beta/rpi                      #transconductance(mS)\n",
      "Vo=-gm*((Rc*Rl)/(Rc+Rl))*.526    #output voltage(V) as \n",
      "Av=Vo                            #voltage gain\n",
      "Ai=Av*((Rs+((Rb*r)/(Rb+r)))/Rl)  #current gain \n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",Av\n",
      "print\"source to load current gain is\",Ai,\"(Solution given in the textbook is incorrect)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -65.75\n",
        "source to load current gain is -38.43745 (Solution given in the textbook is incorrect)\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5,Page number 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=100.       #current gain\n",
      "rd=50*10**3     #internal dynamic resistance(ohms\n",
      "gm=5*10**-3     #transconductance(mS)\n",
      "R1=50*10**3     #resistance(ohms)   \n",
      "R2=10*10**3      #resistance(ohms)\n",
      "Rs=10*10**3      #source current(ohms) \n",
      "Rg=1*10**6.      #gate resistance(ohms)\n",
      "Rd=10*10**3      #drain resistance(ohms)\n",
      "\n",
      "#Calculations                      \n",
      "Vgs=(Rg/(Rs+Rg))                 #gate to source voltage (V) as Vgs=Vs((Rg/(Rs+Rg))   \n",
      "Av=-Vgs*gm*((rd*Rd)/(rd+Rd))      #voltage gain,Av=Vo/Vs and Vo=-gmVgs(rd||Rd)\n",
      "Ai=Av*((Rs+Rg)/Rd)               #current gain\n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",round(Av)\n",
      "print\"source to load current gain is\",round(Ai)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -41.0\n",
        "source to load current gain is -4167.0\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6,Page number 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rs=500           #collector current(k ohms) \n",
      "Io=-1*10**-3     #output current(mA) \n",
      "Rc=5*10**3.       #collector resistance(ohms)\n",
      "hie=2*10**3\n",
      "hoe=10*10**-6.    \n",
      "hfe=100.\n",
      "hre=5*10**-4\n",
      "Rb=50*10**3.     #base resistance(ohms)\n",
      "\n",
      "#Calculations                      \n",
      "Io1=-1/(1+Rc*hoe)*hfe   #as Io=-1/(1+Rc*hoe)*hfe*Ib \n",
      "Ib=-1/Io1               #base current(uA)\n",
      "Vo=Io*Rc                #output voltage(V)\n",
      "Vi=hie*Ib+Vo*hre        #input voltage(V)\n",
      "Is=Ib+Vi/Rb             #source current(ohms)\n",
      "Ai=Io/Is                #current gain\n",
      "Vs=(Is*Rs)+Vi           #source voltage(V)\n",
      "Av=Vo/Vs                #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",round(Av/1E-3)\n",
      "print\"source to load current gain is\",round(Ai/1E-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -189.0\n",
        "source to load current gain is -92.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7,Page number 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100.      #current gain  \n",
      "Ic=4.           #collector current(mA)\n",
      "Vbe=0.7         #base to emitter voltage(V)  \n",
      "Re=2.           #emitter resistance(ohms)\n",
      "Vcc=32.         #supply voltage(V)\n",
      "abeeta=40.      #actual current gain\n",
      "\n",
      "#Calculations\n",
      "Ib=Ic/beeta                        #base current(mA)\n",
      "Rb=(Vcc-Vbe-((Ib+Ic)*Re))/Ib       #as Vcc=(Ib*Rb)+Vbe+(Ib+Ic)*Re              \n",
      "Ib=(Vcc-Vbe-8)/(Rb+Re)             #as Vcc=Rb*Ib+Vbe+(Ib+Ic)*Re\n",
      "Ic1=abeeta*Ib                      #collector current(mA)\n",
      "deltaIc=Ic-Ic1                     #change in collector current(mA)\n",
      "\n",
      "#Result\n",
      "print\"change in Ic when beeta=40 is\",deltaIc,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in Ic when beeta=40 is 2.4 mA\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8,Page number 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rb1=36                   #base resistance 1(kohms)\n",
      "Rb2=12                   #base resistance 2(kohms)\n",
      "Rc=4                     #emitter resistancce(kohms) \n",
      "Re=1.8                   #emitter resistance(kohms)    \n",
      "Vcc=12                   #supply voltage(V)\n",
      "Vbe=0.7                  #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Rb=(Rb1*Rb2)/(Rb1+Rb2)   #base resistance(ohms)\n",
      "Vbb=Vcc*(Rb2/(Rb1+Rb2))  #voltage supply to base(V)\n",
      "                         #(10.8*Ib)+(1.8*Ic)=2.3    equation 1...solving -Vbb+RbIb+Vbe+(Ib+IC)Re\n",
      "                          #(1.8*Ib)+(5.8*Ic)+Vce=12  equation 2  solving -Vcc+RcIc+Vce+(Ob+Ic)Re\n",
      "#Part a\n",
      "beeta=50              #current gain  \n",
      "Ib=2.3/100.8          #(10.8*Ib)+(90*Ib)=2.3 ,using -Vbb+Rb*Ib+Vbe+(Ib+Ic)*Re  \n",
      "                      #as Ic=50Ib and putting this in equation 1      \n",
      "Icq=Ib*beeta\n",
      "Vceq=Vcc-(1.8*Ib)-(5.8*Icq) #from equation 2\n",
      "\n",
      "#Part b\n",
      "beeta=150           #current gain  \n",
      "Ib=2.3/280.8        # (10.8*Ib)+(270*Ib)=2.3,using -Vcc+Rc*Ic+Vce+(Ib+Ic)*Re   \n",
      "                    #as Ic=150Ib and putting this in equation 1      \n",
      "Icq1=Ib*beeta                           \n",
      "Vceq1=Vcc-(1.8*Ib)-(5.8*Icq1)         #from equation 2\n",
      "\n",
      "#Results\n",
      "print\"when beeta increases by 300%,Icq increases by\",round((((Icq1-Icq)/Icq1)*100),1),\"%\"\n",
      "print\"when beeta increases by 300%, Vceq increases by\",round(((Vceq-Vceq1)/Vceq)*100),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "when beeta increases by 300%,Icq increases by 7.1 %\n",
        "when beeta increases by 300%, Vceq increases by 9.0 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9,Page number 156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ic=4                      #collector current(mA)\n",
      "Vce=8                     #collector emitter voltage(V) \n",
      "beeta=100                 #current gain   \n",
      "Rb2=24                    #base resistance(kohms)\n",
      "Vbe=0.7                   #base to emitter voltage(V)\n",
      "Rc=4                     #collector current(kohm)\n",
      "Re=2                     #emitter resistance(kohms) \n",
      "Ib=0.04                  #base current(mA) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vcc=(Ic*Rc)+Vce+Ic*Re         #from formula Vcc=IcRc+Vce+(Ic+Ib)Re..eq 1\n",
      "\n",
      "#Part b\n",
      "Rb1=Rb2*(Vcc-(Vbe+Ic*Re))/((Vbe+Ic*Re)+Ib)  #from eq 1 and also from Vbb= Vcc(Rb2/(Rb1+Rb2))\n",
      "Rb=(Rb1*Rb2)/(Rb1+Rb2)                      #base resistance(ohms)\n",
      "Vbb=(Vcc*Rb2)/(Rb1+Rb2)                     #supply to base(V)\n",
      "\n",
      "#Part c\n",
      "abeeta=40                                 #actual current gain\n",
      "Ib1=((Vbe+Re*Ic)-Vbe)/((1+abeeta)*2+Rb)   #from equation Vbb=IbRb+Vbe+(Ic+Ib)Re\n",
      "Ic1=abeeta*Ib1                            #collector gain\n",
      "\n",
      "#Results\n",
      "print\"a)Vcc is\",Vcc,\"V\"\n",
      "print\"b)values are Rb1:\",round(Rb1,2),\"KOhms,Rb:\",round(Rb,2),\"kohm and Vbb:\",round(Vbb,2),\"V\" \n",
      "print\"c)actual value of Ic1\",round(Ic1,2),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Vcc is 32 V\n",
        "b)values are Rb1: 63.98 KOhms,Rb: 17.45 kohm and Vbb: 8.73 V\n",
        "c)actual value of Ic1 3.22 mA\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10,Page number 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=10       #supply voltage(V)\n",
      "Rc=4.7       #collector current(kohms)\n",
      "Rb=250       #base resistance(kohms)\n",
      "Re=1.2       #emitter resistance(kohms)\n",
      "beeta=100    #current gain\n",
      "Vbe=0.7      #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Ib=(Vcc-Vbe)/(Rb+(beeta*(Rc+Re)))   #base current(uA)\n",
      "Ic=beeta*Ib                         #collector current(mA)\n",
      "Vce=Vcc-Ic*(Rc+Re)                  #collector to emitter voltage(V)\n",
      "#Part b\n",
      "beeta1=150                          #current gain\n",
      "Ib1=(Vcc-Vbe)/(Rb+(beeta1*(Rc+Re))) #base current(mA)\n",
      "Ic1=beeta1*Ib1                      #collector current(mA)\n",
      "Vce1=Vcc-Ic1*(Rc+Re)                #collector to emitter voltage(V)\n",
      "deltaIc=((Ic1-Ic)/Ic)*100           #small change in Ic(mA)\n",
      "deltaVce=((Vce-Vce1)/Vce)*100       #small change in Vce(V)\n",
      "\n",
      "#Results\n",
      "print\"values of Ic is\",round(Ic,2),\"mA and Vce:\",round(Vce,2),\"V\"\n",
      "print\"values of Ic1 is\",round(Ic1,2),\"mA and Vce1 is\",round(Vce1,2),\"V\"\n",
      "print\"% change in Ic is\",round(deltaIc,2),\"% and in Vce is\",round(deltaVce,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "values of Ic is 1.11 mA and Vce: 3.47 V\n",
        "values of Ic1 is 1.23 mA and Vce1 is 2.75 V\n",
        "% change in Ic is 11.01 % and in Vce is 20.74 %\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11,Page number 160"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Id=3              #drain current(mA)\n",
      "Vds=12            #drain source voltage(V)\n",
      "Vgs=-3            #gate source voltage(V)\n",
      "Vdd=36            #drain voltage(V)\n",
      "Vgg=12            #gate voltage(V)\n",
      "Rg=12             #gate resistance(Mohms)\n",
      "\n",
      "#Calculations\n",
      "R1=(Rg*Vdd)/Vgg             #resistance(Mohms)\n",
      "R2=(Rg*R1)/(R1-Rg)          #resistance(kohms)\n",
      "Rs=(Vgg-Vgs)/Id             #resistance(kohms)\n",
      "Rd=(Vdd-Vds-Id*Rs)/Id       #as Vdd-IdRd-Vds-IdRs\n",
      "Vgs=-3.6                    #consider Vgs increases by 20%\n",
      "Idnew=(Vgg-Vgs)/Rs          #new drain current(mA)\n",
      "\n",
      "#Results\n",
      "print\"value of R1:\",R1,\"MOhm,R2:\",R2,\"Mohms,Rs:\",Rs,\"KOhm and Rd:\",Rd,\"kohms\"\n",
      "print\"new Id is\",Idnew,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of R1: 36 MOhm,R2: 18 Mohms,Rs: 5 KOhm and Rd: 3 kohms\n",
        "new Id is 3.12 mA\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12,Page number 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import*\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "k=0.0002                    #device parameter\n",
      "Vt=4                        #thevinin voltage(V)   \n",
      "Vdd=24                      #drain voltage(V)\n",
      "Id0=3                        #drain current(mA)  \n",
      "\n",
      "#Calculations\n",
      "Vgs=(math.sqrt(Id0/k))+4   #as Id=k(Vgs-Vt)^2\n",
      "Rd=-(Vgs-Vdd)/Id0         #as Vds=Vdd-IdRd and Vgs=Vds=7.87                        \n",
      "k=0.0003                  #device parameter \n",
      "\n",
      "Id=symbols('Id')\n",
      "expr=solve(Id**2-7.5*Id+13.7,Id)\n",
      "print\"equation has 2 solutions\",expr                                    # putting value of k=0.0003 in eq of Id,\n",
      "Id1=3.15                                    # we get Vgs=Vds=24-5.4Id and putting Vgs again in Id we get,\n",
      "                                    # Id^2-7.5Id+13.7=0\n",
      "                                    \n",
      "Idchange=((Id1-Id0)/Id0)*100                                                    #changed Id(mA)\n",
      "\n",
      "#Result\n",
      "print\"change in Id is\",Idchange,\"% increase\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "equation has 2 solutions [3.14792027106039, 4.35207972893962]\n",
        "change in Id is 5.0 % increase\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13,Page number 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration \n",
      "Vt=2                        #threshold voltage(V)\n",
      "Id=8                        #drain current(mA)\n",
      "Vgs=6.                       #gate to source voltage(V)\n",
      "k=0.5                       #device parameter\n",
      "Vdd=24                      #drain voltage(V)\n",
      "Vds=10                       #drain to source voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vgs1=4                                            #gate to source voltage(V) \n",
      "Id1=k*(Vgs1-Vt)**2                                 #drain current(mA)\n",
      "\n",
      "#Part b\n",
      "Vgg=3*Vgs1                                         #gate voltage(V)\n",
      "R2=(Vdd/Vgg)-1                                    #resistance(Mohms)\n",
      "Rs=(Vgg-Vgs1)/2                                    #source resistance(k ohms)\n",
      "Rd=(Vdd-Vds-Id1*Rs)/2\n",
      "\n",
      "#part c\n",
      "K=1.5*k                   #increased by 50%\n",
      "Vgs2=3.67                 #solving 12=Vgs+4Id and Id=0.75(Vgs-2)^2 \n",
      "Id2=2.08                   #drain current when k is increased(mA)\n",
      "Vds1=Vdd-Id2*(Rd+Rs)      #drain to source voltage(V)\n",
      "\n",
      "#Results\n",
      "print\"drain current defined by Vgs=4 and Vds=10 is\",Id1,\"mA\"\n",
      "print\"value of Rs,Rd,R2 are\",Rs,\"k ohms,\", Rd,\"k ohms,\",R2,\"Mohms resp.\"\n",
      "print\"actual value of Id and Vds are\",Id2,\"mA,\",Vds1,\"mA and\",Vds,\" V resp.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "drain current defined by Vgs=4 and Vds=10 is 2.0 mA\n",
        "value of Rs,Rd,R2 are 4 k ohms, 3.0 k ohms, 1 Mohms resp.\n",
        "actual value of Id and Vds are 2.08 mA, 9.44 mA and 10  V resp.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14,Page number 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ic=10                       #collector current(mA)\n",
      "beeta=100                   #current gain\n",
      "Vbe=0.7                     #base to emitter voltage(V)\n",
      "Vcc=10                      #supply voltage(V) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "R=(beeta*(Vcc-Vbe))/((beeta+2)*Ic)               #resistance(k ohms)  \n",
      "beeta1=200                                       #current gain\n",
      "Ic1=(beeta1/(beeta1+2))*((Vcc-Vbe)/R)            #collector current(mA)\n",
      "Icchange=((Ic-Ic1)/Ic)                           #change in collector current(mA)  \n",
      "\n",
      "#Part b\n",
      "Ic2=0.1                                          #collector current(mA)\n",
      "R1=(beeta*(Vcc-Vbe))/((beeta+2)*Ic)              #resistance(k ohms)\n",
      "Ic3=(beeta1/(beeta1+2))*((Vcc-Vbe)/R1)           #collector current(mA)\n",
      "Icchange1=((Ic2-Ic3)/Ic2)                        #change in collector current(mA)\n",
      "\n",
      "#Results\n",
      "print\"% change in Ic is\",round(Icchange,1),\"% increase\"\n",
      "print\"% change in Ic is\",round(Icchange1,1),\"% increase\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "% change in Ic is 1.0 % increase\n",
        "% change in Ic is 1.0 % increase\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15,Page number 167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=6                      #supply voltage(V)\n",
      "R=1.2                      #resistance(k ohms)\n",
      "Vbe=0.7                    #base to emitter voltage(V) \n",
      "beeta=100.                 #current gain\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Ir=(Vcc-Vbe)/R             #current(mA)\n",
      "I=(beeta/(beeta+3))*Ir     #current(mA)as transistors are identiical,I=Ie\n",
      "\n",
      "#Result\n",
      "print\"load current I is\",round(I,2),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "load current I is 4.29 mA\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16,Page number 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "Idss=10              #drain current for zero bias(mA)\n",
      "Vp=-4                #peak voltage(V)\n",
      "Idq=Id=2.5           #quienscent drain current(mA)\n",
      "Vdd=24               #voltage drain drain(V)\n",
      "Vgg=4                #gate voltage(V)\n",
      "R1=22                #resistance(Mohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vgs=Vp*(1-(math.sqrt(Id/Idss)))         #solving Id=Idss(1-Vgs/Vp)^2\n",
      "Rs=(Vgg-Vgs)/Id                         #as Vgg-Vgs-IdRs=0 ,Id=Is \n",
      "Rd=2.5*Rs                               #given\n",
      "R2=(Vgg*R1)/(R1-Vgg)                    #from Vgg=(R1*R2)/(R1+R2)\n",
      "\n",
      "#Part b\n",
      "gmo=-(2*Idss)/Vp                       #transconductance(mS)\n",
      "gm=gmo*(math.sqrt(Id/Idss))            #transconductance(mS)\n",
      "\n",
      "#Part c\n",
      "Av=-gm*Rd                              #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"values of Rs:\",Rs,\"Kohms,Rd:\",Rd,\"k ohms and R2 is\",round(R2,1),\"M ohms\"\n",
      "print\"value of gm is\",gm,\"mS and gmo is\",gmo,\"mS\"\n",
      "print\"voltage amplification is\",Av"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "values of Rs: 2.4 Kohms,Rd: 6.0 k ohms and R2 is 4.0 M ohms\n",
        "value of gm is 2.5 mS and gmo is 5 mS\n",
        "voltage amplification is -15.0\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17,Page number 174"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "beeta=98.                          #current gain\n",
      "rpi=1.275                          #dynamic resistance(k ohms)\n",
      "Rb=220.                            #base resistance(k ohms)\n",
      "Re=3.3                             #emitter resistance(k ohms)\n",
      "Vcc=12.                            #supply voltage(V)\n",
      "Vbe=0.7                            #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "x=rpi/(1+beeta)\n",
      "Av=Re/(Re+x)                     #voltage gain\n",
      "\n",
      "#Part b\n",
      "Zb=rpi+(1+beeta)*Re            #impedance(k ohms)\n",
      "Zi=(Zb*Rb)/(Zb+Rb)             #input impedance(k ohms)\n",
      "Zo=(Re*x)/(Re+x)               #output impedance(k ohms)\n",
      "\n",
      "#Part c\n",
      "Ib=(Vcc-Vbe)/(Rb+(Re*(1+beeta)))     #as Ie=(1+beeta)*Ib\n",
      "Ic=beeta*Ib                         #collector current(mA)\n",
      "rpi=beeta*(25/Ic)                   #dynamic resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"voltage gain is\",round(Av,3)\n",
      "print\"input impedance is\",round(Zi,1),\"KOhm and output impedance is\",round((Zo/1E-3),1),\"ohms\"\n",
      "print\"value of Ic is\",round(Ic,3),\"mA\"\n",
      "print\"value of rpi is\",round((rpi/1E+3),3),\"k ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain is 0.996\n",
        "input impedance is 131.7 KOhm and output impedance is 12.8 ohms\n",
        "value of Ic is 2.026 mA\n",
        "value of rpi is 1.21 k ohms\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.18,Page number 176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import*\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idss=16                           #drain current bias to zero(mA) \n",
      "Vp=-4                             #pinch off voltage(V)  \n",
      "Rg=1                              #gate resistance(ohms)\n",
      "Rs=2.2                            #sourse resistance(ohm)\n",
      "Vdd=9                             #drain drain voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "#Id=Idss*(1-(Vgs/Vp))**2\n",
      "# putting value of Vgs=2.2*Id inequation of Id,we get\n",
      "#Id**2-3.84Id+3.31   \n",
      "\n",
      "Id=symbols('Id')\n",
      "expr=solve(Id**2-3.84*Id+3.31,Id)\n",
      "print expr\n",
      "Id1=1.3    \n",
      "Vgs=-Id1*Rs                                         #gate to source voltage(V)\n",
      "gm0=-(2*Idss)/Vp                                    #transconductance(mS)\n",
      "gm=gm0*(1-(Vgs/Vp))                                 #transconductance(mS)  \n",
      "rm=1/gm                                             #transresistance(k ohms) \n",
      "Av=(Rs*gm)/(1+(Rs*gm))                              #voltage gain\n",
      "\n",
      "#Part b\n",
      "Zi=Rg                                               #input impedance(Mohms)\n",
      "Zo=(Rs*rm)/(Rs+rm)                                  #output impedance(ohms)\n",
      "\n",
      "#Results\n",
      "print\"voltage gain is\",round(Av,3)\n",
      "print\"input and output impedences are\",Zi,\"Mohms and\",round((Zo/1E-3),1),\"ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " [1.30648553399288, 2.53351446600712]\n",
        "voltage gain is 0.834\n",
        "input and output impedences are 1 Mohms and 365.7 ohms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.19,Page number 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Re=0.56                          #emitter resistance(k ohms)\n",
      "beta=1600                        #current gain\n",
      "R1=110                           #resistance(k ohms)\n",
      "R2=330                           #resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Av1=Re*(beta+1)               #voltage gain\n",
      "\n",
      "#part b\n",
      "Rb=(R1*R2)/(R1+R2)             #base resistance(k ohms)\n",
      "Vs=(1.56/(Re*(beta+1)))+1       #source voltage(V) \n",
      "Avs=1/Vs\n",
      "\n",
      "#part c\n",
      "R=1+(1+beta)*Re                                    #resistance presented to Ib\n",
      "I=Rb/(Rb+R)                                        #I=Ib/Ii \n",
      "Ai=(1+beta)*I                                      #current gain\n",
      "\n",
      "#part d\n",
      "Rl=10*10**3                             #load resistance(ohm)\n",
      "Re1=(Re*Rl)/(Re+Rl)                     #emitter resistance(k ohms)\n",
      "R1=1+(1+beta)*Re1                       #resistance presented to Ib(k ohms)\n",
      "I1=Rb/(Rb+R1)                           #I1=Ib/Ii\n",
      "Ai1=(beta+1)*I1                         #current gain\n",
      "Av2=Re1*(1+beta)                        #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"a)voltage gain is\",Av1\n",
      "print\"b)Avs is\",round(Avs,2)\n",
      "print\"c)Ai is\",round(Ai,2)\n",
      "print\"when output Vo1 feeds a load of 10 k ohms Ai is\",round(Ai1),\"and Av2 is\",round(Av2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)voltage gain is 896.56\n",
        "b)Avs is 1.0\n",
        "c)Ai is 134.02\n",
        "when output Vo1 feeds a load of 10 k ohms Ai is 134.0 and Av2 is 897.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.20,Page number 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta1=120.                       #current gain\n",
      "beeta2=160.                      #current gain\n",
      "Vcc=18                           #supply voltage(V)\n",
      "Rc=0.1                           #collector resistance(ohms)\n",
      "Rb=2*10**3.                       #base resistance(ohms)\n",
      "Vbe=0.7                          #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Ib1=(Vcc-Vbe)/(Rb+(beeta1*beeta2*Rc))#base current(uA)\n",
      "Ib2=beeta1*Ib1                      #base current(mA)\n",
      "Ie1=(beeta1+1)*Ib1                  #emitter current(mA)\n",
      "Ic=Ie1+(beeta2*Ib2)                 #collector current(mA)\n",
      "Vo=Vcc-(Ic*Rc)                      #output voltage(V)\n",
      "Vi=Vo-Vbe                           #input voltage(V)\n",
      "\n",
      "#Results\n",
      "print\"dc biased current is\",round(Ic,1),\"mA\"\n",
      "print\"output voltage\",round(Vo,2),\"V\"\n",
      "print\"input voltage\",round(Vi,2),\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dc biased current is 85.3 mA\n",
        "output voltage 9.47 V\n",
        "input voltage 8.77 V\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.21,Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "deltaId=2.                         #change in Id(mA)\n",
      "deltaVgs=1.                        #change in Vgs(V)\n",
      "deltaVds=5.                        #change in Vds(V)\n",
      "Idss=10.                           #drain current biased to zero(mA)\n",
      "Id=5.                              #drain current(mA)\n",
      "Vp=-6.                             #pinch off voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "gm=(deltaId)/(deltaVgs)            #transconductance(mS)\n",
      "rds=(deltaVds)/(deltaId)           #resistance(k ohms)\n",
      "gm0=-(2*Idss)/Vp                   #transconductance(mS)\n",
      "gm=gm0*(math.sqrt(Id/Idss))        #transconductance(mS)\n",
      "\n",
      "#Part b\n",
      "R1=4.5                             #resistance(k ohms)\n",
      "R2=2                               #resistance(k ohms)\n",
      "Av=gm*((R1*R2)/(R1+R2))            #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"drain current biased to zero is\",Idss,\"mA and pinch off voltage is\",Vp,\"V\"\n",
      "print\"value of gm and rds are\",round(gm,2),\"mS and\",rds,\"k ohms\"\n",
      "print\"small signal amplifier gain is\",round(Av,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "drain current biased to zero is 10.0 mA and pinch off voltage is -6.0 V\n",
        "value of gm and rds are 2.36 mS and 2.5 k ohms\n",
        "small signal amplifier gain is 3.26\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.22,Page number 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idson=0.2\n",
      "Vgs=5                      #gate to source voltage(V)\n",
      "Vdd=12                     #drain voltage(V)\n",
      "Vt=2                       #thevinine voltage(V)\n",
      "R1=100.                    #resistance(k ohms)                               \n",
      "R2=100.                    #resistance(k ohms)   \n",
      "Rd=30                      #drain resistance(K ohms)\n",
      "Rs=6                       #source resistance(k ohms)\n",
      "deltaVdd=0.3               #change in Vdd(V)\n",
      "rds=50                     #internal drain to source resistance()\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "k=Idson/((Vgs-Vt)**2)              #device parameter\n",
      "Vgg=Vdd*(R1/(R1+R2))               #gate voltage(V)\n",
      "Vgs=4.89                           #gate to source voltage(V)\n",
      "Id=k*(Vgs-Vt)**2                   #drain current(mA)\n",
      "Vds=Vdd-((Rd+Rs)*Id)               #drain to source voltage(V)\n",
      "gm=2*(math.sqrt(k*Id))             #transconductance(mS)\n",
      "deltaVgg=deltaVdd*(R2/(R1+R2))     #change in Vgg(V)\n",
      "\n",
      "vgs=0.105                          #as vgs=0.15-6id where id=u*vgs/(rds+Rs+Rd)=0.74vgs after solving\n",
      "id= 0.074*vgs*10**3\n",
      "\n",
      "#Results\n",
      "print\"id is\",id,\"uA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "id is 7.77 uA\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.23,Page number 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "deltaId=1                         #change in Id(mA)\n",
      "deltaVgs=0.75                     #change in Vgs(V) \n",
      "rd=100                            #internal drain resistance(k ohms)\n",
      "Rd=100                            #drain resistance(k ohms)\n",
      "Vgs=2                             #as Vgs= 2sinwt                \n",
      "\n",
      "#Calculations\n",
      "gm=(deltaId)/(deltaVgs)           #transconductance(m)  \n",
      "Vo=-gm*Vgs*((rd*Rd)/(rd+Rd))      # as Vi=2sin(w*t)\n",
      "\n",
      "#Results\n",
      "print\"value of Vo is\",round(Vo),\"*sinwt mV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Vo is -133.0 *sinwt mV\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.24,Page number 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Finding resistance\n",
      "\n",
      "#Variable declaration\n",
      "Rd=4                 #drain resistance(ohms)\n",
      "Rs=2.5               #ource resistance(ohms)      \n",
      "R1=200*10**3         #resistance(ohms)\n",
      "R2=100*10**3         #resistance(ohms)\n",
      "gm=2.5               #transconductance(mS)\n",
      "rd=60                #internal drain resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part b\n",
      "Ro=Rs/(1+(((1+gm*rd)*Rs)/(rd+Rd)))   #output resistance(ohms)\n",
      "\n",
      "#Part c\n",
      "Rd1=0                              #drain resistance\n",
      "Ro1=Rs/(1+(((1+gm*rd)*Rs)/rd))     #output resistance(ohms)\n",
      "\n",
      "#Results\n",
      "print\"value of Ro is\",round(Ro/1E-3),\"ohms\"\n",
      "print\"value of Ro1 is\",round(Ro1/1E-3),\"ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ro is 362.0 ohms\n",
        "value of Ro1 is 343.0 ohms\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.25,Page number 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100                      #current gain factor\n",
      "Vbe=0.7                        #base to emitter voltage(V)\n",
      "Rb=250                         #base resistance(k ohms)\n",
      "Vee=10                         #emitter voltage(V)\n",
      "Re=1                           #emitter resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Ib=(Vee-Vbe)/(Rb+1+beeta)       # solving Rb*Ib+Vbe+(Ic+Ib)=Vee and putting Ic+Ib=(1+beeta)Ib\n",
      "Ic=beeta*Ib                     #collector current(mA)\n",
      "rpi=beeta*(25/Ic)               #dynamic resistance(ohms)    \n",
      "Vi=(rpi*Ib)+(1+beeta)*Re*Ib     #input voltage(V)\n",
      "Ri=Vi/Ib                        #input resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"value of Ri is\",round((Ri/1E+1),1),\"K ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ri is 104.5 K ohms\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.26,Page number 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=125                       #current gain\n",
      "gm=35                           #transconductance(mS)\n",
      "Re=4                            #emitter resistance(k ohms)\n",
      "Rb=1.5                          #base resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "rpi=beeta/gm                   #dynamic resistance(k ohms)\n",
      "Ri=rpi+((1+beeta)*Re)          #input resistance(k ohms) \n",
      "Ro=((Rb+rpi)*Re)/((Rb+rpi)+((1+beeta)*Re))  #output resistance(ohms) as Ro=Vo/Isc\n",
      "\n",
      "#Part b                                 \n",
      "f=((1+beeta)*Re)/(Rb+rpi+((1+beeta)*Re))  #transfer function\n",
      "\n",
      "#Results\n",
      "print\"value of Ri is\",Ri,\"K ohms and Ro is\",round(Ro,4),\"k\"\n",
      "print\"transfer function is\",round(f,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ri is 507 K ohms and Ro is 0.0354 k\n",
        "transfer function is 0.99\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.28,Page number 199"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration \n",
      "Vcc=16               #supply voltage(V)\n",
      "Vc=12                 #collector voltage(V)\n",
      "Ic=8                  #collector current(mA)\n",
      "Ic1=12                \n",
      "deltaIc=2000          #collector current(uA)\n",
      "deltaVce=4            #collector emitter voltage(Vce) \n",
      "deltaIb=20            #base current(mA)       \n",
      "Rl=2.                 #load reistance(k ohms)      \n",
      "\n",
      "#Calculations\n",
      "hfe=(deltaIc)/(deltaIb)\n",
      "hoe=(deltaIc)/(deltaVce)\n",
      "Rdc=Vcc/Ic                       #dc resistance(k ohms)\n",
      "Rac=Vc/Ic1                       #ac resistance(k ohms)\n",
      "Re=Rdc-Rac                       #emitter resistance(k ohms)\n",
      "Rac1=(Rac*Rl)/(Rac+Rl)           #for load of 2kohms, Rc=Rac\n",
      "Icq=Vcc/(Rac1+Rdc)               #Ic at operatingpoint(mA) \n",
      "Vceq=Vcc-(Icq*Rdc)               #Vc at operating point(V)\n",
      "\n",
      "#Results\n",
      "print\"value of hfe and hoe are\",hfe,\"uS and\",hoe,\"uS\"\n",
      "print\"value Rc and Re are\",Rac,\"k ohms and\",Re,\"k ohms resp.\"\n",
      "print\"value of Icq and Vce\",Icq,\"mA and\",Vceq,\"V resp.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " value of hfe and hoe are 100 uS and 500 uS\n",
        "value Rc and Re are 1 k ohms and 1 k ohms resp.\n",
        "value of Icq and Vce 6.0 mA and 4.0 V resp.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.29,Page number 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "hfe=120              #current gain\n",
      "r1=1.5               #resistance(k ohms)\n",
      "Vi=1                 #input voltage(V) \n",
      "hoe=50*10**-3        #output conductance with input open circuited\n",
      "Rs=2                 #source resistance(k ohms)\n",
      "Vbe=0.7              #base to emitter voltage(V)\n",
      "Vcc=10               #supply voltage(V)\n",
      "r3=0.33              #resistance(k ohms)\n",
      "r4=5.8               #rsistance(k ohms) \n",
      "r5=27                #rsistance(k ohms) \n",
      "hoe=50*10**-3        #output conductance with input open circuited\n",
      "    \n",
      "#Calculations\n",
      "#Part a\n",
      "Vbb=Vcc*(r4/(r4+r5))          #voltage to bae(V)\n",
      "Rb=(r5*r4)/(r5+r4)            # as Vbb-Vbe=RbIb+(hfe+1)Ib*R,here hfe=beeta\n",
      "ib=(Vbb-Vbe)/(Rb+(hfe+1)*r3)  #instantaneous base current(mA)\n",
      "hie=(0.02/ib)*10**3           \n",
      "Ib=Vi/hie                    #base current(mA)\n",
      "h=hfe*Ib\n",
      "Avo=-h*r1                    #voltage gain\n",
      "\n",
      "#Part b\n",
      "r=1/hoe                #resistance(k ohms)\n",
      "R1=(r*r1)/(r+r1)       #resitance(k ohms)\n",
      "R=(R1*Rs)/(R1+Rs)      #resistance(k ohms)\n",
      "Ib1=1/(Rs+R)          #base current(mA)\n",
      "h1=hfe*Ib1\n",
      "Avl=-h1*R             #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"hie and Avo are\",round(hie),\"and\",round((Avo/1E-3),1)\n",
      "print\"Avl is\",round(Avl,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hie and Avo are 837.0 and -215.1\n",
        "Avl is -34.95\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.30,Page number 201"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rl=20              #load resistance(ohms)\n",
      "Vcc=30             #supply voltage(V)\n",
      "beeta=150          #current gain \n",
      "Re=2200            #emitter resistance(ohms)  \n",
      "Rb=350             #base resistance(k ohms) \n",
      "Vbe=0.7            #base to emitter voltage(V)\n",
      "Is=10**-3          #source current(A) \n",
      "r1=2000            #resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "Ib=(Vcc-Vbe)/(Rb+(1+beeta)*Re)#base current(uA)\n",
      "Ic=beeta*Ib                   #collector current(mA)\n",
      "rpi=beeta*(25/Ic)             #dynamic resistance(ohms)   \n",
      "R=(Re*Rl)/(Re+Rl)             #resistance(ohms)  \n",
      "Ib1=17.95                     #round the base emitter(as Rb>>2 kohms,it it ignored)\n",
      "Vl=(beeta+1)*Ib1*R            #load voltage(V)\n",
      "Avl=Vl                              #Voltage gain\n",
      "Il=Vl/Rl                            #load current(A)\n",
      "Ail=Il/Is                           #current gain\n",
      "\n",
      "#Results\n",
      "print\"overall voltage gain is\",round((Avl/1E+3),2)\n",
      "print\"overall current gain is\",round(Ail/1E+3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "overall voltage gain is 51.5\n",
        "overall current gain is 2575.0\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.31,Page number 202"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=15             #supply voltage(V)\n",
      "beeta=30           #current gain \n",
      "R=.47            #emitter resistance(ohms)  \n",
      "Vbe=0.7            #base to emitter voltage(V)\n",
      "Vo=5               #output voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Vbb=Vcc/2                                   #base voltage(V)\n",
      "'''\n",
      "Vbb=(R1/2)*Ib+Vbe*2+(30Ib+Ic2)*R\n",
      "Ic2=beeta*30Ib,so\n",
      "Ic2=30*30Ib=900Ib\n",
      "Vbb=(R1/2)*Ib+Vbe*2+(30+900)*R*Ib....(i)\n",
      "(R1/2)*Ib+437*Ib=6.1.......(ii)\n",
      "0.47*930Ib=5         #output voltage is given like this\n",
      "\n",
      "'''\n",
      "Ib=Vo/(R*930)    #from equation(i)\n",
      "\n",
      "'''\n",
      "substituting value of Ibin eq(ii) we get\n",
      "\n",
      "'''\n",
      "R1=((6.1-4.98)/0.0114)*2                     #resistance(k ohms)  \n",
      "#Results\n",
      "print\"value of R1 is\",round(R1),\"K ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of R1 is 196.0 K ohms\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}