{
 "metadata": {
  "name": "ch_5"
 }, 
 "nbformat": 2, 
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown", 
     "source": [
      "<h1>Chapter 5: Operational Amplifiers- Non-linear Circuits<h1>"
     ]
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.5.1, Page No: 234<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "Vz1=5.5             #Volatage in volt", 
      "Vz2=5.5             #Voltage in volt", 
      "Aol=100000.0        #Open loop gain", 
      "Vd=0.7              #Voltage in volt", 
      "", 
      "#Calculations:", 
      "Vo=Vz1+Vd  # Plus or minus", 
      "Vich=Vo/Aol         #Calculating change in voltage", 
      "Vich=Vich*1000.0    #Calculating change in voltage", 
      "", 
      "#Results:", 
      "print('Delta Vi=%.3f mV'%Vich)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Delta Vi=0.062 mV"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 5.2, Page No: 239<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "R1=56.0*10**3               #Resistance value in ohm", 
      "R2=150.0                    #Resistance value in ohm", 
      "Vi=1.0                      #Voltage in volt", 
      "f=50.0                      #Frequency in hertz", 
      "Vsat=13.5                   #Voltage in volt", 
      "Vref=0.0                    #Voltage in volt", 
      "", 
      "#Calculations:", 
      "Vut=Vsat*R2/(R1+R2)         #Calculating Vut voltage", 
      "Vut=Vut*1000.0              #Calculating Vut voltage", 
      "VL=-Vut                     #Calculating Vlt voltage", 
      "", 
      "#Results:", 
      "print('Vut= %d mV'%Vut)", 
      "print('\\nVL= %d mV'%VL)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Vut= 36 mV", 
        "", 
        "VL= -36 mV"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No: 5.3, Page No: 249<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "Vclipl=0.35            #Voltage in volt", 
      "Vp=0.5                 #Voltage in volt", 
      "gain=10.0              #Gain", 
      "R=1000.0               #Resistance in ohm", 
      "", 
      "#Calculations:", 
      "Vounclip=Vp*gain       #Calculating unclipped output voltage", 
      "Voclip=Vclipl*gain     #Calculating clipped output voltage ", 
      "Vb=Voclip-0.7          #Calculating breakdown voltage", 
      "", 
      "#Results:", 
      "print('When unclipped, output voltage= %.1f V'%Vounclip)", 
      "print('\\nWhen clipped, output voltage= %.1f V'% Voclip)", 
      "print('\\nZener diode breakdown voltage= %.1f V'%Vb)", 
      "print('\\nA 2.8V Zener diode should be connected')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "When unclipped, output voltage= 5.0 V", 
        "", 
        "When clipped, output voltage= 3.5 V", 
        "", 
        "Zener diode breakdown voltage= 2.8 V", 
        "", 
        "A 2.8V Zener diode should be connected"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No: 5.4, Page NO: 251<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "Vref=1.5                #Voltage in volt", 
      "", 
      "#Part A", 
      "#Variable declaration:", 
      "Vpp=5.0                 #Voltage in volt", 
      "Vnp=2.5                 #Voltage in volt", 
      "", 
      "#Calculation:", 
      "Vc=Vnp + Vref           #Calculating capacitor voltage ", 
      "", 
      "#Result:", 
      "print('\\nCapacitor voltage Vc= %.1f V'%Vc) ", 
      "", 
      "#Part B", 
      "#Calculation:", 
      "Vopeak=Vnp + Vref +Vpp  #Calculating peak clamped output voltage", 
      "", 
      "#Result:", 
      "print('\\nPeak value of clamped output voltage Vo(peak)= %.1f V'%Vopeak)", 
      "", 
      "#Part C", 
      "#Calculation:", 
      "Voc=0.7 + Vref         #Calating output voltage during charging", 
      "", 
      "#Result:", 
      "print('\\nOp-amp output voltage during charging Vo= %.1f V'% Voc) ", 
      "", 
      "#Part D", 
      "#Calculation:", 
      "Vd=Vref-Vopeak         #Calculating maximum differenctial input voltage", 
      "", 
      "#Result:", 
      "print('\\nMaximum differential input voltage Vd= %.1f V'%Vd) "
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "", 
        "Capacitor voltage Vc= 4.0 V", 
        "", 
        "Peak value of clamped output voltage Vo(peak)= 9.0 V", 
        "", 
        "Op-amp output voltage during charging Vo= 2.2 V", 
        "", 
        "Maximum differential input voltage Vd= -7.5 V"
       ]
      }
     ], 
     "prompt_number": 4
    }
   ]
  }
 ]
}