summaryrefslogtreecommitdiff
path: root/sample_notebooks/TanveerAhmad/Chapter6.ipynb
blob: 7ed20e47efe28dfe8bc937986b584bc7dfb8883a (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
{
 "metadata": {
  "name": "",
  "signature": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter6 - Oscillators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.1 - page 438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "Vf= 0.0125 # in volt\n",
      "Vo= 0.5 # in volt\n",
      "Beta= Vf/Vo \n",
      "# For oscillator A*Beta= 1\n",
      "A= 1/Beta \n",
      "print \"Amplifier Should have a minimum gain of\",A,\"to provide oscillation\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier Should have a minimum gain of 40.0 to provide oscillation\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.2 - page 439"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "R1= 50 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "R3=R2 # in ohm\n",
      "C1= 60 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "C3=C2 # in F\n",
      "f= 1/(2*pi*R1*C1*sqrt(6)) \n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %( f*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 21.66 kHz\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.3 - page 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "# Given data\n",
      "R1= 200 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "C1= 200 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "f= 1/(2*pi*R1*C1) # in Hz\n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %(f*10**-3)\n",
      "\n",
      "# Note: Calculation to find the value of f in the book is wrong, so answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 3.98 kHz\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.4 - page 460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "L= 100 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= .001 # in \u00b5F\n",
      "C1= C1*10**-6 # in F\n",
      "C2= .01 # in \u00b5F\n",
      "C2= C2*10**-6 # in F\n",
      "C= C1*C2/(C1+C2) # in F\n",
      "# (i)\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Operating frequency = %0.f kHz\" %(round(f*10**-3))\n",
      "# (ii)\n",
      "Beta= C1/C2 \n",
      "print \"Feedback fraction  = %0.1f \" %Beta\n",
      "# (iii)\n",
      "# A*Bita >=1, so Amin*Bita= 1\n",
      "Amin= 1/Beta \n",
      "print \"Minimum gain to substain oscillations is\",Amin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating frequency = 528 kHz\n",
        "Feedback fraction  = 0.1 \n",
        "Minimum gain to substain oscillations is 10.0\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.5 - page 460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "L= 15 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= .004 # in \u00b5F\n",
      "C1= C1*10**-6 # in F\n",
      "C2= .04 # in \u00b5F\n",
      "C2= C2*10**-6 # in F\n",
      "C= C1*C2/(C1+C2) # in F\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Frequency of oscilltions = %0.1f kHz\" %(f*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 681.5 kHz\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.6 - page 461"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "L= 0.01 # in H\n",
      "C= 10 # in pF\n",
      "C= C*10**-12 # in F\n",
      "f= 1/(2*pi*sqrt(L*C)) # in Hz\n",
      "print \"Frequency of oscilltions = %0.2f kHz\" %(f*10**-3)\n",
      "# Note: Calculation to find the value of f in the book is wrong, so answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 503.29 kHz\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.7 - page 466"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "# Given data\n",
      "R1= 220 # in kohm\n",
      "R1=R1*10**3 # in ohm\n",
      "R2=R1 # in ohm\n",
      "C1= 250 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2=C1 # in F\n",
      "f= 1/(2*pi*R1*C1) \n",
      "print \"Frequency of oscilltions = %0.2f Hz\" %f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscilltions = 2893.73 Hz\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.8 - page 467"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "from math import tan\n",
      "# Given data\n",
      "R= 10 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "f=1000 \n",
      "fie= 60 # in \u00b0\n",
      "# The impedence of given circuit , Z= R+j*1/(omega*C)\n",
      "# the phase shift, tan(fie)= imaginary part/ Real part\n",
      "# tand(fie) = 1/(omega*R*C)\n",
      "C= 1/(2*pi*R*tan(fie*pi/180)) \n",
      "print \"The value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "# Note : There is an calculation error to evaluate the value of C, So the answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 9.19 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 6.9 - page 467"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, sqrt\n",
      "# Given data\n",
      "L= 50 # in \u00b5H\n",
      "L= L*10**-6 # in H\n",
      "C1= 300 # in pF\n",
      "C1= C1*10**-12 # in F\n",
      "C2= 100 # in pF\n",
      "C2= C2*10**-12 # in F\n",
      "C_eq= C1*C2/(C1+C2) # in F\n",
      "f= 1/(2*pi*sqrt(L*C_eq)) # in Hz\n",
      "print \"Frequency of oscillations = %0.1f MHz\" %(f*10**-6)\n",
      "Beta= C2/C1 \n",
      "# (iii)\n",
      "# A*Beta >=1, so A*Bita= 1  (for sustained oscillations)\n",
      "Amin= 1/Beta \n",
      "print \"Minimum gain to substain oscillations is\",Amin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillations = 2.6 MHz\n",
        "Minimum gain to substain oscillations is 3.0\n"
       ]
      }
     ],
     "prompt_number": 33
    }
   ],
   "metadata": {}
  }
 ]
}