summaryrefslogtreecommitdiff
path: root/sample_notebooks/WaseemAhmad Ansari/Chapter2.ipynb
blob: d902c695f92cc09eda923b124d35bef7ad227e42 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:3942a48c51f6e66ddeb010a1a5acaeebd4c9f56b964a269d92588d67ccc10453"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Introduction to operational amplifier"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 2.1 Page no. 88"
     ]
    },
    {
     "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": [
      "Ex 2.2 Page no.89"
     ]
    },
    {
     "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),\"kohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of feedback resistor =  40 kohms\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 2.4 Page no.92"
     ]
    },
    {
     "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": [
      "Ex 2.5 Page No.94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data\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)),\"kohm\"         #converting the answer into kohm"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of gm = 4 mMho\n",
        " The value of Rc = 25 kohm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 2.6 Page no. 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# 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)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ACM is = -0.05\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "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": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 2.8 Page no.97"
     ]
    },
    {
     "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
    }
   ],
   "metadata": {}
  }
 ]
}