{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 13 - Non-linear Analog Systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 13_1 Page No. 395"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VT= 0.03  volts\n",
      "R1= 5000.00  ohm\n",
      " Iso = 1.00e-10  ampere\n",
      "part(i)\n",
      "vs= 1.00e-03  volts\n",
      "vo=-VT*(log(vs/(Iso*R1)))= -0.20  volts\n",
      "part(ii)\n",
      "vs= 1.00e-02  volts\n",
      "vo=-VT*(log(vs/(Iso*R1)))= -0.26  volts\n",
      "part(iii)\n",
      "vs= 0.10  volts\n",
      "vo=-VT*(log(vs/(Iso*R1)))= -0.32  volts\n",
      "part(iv)\n",
      "vs= 1.00  volts\n",
      "vo=-VT*(log(vs/(Iso*R1)))= -0.38  volts\n"
     ]
    }
   ],
   "source": [
    "from math import log\n",
    "from __future__ import division  \n",
    "VT=26*10**(-3)\n",
    "print \"VT= %0.2f\"%(VT),\" volts\" # Thermal voltage \n",
    "R1=5*10**(3)\n",
    "print \"R1= %0.2f\"%(R1),\" ohm\"  # resistance\n",
    "Iso=1*10**(-10)\n",
    "print \" Iso = %0.2e\"%(Iso),\" ampere\" # Scale factor (as current)directly proportional to cross-section area of EBJ \n",
    "\n",
    "print \"part(i)\"\n",
    "vs=1*10**(-3)\n",
    "print \"vs= %0.2e\"%(vs),\" volts\" # Input voltage1\n",
    "vo=-VT*(log(vs/(Iso*R1)))\n",
    "print \"vo=-VT*(log(vs/(Iso*R1)))= %0.2f\"%(vo),\" volts\" # Output voltage of Log OP-AMP for input1 i.e vs = 1 mV\n",
    "\n",
    "print \"part(ii)\"\n",
    "vs=10*10**(-3)\n",
    "print \"vs= %0.2e\"%(vs),\" volts\" # Input voltage2\n",
    "vo=-VT*(log(vs/(Iso*R1)))\n",
    "print \"vo=-VT*(log(vs/(Iso*R1)))= %0.2f\"%(vo),\" volts\" # Output voltage of Log OP-AMP for input1 i.e vs = 10 mV\n",
    "\n",
    "print \"part(iii)\"\n",
    "vs=100*10**(-3)\n",
    "print \"vs= %0.2f\"%(vs),\" volts\" # Input voltage3\n",
    "vo=-VT*(log(vs/(Iso*R1)))\n",
    "print \"vo=-VT*(log(vs/(Iso*R1)))= %0.2f\"%(vo),\" volts\" # Output voltage of Log OP-AMP for input1 i.e vs = 100 mV\n",
    "\n",
    "print \"part(iv)\"\n",
    "vs=1\n",
    "print \"vs= %0.2f\"%(vs),\" volts\" # Input voltage4\n",
    "vo=-VT*(log(vs/(Iso*R1)))\n",
    "print \"vo=-VT*(log(vs/(Iso*R1)))= %0.2f\"%(vo),\" volts\" # Output voltage of Log OP-AMP for input1 i.e vs = 1V"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 13_2 Page No. 396"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VT= 0.03  volts\n",
      "R1= 100000.00  ohm\n",
      " Iso = 5.00e-08  ampere\n",
      "vs= 2.50  volts\n",
      "vo=-VT*(log(vs/(Iso*R1)))= -0.16  volts\n"
     ]
    }
   ],
   "source": [
    "from math import log\n",
    "from __future__ import division  \n",
    "VT=26*10**(-3)\n",
    "print \"VT= %0.2f\"%(VT),\" volts\" # Thermal voltage \n",
    "R1=100*10**(3)\n",
    "print \"R1= %0.2f\"%(R1),\" ohm\"  # resistance\n",
    "Iso=50*10**(-9)\n",
    "print \" Iso = %0.2e\"%(Iso),\" ampere\" # Scale factor (as current)directly proportional to cross-section area of EBJ \n",
    "vs=2.5\n",
    "print \"vs= %0.2f\"%(vs),\" volts\" # Input voltage\n",
    "vo=-VT*(log(vs/(Iso*R1)))\n",
    "print \"vo=-VT*(log(vs/(Iso*R1)))= %0.2f\"%(vo),\" volts\" # Output voltage of Log OP-AMP for input1 i.e vs = 2.5 V"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 13_3 Page No. 397"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VT= 0.03  volts\n",
      "RF= 1.00e+05  ohm\n",
      " Iso = 5.00e-08  ampere\n",
      "vs= -0.16  volts\n",
      "vo=Iso*RF*(exp(-vs/VT))= 2.54  volts\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "from __future__ import division  \n",
    "VT=26*10**(-3)\n",
    "print \"VT= %0.2f\"%(VT),\" volts\" # Thermal voltage \n",
    "RF=100*10**(3)\n",
    "print \"RF= %0.2e\"%(RF),\" ohm\"  # resistance\n",
    "Iso=50*10**(-9)\n",
    "print \" Iso = %0.2e\"%(Iso),\" ampere\" # Scale factor (as current)directly proportional to cross-section area of EBJ \n",
    "vs=-0.162\n",
    "print \"vs= %0.2f\"%(vs),\" volts\" # Input voltage\n",
    "vo=Iso*RF*(exp(-vs/VT))\n",
    "print \"vo=Iso*RF*(exp(-vs/VT))= %0.2f\"%(vo),\" volts\" # Output voltage of Antilog OP-AMP for input1 i.e vs = -0.162 V"
   ]
  }
 ],
 "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
}
