{
 "metadata": {
  "name": "",
  "signature": "sha256:b6947316bc65682adaa8d93a4eda990ab9271382dd0514c03ae855d300a77db0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: Feedback Amplifiers And Oscillators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1,Page number 331"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vo=12.            #output voltage(V)\n",
      "f=1.5*10**3       #frequency(Hz)\n",
      "h=0.25            #second harmonic content(%) \n",
      "ho=2.5            #reduced harmonic content of output(%)\n",
      "A=100             #power amplifier gain\n",
      "\n",
      "#Calculations\n",
      "Vd=Vo*h              #second harmonic content in output(V)\n",
      "Vd1=Vo*ho            #reduced value of second harmonic content(V)\n",
      "beta=((Vd1/Vd)-1)/A  #feedback gain from formula Vd1=Vd/(1+beta*A) \n",
      "Vs=Vo*(1+beta*A)/A   #signal voltage(V) from formula (A/(1+Beta*A))*Vs \n",
      "V=Vo/A               #signal input needed without feedback        \n",
      "s=Vs/V               #additional signal amplification needed before feedback amplifier\n",
      "\n",
      "#Results\n",
      "print\"feedback gain is\",beta\n",
      "print\"signal input to the overall system is\",s"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "feedback gain is 0.09\n",
        "signal input to the overall system is 10.0\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2,Page number 332"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "w2=10**4.             #corner frequency(rad/s)  \n",
      "w2new=10**5.          #new corner frequency(rad/s)  \n",
      "Ao=1000.              #high frquency response        \n",
      "\n",
      "#Calculations\n",
      "beta=((w2new/w2)-1)/Ao #feedback factor\n",
      "Anew=Ao/(1+beta*Ao)   #overall gain of amplifier from formula w2new=w2(1+beta*Ao)\n",
      "p=w2*Ao               #gain bandwidth product without feedback from formula Anew=Ao/1+beta*Ao\n",
      "pnew=Anew*w2new       #gain bandwidth product with feedback\n",
      "\n",
      "#Results\n",
      "print\"beta is\",beta\n",
      "print\"overall gain is\",Anew\n",
      "print\"gain-bandwidth products with and without feedback are\",p,\"and\",pnew,\"resp.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "beta is 0.009\n",
        "overall gain is 100.0\n",
        "gain-bandwidth products with and without feedback are 10000000.0 and 10000000.0 resp.\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3,Page number 333"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "A=100.                               #high frquency response        \n",
      "Af=100                               #gain     \n",
      "A1=A**2                              #forward gain\n",
      "A1new=50                             #gain reduces to 50%  \n",
      "\n",
      "#Calculations\n",
      "beta=((A1/Af)-1)/A1                  #feedback factor\n",
      "Afnew=A1new**2/(1+beta*A1new**2)     #new value of A\n",
      "g=Af-Afnew                           #reduction in overall gain\n",
      "\n",
      "#Results\n",
      "print\"% change in gain of feedback unit is\",round(g,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "% change in gain of feedback unit is 2.91\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4,Page number 337"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=0.008                   #positive gain \n",
      "\n",
      "#Calculations\n",
      "Ao=-(8/beta)**(1/3)          #A=Ao/2,so beta(A^3)=-1\n",
      "\n",
      "#Results\n",
      "print\"% change in gain of feedback unit is\",round(Ao/1E-1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "% change in gain of feedback unit is -10.0\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5Page number 337"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import cmath\n",
      "from math import pi,degrees\n",
      "\n",
      "#Variable declarations\n",
      "A = complex(0,60)                  #amplifier\n",
      "B = complex(0,30)                  #amplifier\n",
      "AB = A*B\n",
      "C = (1+A)/AB                       #condition for oscillation\n",
      "phi = cmath.phase(C)               #phase\n",
      "\n",
      "#Result\n",
      "print \"C =\",round(abs(C),4),\"with phase =\",round(degrees(phi),2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C = 0.0333 with phase = -90.95\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7,Page number 347"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rbb=8*10**3                  #base resistance(k ohms)\n",
      "eta=0.7                     #efficiency\n",
      "R1=0.2                      #R1(k ohms)\n",
      "Rt=40*10**3                 #Rt(ohms)\n",
      "Ct=0.12*10**-6              #capacitance(F)\n",
      "Vv=2                        #capacitor is charged to voltage(V)\n",
      "Iv=10*10**-3                #current to capacitor(A)\n",
      "Ip=10*10**-3                 #peak current(A)\n",
      "Vd=0.7                      #diode voltage(V)\n",
      "V=12.                        #voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Rb1=eta*Rbb    #base resistance(ohms) \n",
      "Rb2=Rbb-Rb1             #base resistance(ohms)\n",
      "\n",
      "#Part b\n",
      "Vp=Vd+((Rb1+R1)*V/(Rbb+R1))    #peak voltage(V)\n",
      "\n",
      "#Part c\n",
      "Rtmin=(V-Vv)/Iv          #Rt minimum(k ohms)        \n",
      "Rtmax=(V-Vp)/Ip          #Rt minimum(k ohms)  \n",
      "\n",
      "#Part d\n",
      "Rb11=.12                #resistance during discharge(ohms)\n",
      "t1=Rt*Ct*1.27           #charging time(mS)\n",
      "t2=(Rb11+R1)*Ct*1.52    #discharging time(uS)\n",
      "T=t1+t2                 #cycle time\n",
      "foscE=1/T               #oscillations frequency(Hz)\n",
      "foscA=1/(Rt*Ct*1.2)     #oscillations frequency(Hz)\n",
      "\n",
      "#Part e\n",
      "vR1=(R1*V)/(R1+Rbb)             #vR1 at discharging period\n",
      "vR1d=(R1*(Vp-Vd))/(R1+Rb11)      #vR1 at discharging period\n",
      "\n",
      "#Results\n",
      "print\"Rb1 and Rb2 are\",round((Rb1/1E+3),1),\"k ohms and\",round((Rb2/1E+3),1),\"k ohms resp.\"\n",
      "print\"Vp is\",round(Vp,1),\"V\"\n",
      "print\"Rtmin is\",round(Rtmin/1E+3),\",k ohms and Rtmax is\",round(Rtmax/1E+1),\"k ohms,hence Rt is in the range\"\n",
      "print\"foscE is\",round(foscE),\"Hz and foscA is\",round(foscA),\"Hz\"\n",
      "print\"vR1 is\",round((vR1/1E-3),3),\"and vRd1 is\",round(vR1d,2),\"V (range of Rt is wrong in the book)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rb1 and Rb2 are 5.6 k ohms and 2.4 k ohms resp.\n",
        "Vp is 9.1 V\n",
        "Rtmin is 1.0 ,k ohms and Rtmax is 29.0 k ohms,hence Rt is in the range\n",
        "foscE is 164.0 Hz and foscA is 174.0 Hz\n",
        "vR1 is 0.3 and vRd1 is 5.25 V (range of Rt is wrong in the book)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8,Page number 350"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "A=1500                         #voltage gain\n",
      "beta=1/25.                     #current gain \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Af=A/(1+A*beta)                 #voltage gain with feedback\n",
      "\n",
      "#Part b\n",
      "g=0.1                        #amplifier gain changes by 10%=0.1\n",
      "gf=g/(1+A*beta)              #% by which its gain in feedback mode changes dAf/Af\n",
      "\n",
      "#Results\n",
      "print\"Amplifier gain with feedback is\",round(Af,1)\n",
      "print\"% by which gain in feedback changes is\",round((gf/1E-2),3),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier gain with feedback is 24.6\n",
        "% by which gain in feedback changes is 0.164 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9,Page number 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "A=500                      #voltage gain\n",
      "beta=1/20.                 #current gain\n",
      "Ro=50*10**3                #output resistance(ohms) \n",
      "Ri=1.5*10**3               #input resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Af=A/(1+A*beta)            #voltage gain with feedback   \n",
      "\n",
      "#Part b\n",
      "Rif=Ri*(1+(A*beta))         #input resistance(k ohms)\n",
      "Rof=Ro/(1+A*beta)           #output resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"Amplifier gain is\",round(Af,2)\n",
      "print\"input resistance is\",round(Rif/1E+3),\"K ohms and output resistance is\",round((Rof/1E+2),2),\"Kohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier gain is 19.23\n",
        "input resistance is 39.0 K ohms and output resistance is 19.23 Kohms\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10,Page number 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ro=50*10**3                 #output resistance(ohms)\n",
      "Rd=10*10**3                 #drain resistance(ohms)\n",
      "R1=800*10**3                #resistance(ohms)\n",
      "R2=200*10**3                #resistance(ohms)\n",
      "gm=5500*10**-6              #transconduuctance(us)\n",
      "\n",
      "#Calculations\n",
      "r=(Rd*Ro)/(Rd+Ro)            #Rd||Ro\n",
      "R=R1+R2                      #combined resistance of R1 and R2\n",
      "Rl=(R*r)/(R+r)               #load resistance(ohms)\n",
      "A=-gm*Rl                     #voltage gain without feedback\n",
      "beta=R2/(R1+R2)              #current gain \n",
      "Af=A/(1+A*beta)              #voltage gain with feedback\n",
      "\n",
      "#Results\n",
      "print\"Amplifier gain with feedback is\",round((Af/1E+1),1),\"and without feedback is\",A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier gain with feedback is -4.5 and without feedback is -45.452\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11,Page number 352"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Re=1.25*10**3              #emitter resistance(ohms)\n",
      "Rc=4.8*10**3                #collector resistance(ohms)\n",
      "Rb=800*10**3               #base resistance(ohms)     \n",
      "rpi=900                    #dynamic resistance(ohms)\n",
      "Vcc=16                     #supply voltage(V)\n",
      "beta=100.                  #current gain \n",
      "\n",
      "#Calculations\n",
      "A=-(beta/rpi)             #amplifier voltage gain  \n",
      "B=-Re                     \n",
      "V=(A*Rc)/(1+B*A)          #V=Vo/Vs\n",
      "   \n",
      "#Results\n",
      "print\"Amplifier voltage gain is\",round(V,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplifier voltage gain is -3.8\n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12,Page number 352"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " import math\n",
      "\n",
      "#Variable declaration\n",
      "C1=800*10**-9                   #capacitance(F)\n",
      "C2=2400*10**-9                  #capacitance(F)\n",
      "L=50*10**-6                     #inductance(H)\n",
      "\n",
      "#Calculations\n",
      "Ceq=(C1*C2)/(C1+C2)                #equivalent capacitance(F)\n",
      "fo=1/(2*math.pi*math.sqrt(L*Ceq))  #output frequency(Hz)\n",
      "\n",
      "#Results\n",
      "print\"the oscillation frequency is\",round((fo/1E+3),2),\"KHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the oscillation frequency is 29.06 KHz\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.13,Page number 353"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "C=200*10**-9               #capacitance(F)\n",
      "Lrcf=0.5*10**-3            #shunt across L2\n",
      "L1=800*10**-6              #inductance(H)\n",
      "L2=800*10**-6              #inductance(H)\n",
      "M=200*10**-6              \n",
      "\n",
      "#Calculations\n",
      "L21=(L2*Lrcf)/(L2+Lrcf)                  #effective value of L2(uH)\n",
      "Leq=L1+L21+2*M                           #equivalent inductance(H)\n",
      "fo=1/(2*math.pi*math.sqrt(Leq*C))        #output frequency(Hz)\n",
      "\n",
      "#Results\n",
      "print\"the oscillation frequency is\",round((fo/1E+3),2),\"KHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the oscillation frequency is 9.17 KHz\n"
       ]
      }
     ],
     "prompt_number": 13
    }
   ],
   "metadata": {}
  }
 ]
}