{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2:First Experiences with Op Amp"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.1 Page No 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Vplus=15\n",
      "Vminus=-15\n",
      "Vsatp=13\n",
      "Vsatm=-13          #All in Volts\n",
      "Aol=200000.0         #gain\n",
      "#Example 2-1(a)\n",
      "Vam=-10*(10**-6)   #voltage at minus input\n",
      "Vap=-15*(10**-6)   #voltage at plus input\n",
      "Ed1=Vap-Vam        #Differential Input Voltage\n",
      "Vout1=Ed1*Aol      #Output Voltage\n",
      "if Vout1>15:\n",
      "    print\"Value of o/p voltage1 = 13.0000V\"   #positive saturation voltage\n",
      "elif(Vout1<-15):\n",
      "    print\"Value of o/p voltage1 = -13.0000V\"  #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage1 =  \",Vout1*Vsatp,\"V\"\n",
      "\n",
      "#Example 2-1(b)\n",
      "Vbm=-10*(10**-6)    #voltage at minus input\n",
      "Vbp=+15*(10**-6)    #voltage at plus input\n",
      "Ed2=Vbp-Vbm         #Differential Input Voltage\n",
      "Vout2=Ed2*Aol       #Output Voltage\n",
      "if Vout2>15:\n",
      "    print\"Value of o/p voltage2 = 13.0000V\"   #positive saturation voltage\n",
      "elif(Vout2<-15):\n",
      "    print\"Value of o/p voltage2 = -13.0000V\"  #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage2 =   \",Vout2,\"V\"\n",
      "\n",
      "#Example 2-1(c)\n",
      "Vcm=-10*(10**-6)         #voltage at minus input\n",
      "Vcp=-5*(10**-6)          #voltage at plus input\n",
      "Ed3=Vcp-Vcm              #Differential Input Voltage\n",
      "Vout3=Ed3*Aol            #Output Voltage\n",
      "if(Vout3>15):\n",
      "    print\"Value of o/p voltage3 = 13.0000V\"  #positive saturation voltage\n",
      "elif(Vout3<-15):\n",
      "    print\"Value of o/p voltage3 = -13.0000V\"  #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage3 =  \",Vout3,\"V\"\n",
      "\n",
      "\n",
      "#Example 2-1(d)\n",
      "Vdm=+1.000001           #voltage at minus input\n",
      "Vdp=+1.000000           #voltage at plus input\n",
      "Ed4=Vdp-Vdm             #Differential Input Voltage\n",
      "Vout4=Ed4*Aol           #Output Voltage\n",
      "if(Vout4>15):\n",
      "    print\"Value of o/p voltage4 = 13.0000V\"    #positive saturation voltage\n",
      "elif(Vout4<-15):\n",
      "    print\"Value of o/p voltage4 = -13.0000V\"    #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage4 =  \",round(Vout4,2),\"V\"\n",
      "\n",
      "\n",
      "#Example 2-1(e)\n",
      "Vem=+5*(10**-3)          #voltage at minus input\n",
      "Vep=0                    #voltage at plus input\n",
      "Ed5=Vep-Vem              #Differential Input Voltage\n",
      "Vout5=Ed5*Aol            #Output Voltage\n",
      "if(Vout5>15):\n",
      "    print\"Value of o/p voltage5 = 13.0000V\"   #positive saturation voltage\n",
      "elif(Vout5<-15):\n",
      "    print\"Value of o/p voltage5 = -13.0000V\"   #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage5 =   \",Vout5\n",
      "\n",
      "#Example 2-1(f)\n",
      "Vfm=0                      #voltage at minus input\n",
      "Vfp=+5*(10**-3)            #voltage at plus input\n",
      "Ed6=Vfp-Vfm                #Differential Input Voltage\n",
      "Vout6=Ed6*Aol              #Output Voltage\n",
      "if(Vout6>15):\n",
      "    print\"Value of o/p voltage6 = 13.0000V\"      #positive saturation voltage\n",
      "elif(Vout6<-15):\n",
      "    print\"Value of o/p voltage6 = -13.0000V\"    #negative saturation voltage\n",
      "else:\n",
      "    print\" Value of o/p voltage6 =  V \",Vout6\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Value of o/p voltage1 =   -13.0 V\n",
        " Value of o/p voltage2 =    5.0 V\n",
        " Value of o/p voltage3 =   1.0 V\n",
        " Value of o/p voltage4 =   -0.2 V\n",
        "Value of o/p voltage5 = -13.0000V\n",
        "Value of o/p voltage6 = 13.0000V\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.2 Page No 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "f=50.0           #in Hz\n",
      "Vtemp=4.0        #input signal in volts\n",
      "Ecm=10.0              \n",
      "\n",
      "#Calculation\n",
      "#Example 2-2(a)\n",
      "T=1/f\n",
      "Th=(Vtemp*T)/Ecm   #High time in seconds\n",
      "\n",
      "#Example 2-2(b)\n",
      "d=(Th/T)*100      #duty cycle in percentage\n",
      "\n",
      "#Result\n",
      "print\" High Time is \",Th*1000,\"ms\"\n",
      "print\" Duty cycle is\",d,\"percent\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " High Time is  8.0 ms\n",
        " Duty cycle is 40.0 percent\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.3 Page No 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Vtemp=4.0               #in volts\n",
      "Ecm=5.0                 #maximum peak voltage of a sawtooth carrier wave\n",
      "T=0.01                #in seconds\n",
      "\n",
      "#calculation\n",
      "Th=T*(1-(Vtemp/Ecm))  #High Time\n",
      "\n",
      "#Result\n",
      "print\" High Time is \",Th*1000,\"ms\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " High Time is  2.0 ms\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}