{
 "metadata": {
  "name": "",
  "signature": "sha256:78d18a14b78f673f5bd74601b5a29612b95caf61b293886366daec703c0960a4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter-8 Non-Linear Circuits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2 - Page 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "# Given data \n",
      "R1= 5 # in k\u03a9\n",
      "R2= 10.0 # in k\u03a9\n",
      "V_peak= R1*R2/(R1+R2) # in V\n",
      "Vav= V_peak/pi # in V\n",
      "print \"Peak value of V1 = %0.2f V\" %V_peak\n",
      "print \"Average value of Vo = %0.2f V\" %Vav"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak value of V1 = 3.33 V\n",
        "Average value of Vo = 1.06 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.7 - Page 268"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "from math import exp\n",
      "# Given data \n",
      "t= 0 \n",
      "Vc= 0 # in volts\n",
      "Vo= 5 # in volts\n",
      "R= 10 # in 2 \u03a9 (assume)\n",
      "RC= 1 # (assume)\n",
      "R3= 2*R # in \u03a9\n",
      "R2= 3*R # in \u03a9\n",
      "# From equation : T= 2*Rf*C*log[1+2*R3/R2]\n",
      "T= 2*RC*math.log(1+2*R3/R2) \n",
      "Vc_t= 2 # in volts\n",
      "t= T/2 \n",
      "#Voltage across capacitor,\n",
      "# Vc_t= Vco*[1-%e**(-t/ReqC)]= 1/5*(VR+4*Vo)*[1-%e**(-t/4*RC/5)]\n",
      "VR= Vc_t*5/(1-exp((-t/(4*RC/5))))-4*Vo \n",
      "print \"The value of VR = %0.2f volts\" %VR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of VR = -4.69 volts\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.9 - Page 270"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "# Part (c)\n",
      "R1= 150 # in \u03a9\n",
      "R2= 68*10**3 # in \u03a9\n",
      "Vin= 50*10**-3 # in V\n",
      "Vsat= 14 # in V\n",
      "Vpositive= Vsat*(R1/(R1+R2)) # in V\n",
      "V_UT= Vpositive # in V\n",
      "Vpositive= -Vsat*(R1/(R1+R2)) # in V\n",
      "V_LT= Vpositive # in V\n",
      "print \"The value of V_UT = %0.4f V\" %V_UT\n",
      "print \"The value of V_LT = %0.4f V\" %V_LT"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of V_UT = 0.0308 V\n",
        "The value of V_LT = -0.0308 V\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10 - Page 271"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "V_UT= 5 # in V\n",
      "V_LT= -5 # in V\n",
      "# Hysteresis voltage,\n",
      "Vhy= V_UT-V_LT # in V\n",
      "print \"The hysteresis voltage = %0.f V\" %Vhy"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The hysteresis voltage = 10 V\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}