summaryrefslogtreecommitdiff
path: root/Linear_Integrated_Circuits/Chapter_2.ipynb
blob: d8cc6868027cc8f9ec64d50a31a0c32db7043606 (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
{
 "metadata": {
  "name": "ch_2"
 }, 
 "nbformat": 2, 
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown", 
     "source": [
      "<h1>Chapter 2: Circuit configuration for linear IC's<h1>"
     ]
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 2.1, Page no:40<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''current source to proide output current'''", 
      "", 
      "#Variable Declaration:", 
      "Vcc=5.0              #voltage Vcc in volt", 
      "Vbeon=0.6            #Voltage  Vbeon in volt", 
      "Beta=150.0           #gain", 
      "Io=100.0*10**-6      #output current in amperes", 
      "", 
      "#Calculations:", 
      "Iref=Io*(1+ 2/Beta)  #calculating reference current", 
      "Iref=Iref*10**6      #calculating reference current", 
      "", 
      "R=(Vcc-Vbeon)/Iref   #Calculating value of resistance", 
      "R=R*1000.0           #Calculating value of resistance", 
      "", 
      "#Results:", 
      "print(\"Iref= %.2f uA\"% Iref)", 
      "print(\"\\nResistance= %.2f kohm\"% R)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Iref= 101.33 uA", 
        "", 
        "Resistance= 43.42 kohm"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 2.2, Page No:40<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "''' identical transistor circuit'''", 
      "", 
      "#Variable Declarations:", 
      "Vbe=0.7             #voltage Vbe in volt", 
      "Vcc=12.0            #voltage Vcc in volt", 
      "Rc1=1000.0          #collector resistance in ohm", 
      "Rc2=330.0           #collector resistance in ohm", 
      "", 
      "#Calculations:", 
      "Iref=(Vcc-Vbe)/Rc1  #calculating reference current ", 
      "I0=Iref             #Output current is equal to Reference current ", 
      "V0=Vcc-Rc2*I0       #Calculating output volatge", 
      "", 
      "Iref=Iref/10**-3    #calculating reference current", 
      "", 
      "#Results:", 
      "print(\"Iref= %.1f mA\"%Iref)", 
      "print(\"\\nV0= %.3f V\"%V0)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Iref= 11.3 mA", 
        "", 
        "V0= 8.271 V"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example 2.3, Page No:40<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''output current of transistor'''", 
      "", 
      "#Variable Declaration", 
      "Vbe=0.6             #Voltage Vbe in volt", 
      "Vz=4.7              #Zener voltage in volt", 
      "Re=1000.0           #Emitter resistance in ohm", 
      "", 
      "#Calculations:", 
      "Vre=Vz-Vbe          #Calculating voltage acrross emitter resistance", 
      "", 
      "I=(Vre)/Re          #Calculating output current", 
      "I=I/10**-3          #Calculating output current", 
      "", 
      "#Results", 
      "print(\"I=%.1f mA\"%I)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "I=4.1 mA"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 2.4, Page No.: 42<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''resistance required to produce a current'''", 
      "", 
      "#Variable Declaration:", 
      "import math", 
      "Vcc=20.0            #Vcc in volt", 
      "R1=19300.0          #resistance in ohm", 
      "Vbe=0.7             #Vbe voltage in Volt", 
      "Ic2=0.000005        #current in amperes", 
      "Vt=0.026            # Vt voltage in volt", 
      "", 
      "#Calculations:", 
      "Ic1=(Vcc-Vbe)/R1                    #Calculating current through transistor Q1", 
      "", 
      "R2=(Vt/Ic2)*math.log(Ic1/Ic2)       #Calculating value of R2 for desired current through transistor Q2", 
      "", 
      "Ic1=Ic1/10**-3                      #Calculating current through transistor Q1", 
      "R2=R2/10**3                         #Calculating value of R2 for desired current through transistor Q2", 
      "", 
      "#Results:", 
      "print(\"Ic1= %d mA\"%Ic1)", 
      "print(\"\\nR2= %.2f kohm\"%R2)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Ic1= 1 mA", 
        "", 
        "R2= 27.55 kohm"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.2.5, Page No: 44<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''multiple current source'''", 
      "", 
      "#Variable Declaration:", 
      "Beta=100.0                  #Gain for transistor", 
      "R=20000.0                   #Resistance in ohm", 
      "Vcc=5.0                     #Volatage Vcc in volt", 
      "Vbe=0.6                     #Voltage Vbe in volt", 
      "N=3.0                       #Number of multiple current source", 
      "", 
      "#Calculations:       ", 
      "Iref=(Vcc-Vbe)/R            #Calculating reference current", 
      "", 
      "Ic=Iref*(1+ 4/Beta)         #Calculating current through transistor Q", 
      "Ic1=Iref*(Beta)/(Beta+N+1)  #Calculating current through transistor Q1", 
      "Ic2=Iref*(Beta)/(Beta+N+1)  #Calculating current through transistor Q2", 
      "Ic3=Iref*(Beta)/(Beta+N+1)  #Calculating current through transistor Q3", 
      "", 
      "Iref=Iref/10**-3            #Calculating Reference current", 
      "Ic1=Ic1/10**-3              #Calculating current through transistor Q1", 
      "", 
      "#Results:", 
      "print(\"Iref= %.2f mA\"%Iref)", 
      "print(\"\\nIc1=Ic2=Ic3= %.3f mA\"%Ic1)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Iref= 0.22 mA", 
        "", 
        "Ic1=Ic2=Ic3= 0.212 mA"
       ]
      }
     ], 
     "prompt_number": 5
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.2.6, Page NO: 52<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''design current source using MOSFET'''", 
      "", 
      "#Variable Declaration:", 
      "Iref=0.25*10**-3              #Reference current in amperes", 
      "Io=0.2*10**-3                 #Outpyt current in amperes", 
      "kn=20*10**-6                  #Transconductance in ampere per volt square", 
      "Vth=1.0                       #Threshold voltage in volt", 
      "Vgs2=1.752                    #Voltage Vgs2 in volt", 
      "lamb=0.0                      #Channel length modulation parameter", 
      "Vdd=5.0                       #Voltge Vdd in volt", 
      "Vss=0.0                       #voltage Vss in volt", 
      "", 
      "#Calculations:", 
      "wbyltwo=Io/(kn*(Vgs2-Vth)**2)     #calculating width by length 2 ratio", 
      "Vdssat=Vgs2-Vth                   #Calculating voltage Vdssat", 
      "Vgs1=Vgs2                         #Volage Vgs1 is eqaul to Vgs2", 
      "wbylone=Iref/(kn*(Vgs2-Vth)**2)   #Calculating width by length 1 ratio", 
      "Vgs3=Vdd-Vss-Vgs1                 #Calculating Vgs3", 
      "wbylthr=Iref/(kn*(Vgs3-Vth)**2)   #calculating width by length 3 ratio", 
      "", 
      "#Results:", 
      "print(\"W/L2= %.1f\"%wbyltwo)", 
      "print(\"\\nVds(sat)= %.3f V\"%Vdssat)", 
      "print(\"\\nW/L1= %.1f\"%wbylone)", 
      "print(\"\\nVgs3= %.3f V\"%Vgs3)", 
      "print(\"\\nW/L3= %.2f\"% wbylthr)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "W/L2= 17.7", 
        "", 
        "Vds(sat)= 0.752 V", 
        "", 
        "W/L1= 22.1", 
        "", 
        "Vgs3= 3.248 V", 
        "", 
        "W/L3= 2.47"
       ]
      }
     ], 
     "prompt_number": 6
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 2.7, Page No: 75<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''differential amplifier CMRR'''", 
      "", 
      "#Variable Declaration:", 
      "cmrra=1000.0          #common mode rejection ratio", 
      "cmrrb=10000.0         #common mode rejection ratio ", 
      "v1a=100.0*10**-6      #input voltage in volt", 
      "v2a=-100.0*10**-6     #input voltage in volt", 
      "v1b=1100.0*10**-6     #input voltage in volt", 
      "v2b=900.0*10**-6      #input voltage in volt", 
      "", 
      "#Calculations", 
      "#for first set", 
      "vida=v1a-v2a                   #Calculating differential volatge", 
      "vcma=(v1a+v2a)/2               #calculating common mode voltage", 
      "vic=0.0                        #Calculating common mode voltage", 
      "voa=vida*(1+vic/(cmrra*vida))  #Calculating Output voltage", 
      "voa=voa*10**6                  #Calculating output volatge", 
      "", 
      "# for second set", 
      "vidb=v1b-v2b                   #Calculating differential volatge", 
      "vic=(v1b+v2b)/2                #calculating common mode voltage", 
      "vob=vidb*(1+vic/(cmrrb*vidb))  #Calculating Output voltage", 
      "vob=vob*10**6                  #Calculating Output voltage", 
      "", 
      "#Results:", 
      "print(\"\\nVo for second set= %.1f uV\"%vob)", 
      "print(\"Vo for first set= %.1f uV\"% voa)", 
      "", 
      "#answer in textbook is wrong"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "", 
        "Vo for second set= 200.1 uV", 
        "Vo for first set= 200.0 uV"
       ]
      }
     ], 
     "prompt_number": 7
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.2.8, Page No.76<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''Q-point of differential amplifier'''", 
      "", 
      "#Variable Declaration:", 
      "Beta=100.0               #Gain", 
      "Vee=15.0                 #Voltage Vee in volt", 
      "Vcc=15.0                 #Voltage Vcc in volt", 
      "Vbe=0.7                  #Voltage Vbe in volt", 
      "Re=65.0*10**3            #Resistance in ohm", 
      "Rc=65.0*10**3            #Resistance in ohm", 
      "alpha=100.0/101.0        #Gain", 
      "Ve=-0.7                  #Voltage Ve in volt", 
      "", 
      "#Calculations:", 
      "Ie=(Vee-Vbe)/(2*Re)      #Calculating emitter current", 
      "Ic=alpha*Ie              #Calculating collector current", 
      "Ib=Ic/Beta               #Calculating base current", 
      "", 
      "Vc=Vcc-Ic*Rc             #Calculating collector volatge", 
      "", 
      "Vce=Vc-Ve                #Calculating voltage between collector and emitter", 
      "", 
      "Ie=Ie*10**6              #Calculating emitter current", 
      "", 
      "Ic=Ic*10**6              #Calculating collector current", 
      "", 
      "Ib=Ib*10**6              #Calculating base current", 
      "", 
      "# by approximating, because Vee>>Vbe", 
      "", 
      "Ieapprox=Vee/(2*Re)      #calculating emitter current by approximation", 
      "Ieapprox=Ieapprox*10**6  #calculating emitter current by approximation", 
      "", 
      "#Results:", 
      "print('Ie= %.1f uA'%Ie)", 
      "print('\\nIc= %.1f uA'%Ic)", 
      "print('\\nIb= %.3f uA'%Ib)", 
      "print('\\nVc= %.3f V'%Vc)", 
      "print('\\nVce= %.3f V'%Vce)", 
      "", 
      "print('\\nIe (approx)= %.2f uA'%Ieapprox)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Ie= 110.0 uA", 
        "", 
        "Ic= 108.9 uA", 
        "", 
        "Ib= 1.089 uA", 
        "", 
        "Vc= 7.921 V", 
        "", 
        "Vce= 8.621 V", 
        "", 
        "Ie (approx)= 115.38 uA"
       ]
      }
     ], 
     "prompt_number": 8
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.2.9, Page No.89<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "'''Q-point for MOSFET of differential amplifier'''", 
      "", 
      "#Variable Declaration:", 
      "import math", 
      "Vdd=12.0                     #Voltage Vdd in volt", 
      "Vss=-12.0                    #Voltage Vss in volt", 
      "Iss=175.0*10**-6             #Current Iss in amperes", 
      "Rd=65.0*10**3                #resistance Rd in ohm", 
      "kn=3.0*10**-3                #Transconductance", 
      "Vth=1.0                      #Voltage Vth in volt", 
      "", 
      "#Calculations:", 
      "Ids=Iss/2.0                  #Calculating Ids", 
      "", 
      "Vgs=Vth + math.sqrt(Iss/kn)  #Calculating Vgs", 
      " ", 
      "Vds = Vdd- Ids*Rd + Vgs      #Calculating Vds", 
      "", 
      "#Requirement for saturation", 
      "Vicmax= Vdd - Ids*Rd + Vth   #Calculating Vicmax", 
      "", 
      "Ids=Ids*10**6                #Calculating Ids", 
      "", 
      "#Results:", 
      "print('\\nIds=%.1f uA'% Ids)", 
      "print('\\nVgs=%.3f V'%Vgs)", 
      "print('\\nVds=%.2f V'% Vds)", 
      "print('\\nVicmax=%.2f V'% Vicmax)", 
      "print('\\nRequirement of saturation for M1 \\nfor non-zero Vic necessiates Vic <= 7.312 V')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "", 
        "Ids=87.5 uA", 
        "", 
        "Vgs=1.242 V", 
        "", 
        "Vds=7.55 V", 
        "", 
        "Vicmax=7.31 V", 
        "", 
        "Requirement of saturation for M1 ", 
        "for non-zero Vic necessiates Vic <= 7.312 V"
       ]
      }
     ], 
     "prompt_number": 9
    }
   ]
  }
 ]
}