{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 6 Applications of Operational Amplifier" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.1 Pg 140" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the input resistance is = 20.00 kohm\n", "The resistance R2 is = 100.00 kohm\n" ] } ], "source": [ "# Design an inverting amplifier\n", "Av = -5 #\n", "#V1 = 0.1 sin wt #\n", "V1 = 0.1 # # *sin wt #\n", "i = 5*10**-6 #\n", "\n", "# the input resistance \n", "R1 = V1/i / 1000 # kohm\n", "print 'the input resistance is = %0.2f'%R1,'kohm'#\n", "\n", "# The resistance R2\n", "#Av = -(R2/R1)#\n", "R2 = -(Av*R1)#\n", "print 'The resistance R2 is = %0.2f'%R2,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.2 Pg 141" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the input resistance is = 20.00 kohm\n", "The resistance R2 is = 80.00 kohm\n" ] } ], "source": [ "# Design an non inverting amplifier\n", "Av = 5 #\n", "#V1 = 0.1 sin wt #\n", "V1 = 0.1 #\n", "i = -5*10**-6 #\n", "\n", "# the input resistance \n", "R1 = -V1/i/1000 # kohm\n", "print 'the input resistance is = %0.2f'%R1,'kohm'#\n", "\n", "# The resistance R2\n", "#Av = 1+(R2/R1)#\n", "R2 = (Av-1)*R1#\n", "print 'The resistance R2 is = %0.2f'%R2,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.3 Pg 146" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the cut off frequency of phase shifter is = 723.43 Hz\n", "The phase shift is = -15.75\n" ] } ], "source": [ "from math import atan ,degrees,pi\n", "# To calculate phase shift between two extremes \n", "C = 0.22*10**-6 #\n", "R = 1*10**3 #\n", "f = 1*10**3 #\n", "\n", "# the cut off frequency of phase shifter \n", "fc = 1/(2*pi*R*C) #\n", "print 'the cut off frequency of phase shifter is = %0.2f'%fc,'Hz'#\n", "f\n", "# the phase shift\n", "f = 1 # # KHz\n", "fc = 7.23 # # KHz \n", "PS = -2*degrees(atan(f/fc))\n", "print 'The phase shift is = %0.2f'%PS" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.4 Pg 146" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistance is = 1.92 kohm\n" ] } ], "source": [ "# To design a phase shifter\n", "f = 2*10**3 #\n", "PS = -135 #\n", "# the phase shift\n", "# PS = -2*atand(2*pi*R*C)#\n", "#RC = 192.1*10**-6 #\n", "C = 0.1*10**-6 #\n", "R = (192.1*10**-6)/C/1000 # kohm\n", "print 'The value of resistance is = %0.2f'%R,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.5 Pg 153" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistance R1 is = 25.00 kohm\n", "The value of resistance R3 is = 25.00 kohm\n", "The value of resistance R2 is = 750.00 kohm\n", "The value of resistance R4 is = 750.00 kohm\n" ] } ], "source": [ "# Design a difference amplifier\n", "Ri = 50 # kohm\n", "Ad = 30 \n", "\n", "R1 = Ri/2 #\n", "print 'The value of resistance R1 is = %0.2f'%R1,'kohm'#\n", "R3 = R1 #\n", "print 'The value of resistance R3 is = %0.2f'%R3,'kohm'#\n", "\n", "# the differential gain\n", "#Ad = R2/R1 #\n", "R2 = 30*R1 #\n", "print 'The value of resistance R2 is = %0.2f'%R2,'kohm'#\n", "\n", "R4 = R2 #\n", "print 'The value of resistance R4 is = %0.2f'%R4,'kohm'# " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.6 Pg 154" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The common mode rejection ratio is = 26.58 dB\n" ] } ], "source": [ "from math import log10\n", "# Calculate CMRR ratio\n", "Ad = 10.24 #\n", "Acm = 0.48 #\n", "\n", "# the common mode rejection ratio CMRR is defined as\n", "CMRRdB = 20*log10(Ad/Acm)#\n", "print 'The common mode rejection ratio is = %0.2f'%CMRRdB,' dB'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.7 Pg 156" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " The feedback resistance is = 100.00 kohm\n", " The value of resistance R1 is = 100.00 kohm\n" ] } ], "source": [ "from __future__ import division\n", "# Design current to voltage converter\n", "Vo =-10 #\n", "Is = 100*10**-6 #\n", "\n", "# the output voltage of current to voltage converter is defined as\n", "#Vo =-1s*R2 \n", "R2 = -Vo/Is/1000 #kohm\n", "print ' The feedback resistance is = %0.2f'%R2,'kohm'#\n", "\n", "R1 = R2 #\n", "print ' The value of resistance R1 is = %0.2f'%R1,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.8 Pg 157" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistance R2 is = 44.78 kohm\n" ] } ], "source": [ "from __future__ import division\n", "# Design high sensitivity current to voltage converter\n", "R1 = 5 # kohm\n", "Is = 1 #\n", "KR = 0.01/10**9 # # V / nA\n", "\n", "# the output voltage of high sensitivity current to voltage converter\n", "Vo =-KR*Is #\n", "KR = 10*10**6 #\n", "R = 1*10**6 # #we assume then\n", "K = 10 #\n", "#1 + (R2/R1)+(R2/R) = 10 #\n", "# solving above equation we get\n", "\n", "R2 = 9*((5*10**6)/(10**3+5))/1000 # kohm\n", "print 'The value of resistance R2 is = %0.2f'%R2,'kohm'# " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.9 Pg 160" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The load current iL is = 5.00 mA\n", "The current i3 is = 0.50 mA\n", "The current iA is = 5.50 mA\n", "The output voltage is = 6.00 V\n", "The current i1 is = 49.40 A\n", "The current i2 is = 49.40 A\n" ] } ], "source": [ "from __future__ import division\n", "# Determine a load current in a V to I converter\n", "R1 = 10 # kohm\n", "R2 = 10 # koohm\n", "R3 = 1 # kohm\n", "R4 = 1 # kohm\n", "VI = -5 #\n", "\n", "# The Load Current\n", "iL = -VI/R3 #\n", "print 'The load current iL is = %0.2f'%iL,'mA'#\n", "\n", "VL = 0.5 #\n", "# The Current i3 and iA\n", "i3 = VL/R3 #\n", "print 'The current i3 is = %0.2f'%i3,'mA'#\n", "\n", "iA = i3+iL #\n", "print 'The current iA is = %0.2f'%iA,'mA'#\n", "\n", "# the output voltage \n", "Vo = (iA*R3)+VL #\n", "print 'The output voltage is = %0.2f'%Vo,' V'#\n", "\n", "ZL =100 #\n", "# The current i1 and i2 \n", "#i1 = (VI-iL*ZL)/R1 #\n", "i1 = (iL*ZL-Vo)/R2 #\n", "print 'The current i1 is = %0.2f'%i1,' A'#\n", "\n", "i2 = i1 #\n", "print 'The current i2 is = %0.2f'%i2,' A'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.10 Pg 163" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistance R1f is = 0.0606 K ohm \n", "The value of resistance R2 is = 75.5 K ohm \n" ] } ], "source": [ "from __future__ import division\n", "# Design an instrumentation amplifier\n", "#A = 5 to 500 # adjustable gain\n", "VR = 100*10**3 #\n", "\n", "# the maximum differential gain of instrumentation amplifier is 500 \n", "#Amax = (R4/R3)*(1+(2R2/R1))#\n", "#by solving above equation we get following equation\n", "# 2R2 -249R1f = 0 equation 1\n", "\n", "# the minimum differential gain of instrumentation amplifier is 5\n", "# Amin = (R4/R3)*(1+(2R2/R1)) #\n", "#by solving above equation we get following equation\n", "# 2R2 -1.5R1f = 150*10**3 equation 2\n", "\n", "#by solving equation 1 and 2 we get\n", "print 'The value of resistance R1f is = 0.0606 K ohm '#\n", "\n", "print 'The value of resistance R2 is = 75.5 K ohm '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.11 Pg 164" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistane R1 is = 9.09 kohm\n" ] } ], "source": [ "from __future__ import division\n", "# To find the value of resistance R1 for instrumentation amplifier\n", "A =100 #\n", "R2 = 450*10**3 #\n", "R3 = 1*10**3 #\n", "R4 = 1*10**3 #\n", "\n", "# The gain of differential amplifier \n", "# A = (R4/R3)*(1+(2R2/R1)) #\n", "#but R3 = R4 then\n", "# A = 1+(2R2/R1) #\n", "R1 = 2*R2/(A-1)/1000 # kohm\n", "print 'The value of resistane R1 is = %0.2f'%R1,'kohm'# " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.12 Pg 167" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " At t = 1 msec the time constant RC is = 0.10 m sec\n", " if C = 0.01 uF then R of RC time constant is = 10 K ohm \n", " if C = 0.001 uF then R of RC time constant is = 100 K ohm \n" ] } ], "source": [ "from __future__ import division\n", "# determine the time constant of an integrator\n", "Vo = 10 # # at t= 1 m sec\n", "t = 1 # # m sec\n", "\n", "# the output of integrator \n", "#Vo = t/RC # when t is from 0 to 1\n", "RC = t/Vo #\n", "print ' At t = 1 msec the time constant RC is = %0.2f'%RC,' m sec'#\n", "\n", "print ' if C = 0.01 uF then R of RC time constant is = 10 K ohm '#\n", "\n", "print ' if C = 0.001 uF then R of RC time constant is = 100 K ohm '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.13 Pg 168" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " The feedback resistance Rf is = 100.00 kohm\n", " The frequency fa is = 2.00 kHz\n", " The value of capacitor C is = 0.8 nF \n" ] } ], "source": [ "from __future__ import division\n", "from math import pi\n", "# Design an integrator circuit\n", "A = 10 #\n", "f =20*10**3 #\n", "R = 10*10**3 # # we assume \n", "Rf =10*R #\n", "\n", "print ' The feedback resistance Rf is = %0.2f'%(Rf/1000),'kohm'#\n", "\n", "# for proper integration f>= 10fa \n", "fa = f/10/1000 #\n", "print ' The frequency fa is = %0.2f'%fa,'kHz'#\n", "\n", "# in practical integrator\n", "#fa = 1/(2*pi*Rf*C)#\n", "\n", "C = 1/(2*pi*Rf*fa)*1e6# nF\n", "print ' The value of capacitor C is = %0.1f'%C,'nF '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.1 Pg 185" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R1 is = 0.199 Mohm\n", "the value of resistance R2 is = 1 Mohm\n" ] } ], "source": [ "from __future__ import division\n", "# design an inverting amplifier with a closed loop voltage gain of Av = -5\n", "Av = -5 #\n", "Is = 5*10**-6 # # A\n", "Rs = 1*10**3 # # ohm\n", "# input voltage source Vs = sinwt volts\n", "\n", "# in an inverting amplifier frequency effect is neglected then i/p volt Vin = 1 V and total resistance equal to Rs+R1\n", "\n", "# the input current can be written as Iin=Is\n", "# Is = (Vin/Rs+R1)#\n", "Iin = Is#\n", "Vin = 1 # # V\n", "R1 = (1-(Iin*Rs))/Iin #\n", "print 'the value of resistance R1 is = %0.3f'%(R1/1e6),'Mohm'#\n", "\n", "# closed loop voltage gain of an inverting amplifier\n", "#Av = -(R2/Rs+R1)\n", "R2 = -(Av*(Rs+R1))#\n", "print 'the value of resistance R2 is = %0.f'%(R2/1e6),'Mohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.2 Pg 186" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R1 is = 8 kohm\n", "the value of resistance R2 is = 72 kohm\n" ] } ], "source": [ " # design an inverting amplifier with a closed loop voltage gain of Av = 10\n", "Av = 10 #\n", "Vin = 0.8 # #V\n", "Iin = 100*10**-6 # # A\n", "# in an non- inverting amplifier the input voltage Vin=V1=V2 because of vortual short effect then the i/p current In = Vin/R1\n", "R1 = Vin/Iin/1e3\n", "print 'the value of resistance R1 is = %0.f'%R1,'kohm'#\n", "\n", "# closed loop voltage gain of an non-inverting amplifier\n", "#Av = Vo/Vin = (1+R2/R1)\n", "R2 = (Av-1)*R1 # kohm\n", "print 'the value of resistance R2 is = %0.f'%R2,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.3 Pg 187" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R1 is = 20.00 kohm\n", "the value of resistance R2 is = 80.00 kohm\n", "the output current I2 is = 50 uA\n" ] } ], "source": [ "# design an non-inverting amplifier with colsed loop gain of 5 limited voltage of -5 V <= Vo <= 5 V and maximum i/p c/n 50 uA\n", "R1 = 8*10**3 # # ohm\n", "R2 = 72*10**3 # # ohm\n", "Iin = 50*10**-6 # # A\n", "Vo = 5 # # V \n", "\n", "# closed loop gain\n", "#Av = Vo/Vin = (1+R2/R1)\n", "Av = 1+(R2/R1)#\n", "# but \n", "Av = 5 #\n", "# then\n", "# (R2/R1) = 4 #\n", "\n", "# the output voltage of the amplifier is Vo = 5 V \n", "#i.e\n", "Vin = 1 # # V\n", "# Iin = Vin/R1 #\n", "R1 = Vin/Iin/1e3\n", "print 'the value of resistance R1 is = %0.2f'%R1,'kohm'#\n", "\n", "R2 = 4*R1 #\n", "print 'the value of resistance R2 is = %0.2f'%R2,'kohm'#\n", "\n", "# the output current I2 is given as\n", "I2 = (Vo-Vin)/R2*1e3 # uA\n", "print 'the output current I2 is = %0.f'%I2,'uA'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.4 Pg 188" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance Ria is = 20.00 kohm\n", "the value of resistance Rib is = 15.00 kohm\n", "the value of resistance Ric is = 30.00 kohm\n" ] } ], "source": [ "# Design a op-amp circuit to provide the output voltage Vo = -2(3 V1 +4 V2 +2 V3)\n", "# Vo = -2(3 V1 + 4 V2+ 2 V3)# equation 1\n", "# the output of the summer circuit is given as\n", "# Vo = -R2((Via/Ria)+(Vib/Rib)+(Vic/Ric)) equation 2\n", "\n", "# compare equation 1 and 2 of Vo we get \n", "\n", "# (R2/Ria)= 6 #\n", "# (R2/Rbi=8 #\n", "# (R2/Ric)=4 #\n", "\n", "R2 = 120*10**3/1e3 # # we choose then \n", "\n", "Ria = R2/6 #\n", "print 'the value of resistance Ria is = %0.2f'%Ria,'kohm'#\n", "\n", "Rib = R2/8 #\n", "print 'the value of resistance Rib is = %0.2f'%Rib,'kohm'#\n", "\n", "Ric = R2/4 #\n", "print 'the value of resistance Ric is = %0.2f'%Ric,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.5 Pg 188" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance Ria is = 90.00 kohm\n", "the value of resistance Rib is = 42.00 kohm\n", "the value of resistance Ric is = 63.00 kohm\n", "the value of resistance Rid is = 210.00 kohm\n" ] } ], "source": [ " # Design a summing amplifier circuit to provide the output voltage Vo = -(7 V11 + 15 V12 + 10 V13 + 3 V14)\n", "R2 = 630# kohm # Assume feedback resistance\n", "# Vo = -(7 V11 + 15 V12 + 10 V13 + 3 V14)# equation 1\n", "# the output of the summer circuit is given as\n", "# Vo = -R2((Via/Ria)+(Vib/Rib)+(Vic/Ric)+(Vid/Rid)) equation 2\n", "\n", "# compare equation 1 and 2 of Vo we get \n", "\n", "# (R2/Ria)= 7 #\n", "# (R2/Rbi= 15 #\n", "# (R2/Ric)= 10 #\n", "# (R2/Rid)= 3 #\n", "\n", "Ria = R2/7 #\n", "print 'the value of resistance Ria is = %0.2f'%Ria,' kohm'#\n", "\n", "Rib = R2/15 #\n", "print 'the value of resistance Rib is = %0.2f'%Rib,' kohm'#\n", "\n", "Ric = R2/10 #\n", "print 'the value of resistance Ric is = %0.2f'%Ric,' kohm'#\n", "\n", "Rid = R2/3 #\n", "print 'the value of resistance Rid is = %0.2f'%Rid,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.6 Pg 190" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R2 is = 300.00 kohm\n", "the value of resistance R4 is = 33333.33 kohm\n" ] } ], "source": [ "# Design a op-amp circuit to provide the output voltage Vo = V2 - 3 V1 with Ri1 =Ri2 = 100*10**3\n", "Ri1 = 100 # # kohm\n", "Ri2 = 100 # # kohm\n", "# the i/p resistance \n", "R1 = Ri1 #\n", "R3 = Ri2 #\n", "\n", "# Vo = V2 - 3 V1# equation 1\n", "# the output of the summer circuit is given as\n", "# Vo = [(R4/(R3+R4)*(1+(R2/R1))*Vi2-(R2/R1)*Vi1] equation 2\n", "\n", "# compare equation 1 and 2 of Vo we get \n", "# (R4/(R3+R4)*(1+(R2/R1)) = 1 # equation 3\n", "# R2/R1 = 3 # equation 4\n", "\n", "# by subsituting the value of R1 and R3 in equation 3 and 4\n", "\n", "# from equation 4\n", "R2 = 3*R1 #\n", "print 'the value of resistance R2 is = %0.2f'%R2,'kohm'#\n", "\n", "# from equation 3\n", "R4 = (100*10**3)/3 #\n", "print 'the value of resistance R4 is = %0.2f'%R4,'kohm'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.7 Pg 191" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The load current iL is = 5 mA\n", "The voltage across load VL is = 1.00 V\n", "The non-inverting current across i3 is = 1.00 mA\n", "The non-inverting current across i4 is = 6.00 mA\n", "The output voltage of given voltage to current converter is = 6.00 V\n" ] } ], "source": [ "from __future__ import division\n", "# determine the load current and output voltage\n", "Vin = -5 # # V\n", "ZL = 200 # # ohm\n", "R1 = 10*10**3 # # ohm\n", "R2 = 10*10**3 # # ohm\n", "R3 = 1*10**3 # # ohm\n", "R4 = 1*10**3 # # ohm\n", "\n", "# the load c/n of the given voltage to c/n converter circuit is given by\n", "iL =-Vin/(R1*R4)*R2*1e3 # m\n", "print 'The load current iL is = %0.f'%iL,'mA'#\n", "\n", "# the voltage across the load \n", "VL = iL/1e3*ZL#\n", "print 'The voltage across load VL is = %0.2f'%VL,' V'#\n", "\n", "# the non-inverting current across i3 and i4 are\n", "i3 = VL/R3*1000 #mA\n", "print 'The non-inverting current across i3 is = %0.2f'%i3,'mA'#\n", "\n", "i4 = iL+i3 # mA\n", "print 'The non-inverting current across i4 is = %0.2f'%i4,'mA'#\n", "\n", "# the output voltage of given voltage to current converter is given by\n", "Vo = (iL/1e3*R3)+VL #\n", "print 'The output voltage of given voltage to current converter is = %0.2f'%Vo,' V'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.8 Pg 192" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The common mode rejection ratio CMRR is = 120.50 \n", "The common mode rejection ratio CMRR in decibel is = 41.62 dB \n" ] } ], "source": [ "from __future__ import division\n", "from math import log10\n", "# determine the common mode rejection ratio CMRR\n", "# R2/R1 = 10 #\n", "# R4/R3 = 11 #\n", "\n", "# the output of the difference amplifier is given by\n", "# Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#\n", "\n", "# putting R1 R2 R3 R4 value in above equation we get Vo as\n", "\n", "# Vo =(121/12)*VI2-10VI1 # equation 1\n", "\n", "# the differential mode input of difference amplifier is given by\n", "# Vd = VI2-VI1 # eqution 2\n", "\n", "# the common mode input of difference amplifier is given by\n", "# VCM = (VI2+VI1)/2 # equation 3\n", "\n", "# from equation 2 and 3 \n", "\n", "# VI1 = VCM-Vd/2 # equation 4\n", "\n", "# VI2 = VCM+Vd/2 # equation 5\n", "\n", "# substitute equation 4 and 5 in 1 we get \n", "# Vo = (VCM/12)+(241Vd/24)# equation6\n", "\n", "# Vd = Ad*Vd+ACM*VCM # equation 7\n", "\n", "#equation from equation 6 and 7 we get\n", "\n", "Ad = 241/24 #\n", "ACM = 1/12 #\n", "\n", "# the common mode rejection ratio CMRR is \n", "CMRR = abs(Ad/ACM)#\n", "print 'The common mode rejection ratio CMRR is = %0.2f'%CMRR,' '#\n", "\n", "# in decibal it can be expressed as\n", "\n", "CMRR = 20*log10(CMRR)#\n", "print 'The common mode rejection ratio CMRR in decibel is = %0.2f'%CMRR,' dB '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.9 Pg 194" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output of the difference amplifier is = -8.12 V \n", "The output of the difference amplifier is = 0.12 V \n", "the common mode input of difference amplifier is = 2.00 \n", "the common mode gain ACM of difference amplifier is = 0.06 \n", "the differential gain of the difference amplifier is = 2.00 \n", "The common mode rejection ratio CMRR is = 32.00 \n", "The common mode rejection ratio CMRR in decibel is = 30.10 dB \n" ] } ], "source": [ "from __future__ import division\n", "from math import log10\n", "# determine Vo when 1) VI1 = 2 V VI2 = -2 V and 2) VI1 = 2 V VI2 = 2 V\n", "# and common mode rejection ratio CMRR\n", "R1 = 10*10**3 # # ohm\n", "R2 = 20*10**3 # # ohm\n", "R3 = 10*10**3 # # ohm\n", "R4 = 22*10**3 # # ohm\n", "\n", "\n", "# the output of the difference amplifier is given by\n", "# Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#\n", "\n", "# Case 1 when VI1 = 2 V VI2 = -2 V\n", "VI1 = 2 #\n", "VI2 = -2 #\n", "\n", "Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#\n", "print 'The output of the difference amplifier is = %0.2f'%Vo,' V '#\n", "\n", "# case 2 when VI1 = 2 V VI2 = 2 V\n", "VI1 = 2 #\n", "VI2 = 2 #\n", "\n", "Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#\n", "print 'The output of the difference amplifier is = %0.2f'%Vo,' V '#\n", "\n", "# the common mode input of difference amplifier is given by\n", "VCM = (VI2+VI1)/2 #\n", "print 'the common mode input of difference amplifier is = %0.2f'%VCM,' '#\n", "\n", "# the common mode gain ACM of difference amplifier is given by\n", "ACM = Vo/VCM\n", "print 'the common mode gain ACM of difference amplifier is = %0.2f'%ACM,' '#\n", "\n", "# the differential gain of the difference amplifier is given \n", "Ad = R2/R1 # \n", "print 'the differential gain of the difference amplifier is = %0.2f'%Ad,' '#\n", "\n", "# the common mode rejection ratio CMRR is \n", "CMRR = abs(Ad/ACM)#\n", "print 'The common mode rejection ratio CMRR is = %0.2f'%CMRR,' '#\n", "\n", "# in decibal it can be expressed as\n", "CMRR = 20*log10(CMRR)#\n", "print 'The common mode rejection ratio CMRR in decibel is = %0.2f'%CMRR,' dB '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.10 Pg 195" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the maximum differential voltage gain of the instrumentation amplifier is = 101.00 \n", "the minimum differential voltage gain of the instrumentation amplifier is = 5.00 \n", " the range of the differential voltage gain of the instrumentation amplifier is \n", " 5 <= Av <= 101 \n" ] } ], "source": [ "# To determine the range of the differential voltage gain\n", "#R1 = 1 K ohm to 25 K ohm #\n", "R2 = 50 # # K ohm\n", "R3 = 10 # # K ohm\n", "R4 = 10 # # K ohm\n", "\n", "# the output of instrumentation amplifier is given by\n", "#Vo = (R4/R3)*(1+(2*R2/R1))*(VI@-VI1)#\n", "\n", "# the differential voltage gain of the instrumentation amplifier can be written as\n", "#Av = (Vo/(VI2-VI1)) = (R4/R3)*(1+(2R2/R1))#\n", "\n", "# For R1 = 1 K ohm the maximum differential voltage gain of the instrumentation amplifier is\n", "R1 = 1 # # K ohm\n", "Av = (R4/R3)*(1+(2*R2/R1))#\n", "print 'the maximum differential voltage gain of the instrumentation amplifier is = %0.2f'%Av,' '#\n", "\n", "# For R1 = 25 K ohm the mminimum differential voltage gain of the instrumentation amplifier is\n", "R1 = 25 # # K ohm\n", "Av = (R4/R3)*(1+(2*R2/R1))#\n", "print 'the minimum differential voltage gain of the instrumentation amplifier is = %0.2f'%Av,' '#\n", "\n", "print ' the range of the differential voltage gain of the instrumentation amplifier is '#\n", "print ' 5 <= Av <= 101 '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.11 Pg 196" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The variable resistance R1 varies is 401 ohm <= R1 <= 100.2 K-ohm \n" ] } ], "source": [ "# To design an instrumentation amplifier\n", "# 4 <= Av <= 1000 # gain\n", "Ad = 2 #\n", "Res = 100 # # K ohm\n", "\n", "# we cosider the variable resistance is R1 , the maximum and the minimum range of variable resistance \n", "# R1min = R1 # \n", "# R1max = R1+100 #\n", "\n", "# the gain of difference amplifier \n", "#A3 = Ad = Vo/(Vo2-Vo1) = (R4/R3)\n", "\n", "# the maximum range of differential voltage gain Avmax = 1000 when R1min = R1\n", "#Avmax = R4/R3*(1+(2*R2/R1min))#\n", "\n", "# by solvin we get following equation\n", "# 499*R1-2*R2=0 equation 1\n", "\n", "# the maximum range of differential voltage gain Avmin =4 when R1max = R1+100 K ohm\n", "# Avmin = (R4/R3)*(1+(2R2/R1max))#\n", "\n", "# by solving above equation we get\n", "# R1 -2 R2 = -200 K ohm equation 2\n", "\n", "#by solving equation 1 and 2 we get\n", "R1 = 401 # # ohm\n", "R2 = 100.2 # # ohm\n", "print 'The variable resistance R1 varies is 401 ohm <= R1 <= 100.2 K-ohm ' #" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.12 Pg 198" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " The time constant of the given filter is RC = 0.20 msec \n" ] } ], "source": [ " # Determine the time constant of the integrator\n", "Vo = 10 #\n", "t = 2*10**-3 #\n", "VI = -1 # # at t =0 #\n", "\n", "# The output voltage of an integrator is define as\n", "RC = t/10*1e3 # ms\n", "print ' The time constant of the given filter is RC = %0.2f'%RC,'msec '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.13 Pg 198" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " The time constant of the given filter is RC = 0.1 msec \n", "The capacitor value is = 0.1 F\n" ] } ], "source": [ "from __future__ import division\n", "# Determine the time constant of the integrator\n", "Vo = 20 #\n", "t = 1*10**-3 #\n", "VI = -1 # # at t =0 #\n", "\n", "# The output voltage of an integrator is define as\n", "RC = t/10 #\n", "print ' The time constant of the given filter is RC = %0.1f'%(RC*1000),'msec '#\n", "\n", "R = 1*10**3 # # we assume \n", "C = RC/R*10**6 #\n", "print 'The capacitor value is = %0.1f'%C,'F'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.14 Pg 199" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The value of resistance RIa is = 90.00 K ohm \n", "The value of resistance RIb is = 22.50 K ohm \n", "The value of resistance RIc is = 18.00 K ohm \n", "The value of resistance RId is = 15.00 K ohm \n" ] } ], "source": [ " # to design a summing amplifier\n", "\n", "# the output of the summing amplifier is given by\n", "#Vo = -R2*((VIa/RIa)+(VIb/RIb)+(VIc/RIc)+(VId/RId))# equation 1\n", "\n", "# the equation given is\n", "#Vo = -(3*VIa+12*VIb+15*VIc+18*VId)# equation 2\n", "\n", "# comparing equation 1 and 2\n", "#R2/RIa = 3 #\n", "#R2/RIb = 12 #\n", "#R2/RIc = 15 #\n", "#R2/RId = 18 # \n", "\n", "# the feedback resistance R2= 270 K ohm \n", "R2 = 270 # # K ohm\n", "RIa = R2/3 #\n", "print 'The value of resistance RIa is = %0.2f'%RIa,' K ohm '#\n", "\n", "RIb = R2/12 #\n", "print 'The value of resistance RIb is = %0.2f'%RIb,' K ohm '#\n", "\n", "RIc = R2/15 #\n", "print 'The value of resistance RIc is = %0.2f'%RIc,' K ohm '#\n", "\n", "RId = R2/18 #\n", "print 'The value of resistance RId is = %0.2f'%RId,' K ohm '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.15 Pg 200" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output of first op-amp A1 is = -275*sin wt mV \n", "The output of second op-amp A2 is = 275*sin wt mV \n", "The output of third op-amp A3 is = 825*sin wt mV \n", "current through the resistor R1 and R2 is = 5 sin wt uA \n", "current through the non-inverting terminal resistor R3 and R4 = 5.5 sin wt uA \n", "current through the inverting terminal resistor R3 and R4 = 22 sin wt uA \n" ] } ], "source": [ "# for the instrumentation amplifier find Vo1 , Vo2 , Vo \n", "# Vi1 = -25 sin wt # # mV\n", "# Vi2 = 25 sin wt # # mV\n", "R1 = 10*10**3 #\n", "R2 = 20*10**3 #\n", "R3 = 20*10**3 #\n", "R4 = 10*10**3 #\n", "\n", "# the output of first op-amp A1 is given by\n", "# Vo1 = (1+(R2/R1))*Vi1-(R2/R1)*Vi2 #\n", "#by solving above equation we get\n", "print 'The output of first op-amp A1 is = -275*sin wt mV '#\n", "\n", "# the output of second op-amp A2 is given by\n", "# Vo2 = (1+(R2/R1))*Vi2-(R2/R1)*Vi1 #\n", "#by solving above equation we get\n", "print 'The output of second op-amp A2 is = 275*sin wt mV '#\n", "\n", "# the output of third op-amp A3 is given by\n", "# Vo = (R4/R3)-(1+(2R2/R1)*(Vi2-Vi1) #\n", "#by solving above equation we get\n", "print 'The output of third op-amp A3 is = 825*sin wt mV '#\n", "\n", "# current through the resistor R1 and R2 is\n", "#i = (Vi1-Vi2)/R1 #\n", "print 'current through the resistor R1 and R2 is = 5 sin wt uA '#\n", "\n", "# current through the non-inverting terminal resistor R3 and R4 \n", "#i3 = Vo2/(R3+R4)#\n", "print 'current through the non-inverting terminal resistor R3 and R4 = 5.5 sin wt uA '#\n", "\n", "# current through the inverting terminal resistor R3 and R4 \n", "#i2 = Vo1-(R3/(R3+R4))*Vo2/R3 #\n", "print 'current through the inverting terminal resistor R3 and R4 = 22 sin wt uA '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.16 Pg 202" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The input resistance Rin is = 0.00999 ohm \n", "The value of Resistance Rs is = 1.0990 K ohm \n" ] } ], "source": [ "from __future__ import division\n", "# for the a current to voltage converter show a) Rin = (Rf/1+Aop) b) Rf = 10 K ohm Aop = 1000 \n", "\n", "#a) The input resistance given as\n", "#Rin = (Rf)/(1+Aop) #\n", "\n", "# The input resistance of the circuit can be written as\n", "#Rin = (V1/i!)#\n", "\n", "# the feedback current of the given circuit is defined as\n", "#i1 =(V1-Vo)/RF #\n", "\n", "# the feedback resistance RF is \n", "#RF =(V1-Vo)/i1 #\n", "\n", "# The output voltage Vo is\n", "#Vo = -Aop*V1 #\n", "\n", "#by using this output feedback currenty i1 can be reformed as\n", "#i1 = (V1-(-Aop*V1))/RF #\n", "\n", "#i1 = V1*(1+Aop)/RF #\n", "\n", "# Then Rin Becomes \n", "#Rin =Rf/(1+Aop)#\n", "\n", "Rf =10*10**3 #\n", "Aop = 1000 #\n", "\n", "# the input current and output voltage of the circuit are defined as\n", "#i1 =(Rs)/(Rs+Rin) #\n", "# Vo = -(Aop*(RF/1+Aop))*i1 #\n", "\n", "#the input resistance Rin is \n", "Rin =(Rf/(1+Aop)) #\n", "\n", "# subsituting the value of RF Aop Rin and Vo we get \n", "RF = 10 #\n", "Rin = RF/(1+Aop)\n", "print 'The input resistance Rin is = %0.5f'%Rin,' ohm '#\n", "\n", "Aop = 1000 #\n", "#(1000/1001)*(Rs/(Rs*0.00999))> 0.99 #\n", "# by solving above equation we get \n", "Rs = 1.099 # # K ohm \n", "print 'The value of Resistance Rs is = %0.4f'%Rs,' K ohm '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.17 Pg 204" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "for Aop = 10**4 closed loop gain is = 0.9999 \n", "for Aop = 10**3 closed loop gain is = 0.9990 \n", "for Aop = 10**2 closed loop gain is = 0.9901 \n", "for Aop = 10**1 closed loop gain is = 0.9091 \n" ] } ], "source": [ "from __future__ import division\n", "# determine the closed loop gain\n", "\n", "# the output of the voltage follower is given as\n", "#Vo = Aop(V1-Vo)#\n", "\n", "# the closed loop gain of the voltage follower \n", "#A = 1/(1+(1/Aop))#\n", " \n", "# for Aop = 10**4 closed loop gain\n", "Aop = 10**4 #\n", "A = 1/(1+(1/Aop))#\n", "print 'for Aop = 10**4 closed loop gain is = %0.4f'%A,' '#\n", "\n", "# for Aop = 10**3 closed loop gain\n", "Aop = 10**3 #\n", "A = 1/(1+(1/Aop))#\n", "print 'for Aop = 10**3 closed loop gain is = %0.4f'%A,' '#\n", "\n", "# for Aop = 10**2 closed loop gain\n", "Aop = 10**2 #\n", "A = 1/(1+(1/Aop))#\n", "print 'for Aop = 10**2 closed loop gain is = %0.4f'%A,' '#\n", "\n", "# for Aop = 10**1 closed loop gain\n", "Aop = 10**1 #\n", "A = 1/(1+(1/Aop))#\n", "print 'for Aop = 10**1 closed loop gain is = %0.4f'%A,' '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.18 Pg 205" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "for the frequency f = 10 Hz the output is = 106.10 V \n", "for the frequency f = 1000 Hz the output is = 1.06 V \n", "for the frequency f = 10000 Hz the output is = 0.106 V \n" ] } ], "source": [ "from __future__ import division\n", "from math import pi\n", "# To determine the output voltage of integrator\n", "Vin = 1 #\n", "R = 150*10**3 ## ohm\n", "C = 1*10**-9 # # F\n", "\n", "# the output voltage of an integrator is given as\n", "#Vo = (fc/f)*Vin #\n", "\n", "#fc = 1/(2*pi*R*C)#\n", "\n", "#Vo = (1/(2*pi*R*C*f))*Vin#\n", "\n", "#for the frequency f = 10 Hz the output is\n", "f = 10 # # Hz\n", "Vo = (1/(2*pi*R*C*f))*Vin#\n", "print 'for the frequency f = 10 Hz the output is = %0.2f'%Vo,' V '#\n", "\n", "#for the frequency f = 1000 Hz the output is\n", "f = 1000 # # Hz\n", "Vo = (1/(2*pi*R*C*f))*Vin#\n", "print 'for the frequency f = 1000 Hz the output is = %0.2f'%Vo,' V '#\n", "\n", "#for the frequency f = 10000 Hz the output is\n", "f = 10000 # # Hz\n", "Vo = (1/(2*pi*R*C*f))*Vin#\n", "print 'for the frequency f = 10000 Hz the output is = %0.3f'%Vo,' V '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.19 Pg 206" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The cutoff frequency of the integrator is = 13.263 kHz\n", "The gain of the integrator is = 3.18\n" ] } ], "source": [ "from __future__ import division\n", "from math import sqrt\n", "# To determine the magnitude gain of the integrator\n", "Vin = 1 #\n", "f = 50*10**3 #\n", "Rf = 120*10**3 #\n", "R = 10*10**3 #\n", "C = 0.1*10**-9 #\n", "\n", "# the magnitude gain of the integrator is given by\n", "#A = (Rf/R)/(sqrt(1+(f/fc)**2))#\n", "\n", "# the cutoff frequency of the integrator \n", "fc = 1/(2*pi*Rf*C)/1e3\n", "print 'The cutoff frequency of the integrator is = %0.3f'%fc,'kHz'#\n", "\n", "\n", "A = (Rf/R)/(sqrt(1+(f/fc)**2))*1e3#\n", "print 'The gain of the integrator is = %0.2f'%A" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.20 Pg 207" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the break frequency fa is = 31.83 kHz \n", "the break frequency fb is = 21.22 kHz \n", "The gain of the differentiator is = 0.6667 \n" ] } ], "source": [ "from __future__ import division\n", "from math import sqrt,pi\n", "# To determine the magnitude gain of the differentiator\n", "Vin = 1 #\n", "f = 50*10**3 #\n", "R = 75*10**3 #\n", "R1 = 50*10**3 #\n", "C = 0.1*10**-9 #\n", "\n", "# the magnitude gain of the differentiator is given by\n", "#A = (f/fa)/(sqrt(1+(f/fb)**2))#\n", "\n", "# the break frequency fa is defined as\n", "fa = 1/(2*pi*R1*C) / 1e3\n", "print 'the break frequency fa is = %0.2f'%fa,'kHz '#\n", "\n", "# the break frequency fb is defined as\n", "fb = 1/(2*pi*R*C) /1e3\n", "print 'the break frequency fb is = %0.2f'%fb,'kHz '#\n", "\n", "\n", "A = (f/fa)/(sqrt(1+(f/fb)**2))#\n", "print 'The gain of the differentiator is = %0.4f'%A,' '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.21 Pg 209" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The input voltage of an op-amp is = -40 mV\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the input voltage of an op-amp\n", "Vo = 2 # # V\n", "R1 = 20*10**3 # # ohm\n", "R2 = 1*10**6 # # ohm\n", "\n", "# the input voltage of an op-amp\n", "Vin = -(R1/R2)*Vo *1000 # mV\n", "print 'The input voltage of an op-amp is = %0.f'%Vin,'mV'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.22 Pg 209" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the output voltage of follower Vo1 is = 2.00 V\n", "The output voltage of an inverting amplifier is = -20.00 V \n" ] } ], "source": [ "from __future__ import division\n", "# To determine the output voltage\n", "Vin = 2 #\n", "R2 = 20*10**3 #\n", "R1 = 2*10**3 #\n", "\n", "# the output voltage of follower Vo1 is\n", "Vo1 = Vin #\n", "print 'the output voltage of follower Vo1 is = %0.2f'%Vo1,' V'#\n", "# the output voltage of an inverting amplifier\n", "Vo = -(R2/R1)*Vo1 #\n", "print 'The output voltage of an inverting amplifier is = %0.2f'%Vo,' V '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.23 Pg 210" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output of the inverting amplifier is = -15.00 V\n", "The output of the non-inverting amplifier is = 20.00 V\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the output voltage of an op-amp\n", "Vin = 5 # # V\n", "R1 = 25*10**3 # # ohm\n", "R2 = 75*10**3 # # ohm\n", "\n", "# in this problem op-amp A1 perform the voltage follower and op-amp A2 perform inverting amplifier and op-amp A3 perform non-inverting amplifier\n", "\n", "# the output voltage of follower op-amp A1\n", "Vo1 = Vin #\n", "\n", "# the output of the inverting amplifier A2\n", "Vo2 = -((R2/R1)*Vo1) #\n", "print 'The output of the inverting amplifier is = %0.2f'%Vo2,' V'#\n", "\n", "# the output of the non-inverting amplifier A3\n", "Vo =(1+(R2/R1))*Vo1 #\n", "print 'The output of the non-inverting amplifier is = %0.2f'%Vo,' V'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.24 Pg 211" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output voltage of an inverting amplifier is = 27.50 V \n", "the output voltage of follower Vo1 is = 2.50 V\n", "the output of the inverting summing amplifier is = 101.25 V \n" ] } ], "source": [ "from __future__ import division\n", "# To determine the output voltage\n", "Vin = 2.5 #\n", "Rf = 100*10**3 #\n", "R1 = 10*10**3 #\n", "RI1 = 25*10**3 #\n", "RI2 = 10*10**3 #\n", "R2 = 100*10**3 #\n", "\n", "# the output voltage of an inverting amplifier\n", "Vo1 = (1+(R2/R1))*Vin # #\n", "print 'The output voltage of an inverting amplifier is = %0.2f'%Vo1,' V '#\n", "\n", "# the output voltage of follower Vo2 is\n", "Vo2 = Vin #\n", "print 'the output voltage of follower Vo1 is = %0.2f'%Vo2,' V'#\n", "\n", "# the output of the inverting summing amplifier\n", "R2 = 75*10**3 #\n", "Vo = R2*((Vo1/RI1)+(Vo2/RI2))#\n", "print 'the output of the inverting summing amplifier is = %0.2f'%Vo,' V '#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.25 Pg 212" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the total gain of the circuit is = 36.00 \n", "The output voltage of the op-amp is = 90.00 V\n" ] } ], "source": [ "from __future__ import division\n", "# To calculate the output voltage\n", "Vin = 2.5 # \n", "R1 = 10*10**3 #\n", "R2 = 10*10**3 #\n", "R3 = 10*10**3 #\n", "Rf = 30*10**3 #\n", "\n", "# the total gain of the circuit \n", "#Av =A1v*A2v*A3v #\n", "Av = (1+(Rf/R1))*(-Rf/R2)*(-Rf/R3)#\n", "print 'the total gain of the circuit is = %0.2f'%Av,' '#\n", "\n", "# The output voltage of the op-amp \n", "Vo = Av*Vin #\n", "print 'The output voltage of the op-amp is = %0.2f'%Vo,' V'#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.26 Pg 212" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output of op-amp A1 is = -10.00 V1\n", "The output of op-amp A2 is Vo = 40V1 - 2V2 \n", "The output is equal to the difference between 40V1 and 2V2 \n" ] } ], "source": [ "from __future__ import division\n", "# to calculate the output voltage of op-amp circuit\n", "Rf = 100*10**3 # # ohm\n", "R1 = 10*10**3 # # ohm\n", "R2 = 25*10**3 # # ohm\n", "R3 = 50*10**3 # # ohm\n", "\n", "# the output of op-amp A1 is\n", "# VA1 = (-Rf/R1)*V1 #\n", "VA1 = (-Rf/R1)#\n", "print 'The output of op-amp A1 is = %0.2f'%VA1,'V1' # # *V1 because the output is come from 1 op-amp\n", "\n", "# the output of op-amp A2 is\n", "# Vo = -Rf*((VA1/R2)+(V2/R3))#\n", "#Vo = -100*(-0.4*V1+0.02V2)#\n", "print 'The output of op-amp A2 is Vo = 40V1 - 2V2 '# \n", "\n", "print 'The output is equal to the difference between 40V1 and 2V2 '# " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.27 Pg 213" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the upper crossover voltage of schmitt trigger is = 1.00 V\n", "the lower crossover voltage of schmitt trigger is = -1.00 V\n", "the hysteresis width HW of schmitt trigger is = 2.00 V\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the hysteresis width of a schmitt trigger\n", "R1 = 25*10**3 # # ohm\n", "R2 = 75*10**3 # # ohm\n", "VTH = 4 # # V\n", "VTL = -4 # # V\n", "\n", "# the upper crossover voltage of schmitt trigger is defined as\n", "VU = (R1/(R1+R2))*VTH#\n", "print 'the upper crossover voltage of schmitt trigger is = %0.2f'%VU,' V'\n", "\n", "# the lower crossover voltage of schmitt trigger is defined as\n", "VL = (R1/(R1+R2))*VTL#\n", "print 'the lower crossover voltage of schmitt trigger is = %0.2f'%VL,' V'\n", "\n", "# the hysteresis width of schmitt trigger is\n", "HW = VU-VL #\n", "print 'the hysteresis width HW of schmitt trigger is = %0.2f'%HW,' V'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.28 Pg 214" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the upper crossover voltage of schmitt trigger is = 1.43 V\n", "the lower crossover voltage of schmitt trigger is = -1.43 V\n", "the hysteresis width HW of schmitt trigger is = 2.86 V\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the hysteresis width of a schmitt trigger\n", "R1 = 15*10**3 # # ohm\n", "R2 = 90*10**3 # # ohm\n", "VTH = 10 # # V\n", "VTL = -10 # # V\n", "\n", "# the upper crossover voltage of schmitt trigger is defined as\n", "VU = (R1/(R1+R2))*VTH#\n", "print 'the upper crossover voltage of schmitt trigger is = %0.2f'%VU,' V'\n", "\n", "# the lower crossover voltage of schmitt trigger is defined as\n", "VL = (R1/(R1+R2))*VTL#\n", "print 'the lower crossover voltage of schmitt trigger is = %0.2f'%VL,' V'\n", "\n", "# the hysteresis width of schmitt trigger is\n", "HW = VU-VL #`\n", "print 'the hysteresis width HW of schmitt trigger is = %0.2f'%HW,' V'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.29 Pg 214" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R1 is = 5.00 kohm\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the resistance R1 when low and high saturated output states are given\n", "R2 = 20*10**3 # # ohm\n", "VH = 2 # # V crossover voltage\n", "VL = -2 # # V crossover voltage\n", "VOH = 10 # # V saturated output states\n", "VOL = -10 # # V saturated output states\n", "\n", "# the upper crossover voltage of schmitt trigger is defined as\n", "# V = (R1/(R1+R2))*VOH#\n", "# solving above equation we get \n", "# 2R1+2R2 = 10R1 #\n", "R1 = (2*R2)/8/1000 # kohm\n", "print 'the value of resistance R1 is = %0.2f'%R1,'kohm'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.30 Pg 215" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the value of resistance R2 is = 30.00 kohm\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the value of resistance R1 and R2 when low and high saturated output states are given\n", "VH = 3 # # V crossover voltage\n", "VL = -3 # # V crossover voltage\n", "VOH = 12 # # V saturated output states\n", "VOL = -12 # # V saturated output states\n", "\n", "# the upper crossover voltage of schmitt trigger is defined as\n", "# V = (R1/(R1+R2))*VOH#\n", "# solving above equation we get \n", "# 3R1+3R2 = 12R1 #\n", "\n", "# 3*R1 = R2 #\n", "R1 = 10*10**3 # # ohm we assume\n", "R2 = 3*R1 / 1e3#\n", "print 'the value of resistance R2 is = %0.2f'%R2,'kohm'" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }