{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 16 Op-Amp Negative Feedback"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.1 Page No 385"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output voltage = 49.98 mV\n",
      "The error voltage = 0.50 µV\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "A=100000.0##unit less\n",
    "R1= 98.0*10**3##  Ω\n",
    "R2= 2.0*10**3##  Ω\n",
    "Vin= 1.*10**-3##  V\n",
    "B= R2/(R1+R2)## unit less\n",
    "A_CL= 1/B## unit less\n",
    "A_CL= A/(1+A*B)## unit less\n",
    "# The output voltage \n",
    "Vout= Vin*A_CL##  V\n",
    "# The error voltage \n",
    "Verror= Vout/A##  V\n",
    "Vout= Vout*10**3##  mV\n",
    "Verror= Verror*10**6##  µV\n",
    "print \"The output voltage = %.2f mV\"%Vout\n",
    "print \"The error voltage = %.2f µV\"%Verror"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.2 Page No 386"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of A_CL = 49.88\n",
      "The value of Vout = 49.88 mV\n",
      "The value of Verror = 2.49 µV\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "A=20000#\n",
    "B= 0.02#\n",
    "Vin= 1##  mV\n",
    "Vin= Vin*10**-3##  V\n",
    "# The closed loop voltage gain,\n",
    "A_CL= A/(1+A*B)#\n",
    "# The output voltage,\n",
    "Vout= Vin*A_CL##  V\n",
    "# The error voltage,\n",
    "Verror= Vout/A##  V\n",
    "Vout= Vout*10**3##  mV\n",
    "Verror= Verror*10**6##  µV\n",
    "print \"The value of A_CL = %.2f\"%A_CL\n",
    "print \"The value of Vout = %.2f mV\"%Vout\n",
    "print \"The value of Verror = %.2f µV\"%Verror"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.3 Page No 389"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The closed loop input impedence = 201.80 MΩ\n",
      "The closed loop output  impedence = 0.74 Ω\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "A=100000.0#\n",
    "R1= 100.0*10**3##  Ω\n",
    "R2= 100.0##  Ω\n",
    "r_in= 2.0*10**6##  Ω\n",
    "r_out= 75.0##  Ω\n",
    "B= R2/(R1+R2)## unit less\n",
    "# The closed loop input impedence \n",
    "r_in_CL= (1+A*B)*r_in##  Ω\n",
    "# The closed loop output impedence \n",
    "r_out_CL= r_out/(1+A*B)##  Ω\n",
    "r_in_CL=r_in_CL*10**-6##  Mohm\n",
    "print \"The closed loop input impedence = %.2f MΩ\"%r_in_CL\n",
    "print \"The closed loop output  impedence = %.2f Ω\"%r_out_CL"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.4 Page No 389"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The closed loop voltage gain = 1.00\n",
      "The closed-loop input impedance = 202.00 MΩ\n",
      "The closed-loop output impedance = 7.50e-04 Ω\n",
      "The output offset voltage = 5.51 mV\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "A=100.0#\n",
    "R_B= 39.0*10**3##  Ω\n",
    "r_in= 2.0*10**6##  Ω\n",
    "r_out= 75.0##  Ω\n",
    "Vin_off= 2.0*10**-3##  V\n",
    "I_B1= 90.0*10**-9##  A\n",
    "I_in_off= 20.0*10**-9##  A\n",
    "# The closed loop voltage gain \n",
    "B=1## unit less\n",
    "# The closed-loop input impedance\n",
    "r_in_CL= (1.0+A*B)*r_in##  Ω\n",
    "r_in_CL= r_in_CL*10**-6##  Mohm\n",
    "print \"The closed loop voltage gain = %.2f\"%B\n",
    "print \"The closed-loop input impedance = %.2f MΩ\"%r_in_CL\n",
    "A=100000.0#\n",
    "# The closed-loop output impedance\n",
    "r_out_CL= r_out/A##  Ω\n",
    "print \"The closed-loop output impedance = %.2e Ω\"%r_out_CL\n",
    "#Let V= V1-V2 = Vin_off+I_B1*R_B\n",
    "V= Vin_off+I_B1*R_B##  A\n",
    "# The output offset voltage \n",
    "Voo_CL= A*V/A##  V\n",
    "Voo_CL= Voo_CL*10**3##  mV\n",
    "print \"The output offset voltage = %.2f mV\"%Voo_CL"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.5 Page No 393"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The closed-loop voltage gain = 22.00\n",
      "The desensitivity = 4545.45\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "R_F= 22.0*10**3##  Ω\n",
    "R_S= 1.0*10**3##  Ω\n",
    "A= 100000.0## unit less\n",
    "# The closed-loop voltage gain\n",
    "A_CL= R_F/R_S#\n",
    "# The desensitivity\n",
    "desensitivity= A/A_CL#\n",
    "print \"The closed-loop voltage gain = %.2f\"%A_CL\n",
    "print \"The desensitivity = %.2f\"%desensitivity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.6 Page No 396"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For A_CL= 1000, The value of f_CL = 1.00 kHz\n",
      "For A_CL= 100, The value of f_CL = 10.00 kHz\n",
      "For A_CL= 10, The value of f_CL = 100.00 kHz\n",
      "For A_CL= 1, The value of f_CL = 1.00 MHz\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "f_unity= 1.0*10**6##  Hz\n",
    "# For A_CL= 1000, The value of f_CL\n",
    "A_CL= 1000.0#\n",
    "f_CL= f_unity/A_CL##  Hz\n",
    "f_CL= f_CL*10**-3##  kHz\n",
    "print \"For A_CL= 1000, The value of f_CL = %.2f kHz\"%f_CL\n",
    "# For A_CL= 100, The value of f_CL\n",
    "A_CL= 100.0#\n",
    "f_CL= f_unity/A_CL##  Hz\n",
    "f_CL= f_CL*10**-3##  kHz\n",
    "print \"For A_CL= 100, The value of f_CL = %.2f kHz\"%f_CL\n",
    "# For A_CL= 10, The value of f_CL\n",
    "A_CL= 10.0#\n",
    "f_CL= f_unity/A_CL##  Hz\n",
    "f_CL= f_CL*10**-3##  kHz\n",
    "print \"For A_CL= 10, The value of f_CL = %.2f kHz\"%f_CL\n",
    "# For A_CL= 1, The value of f_CL\n",
    "A_CL= 1.0#\n",
    "f_CL= f_unity/A_CL##  Hz\n",
    "f_CL= f_CL*10**-6##  MHz\n",
    "print \"For A_CL= 1, The value of f_CL = %.2f MHz\"%f_CL"
   ]
  }
 ],
 "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
}