summaryrefslogtreecommitdiff
path: root/Electronic_Circuits_by_P._Raja/Chapter1.ipynb
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-08-28 16:53:23 +0530
committerThomas Stephen Lee2015-08-28 16:53:23 +0530
commit4a1f703f1c1808d390ebf80e80659fe161f69fab (patch)
tree31b43ae8895599f2d13cf19395d84164463615d9 /Electronic_Circuits_by_P._Raja/Chapter1.ipynb
parent9d260e6fae7328d816a514130b691fbd0e9ef81d (diff)
downloadPython-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.gz
Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.bz2
Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.zip
add books
Diffstat (limited to 'Electronic_Circuits_by_P._Raja/Chapter1.ipynb')
-rwxr-xr-xElectronic_Circuits_by_P._Raja/Chapter1.ipynb1053
1 files changed, 1053 insertions, 0 deletions
diff --git a/Electronic_Circuits_by_P._Raja/Chapter1.ipynb b/Electronic_Circuits_by_P._Raja/Chapter1.ipynb
new file mode 100755
index 00000000..c97fbbe0
--- /dev/null
+++ b/Electronic_Circuits_by_P._Raja/Chapter1.ipynb
@@ -0,0 +1,1053 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 1 - Operational Amplifiers"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.1 - page 11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "G= -100 \n",
+ "R1= 2.2 # in kohm\n",
+ "R1=R1*10**3 # in ohm\n",
+ "# Formula G=-Rf/R1\n",
+ "Rf= -G*R1 \n",
+ "print \"The value of Rf = %0.f kohm \" %(Rf*10**-3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Rf = 220 kohm \n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.2 - page 11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "Rf= 200 # in kohm\n",
+ "R1= 2 # in kohm\n",
+ "vin=2.5 # in mV\n",
+ "vin=vin*10**-3 # in volt\n",
+ "G= -Rf/R1 \n",
+ "vo= G*vin # in V\n",
+ "print \"The output voltage = %0.2f Volt \" %vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The output voltage = -0.25 Volt \n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.3 - page 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "G=-10 \n",
+ "Ri= 100 # in kohm\n",
+ "R1= Ri # in kohm\n",
+ "R1=R1*10**3 # in ohm\n",
+ "# Formula G=-R2/R1\n",
+ "R2= R1*abs(G) # ohm\n",
+ "print \"Value of R1 = %0.f kohm \" %(R1*10**-3)\n",
+ "print \"and value of R2 = %0.f Mohm \" %(R2*10**-6)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value of R1 = 100 kohm \n",
+ "and value of R2 = 1 Mohm \n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.4 - page 37"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "R1= 100 # in kohm\n",
+ "R2= 500 # in kohm\n",
+ "V1= 2 # in volt\n",
+ "Vo= (1+R2/R1)*V1 # in volt\n",
+ "print \"Output voltage for noninverting amplifier = %0.f Volt\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage for noninverting amplifier = 12 Volt\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.5 - page 38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf= 1 # in Mohm\n",
+ "Rf=Rf*10**6 #in ohm\n",
+ "\n",
+ "# Part(a)\n",
+ "V1=1 #in volt\n",
+ "V2=2 #in volt\n",
+ "V3=3 #in volt\n",
+ "R1= 500 # in kohm\n",
+ "R1=R1*10**3 #in ohm\n",
+ "R2= 1 # in Mohm\n",
+ "R2=R2*10**6 #in ohm\n",
+ "R3= 1 # in Mohm\n",
+ "R3=R3*10**6 #in ohm\n",
+ "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n",
+ "print \"(a) Output voltage = %0.f Volt \" %Vo\n",
+ "\n",
+ "# Part(b)\n",
+ "V1=-2 #in volt\n",
+ "V2=3 #in volt\n",
+ "V3=1 #in volt\n",
+ "R1= 200 # in kohm\n",
+ "R1=R1*10**3 #in ohm\n",
+ "R2= 500 # in kohm\n",
+ "R2=R2*10**3 #in ohm\n",
+ "R3= 1 # in Mohm\n",
+ "R3=R3*10**6 #in ohm\n",
+ "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n",
+ "print \"(b) Output voltage = %0.f Volt\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) Output voltage = -7 Volt \n",
+ "(b) Output voltage = 3 Volt\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.6 - page 38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "print \"Minimum closed loop voltage gain for R2=0 and R1= 2 kohm\"\n",
+ "R2=0 \n",
+ "R1=2 # in kohm\n",
+ "R1=R1*10**3 # in ohm\n",
+ "Av_min= (1+R2/R1)\n",
+ "print \"Av(min) =\",Av_min\n",
+ "\n",
+ "print \"Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm\"\n",
+ "R2=100 # in kohm\n",
+ "R1=2 # in kohm\n",
+ "Av_max= (1+R2/R1)\n",
+ "print \"Av(max) =\",Av_max"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Minimum closed loop voltage gain for R2=0 and R1= 2 kohm\n",
+ "Av(min) = 1.0\n",
+ "Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm\n",
+ "Av(max) = 51.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.7 - page 39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "V1= 745 # in \u00b5V\n",
+ "V2= 740 # in \u00b5V\n",
+ "V1=V1*10**-6 # in volt\n",
+ "V2=V2*10**-6 # in volt\n",
+ "CMRR=80 # in dB\n",
+ "Av=5*10**5 \n",
+ "# (i)\n",
+ "# CMRR in dB= 20*log(Ad/Ac)\n",
+ "Ad=Av \n",
+ "Ac= Ad/10**(CMRR/20) \n",
+ "# (ii)\n",
+ "Vo= Ad*(V1-V2)+Ac*(V1+V2)/2 \n",
+ "print \"Output voltage = %0.2f Volt\" %Vo\n",
+ "\n",
+ "# Note:- In the book, there is calculation error to evaluate the value of Ac,\n",
+ "#so the value of Ac is wrong ans to evaluate the output voltage there is also calculation error "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage = 2.54 Volt\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.8 - page 40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "R1= 1 # in Mohm\n",
+ "Ri=R1 # in Mohm\n",
+ "Rf=1 # in Mohm\n",
+ "A_VF= -Rf/R1 \n",
+ "print \"Voltage gain = %0.f\" %A_VF"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Voltage gain = -1\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.10 - page 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "V1=2 # in V\n",
+ "V2=3 # in V\n",
+ "Rf=3 # in kohm\n",
+ "R1=1 # in kohm\n",
+ "Vo1= (1+Rf/R1)*V1 \n",
+ "print \"Output voltage when only 2V voltage source is acting is %0.f Volt\" %Vo1\n",
+ "Vo2= (1+Rf/R1)*V2 \n",
+ "print \"Output voltage due to 3V voltage source is %0.f Volt\" %Vo2\n",
+ "Vo= Vo1+Vo2 # in volts\n",
+ "print \"Total output voltage is %0.f Volts\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage when only 2V voltage source is acting is 8 Volt\n",
+ "Output voltage due to 3V voltage source is 12 Volt\n",
+ "Total output voltage is 20 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.11 - page 42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf=500 # in kohm\n",
+ "min_vvs= 0 # minimum value of variable resistor in ohm\n",
+ "max_vvs= 10 # maximum value of variable resistor in ohm\n",
+ "Ri_min= 10+min_vvs # in kohm\n",
+ "Ri_max= 10+max_vvs #in kohm\n",
+ "# Av= Vo/Vi= -Rf/Ri\n",
+ "Av=-Rf/Ri_min \n",
+ "print \"Closed loop voltage gain corresponding to Ri(min) is\",Av\n",
+ "Av=-Rf/Ri_max \n",
+ "print \"and closed loop voltage gain corresponding to Ri(max) is\",Av"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Closed loop voltage gain corresponding to Ri(min) is -50.0\n",
+ "and closed loop voltage gain corresponding to Ri(max) is -25.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.12 - page 43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "Rf=200 # in kohm\n",
+ "R1= 20 # in kohm\n",
+ "# Av= Vo/Vi= -Rf/Ri\n",
+ "Av= -Rf/R1 \n",
+ "Vi_min= 0.1 # in V\n",
+ "Vi_max= 0.5 # in V\n",
+ "# Vo= Av*Vi\n",
+ "Vo_min= Av*Vi_min # in V\n",
+ "Vo_max= Av*Vi_max # in V\n",
+ "print \"Output voltage ranges from\",Vo_min,\"V to\",Vo_max,\"V\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage ranges from -1.0 V to -5.0 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.13 - page 43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf= 250 # in kohm\n",
+ "# Output voltage expression, Vo= -5*Va+3*Vb\n",
+ "# and we know that for a difference amplifier circuit, \n",
+ "# Vo= -Rf/R1*Va + [R2/(R1+R2)]*[1+Rf/R1]*Vb\n",
+ "# Comparing both the expression, we get\n",
+ "# -Rf/R1*Va= -5*Va, or\n",
+ "R1= Rf/5 # in kohm\n",
+ "print \"The value of R1 = %0.2f kohm\" %R1\n",
+ "# and \n",
+ "R2= 3*R1**2/(R1+Rf-3*R1)\n",
+ "print \"The value of R2 = %0.2f kohm\" %R2\n",
+ "\n",
+ "# Note : Answer in the book is wrong"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R1 = 50.00 kohm\n",
+ "The value of R2 = 50.00 kohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.14 - page 44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "Vi_1= 150 # in \u00b5V\n",
+ "Vi_2= 140 # in \u00b5V\n",
+ "Vd= Vi_1-Vi_2 # in \u00b5V\n",
+ "Vd=Vd*10**-6 # in V\n",
+ "Vc= (Vi_1+Vi_2)/2 # in \u00b5V\n",
+ "Vc=Vc*10**-6 # in V\n",
+ "# Vo= Ad*Vd*(1+Vc/(CMRR*Vd))\n",
+ "\n",
+ "# (i) For Ad=4000 and CMRR= 100\n",
+ "Ad=4000 \n",
+ "CMRR= 100 \n",
+ "Vo= Ad*Vd*(1+Vc/(CMRR*Vd)) # in volt\n",
+ "print \"(a) Output voltage = %.1f mV\" %(Vo*10**3)\n",
+ "\n",
+ "# (ii) For Ad=4000 and CMRR= 10**5\n",
+ "Ad=4000 \n",
+ "CMRR= 10**5 \n",
+ "Vo= Ad*Vd*(1+Vc/(CMRR*Vd)) # in volt\n",
+ "print \"(b) Output voltage = %0.1f mV\" %(Vo*10**3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) Output voltage = 45.8 mV\n",
+ "(b) Output voltage = 40.0 mV\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.15 - page 45"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf=470 # in kohm\n",
+ "R1=4.3 # in kohm\n",
+ "R2=33 # in kohm\n",
+ "R3=33 # in kohm\n",
+ "Vi= 80 # in \u00b5V\n",
+ "Vi=Vi*10**-6 # in volt\n",
+ "A1= 1+Rf/R1 \n",
+ "A2=-Rf/R2 \n",
+ "A3= -Rf/R3 \n",
+ "A=A1*A2*A3 \n",
+ "Vo= A*Vi # in volt\n",
+ "print \"Output voltage = %0.2f Volts\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage = 1.79 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.16 - page 46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from sympy import symbols, simplify, sin\n",
+ "t = symbols('t')\n",
+ "# Given data\n",
+ "R1= 33 # in k\u03a9\n",
+ "R2= 10 # in k\u03a9\n",
+ "R3= 330 # in k\u03a9\n",
+ "V1 = simplify(50*sin(1000*t)) # in mV\n",
+ "V2 = simplify(10*sin(3000*t)) # in mV\n",
+ "Vo = -(R3/R1*V1+R3/R2*V2)/1000 # in V\n",
+ "print \"Output voltage is\",Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage is -0.5*sin(1000*t) - 0.33*sin(3000*t)\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.17 - page 47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "R1=10 # in kohm\n",
+ "R2=150 # in kohm\n",
+ "R3=10 # in kohm\n",
+ "R4=300 # in kohm\n",
+ "V1= 1 # in V\n",
+ "V2= 2 # in V\n",
+ "Vo= ((1+R4/R2)*(R3*V1/(R1+R3))-(R4/R2)*V2) \n",
+ "print \"Output voltage = %0.2f Volts\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage = -2.50 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.18 - page 47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "R1=12 # in kohm\n",
+ "Rf=360 # in kohm\n",
+ "V1= -0.3 # in V\n",
+ "Vo= (1+Rf/R1)*V1 # in V\n",
+ "print \"(a) Output voltage result in %0.2f Volts\" %Vo\n",
+ "\n",
+ "# Part(b)\n",
+ "Vo= 2.4 # in V\n",
+ "# We know, Vo= (1+Rf/R1)*V1\n",
+ "V1= Vo/(1+Rf/R1) \n",
+ "print \"(b) To result in an output of 2.4 Volt, Input voltage = %0.2f mV\" %(V1*10**3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) Output voltage result in -9.30 Volts\n",
+ "(b) To result in an output of 2.4 Volt, Input voltage = 77.42 mV\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.19 - page 48"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf=68 # in kohm\n",
+ "R1=33 # in kohm\n",
+ "R2=22 # in kohm\n",
+ "R3=12 # in kohm\n",
+ "V1= 0.2 # in V\n",
+ "V2=-0.5 # in V\n",
+ "V3= 0.8 # in V\n",
+ "Vo= -Rf/R1*V1 + (-Rf/R2)*V2 + (-Rf/R3)*V3 # in volts\n",
+ "print \"Output voltage = %0.3f Volts\" %Vo\n",
+ "#Answer in the textbook is not accurate."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage = -3.400 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.20 - page 48"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "Rf=100 # in kohm\n",
+ "R1=20 # in kohm\n",
+ "V1= 1.5 # in V\n",
+ "Vo1= V1 \n",
+ "Vo= -Rf/R1*Vo1 # in volts\n",
+ "print \"Output voltage = %0.2f Volts\" %Vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output voltage = -7.50 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.22 - page 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "# Given data\n",
+ "vo= -10 # in V\n",
+ "i_f= 1 # in mA\n",
+ "i_f= i_f*10**-3 #in A\n",
+ "# Formula vo= -i_f*Rf\n",
+ "Rf= -vo/i_f # in \u03a9\n",
+ "# The output voltage, vo= -(v1+5*v2) (i)\n",
+ "# vo= -Rf/R1*v1 - Rf/R2*v2 (ii)\n",
+ "# Comparing equations (i) and (2)\n",
+ "R1= Rf/1 # in \u03a9\n",
+ "R2= Rf/5 # in \u03a9\n",
+ "print \"The value of Rf = %0.2f k\u03a9\" %(Rf*10**-3)\n",
+ "print \"The value of R1 = %0.2f k\u03a9\" %(R1*10**-3)\n",
+ "print \"The value of R2 = %0.2f k\u03a9\" %(R2*10**-3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Rf = 10.00 k\u03a9\n",
+ "The value of R1 = 10.00 k\u03a9\n",
+ "The value of R2 = 2.00 k\u03a9\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.24 - page 52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "from sympy import symbols\n",
+ "v1,v2 = symbols('v1 v2')\n",
+ "# Given data\n",
+ "R1= 9 # in k\u03a9\n",
+ "R2= 1 # in k\u03a9\n",
+ "R3= 2 # in k\u03a9\n",
+ "R4= 3 # in k\u03a9\n",
+ "# for node 1\n",
+ "va = R4/(R4+R3)*v1\n",
+ "vo1 = (1+R1/R2)*va\n",
+ "# for node 2\n",
+ "va=R3/(R3+R4)*v2\n",
+ "vo2 = (1+R1/R2)*va\n",
+ "vo = vo1+vo2\n",
+ "print \"Total voltage is, vo =\",vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total voltage is, vo = 6.0*v1 + 4.0*v2\n"
+ ]
+ }
+ ],
+ "prompt_number": 27
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.25 - page 54"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "from sympy import symbols\n",
+ "v1,v2,v3 = symbols('v1 v2 v3')\n",
+ "# Given data\n",
+ "R1= 9 # in k\u03a9\n",
+ "R2= 1 # in k\u03a9\n",
+ "R3= 2 # in k\u03a9\n",
+ "R4= 3 # in k\u03a9\n",
+ "# Voltage at node 1\n",
+ "va= R4*v1/(R3+R4)\n",
+ "vo1= (1+R1/R2)*va\n",
+ "# Voltage at node 2\n",
+ "va= R3*v2/(R3+R4)\n",
+ "# From (i) and (ii)\n",
+ "vo2= (1+R1/R2)*va\n",
+ "# Voltage at node 3\n",
+ "va= R3*v2/(R3+R4)\n",
+ "vo3= (-R1/R2)*v3\n",
+ "vo = vo1+vo2+vo3\n",
+ "print \"Total voltage is\",vo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total voltage is 6.0*v1 + 4.0*v2 - 9.0*v3\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.26 - page 55"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Given data\n",
+ "import numpy as np\n",
+ "from __future__ import division\n",
+ "# omega_t= Ao*omega_b\n",
+ "# 2*pi*f_t = Ao*2*pi*f_b\n",
+ "# f_t= Ao*f_b\n",
+ "# Part (i)\n",
+ "Ao1= 10**5 \n",
+ "f_b1= 10**2 # in Hz\n",
+ "f_t1= Ao1*f_b1 # in Hz\n",
+ "row1 = np.array([Ao1,f_b1,f_t1])\n",
+ "# Part (ii)\n",
+ "Ao2= 10**6 \n",
+ "f_t2= 10**6 # in Hz\n",
+ "f_b2= f_t2/Ao2 # in Hz\n",
+ "row2 = np.array([Ao2,f_b2,f_t2])\n",
+ "# Part (iii)\n",
+ "f_b3= 10**3 # in Hz\n",
+ "f_t3= 10**8 # in Hz\n",
+ "Ao3= f_t3/f_b3 \n",
+ "row3 = np.array([Ao3,f_b3,f_t3])\n",
+ "# Part (iv)\n",
+ "f_b4= 10**-1 # in Hz\n",
+ "f_t4= 10**6 # in Hz\n",
+ "Ao4= f_t4/f_b4 \n",
+ "row4 = np.array([Ao4,f_b4,f_t4])\n",
+ "# Part (v)\n",
+ "Ao5= 2*10**5 \n",
+ "f_b5= 10 # in Hz\n",
+ "f_t5= Ao5*f_b5 # in Hz\n",
+ "row5 = np.array([Ao5,f_b5,f_t5])\n",
+ "print \"-\"*33\n",
+ "print \"Ao fb(Hz) ft(Hz)\"\n",
+ "print \"-\"*33\n",
+ "print \"%.e %.e %.e\" %(row1[0], row1[1], row1[2])\n",
+ "print \"%.e %.f %.e\" %(row2[0], row5[1], row2[2])\n",
+ "print \"%.e %.e %.e\" %(row3[0], row3[1], row3[2])\n",
+ "print \"%.e %.e %.e\" %(row4[0], row4[1], row4[2])\n",
+ "print \"%.e %.f %.e\" %(row5[0], row5[1], row5[2])\n",
+ "# Answer for f_b2 is wrong in the textbook."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "---------------------------------\n",
+ "Ao fb(Hz) ft(Hz)\n",
+ "---------------------------------\n",
+ "1e+05 1e+02 1e+07\n",
+ "1e+06 10 1e+06\n",
+ "1e+05 1e+03 1e+08\n",
+ "1e+07 1e-01 1e+06\n",
+ "2e+05 10 2e+06\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.27 - page 56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "from numpy import sqrt\n",
+ "# Given data\n",
+ "Ao= 86 # in dB\n",
+ "A= 40 # in dB\n",
+ "f=100 # in kHz\n",
+ "f=f*10**3 # in Hz\n",
+ "# From 20*log(S) = 20*log(Ao/A), where S, stands for sqrt(1+(f/fb)**2)\n",
+ "S= 10**((Ao-A)/20) \n",
+ "# S= sqrt(1+(f/fb)**2)\n",
+ "fb= f/sqrt(S**2-1) # in Hz\n",
+ "Ao= 10**(Ao/20) \n",
+ "ft= Ao*fb # in Hz\n",
+ "print \"The value of Ao = %0.3e\" %Ao\n",
+ "print \"The value of fb = %0.f Hz\" %fb\n",
+ "print \"The value of ft = %0.f MHz\" %round(ft*10**-6)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Ao = 1.995e+04\n",
+ "The value of fb = 501 Hz\n",
+ "The value of ft = 10 MHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exa 1.28 - page 56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "from numpy import pi, sqrt\n",
+ "# Given data\n",
+ "Ao= 10**4 # in V/V\n",
+ "f_t= 10**6 # in Hz\n",
+ "R2byR1= 20 \n",
+ "omega_t= 2*pi*f_t \n",
+ "omega_3dB= omega_t/(1+R2byR1) \n",
+ "f3dB= omega_3dB/(2*pi) # in Hz\n",
+ "print \"3-dB frequency of the closed loop amplifier is %0.1f kHz\" %(f3dB*10**-3)\n",
+ "f3dB= 0.1*f3dB # in Hz\n",
+ "voBYvi= -R2byR1/sqrt(1+(2*pi*f3dB/omega_3dB)**2) \n",
+ "voBYvi= abs(voBYvi) # in v/v\n",
+ "print \"Gain = %0.1f v/v\" %(voBYvi)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3-dB frequency of the closed loop amplifier is 47.6 kHz\n",
+ "Gain = 19.9 v/v\n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}