summaryrefslogtreecommitdiff
path: root/Microelectronic_Circuits_by_A.S._Sedra_and_K.C._Smith/Chapter1.ipynb
blob: fb4718f9ecd6543608f71c7b6fb508b4e7de879e (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
{

 "metadata": {

  "name": "",

  "signature": "sha256:b8c93f0ed8e762e74a7e32d1ae1c9fc9e20a3917843706f0d24d06eedbf42b4e"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter01:INTRODUCTION TO ELECTRONICS"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.1:pg-17"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example1.1: Amplifier gain, power and eficiency\n",

      "# Amplifier operates at +10-V/-10-V power supply.\n",

      "A_v=9/1.0; # sinusoidal voltage input of 1V peak and sinusoidal output voltage of 9V peak\n",

      "I_o=9/1000.0; # 1 kilo ohms load\n",

      "print A_v,\"= Voltage gain (V/V) \" \n",

      "print round(20*log10(A_v),1),\"= Voltage gain (dB) \" \n",

      "I_i=0.0001 # sinusoidal current input of 0.1mA peak\n",

      "A_i=I_o/I_i;\n",

      "print A_i,\"= Current gain (A/A) \"\n",

      "print round(20*log10(A_i),1),\"= Current gain (dB)\"\n",

      "V_orms = 9/math.sqrt(2);\n",

      "I_orms = 9/math.sqrt(2);\n",

      "P_L=V_orms*I_orms; # output power in mW\n",

      "V_irms=1/math.sqrt(2);\n",

      "I_irms=0.1/math.sqrt(2);\n",

      "P_I=V_irms*I_irms; # input power in mW\n",

      "A_p=P_L/P_I; \n",

      "print A_p,\"= Power gain (W/W) \"\n",

      "print round(10*log10(A_p),1),\"= Power gain (dB) \"\n",

      "P_dc=10*9.5+10*9.5; # amplifier draws a current of 9.5mA from each of its two power supplies\n",

      "print P_dc,\"= Power drawn from the dc supplies (mW)\"\n",

      "P_dissipated=P_dc+P_I-P_L;\n",

      "print round(P_dissipated,1),\"= Power dissipated in the amplifier (mW)\"\n",

      "n=P_L/P_dc*100;\n",

      "print round(n,1),\"= Amplifier efficiency in percentage\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "9.0 = Voltage gain (V/V) \n",

        "19.1 = Voltage gain (dB) \n",

        "90.0 = Current gain (A/A) \n",

        "39.1 = Current gain (dB)\n",

        "810.0 = Power gain (W/W) \n",

        "29.1 = Power gain (dB) \n",

        "190.0 = Power drawn from the dc supplies (mW)\n",

        "149.6 = Power dissipated in the amplifier (mW)\n",

        "21.3 = Amplifier efficiency in percentage\n"

       ]

      }

     ],

     "prompt_number": 8

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.2:pg-21"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 1.2: Gain of transistor amplifier\n",

      "# Amplifier has transfer characteristics v_O=10-(10**-11)*(exp**40*v_1) applies for v_1 is greater than or equal 0V and v_o is greater than or equal to 0.3V\n",

      "L_l = 0.3; # limit L_-\n",

      "print round(L_l,2),\"=The limit L_- (V) \"\n",

      "v_I=1/40.0*math.log((10-0.3)/10**-11); # from the transfer characteristics and v_o=0.3V\n",

      "print round(v_I,2),\"=v_I in volts \"\n",

      "L_u=10-10**-11; # obtained by v_I=0 in transfer characteristics\n",

      "print round(L_u,3),\"=the limit L_+ (V) \"\n",

      "V_I=1/40.0*math.log((10-5)/10**-11); # V_O=5V\n",

      "print round(V_I,3),\"=The value of the dc bias voltage that results in V_O=5V (V)\"\n",

      "A_v=-10**-11*exp(40*V_I)*40; # A_v=dv_O/dv_I\n",

      "print round(A_v,2),\"=Gain at the operating point (V/V) \"\n",

      "print \"NOTE the gain is negative that implies the amplifier is an inverting amplifier\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.3 =The limit L_- (V) \n",

        "0.69 =v_I in volts \n",

        "10.0 =the limit L_+ (V) \n",

        "0.673 =The value of the dc bias voltage that results in V_O=5V (V)\n",

        "-200.0 =Gain at the operating point (V/V) \n",

        "NOTE the gain is negative that implies the amplifier is an inverting amplifier\n"

       ]

      }

     ],

     "prompt_number": 11

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.3:pg-25"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 1.3 : Overall voltage gain of cthree-stage amplifier\n",

      "gainloss_in=10**6/(1*10**6+100.0*10**3); # fraction of input signal is obtained using voltage divider rule , gainloss_in= v_i1/v_s\n",

      "A_v1=10*100000.0/(100000+1000); # A_v1 = v_i2/v_i1 is the voltage gain at first stage\n",

      "A_v2=100*10000.0/(10000+1000); # A_v2 = v_i3/v_i2 is the voltage gain at second stage\n",

      "A_v3=100/(100+10.0); # A_v3 = v_L/v_i3 is the voltage gain at the output stage\n",

      "A_v=A_v1*A_v2*A_v3; # A_v is the total voltage gain \n",

      "print round(A_v),\" = The overall voltage gain (V/V) \"\n",

      "print round(20.0*log10(A_v),1),\"= The overall voltage gain (dB) \"\n",

      "gain_src_ld=A_v*gainloss_in;\n",

      "print round(gain_src_ld,2),\"= The voltage gain from source to gain (V/V) \"\n",

      "print round(20.0*log10(gain_src_ld),1),\"= The voltage gain from source to load (dB) \"\n",

      "A_i=10**4*A_v; # A_i=i_o/i_i=(v_L/100)/(v_i1/10**6)\n",

      "print \"{:.2e}\".format(A_i),\" = The current gain (A/A)\"\n",

      "print round(20.0*log10(A_i),1),\"= The current gain (dB) \"\n",

      "A_p=818*818*10**4; # A_p=P_L/P_I=v_L*i_o/v_i1*i_i\n",

      "print \"{:.2e}\".format(A_p),\"= The power gain (W/W) \"\n",

      "print round(10*log10(A_p),1),\"= The power gain (dB) \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "818.0  = The overall voltage gain (V/V) \n",

        "58.3 = The overall voltage gain (dB) \n",

        "743.88 = The voltage gain from source to gain (V/V) \n",

        "57.4 = The voltage gain from source to load (dB) \n",

        "8.18e+06  = The current gain (A/A)\n",

        "138.3 = The current gain (dB) \n",

        "6.69e+09 = The power gain (W/W) \n",

        "98.3 = The power gain (dB) \n"

       ]

      }

     ],

     "prompt_number": 23

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.4:pg-29"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example1.4 : Bipolar junction transistor\n",

      "\n",

      "# 1,4a\n",

      "# using voltage divider rule the fraction of input signal v_be=v_s*r_pi/(r_pi+R_s)\n",

      "# output voltage v_o=-g_mv_be(R_L||r_o)\n",

      "r_pi=2.5*10**3; # (ohm)\n",

      "R_s=5*10**3; # (ohm)\n",

      "R_L=5*10**3 # (ohm)\n",

      "g_m=40*10**-3; # (mho)\n",

      "r_o=100*10**3; # (ohm)\n",

      "gain=-(r_pi*g_m*(R_L*r_o/(R_L+r_o)))/(r_pi+R_s); # gain=v_o/v_s\n",

      "print round(gain,1),\"= The voltage gain (V/V) \"\n",

      "gain_negl_r_o=-r_pi*g_m*R_L/(r_pi+R_s);\n",

      "print round(gain_negl_r_o,1),\"= Gain neglecting the effect of r_o (V/V) \"\n",

      "\n",

      "# 1.4b\n",

      "# Bi_b=g_m*v_be\n",

      "# B is short circuit gain\n",

      "B=g_m*r_pi;\n",

      "print B,\"= The short circuit gain (A/A) \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "-63.5 = The voltage gain (V/V) \n",

        "-66.7 = Gain neglecting the effect of r_o (V/V) \n",

        "100.0 = The short circuit gain (A/A) \n"

       ]

      }

     ],

     "prompt_number": 26

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.5:pg-36"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 1.5 :  DC gain, 3dB frequency and frequency at which gain=0 of voltage amplifier\n",

      "\n",

      "# 1.5b\n",

      "R_s =20*10**3; # (ohm)\n",

      "R_i =100.0*10**3; # (ohm)\n",

      "C_i =60.0*10**-12; # (ohm)\n",

      "u = 144.0; # (V/V)\n",

      "R_o = 200.0; # (ohm)\n",

      "R_L = 1000; # (ohm)\n",

      "K=u/((1+R_s/R_i)*(1+R_o/R_L));\n",

      "print K,\"= The dc gain (V/V)\"\n",

      "print round(20*log10(K),2),\" = The dc gain (dB) \"\n",

      "w_o=1/(C_i*R_s*R_i/(R_s+R_i));\n",

      "print  \"{:.0e}\".format(w_o),\" = The 3-dB frequency (rad/s) \"\n",

      "f_o= w_o/2/math.pi;\n",

      "print round(f_o/1000,1),\" = Frequency (KHz) \"\n",

      "print \"{:.0e}\".format(100*w_o),\" = unity gain frequency (rad/s)\"\n",

      "print round(100*f_o/1e6,2),\" = Unity gain frequency (MHz)\""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "100.0 = The dc gain (V/V)\n",

        "40.0  = The dc gain (dB) \n",

        "1e+06  = The 3-dB frequency (rad/s) \n",

        "159.2  = Frequency (KHz) \n",

        "1e+08  = unity gain frequency (rad/s)\n",

        "15.92  = Unity gain frequency (MHz)\n"

       ]

      }

     ],

     "prompt_number": 39

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex1.6:pg-46"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 1.6: Time for the output to reach (V_OH+V_OL)/2\n",

      "V_DD=5; # (V)\n",

      "R=1000.0; # (ohm)\n",

      "R_on=100.0; # (ohm)\n",

      "V_offset=0.1; # (V)\n",

      "C=10.0*10**-12; # (F)\n",

      "V_OH=5; # (V)\n",

      "V_OL=V_offset+(V_DD-V_offset)*R_on/(R+R_on);\n",

      "T=R*C;\n",

      "v_o_t_PLH=(V_OH+V_OL)/2; #to find t_PLH \n",

      "t_PLH=0.69*T;# t_PLH is low to high propogtion delay\n",

      "print t_PLH/1e-9,\"= time required for the output to reach (V_OH+V_OL)/2 (miliseconds) \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "6.9 = time required for the output to reach (V_OH+V_OL)/2 (miliseconds) \n"

       ]

      }

     ],

     "prompt_number": 46

    }

   ],

   "metadata": {}

  }

 ]

}