{
 "metadata": {
  "name": "",
  "signature": "sha256:4938ab1cbcdde4c79a4edd16b6b058287ba152a41695f11025117cf99374b771"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter11 - Non linear applications of op-amp"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 11.1 - page : 354"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import log\n",
      "Vin=12.5 #V\n",
      "Ri=10 #kohm\n",
      "IS=10**-13 #A\n",
      "T=27 #degree C\n",
      "VT=26 #mV\n",
      "Vref=Ri*IS*1000 #V\n",
      "Vout=-VT*10**-3*log(Vin/Vref) #V\n",
      "print \"Output Voltage, Vout = %0.1f V \" %Vout"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output Voltage, Vout = -0.6 V \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 11.3 - page : 362"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "R1=10 #kohm\n",
      "k=1.38*10**-23 #J/K\n",
      "T=298 #K\n",
      "q=1.6*10**-19 #C\n",
      "Kdash=k*T/q #Kdash=k*T/q assumed for temporary calculation\n",
      "print \"Output Voltage, Vout(V) is \",round(-Kdash,4),\"*log(Vin/%0.f*10**3)\" %R1\n",
      "#Not possible to tale log of symbols."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output Voltage, Vout(V) is  -0.0257 *log(Vin/10*10**3)\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 11.4 - page : 362"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "R1=10 #kohm\n",
      "R2=10 #kohm\n",
      "k=1.38*10**-23 #J/K\n",
      "T=298 #K\n",
      "q=1.6*10**-19 #C\n",
      "Kdash=k*T/q #Kdash=k*T/q assumed for temporary calculation\n",
      "print \"Output Voltahe, Vout(V) is -R1*(log(\",round(-1/Kdash,1),\"*Vin)**-1\"\n",
      "#Not possible to tale log of symbols."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output Voltahe, Vout(V) is -R1*(log( -38.9 *Vin)**-1\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 11.7 - page : 366"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import log10\n",
      "k=1 #for the givn connection\n",
      "#(a)\n",
      "Vin=5 #V\n",
      "Vout=-k*log10(Vin/0.1) #V\n",
      "print \"(a) For 5V input, Output Voltage = %0.2f V \" %Vout\n",
      "#(b)\n",
      "Vin=2 #V\n",
      "Vout=-k*log10(Vin/0.1) #V\n",
      "print \"(b) For 2V input, Output Voltage = %0.1f V \" %Vout \n",
      "#(c)\n",
      "Vin=0.1 #V\n",
      "Vout=-k*log10(Vin/0.1) #V\n",
      "print \"(c) For 0.1V input, Output Voltage = %0.f V \" %Vout \n",
      "#(d)\n",
      "Vin=50 #mV\n",
      "Vout=-k*log10(Vin/1000/0.1) #V\n",
      "print \"(d) For 50mV input, Output Voltage = %0.1f V \" %Vout \n",
      "#(e)\n",
      "Vin=5 #mV\n",
      "Vout=-k*log10(Vin/1000/0.1) #V\n",
      "print \"(e) For 5mV input, Output Voltage = %0.1f V \" %Vout "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) For 5V input, Output Voltage = -1.70 V \n",
        "(b) For 2V input, Output Voltage = -1.3 V \n",
        "(c) For 0.1V input, Output Voltage = -0 V \n",
        "(d) For 50mV input, Output Voltage = 0.3 V \n",
        "(e) For 5mV input, Output Voltage = 1.3 V \n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 11.8 - page : 367"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import log10\n",
      "k=1 #for the givn connection\n",
      "#For 755N module\n",
      "Rin=10 #kohm\n",
      "Iref=10 #micro A\n",
      "Vref=Rin*Iref/1000 #V\n",
      "#(a)\n",
      "Vin=5 #V\n",
      "Vout1=-k*log10(Vin/0.1) #V\n",
      "Vout=Vref*10**(-Vout1/k) #V\n",
      "print \"(a) For 5V input to log amp, Antilog amp Output = %0.f V \" %Vout \n",
      "#(b)\n",
      "Vin=2 #V\n",
      "Vout1=-k*log10(Vin/0.1) #V\n",
      "Vout=Vref*10**(-Vout1/k) #V\n",
      "print \"(b) For 2V input to log amp, Antilog amp Output = %0.f V \" %Vout \n",
      "#(c)\n",
      "Vin=0.1 #V\n",
      "Vout1=-k*log10(Vin/0.1) #V\n",
      "Vout=Vref*10**(-Vout1/k) #V\n",
      "print \"(c) For 0.1V input to log amp, Antilog amp Output = %0.1f V \" %Vout \n",
      "#(d)\n",
      "Vin=50 #mV\n",
      "Vout1=-k*log10(Vin/1000/0.1) #V\n",
      "Vout=Vref*10**(-Vout1/k) #V\n",
      "print \"(d) For 50mV input to log amp, Antilog amp Output = %0.f mV \" %(Vout*1000)\n",
      "#(e)\n",
      "Vin=5 #mV\n",
      "Vout1=-k*log10(Vin/1000/0.1) #V\n",
      "Vout=Vref*10**(-Vout1/k) #V\n",
      "print \"(e) For 5mV input to log amp, Antilog amp Output = %0.f mV \" %(Vout*1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) For 5V input to log amp, Antilog amp Output = 5 V \n",
        "(b) For 2V input to log amp, Antilog amp Output = 2 V \n",
        "(c) For 0.1V input to log amp, Antilog amp Output = 0.1 V \n",
        "(d) For 50mV input to log amp, Antilog amp Output = 50 mV \n",
        "(e) For 5mV input to log amp, Antilog amp Output = 5 mV \n"
       ]
      }
     ],
     "prompt_number": 49
    }
   ],
   "metadata": {}
  }
 ]
}