summaryrefslogtreecommitdiff
path: root/Analog_Integrated_Circuits_by_R.S._Tomar/Chapter6_1.ipynb
blob: b4790d59a92c953dffcb30efb58a1fc40d211cc9 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:7063e92d4f64e517cc0dbce51d65911cbb3639cdb52d68efbfa4c03a57d713df"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter6 - Oscillators and waveform generators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.1 - page 170"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import pi, sqrt, ceil\n",
      "f0=600 #Hz#Oscillating Frequency\n",
      "print \"Various design parameters are :-\"\n",
      "C=0.05 #micro F#Chosen for the design\n",
      "print \"Capacitance = %0.2f micro F\" %C\n",
      "R=1/(2*pi*f0*sqrt(6)*C*10**-6) #ohm\n",
      "R=R/1000 #kohm\n",
      "print \"Resistance R = %0.1f kohm\" %R\n",
      "#To avoid loading effect\n",
      "Ri=10*R #kohm#Ri>=10*R\n",
      "Ri=ceil(Ri) #kohm\n",
      "print \"Resistance Ri = %0.1f kohm\" % Ri\n",
      "Rf=29*Ri #kohm#Rf>=29*Ri\n",
      "print \"Resistance Rf = %0.1f kohm\" %Rf\n",
      "Rf=640 #kohm\n",
      "#Balancing the circuit\n",
      "Rom=Rf*Ri/(Rf+Ri) #kohm\n",
      "Rom=ceil(Rom) #kohm\n",
      "print \"Resistance Rom = %0.1f kohm\" %Rom"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "Capacitance = 0.05 micro F\n",
        "Resistance R = 2.2 kohm\n",
        "Resistance Ri = 22.0 kohm\n",
        "Resistance Rf = 638.0 kohm\n",
        "Resistance Rom = 22.0 kohm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.3 - page 181"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import pi\n",
      "f0=12 #kHz#Oscillating Frequency\n",
      "print \"Various design parameters are :-\"\n",
      "C=0.01 #micro F#Chosen for the design between 0.01 & 1 micro F\n",
      "print \"Capacitance = %0.2f micro F \" % C\n",
      "R=1/(2*pi*f0*1000*C*10**-6) #ohm\n",
      "R=R/1000 #kohm\n",
      "print \"Resistance R = %0.1f kohm\" %R\n",
      "Ri=3*R/2 #kohm#Ri>=3*R/2\n",
      "print \"Resistance Ri = %0.2f kohm\" %Ri\n",
      "Ri=2.2 #kohm\n",
      "Rf=2*Ri #kohm\n",
      "print \"Resistance Rf = %.1f kohm\" %Rf"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "Capacitance = 0.01 micro F \n",
        "Resistance R = 1.3 kohm\n",
        "Resistance Ri = 1.99 kohm\n",
        "Resistance Rf = 4.4 kohm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.5 - page 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import pi\n",
      "f0=2 #kHz#Oscillating Frequency\n",
      "print \"Various design parameters are :-\"\n",
      "C=0.05 #micro F#Chosen for the design\n",
      "print \"Capacitance = %0.2f micro F \" %C\n",
      "R=1/(2*pi*f0*1000*C*10**-6) #ohm\n",
      "R=R/1000 #kohm\n",
      "print \"Resistance R = %0.1f kohm \" %R \n",
      "Ri=3*R/2 #kohm#Ri>=3*R/2\n",
      "print \"Resistance Ri = %0.1f kohm \" %Ri \n",
      "Rf=2*Ri #kohm\n",
      "print \"Resistance Rf = %0.1f kohm \" %Rf "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "Capacitance = 0.05 micro F \n",
        "Resistance R = 1.6 kohm \n",
        "Resistance Ri = 2.4 kohm \n",
        "Resistance Rf = 4.8 kohm \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.6 - page : 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import pi\n",
      "#Data given\n",
      "R1=1 #kohm\n",
      "R2=1 #kohm\n",
      "R=1 #kohm\n",
      "C=4.7 #micro F\n",
      "f0=1/(2*pi*R*10**3*C*10**-6) #Hz#Oscillating Frequency\n",
      "print \"Oscillation frequency = %0.2f Hz \" %f0 "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Oscillation frequency = 33.86 Hz \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.7 - page : 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "f0=200 #Hz#Oscillating Frequency\n",
      "print \"Various design parameters are :-\" \n",
      "C=0.05 #micro F#Chosen for the design\n",
      "print \"Capacitance = %0.2f micro F \" %C \n",
      "R=0.159/(f0*C*10**-6) #ohm\n",
      "R=R/1000 #kohm\n",
      "print \"Resistance R = %0.1f kohm \" %R \n",
      "R=510 #kohm\n",
      "C1=C;C2=C;C3=C #micro F\n",
      "print \"Capacitance C1 = C2 = C3 = %0.2f micro F \" %(C3) \n",
      "R2=R;R3=R #kohm\n",
      "print \"Resistance R2 = %0.1f kohm, R3 = %0.1f kohm \" %(R3,R2)\n",
      "#Answer for R is calculated wrong in the textbook."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "Capacitance = 0.05 micro F \n",
        "Resistance R = 15.9 kohm \n",
        "Capacitance C1 = C2 = C3 = 0.05 micro F \n",
        "Resistance R2 = 510.0 kohm, R3 = 510.0 kohm \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.8 - page : 189"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "Rf=570 #kohm\n",
      "Ri=15 #kohm\n",
      "A=Rf/Ri #Gain of the circuit\n",
      "Amin=29 #Minimum Gain requirement of RC phase shift oscillator\n",
      "deltaA=(A-Amin)/Amin*100 #%(Exceeding Gain)\n",
      "print \"Gain is exceeded by %0.f %% \" %deltaA "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gain is exceeded by 31 % \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.9 - page : 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import pi, sqrt\n",
      "print \"Part (a)\"\n",
      "L1=25 #micro H\n",
      "L2=10 #micro H\n",
      "Rf=22 #kohm\n",
      "C=0.01 #micro F\n",
      "LT=L1+L2 #micro H\n",
      "fr=1/(2*pi*sqrt(C*10**-6*LT*10**-6)) #Hz\n",
      "fr=fr/1000 #kHz\n",
      "f0=fr #/kHz\n",
      "print \"Oscillation frequency = %0.1f kHz \" %f0 \n",
      "Ri=Rf/(L1/L2) #kohm\n",
      "print \"Resistance Ri = %0.1f kohm \" %Ri \n",
      "print \"Part (b)\"\n",
      "C1=220 #pF\n",
      "C2=680 #pF\n",
      "Rf=22 #kohm\n",
      "L=1 #mH\n",
      "CT=C1*C2/(C1+C2) #pF\n",
      "fr=1/(2*pi*sqrt(L*10**-3*CT*10**-12)) #Hz\n",
      "fr=fr/1000 #kHz\n",
      "f0=fr #/kHz\n",
      "f0=round(f0) #kHz\n",
      "print \"Oscillation frequency = %0.1f kHz \" %f0\n",
      "Ri=Rf/(C1/C2) #kohm\n",
      "print \"Resistance Ri = %0.1f kohm \" %Ri"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (a)\n",
        "Oscillation frequency = 269.0 kHz \n",
        "Resistance Ri = 8.8 kohm \n",
        "Part (b)\n",
        "Oscillation frequency = 390.0 kHz \n",
        "Resistance Ri = 68.0 kohm \n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.10 - page : 198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "f0=1 #/kHz\n",
      "Vsat=14 #V\n",
      "print \"Various design parameters are :-\"\n",
      "C1=0.05 #micro F#Chosen for the design\n",
      "print \"Capacitance = %0.2f micro F \" %C1\n",
      "Rf=1/(2*f0*10**3*C1*10**-6)/1000 #kohm\n",
      "print \"Resistance Rf = %0.1f kohm \" %Rf \n",
      "#R2=0.86*R1 and Rf=R1||R2\n",
      "R2byR1=0.86 #from R2=0.86*R1 \n",
      "R2=Rf*(1+R2byR1) #kohm\n",
      "R1=R2/R2byR1 #kohm\n",
      "print \"Resistance R1 = %0.1f kohm \" %R1 \n",
      "print \"Resistance R2 = %0.1f kohm \" %R2 "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "Capacitance = 0.05 micro F \n",
        "Resistance Rf = 10.0 kohm \n",
        "Resistance R1 = 21.6 kohm \n",
        "Resistance R2 = 18.6 kohm \n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.11 - page 199"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "from math import log\n",
      "T=10 #ms#(Time period)\n",
      "f0=1/(T*10**-3) #Hz\n",
      "C=0.05 #micro F#Chosen for the design\n",
      "#Formula : f0=1/{2*Rf*C*log(1+2*R2/R1)}\n",
      "Rf=1/(f0*2*C*10**-6*log(1+2))/1000 #kohm#By putting R1=R2 for this case\n",
      "Rf=round(Rf) #kohm\n",
      "print \"Resistance Rf = %0.1f kohm \" %Rf \n",
      "print \"Capacitance for the design is %0.2f micro F \" %C "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance Rf = 91.0 kohm \n",
        "Capacitance for the design is 0.05 micro F \n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.12 - page : 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "from math import log\n",
      "R1=4.7 #kohm\n",
      "R2=3.3 #kohm\n",
      "Rf=2 #kohm\n",
      "C=0.1 #micro F\n",
      "f0=1/2/(Rf*1000)/(C*10**-6)/log(1+2*R2/R1)/1000 #kHz\n",
      "print \"Frequency of output signal is %0.2f kHz \" %f0 "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of output signal is 2.85 kHz \n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.13 - page : 204"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "f0=1.5 #kHz\n",
      "Vout=6 #V##peak to peak\n",
      "Vsat=13.5 #V\n",
      "print \"Various design parameters are : \"\n",
      "R2=10 #kohm#/choosen for the design\n",
      "R1=R2*2*Vsat/Vout #kohm\n",
      "print \"R1 = %0.2f kohm \" %R1 \n",
      "print \"R2 = %0.2f kohm \" %R2 \n",
      "#Let Cf=0.05 micro F for the design\n",
      "Cf=0.05 #micro F\n",
      "print \"Cf = %0.2f micro F \" %Cf \n",
      "Ri=R1*1000/(f0*1000)/4/(Cf*10**-6*R2*1000)/1000 #kohm\n",
      "print \"Ri = %0.2f kohm \" %Ri "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are : \n",
        "R1 = 45.00 kohm \n",
        "R2 = 10.00 kohm \n",
        "Cf = 0.05 micro F \n",
        "Ri = 15.00 kohm \n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex 6.14\n",
      "from __future__ import division \n",
      "#Data given\n",
      "R1=6.8 #kohm\n",
      "Ri=100 #kohm\n",
      "R2=1.5 #kohm\n",
      "Cf=0.01 #micro F\n",
      "Vsat=14 #V\n",
      "Vo_pp=2*R2/R1*Vsat #V##Peak to peak output of triangular wave\n",
      "print \"Peak to peak output of triangular wave is %0.1f V \" %Vo_pp\n",
      "f0=R1*1000/(4*Ri*10**3*Cf*10**-6*R2*10**3)/1000 #kHz#Oscillating Frequency\n",
      "print \"Oscillation frequency is %0.2f Hz\" %f0"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak to peak output of triangular wave is 6.2 V \n",
        "Oscillation frequency is 1.13 Hz\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.15 - page : 205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "#Data given\n",
      "f0=1 #kHz\n",
      "Vo_pp=7 #V\n",
      "Vsat=14 #V\n",
      "print \"Various design parameters are :-\"\n",
      "#Let R2=10 #kohm for the design\n",
      "R2=10 #kohm\n",
      "R1=2*R2*Vsat/Vo_pp #kohm\n",
      "print \"R1 = %0.2f kohm \" %R1 \n",
      "print \"R2 = %0.2f kohm \" %R2 \n",
      "#Choose Cf=0.1 micro F for the design\n",
      "Cf=0.1 #micro F\n",
      "print \"Cf = %0.2f micro F \" %Cf \n",
      "Ri=R1*10**3/(4*f0*10**3*Cf*10**-6*R2*10**3)/1000 #kohm\n",
      "print \"Ri = %0.2f kohm \" %Ri "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :-\n",
        "R1 = 40.00 kohm \n",
        "R2 = 10.00 kohm \n",
        "Cf = 0.10 micro F \n",
        "Ri = 10.00 kohm \n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.16 - page : 208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "from math import log\n",
      "#Data given\n",
      "tau=1 #ms(time period)\n",
      "R1byR2_min=1.8 # min R1/R2\n",
      "R1byR2_max=9 # max R1/R2\n",
      "Beta_min=1/(1+R1byR2_min) #minimum value of Beta\n",
      "Beta_max=1/(1+R1byR2_max) #maximum value of Beta\n",
      "Tmax=2*tau*log((1+Beta_min)/(1-Beta_min)) #ms##For minimum value of Beta\n",
      "fmin=1/(Tmax*10**-3) #Hz\n",
      "Tmin=2*tau*log((1+Beta_max)/(1-Beta_max)) #ms##For maximum value of Beta\n",
      "fmax=1/(Tmin*10**-3)/1000 #kHz\n",
      "print \"Frequency range is %d Hz to %0.1f kHz.\" %(fmin, fmax)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency range is 669 Hz to 2.5 kHz.\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.17 : page 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "from math import sqrt, pi\n",
      "#Data given\n",
      "Ls=3 #H\n",
      "Cs=0.05 #pF\n",
      "Rs=2 #kohm\n",
      "Cm=10 #pF\n",
      "fS=1/2/pi/sqrt(Ls*Cs*10**-12)/1000 #kHz\n",
      "print \"Series resonant frequency is %0.f kHz \" %fS \n",
      "CT=Cm*Cs/(Cm+Cs) #pF##Equivalent capacitance\n",
      "fP=1/2/pi/sqrt(Ls*CT*10**-12)/1000 #kHz\n",
      "print \"Parallel resonant frequency is %0.f kHz \" %fP "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Series resonant frequency is 411 kHz \n",
        "Parallel resonant frequency is 412 kHz \n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.18  - page : 220"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "#Data given\n",
      "f0=5 #kHz\n",
      "D=60 #%##duty cycle\n",
      "VCC=12 #V\n",
      "#As D=t1/(t1+t2)\n",
      "t2BYt1=1/(D/100)-1 #ratio of t1 & t2\n",
      "#RB/(2*RA-RB)=t2/t1\n",
      "RAbyRB=(1/t2BYt1+1)/2 #Ratio of RA & RB\n",
      "print \"Various design parameters are :\"\n",
      "#Let CT=0.05 micro F for this design choosing between 0.01 & 1 microo F\n",
      "CT=0.05 #micro F\n",
      "print \"CT = %0.2f micro F \" %CT \n",
      "RA=1/(f0*10**3)/(5/3)**2/(CT*10**-6)/1000 #kohm\n",
      "print \"RA = %0.2f kohm \" %RA\n",
      "RB=RA/RAbyRB #kohm\n",
      "print \"RB = %0.2f kohm \" %RB"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Various design parameters are :\n",
        "CT = 0.05 micro F \n",
        "RA = 1.44 kohm \n",
        "RB = 1.15 kohm \n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 6.19 - page : 225"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "#Data given\n",
      "Rf=15 #kohm\n",
      "RT1=4.7 #kohm\n",
      "R1=56 #kohm\n",
      "R2=6.8 #kohm\n",
      "R3=10 #kohm\n",
      "R4=1 #kohm\n",
      "R5=1 #kohm\n",
      "CB=1 #micro F\n",
      "CT=0.05 #mic\n",
      "VCC=15 #V\n",
      "V1=-15 #V##Voltage given through the resistance(R1) 56 kohm\n",
      "print \"Part (i)\"\n",
      "Vin=2 #V\n",
      "Vo=Rf/R1*(-V1)-Rf/R2*Vin #V\n",
      "print \"Voltage Vo = %0.3f V \" %Vo \n",
      "N_VCC=0 #V##-VCC##voltage given to the 12th pin of IC\n",
      "V7=N_VCC+3 #V\n",
      "print \"Voltage V7 = %0.2f V \" %V7\n",
      "I=(V7-Vo)/RT1 #mA\n",
      "print \"Current I = %0.2f mA \" %I \n",
      "Rmult=R4*R5/(R4+R5)+R3 #kohm##on pin 3\n",
      "print \"Total resistance on pin 3, Rmult = %0.2f kohm \" %Rmult\n",
      "f0=0.32*I*10**-3/(CT*10**-6)/1000 #kHz\n",
      "print \"Oscillation frequency is %0.1f kHz \" %f0\n",
      "print \"Part (ii)\"\n",
      "Vin=5 #V\n",
      "Vo=Rf/R1*(-V1)-Rf/R2*Vin #V\n",
      "print \"Voltage Vo = %0.f V \" %Vo \n",
      "N_VCC=0 #V##-VCC##voltage given to the 12th pin of IC\n",
      "V7=N_VCC+3 #V\n",
      "print \"Voltage V7 = %0.f V \" %V7 \n",
      "I=(V7-Vo)/RT1 #mA\n",
      "print \"Current I = %0.2f mA \" %I \n",
      "Rmult=R4*R5/(R4+R5)+R3 #kohm##on pin 3\n",
      "print \"Total resistance on pin 3, Rmult = %0.2f kohm \" %Rmult \n",
      "f0=0.32*I*10**-3/(CT*10**-6)/1000 #kHz\n",
      "print \"Oscillation frequency is %0.2f kHz\" %f0"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (i)\n",
        "Voltage Vo = -0.394 V \n",
        "Voltage V7 = 3.00 V \n",
        "Current I = 0.72 mA \n",
        "Total resistance on pin 3, Rmult = 10.50 kohm \n",
        "Oscillation frequency is 4.6 kHz \n",
        "Part (ii)\n",
        "Voltage Vo = -7 V \n",
        "Voltage V7 = 3 V \n",
        "Current I = 2.13 mA \n",
        "Total resistance on pin 3, Rmult = 10.50 kohm \n",
        "Oscillation frequency is 13.63 kHz\n"
       ]
      }
     ],
     "prompt_number": 49
    }
   ],
   "metadata": {}
  }
 ]
}