summaryrefslogtreecommitdiff
path: root/Linear_Integrated_Circuits/Chapter2.ipynb
blob: 011589fa28686d22c8820906dc082fa85671da59 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Operational Amplifier"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1 Page No.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data\n",
      "\n",
      "R1 = 5*10**3\n",
      "Rf = 20*10**3\n",
      "vi = 1 \n",
      "RL = 5*10**3\n",
      "\n",
      "# calculating the values \n",
      "vo = float((1+(Rf/R1))*vi) \n",
      "ACL = int(vo/vi)\n",
      "iL = int((vo/RL)*10**3)\n",
      "i1 = float(((vo - vi)/Rf))*(10**3)\n",
      "io = iL+i1\n",
      " \n",
      " \n",
      "# printing the values\n",
      "print \"Output voltage vo = \",vo,\"V\"\n",
      "print \"Gain ACL          = \",ACL\n",
      "print \"Load current iL   = \",iL,\"mA\"\n",
      "print \"The value of i1   = \",i1,\"mA\"\n",
      "print \"Output current io = \", io,\"mA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage vo =  5.0 V\n",
        "Gain ACL          =  5\n",
        "Load current iL   =  1 mA\n",
        "The value of i1   =  0.2 mA\n",
        "Output current io =  1.2 mA\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2 Page No.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "\n",
      "R1 = 10*10**3      #R1 input resistance \n",
      "Rf = 100*10**3     # Rf feedback resistance\n",
      "vi = float(1)          #input voltage  \n",
      "RL = 25*10**3\n",
      "#calculating the values \n",
      "\n",
      "i1 = float((vi/R1)*10**3)                 # input resistace id the ratio of input voltage to the input resitance \n",
      "vo = float(-(Rf/R1)*vi)            # finding the output voltage \n",
      "iL = float((abs(vo)/RL)*10**3)                  #  calculating the load current \n",
      "io = float((i1+iL))                 # calculating the output current which is equal to the sum of input current and load current\n",
      "\n",
      "#printing the values \n",
      "\n",
      "print \"The input current i1  =\",i1,\"mA\"\n",
      "print \"The output voltage vo =\",vo,\"V\"\n",
      "print \"The load current iL   =\",iL,\"mA\"\n",
      "print \"The output current io =\",io,\"mA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The input current i1  = 0.1 mA\n",
        "The output voltage vo = -10.0 V\n",
        "The load current iL   = 0.4 mA\n",
        "The output current io = 0.5 mA\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3 Page No.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "\n",
      "ACL = 5     # Gain of the amplifier\n",
      "R1 = 10*10**3 # input resisitance in ohms \n",
      "\n",
      "# calculations\n",
      "\n",
      "Rf = (5-1) * R1 # calculating the resistance of feedback resistor \n",
      "\n",
      "# printing the values \n",
      "\n",
      "print \"The value of feedback resistor = \", (Rf/10**3),\"KiloOhms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of feedback resistor =  40 KiloOhms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4 Page No.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Given Data\n",
      "\n",
      "R1 = 5*10**3\n",
      "Rf = 20*10**3\n",
      "vi = 1 \n",
      "RL = 5*10**3\n",
      "\n",
      "# calculating the values \n",
      "vo = float((1+(Rf/R1))*vi) \n",
      "ACL = int(vo/vi)\n",
      "iL = int((vo/RL)*10**3)\n",
      "i1 = float(((vo - vi)/Rf))*(10**3)\n",
      "io = iL+i1\n",
      " \n",
      " \n",
      "# printing the values\n",
      "print \"Output voltage vo = \",vo,\"V\"\n",
      "print \"Gain ACL          = \",ACL\n",
      "print \"Load current iL   = \",iL,\"mA\"\n",
      "print \"The value of i1   = \",i1,\"mA\"\n",
      "print \"Output current io = \", io,\"mA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage vo =  5.0 V\n",
        "Gain ACL          =  5\n",
        "Load current iL   =  1 mA\n",
        "The value of i1   =  0.2 mA\n",
        "Output current io =  1.2 mA\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6 Page No.61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Given Data\n",
      "from decimal import Decimal, ROUND_HALF_UP\n",
      "import math\n",
      "Beta = 200\n",
      "ICQ = 100*10**-6\n",
      "ADM = 100\n",
      "CMRR = 80\n",
      "\n",
      "# finding the solution \n",
      "# for VT =25 milli volt \n",
      "VT = 25*10**-3\n",
      "gm = float(ICQ/VT)\n",
      "Rc = (ADM/gm) \n",
      "CMRR = 10**(80/20) # log inverse is equal to powers of 10\n",
      "RE = float((CMRR-1)/gm)\n",
      "x = Decimal((RE/10**6))\n",
      "\n",
      "# printing the values \n",
      "\n",
      "print \" The value of gm =\",int(math.ceil((gm*10**3))),\"mMho\"            #converting the answer into milli Mho\n",
      "print \" The value of Rc =\",int((Rc/10**3)),\"kiloOhm\"         #converting the answer into Kilo Ohm\n",
      "print \" The value of RE =\", x.quantize(Decimal('2.5')),\"MegaOhm\"         #converting the answer into MegaOhm"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of gm = 4 mMho\n",
        " The value of Rc = 25 kiloOhm\n",
        " The value of RE = 2.5 MegaOhm\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7 Page No.61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "# Given Data\n",
      "RC = 2*10**3\n",
      "RE = 4.3*10**3\n",
      "VCC = VEE = 5\n",
      "beta0 = 200\n",
      "VBE = 0.7\n",
      "VT = 25*10**-3                                  # VT = 25 mV \n",
      "\n",
      "#calculations \n",
      "\n",
      "Ibq  = (((VEE - VBE)/(2*(1+beta0)*RE)))*10**6   # converting the into mA\n",
      "IBQ = int(Ibq*10)/10.0                          # rounding the answer 2.48 to 2.4\n",
      "ICQ = beta0 * IBQ*10**-3                        # finding ICQ and convert it into milli Ambere\n",
      "V01 = V02 = VCC - (RC * ICQ*10**-3)\n",
      "VCEQ = V01 + VBE\n",
      "gm = ICQ / VT                                   # Finding the gm value in milli Mho\n",
      "rpi = float(beta0/gm)                           # finding rpi interms of KiloOhms \n",
      "ADM = -(gm*RC)/10**3                            # Calculating the gain \n",
      "ACM = float((-beta0*RC)/(rpi*10**3 + (2*beta0) * RE)) # Calulating the value of ACM and coverting it into a float \n",
      "CMRR = float(round(ADM,2)/round(ACM,2))               # rounding ACM and ADM to 2 digits after decimals and taking the\n",
      "                                                      #ratio\n",
      "CMRRdb = float(20*math.log10(round(CMRR,1)))          # Find the CMRR in dB using equation 20*log(CMRR)\n",
      "\n",
      "# Printing all values \n",
      "\n",
      "print \"The IBQ        =\",IBQ,\"uA\"\n",
      "print \"The ICQ        =\",ICQ,\"mA\"\n",
      "print \"The V01        =\",V01,\"mV\"\n",
      "print \"The VCEQ       =\",VCEQ,\"V\"\n",
      "print \"The gm         =\",gm,\"m Mho\"\n",
      "print \"The rpi        =\",round(rpi,1),\"kilo Ohm\"\n",
      "print \"The ADM        =\",round(ADM,2)\n",
      "print \"The ACM        =\",round(ACM,2)\n",
      "print \"The CMRR       =\",round(CMRR,1)\n",
      "print \"The CMRR in dB =\",int(CMRRdb*10)/10.0,\"dB\"\n",
      "                                      "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The IBQ        = 2.4 uA\n",
        "The ICQ        = 0.48 mA\n",
        "The V01        = 4.04 mV\n",
        "The VCEQ       = 4.74 V\n",
        "The gm         = 19.2 m Mho\n",
        "The rpi        = 10.4 kilo Ohm\n",
        "The ADM        = -38.4\n",
        "The ACM        = -0.23\n",
        "The CMRR       = 167.0\n",
        "The CMRR in dB = 44.4 dB\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8 Page No.62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# v1 = 15*sin*2*pi(60)t + 5*sin*2*pi(1000)t mV\n",
      "# v1 = 15*sin*2*pi(60)t - 5*sin*2*pi(1000)t mV\n",
      "\n",
      "# Given data \n",
      "\n",
      "gm = 4*10**-3\n",
      "RC = 125*10*3\n",
      "RE = 1.25*10**3\n",
      "beta0 = 200\n",
      "\n",
      "# calculating the values\n",
      "\n",
      "rpi = beta0/gm              # value is in ohms \n",
      "ADM =-500                   # Given Value\n",
      "ACM = -((200*RC)/(402*RE)+rpi)*10**-6\n",
      "print \"ACM is =\",round(ACM,2)\n",
      "\n",
      "# derivation part is as follows  \n",
      "# VDM = (v1 - v2)/2 = 5*sin*2*pi(1000)*t\n",
      "# VCM = (v1 - v2)/2 = 15*sin*2*pi(60)*t\n",
      "# VO1 = ADM*VDM + ACM*VCM\n",
      "# VO2 = ADM*VDM - ACM*VCM\n",
      "# V01 = -2500*sin*2*pi(1000)t - 0.75*sin*2*pi(60)t mV\n",
      "# V01 =  2500*sin*2*pi(1000)t - 0.75*sin*2*pi(60)t mV"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ACM is = -0.05\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9 Page No.63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from fractions import Fraction \n",
      "# Given data\n",
      "\n",
      "beta0 = 100\n",
      "IQ = 5*10**-4\n",
      "RC = 10*10**3\n",
      "RE = 150\n",
      "VT = 25*10**-3 \n",
      "\n",
      "# calculations \n",
      "\n",
      "ICQ = float(IQ/2)\n",
      "gm  = float(ICQ / VT)\n",
      "rpi = beta0/gm\n",
      "# calculaing the gain in Differential mode\n",
      "ADM = ((0.5)*(beta0*RC))/(rpi+((1+beta0)*RE))\n",
      "# To get the differentila mode gain multiply the value by 2\n",
      "ADM2 = (ADM*2)\n",
      "\n",
      "# print the values \n",
      "\n",
      "print \"ICQ value is =\",ICQ*10**3,\"mA\"\n",
      "print \"gm value is  =\",Fraction(gm).limit_denominator(100),\"Mho\"  \n",
      "print \"rpi value is =\",int(rpi/10**3),\"kilo Ohm\"\n",
      "print \"THe gain is  =\",int(math.ceil(ADM2)),\"V/V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ICQ value is = 0.25 mA\n",
        "gm value is  = 1/100 Mho\n",
        "rpi value is = 10 kilo Ohm\n",
        "THe gain is  = 40 V/V\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10 Page No.67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data \n",
      "VCC = 10.0                  # initializing as floats \n",
      "beta = 125.0\n",
      "VBE = 0.7\n",
      "\n",
      "# calculations \n",
      "# Define a function for calculating the value of R1 according to the equation given in 2.67\n",
      "def R1(I):\n",
      "    R1 = (beta/(2+beta))*((VCC-VBE)/I)       \n",
      "    return (R1/1000)\n",
      "# Cosisdering Ic = 1mA\n",
      "print \"The value of R1 when I is 1 mA  = \",round(R1(10**-3),2),\"Kilo Ohm\"           # calling the function R1 with arguiment as current value 1 mA\n",
      "print \"The value of R1 when I is 10 uA = \",int(round(R1(10*10**-6),0)),\"Kilo Ohm\"  # calling the function R1 with arguiment as current value 10 uA"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 when I is 1 mA  =  9.15 Kilo Ohm\n",
        "The value of R1 when I is 10 uA =  915 Kilo Ohm\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11 Page No.69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "import math\n",
      "I0 = 10*10**-6\n",
      "VCC =10\n",
      "VBE = 0.7\n",
      "beta = 125\n",
      "VT = 25*10**-3\n",
      "\n",
      "# Solution of the problem is \n",
      "Iref = 10**-3 # Assumption\n",
      "\n",
      "R1 = (VCC - VBE)/Iref\n",
      "# Finding the value RE from the equation 2.74\n",
      "RE = (VT/(1+(1/beta)*I0))*math.log(Iref/I0)\n",
      "\n",
      "# printing the values \n",
      "\n",
      "print \"The value of R1 =\",R1/10**3,\"Kilo Ohms\"\n",
      "print \"The value of RE =\",round(RE*100,1),\"Kilo Ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 9.3 Kilo Ohms\n",
        "The value of RE = 11.5 Kilo Ohms\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.13 Page No.74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "VCC = 10.0\n",
      "beta = 100\n",
      "VBE = 0.7\n",
      "RE = 10*10**3\n",
      "\n",
      "# solution\n",
      "# fom the KVL loop1\n",
      "Iref = ((VCC - VBE)/RE)   # Finding the Iref \n",
      "# Assuming the transistor are identical \n",
      "# Iref = 2IE\n",
      "# IE = IC + IB\n",
      "IC = (beta*Iref/(2*(1+beta)))\n",
      "I0 = IC\n",
      "#Displaying the values \n",
      "\n",
      "print \"The value of Iref =\",Iref*10**3,\"mA\"             # Converting the value into mA\n",
      "print \"The value of IC   =\",round(IC*10**3,2),\"mA\"      # Converting the value into mA and rounding the answer\n",
      "print \"The value of I0   =\",round(I0*10**3,2),\"mA\"      # Converting the value into mA and rounding the answer"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Iref = 0.93 mA\n",
        "The value of IC   = 0.46 mA\n",
        "The value of I0   = 0.46 mA\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.14 Page No.75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data  \n",
      "\n",
      "VCC = 12.0\n",
      "Rref = 15*10**3 \n",
      "R1 = 2.8*10**3\n",
      "beta = 200\n",
      "VBE = 0.7\n",
      "V0 = 6.0\n",
      "\n",
      "#Calculations \n",
      "#Calculations for finding the IC1 and IC2\n",
      "Iref = (VCC - VBE)/Rref\n",
      "I1 = VBE / R1\n",
      "IC1 = (Iref - I1)/(1+(2/beta))\n",
      "IC2 = IC1 # Due to mirror effect \n",
      "RC = (VCC - V0)/IC1\n",
      "\n",
      "# Displaying the values \n",
      "\n",
      "print \"The value of Iref  =\",round(Iref*10**3,2),\"mA\"             # convert into milli amps and rounding the output\n",
      "print \"The value of I1    =\",round(I1*10**3,2),\"mA\"               # convert into milli amps and rounding the output\n",
      "print \"The value of IC1   =\",round(IC1*10**3,1),\"mA\"              # convert into milli amps and rounding the output\n",
      "print \"The value of Rc    =\",int(round(RC*10**-3,0)),\"Kilo Ohm\"   # convert into kilo Ohms and rounding the output"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Iref  = 0.75 mA\n",
        "The value of I1    = 0.25 mA\n",
        "The value of IC1   = 0.5 mA\n",
        "The value of Rc    = 12 Kilo Ohm\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.15 Page No.75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data  \n",
      "\n",
      "VCC = 10.0\n",
      "VBE = 0.75\n",
      "R1 = 4.7*10**3\n",
      "\n",
      "# solution \n",
      "# I is approximately equals to Ic(2 + (1/beta)), since 1/beta is a small value its considerd as 2Ics \n",
      "I = (VCC - VBE)/R1\n",
      "# IE3 is approxiamtly equal to IC3 = I/2\n",
      "#finding the value of IC \n",
      "IC = I /2\n",
      "print \" The value of I  =\",round(I*10**3,2),\"mA\"\n",
      "print \" The value of IC =\",round(IC*10**3,2),\"mA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of I  = 1.97 mA\n",
        " The value of IC = 0.98 mA\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.16 Page No.80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC = 15.0\n",
      "VBE = 0.7\n",
      "R = 10*10**3\n",
      "RC2 = 5*10**3\n",
      "# consider beta is a large value \n",
      "I = (VCC - VBE)/R\n",
      "IC1 = IC2 = I\n",
      "#V12 = V1 - V2\n",
      "V12 = VBE + IC2 * RC2 \n",
      "\n",
      "# displaying the values\n",
      "print \"The value of I        =\",round(I*10**3,2),\"mA\"\n",
      "print \"The value of V1 - V2  =\",V12,\"V\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of I        = 1.43 mA\n",
        "The value of V1 - V2  = 7.85 V\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.17 Page No.83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Given data\n",
      "\n",
      "VEE = 6.0\n",
      "VCC = 6.0\n",
      "VD = VD1 = VD2 = VD3 = VD4 = 0.7\n",
      "R5 = 3.2*10**3\n",
      "R4 = 1.5*10**3\n",
      "VBE1 = VBE2 =VBE3 = VBE4 = VBE5 = VBE6 = VBE7 = VBE8 = 0.7\n",
      "R1 = 2.2*10**3\n",
      "R2 = 7.75*10**3\n",
      "R3 = 5.2*10**3\n",
      "R6 = 1.5*10**3\n",
      "R7 = 3*10**3\n",
      "R8 = 3.4*10**3\n",
      "R9 = 6*10**3\n",
      "R10 =30*10**3\n",
      "hfe = 100\n",
      "VT = 26*10**-3\n",
      "\n",
      "# Solution for part A\n",
      "\n",
      "VBN1 = round((-VEE+VD+VD)*R5/(R4+R5),2)\n",
      "I1 = (VEE+VBN1-VBE1)/R1\n",
      "IQ = I1  # If the base current of Q1 is neglected\n",
      "IC2 = IC3 = IQ2 = round(IQ/2,6)\n",
      "VC2 = VC3 = round((VCC - R2*IC2),2)\n",
      "VE4 = VC2 - VBE4 \n",
      "I6 = round(VE4/R6,6)\n",
      "IC4 = IC5 = round((I6/2),6)\n",
      "VC5 = round(VCC - IC5*R7,2)\n",
      "VE6 = round(VC5 - VBE6,2)\n",
      "IC7 = I8 = round((VEE - VD3)/R8,5)\n",
      "VB8 = VBE8 + VD4 - VEE\n",
      "I9 = round((VE6 - VB8)/R9,5)\n",
      "I10 = IC7 - I9\n",
      "Vo = (I10 * R10) + VB8\n",
      "V0 = int(Vo)         # Vo value is assumed to be very small\n",
      "\n",
      "# Displaying the values \n",
      "print \"PART A\"\n",
      "print \"==================\"\n",
      "print \"the value of VBN1 =\",VBN1,\"V\"\n",
      "print \"The value of I1   =\",I1*10**3,\"mA\"\n",
      "print \"The value of IQ   =\",IQ*10**3,\"mA\"\n",
      "print \"The value of IC2  =\",IC2*10**3,\"mA\"\n",
      "print \"The value of VC3  =\",VC3,\"V\"\n",
      "print \"The value of VE4  =\",VE4,\"V\"\n",
      "print \"The value of IC4  =\",IC4*10**3,\"mA\"\n",
      "print \"The value of VC5  =\",VC5,\"V\"\n",
      "print \"The value of VE6  =\",VE6,\"V\"\n",
      "print \"The value of IC7  =\",IC7*10**3,\"mA\"\n",
      "print \"The value of VB8  =\",VB8,\"V\"\n",
      "print \"The value of I9   =\",I9*10**3,\"mA\"\n",
      "print \"The value of I10  =\",I10*10**3,\"mA\"\n",
      "print \"The value of V0   =\",V0,\"V\"\n",
      "\n",
      "# Solution for part B\n",
      "VT = 26*10**-3                #the volt equivalent of temperature \n",
      "IC2 = IC3 = IC4 = IC5 = IC = 0.5*10**-3\n",
      "hie = (hfe*VT)/IC\n",
      "RL2 = RL3 = (R2*R3)/(R2+R3)\n",
      "AV1 = round((hfe*RL2)/hie,0)\n",
      "AV2 = round(-(hfe*R7)/(2*hie),2)\n",
      "AV3 = 1                                        # the thrid stage emitter follower differential gain \n",
      "AV4 = int(-R10/R9)\n",
      "AV = AV1*round(AV2,1)*AV4                      # again rounding AV2 to get the desired value\n",
      "\n",
      "# Displaying the values\n",
      "print \"PART B\"\n",
      "print \"==================\"\n",
      "print \"The value of hie =\",int(hie)\n",
      "print \"The value of RL2 =\",RL2*10**-3,\"Kilo Ohms\"\n",
      "print \"The value of AV1 =\",int(AV1)\n",
      "print \"The value of AV2 =\",round(AV2,1)\n",
      "print \"The value of AV3 =\",AV3\n",
      "print \"The value of AV4 =\",AV4\n",
      "print \"The value of AV  =\",int(AV)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "PART A\n",
        "==================\n",
        "the value of VBN1 = -3.13 V\n",
        "The value of I1   = 0.986363636364 mA\n",
        "The value of IQ   = 0.986363636364 mA\n",
        "The value of IC2  = 0.493 mA\n",
        "The value of VC3  = 2.18 V\n",
        "The value of VE4  = 1.48 V\n",
        "The value of IC4  = 0.494 mA\n",
        "The value of VC5  = 4.52 V\n",
        "The value of VE6  = 3.82 V\n",
        "The value of IC7  = 1.56 mA\n",
        "The value of VB8  = -4.6 V\n",
        "The value of I9   = 1.4 mA\n",
        "The value of I10  = 0.16 mA\n",
        "The value of V0   = 0 V\n",
        "PART B\n",
        "==================\n",
        "The value of hie = 5200\n",
        "The value of RL2 = 3.11196911197 Kilo Ohms\n",
        "The value of AV1 = 60\n",
        "The value of AV2 = -28.9\n",
        "The value of AV3 = 1\n",
        "The value of AV4 = -5\n",
        "The value of AV  = 8670\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.18 Page No.87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "VEE = 15.0\n",
      "VCC = 15.0\n",
      "VBE1 = VBE2 = VBE3 = VBE4 = VBE5 = VBE= 0.7\n",
      "R = 28.6*10**3\n",
      "RC1 = 20*10**3\n",
      "RC6 = 3*10**3\n",
      "RC8 = 2.3*10**3\n",
      "RA = 15.7*10**3\n",
      "hfe = 100\n",
      "VT = 25*10**-3\n",
      "\n",
      "# Solution for part 1 DC - ANALYSIS\n",
      "\n",
      "I = (VEE - VBE3)/R\n",
      "ICQ4 = I\n",
      "ICQ1 = ICQ2 = ICQ4/2\n",
      "# Q1 and Q2 are biased at 0.25mA so their Collector voltages are\n",
      "IC1 = IC = ICQ1\n",
      "VCQ1 = VCQ2 = VCC - (IC1*RC1)\n",
      "VEQ5 = VEQ6 = VCQ1 - VBE\n",
      "IQ7 = 4*I\n",
      "# The collector current of Q5 and Q6 are \n",
      "ICQ5 = ICQ6 = IQ7/2\n",
      "VCQ6 = VCC - (ICQ6 * RC6)\n",
      "VEQ8 = VCQ6 + VBE\n",
      "IEQ8 = (VCC - VEQ8)/RC8\n",
      "# The voltage VA at the collector of Q8 is \n",
      "VA = -VCC + (IEQ8 * RA)\n",
      "IEQ9 = (0-(-VCC))/RC6\n",
      "\n",
      "# Displaying all values of Part 1\n",
      "\n",
      "print \"The value of I      =\",int(I*10**3),\"mA\"\n",
      "print \"The value of ICQ1   =\",int(ICQ1*10**3),\"mA\"\n",
      "print \"The value of VCQ1   =\",int(VCQ1),\"V\"\n",
      "print \"The value of VEQ5   =\",int(VEQ5),\"V\"\n",
      "print \"The value of IQ7    =\",int(IQ7*10**3),\"mA\"\n",
      "print \"The value of ICQ5   =\",int(ICQ5*10**3),\"mA\"\n",
      "print \"The value of VCQ6   =\",int(VCQ6),\"V\"\n",
      "print \"The value of VEQ8   =\",int(VEQ8),\"V\"\n",
      "print \"The value of IEQ8   =\",int(IEQ8*10**3),\"mA\"\n",
      "print \"The value of VA     =\",VA,\"V\"\n",
      "print \"The value of IEQ9   =\",int(IEQ9*10**3),\"mA\"\n",
      "\n",
      "# Part 2 AC -ANALYSIS\n",
      "\n",
      "hieQ12 = (hfe * VT)/IC\n",
      "# The ac emitter resistance of transister Q5 - Q6\n",
      "hieQ56 = (hfe * VT)/ICQ5\n",
      "RL1 = RL2 = (RC1*hieQ56)/(RC1 + hieQ56)          # parallel combination of resistor RC1 and hieQ56\n",
      "ADM1 = (hfe * RL2)/hieQ12\n",
      "ADM2 = -(hfe * RC6)/(2*hieQ56)\n",
      "\n",
      "\n",
      "# Displaying the values \n",
      "\n",
      "print \"The value of ac emiiter resistace of the transistor Q1-Q2  = \",int(round(hieQ12*10**-3,0)),\"Kilo Ohm\"\n",
      "print \"The value of ac emiiter resistace of the transistor Q5-Q6  = \",round(hieQ56*10**-3,1),\"Kilo Ohm\"\n",
      "print \"The value of effective load of Q1-Q2                       = \",round(RL1*10**-3,1),\"Kilo Ohm\"\n",
      "print \"The value of voltage gain of first differential pair       = \",int(round(ADM1,0)),\"Kilo Ohm\"\n",
      "print \"The value of voltage gain of second differential pair      = \",int(ADM2),\"Kilo Ohm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of I      = 0 mA\n",
        "The value of ICQ1   = 0 mA\n",
        "The value of VCQ1   = 10 V\n",
        "The value of VEQ5   = 9 V\n",
        "The value of IQ7    = 2 mA\n",
        "The value of ICQ5   = 1 mA\n",
        "The value of VCQ6   = 12 V\n",
        "The value of VEQ8   = 12 V\n",
        "The value of IEQ8   = 1 mA\n",
        "The value of VA     = 0.7 V\n",
        "The value of IEQ9   = 5 mA\n",
        "The value of ac emiiter resistace of the transistor Q1-Q2  =  10 Kilo Ohm\n",
        "The value of ac emiiter resistace of the transistor Q5-Q6  =  2.5 Kilo Ohm\n",
        "The value of effective load of Q1-Q2                       =  2.2 Kilo Ohm\n",
        "The value of voltage gain of first differential pair       =  22 Kilo Ohm\n",
        "The value of voltage gain of second differential pair      =  -60 Kilo Ohm\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}