{
 "metadata": {
  "name": "",
  "signature": "sha256:e13354825bf2b4dbe3b80a8d5cababd4cb08909e23bd09123fe19184d491856f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 - Resistive Capacitive RC Circuits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate voltage after 8ms\n",
      "c=1.#Capacitance of capacitor(in micro farad)\n",
      "vs=6.#Source voltage(in volts)\n",
      "r=10.#Resistor(in kilo ohm)\n",
      "vi=-3.#Initial voltage(in volts)\n",
      "t=8.#Time (in milli sec)\n",
      "e=vs-((vs-vi)*2.718**(-t/(r*c)))\n",
      "print '%s %.2f' %('Voltage after 8ms(in volts)=',e)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage after 8ms(in volts)= 1.96\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Determine (a)Ec at 1.5ms (b)Ec at 6ms\n",
      "r1=1.#Resistor(in kilo ohm)\n",
      "c1=1.#Capacitance(in micro farad)\n",
      "e1=10.#Voltage(in volts)\n",
      "r2=20.#Resistor(in kilo ohm)\n",
      "c2=0.1#Capacitance(in micro farad)\n",
      "e2=12.#Voltage(in volts)\n",
      "t1=r1*c1*0.78\n",
      "e=e1*1.\n",
      "ec1=e*t1\n",
      "t2=r2*c2*0.025\n",
      "E=e2*1.\n",
      "ec2=E*t2\n",
      "print '%s %.1f %s %.1f'%('(a)Ec at 1.5ms(in volts) =',ec1,'\\n(b)Ec at 6ms(in volts) =',ec2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Ec at 1.5ms(in volts) = 7.8 \n",
        "(b)Ec at 6ms(in volts) = 0.6\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate Rise time,time for capacitor to charge to required amount and time required for complete charging\n",
      "V=5.#Voltage source(in volts)\n",
      "r=39.#Resistor(in kilo ohm)\n",
      "c=500.#Capacitance of capacitor(in pf)\n",
      "tr=2.2*r*c*10.**(-3)\n",
      "t=r*c*10.**(-3)\n",
      "tc=5*r*c*10.**(-3)\n",
      "print '%s %.1f %s %.1f %s %.1f' %('Rise time=',tr,'\\ntime for  63.2% charging=',t,'\\nand time required for complete charging(in micro sec)=',tc)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rise time= 42.9 \n",
        "time for  63.2% charging= 19.5 \n",
        "and time required for complete charging(in micro sec)= 97.5\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate minimum square wave frequency\n",
      "C=1.#Coupling capacitor(in micro farad)\n",
      "R=1.#Input resistance(in Mega ohm)\n",
      "t=0.01#Tilt\n",
      "PW=t*R*C\n",
      "f=1./(2.*PW)\n",
      "print '%s %.f' %('Frequency required(in hertz)=',f)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency required(in hertz)= 50\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Determine fastest rise time\n",
      "r=600.#Output resistance(in ohms)\n",
      "c=30.#Input capacitance(in pf)\n",
      "tr=2.2*r*c*10.**(-3)\n",
      "print '%s %.1f' %('Fastest rise time(in ns)=',tr)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fastest rise time(in ns)= 39.6\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate voltage at 14 ms \n",
      "Eo=0#Voltage at t=0sec(in volt)\n",
      "E=20.#Peak voltage(in volts)\n",
      "r=3.3#Resistance(in kilo ohm)\n",
      "c=1.#Capacitance(in micro farad)\n",
      "t1=4.#Time(in ms)\n",
      "t2=2.#Time(in ms)\n",
      "e1=E-((E-Eo)*(2.718)**(-t1/(r*c)))\n",
      "e2=Eo-((Eo-e1)*(2.718)**(-t1/(r*c)))\n",
      "e3=E-((E-e2)*(2.718)**(-t1/(r*c)))\n",
      "e3=Eo-((Eo-e3)*(2.718)**(-t2/(r*c)))\n",
      "print '%s %.2f' %('Voltage at 14ms(in volts)=',e3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage at 14ms(in volts)= 8.34\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Determine max and min voltage at which capacitor voltage will settle\n",
      "E=20.#Peak voltage(in volts)\n",
      "t=4.#Time interval(in ms)\n",
      "r=3.3#Resistance(in kilo ohms)\n",
      "c=1.#Capacitance(in micro farad)\n",
      "Emax=E/(1.+(2.718**(-t/(r*c))))\n",
      "Emin=E-Emax\n",
      "print '%s %.2f %s %.2f' %('Maximum voltage(in volts)=',Emax, '\\n minimum voltage(in volts)=',Emin)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum voltage(in volts)= 15.41 \n",
        " minimum voltage(in volts)= 4.59\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate output voltage for (a)10V and 1ms Pw (b)10V and 2ms PW (c)20V and 1ms PW\n",
      "e1=10.#Voltage applied(in volts)\n",
      "e0=0#Voltage at t=0sec(in volts)\n",
      "t1=1.#PW(in ms)\n",
      "t2=2.#PW(in ms)\n",
      "e2=20.#Input voltage(in volts)\n",
      "r=10.#Resistance(in kilo ohm)\n",
      "c=20.#Capacitance(in micro farad)\n",
      "eo1=(e1-((e1-e0)*(2.718)**(-t1/(r*c))))*1000\n",
      "eo2=(e1-((e1-e0)*(2.718)**(-t2/(r*c))))*1000\n",
      "eo3=(e2-((e2-e0)*(2.718)**(-t1/(r*c))))*1000\n",
      "print '%s %.f %s %.f %s %.f' %('Output voltage for\\n(a)(in mv)=',eo1,'\\n(b)(in mv)=',eo2,'\\n(c)(in mv)=',eo3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage for\n",
        "(a)(in mv)= 50 \n",
        "(b)(in mv)= 99 \n",
        "(c)(in mv)= 100\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate output voltage for (a)10V and (b)20V\n",
      "E1=10.#Input voltage(in volts)\n",
      "E2=20.#Input voltage(in volts)\n",
      "c=1.#Capacitance(in micro farad)\n",
      "r=1.#Resistance(in kilo ohm)\n",
      "t=100.#Pulse width(in ms)\n",
      "i1=(c*E1*10.**(-6.))/(t*10.**(-3.))\n",
      "eo1=i1*r*1000.\n",
      "print '%s %.1f' %('Output voltage for (a)(in volts)=',eo1)\n",
      "i2=(c*E2*10.**(-6.)/(t*10.**(-3.)))\n",
      "eo2=i2*r*1000.\n",
      "print '%s %.1f' %('Output voltage for (b)(in volts)=',eo2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage for (a)(in volts)= 0.1\n",
        "Output voltage for (b)(in volts)= 0.2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Caption:Calculate amplitude of output waveform for (a)Rise time (b)Fall time\n",
      "r=1.#Resistance(in kilo ohm)\n",
      "c=100.#Capacitance(in pf)\n",
      "tr=1.#Rise time(in micro sec)\n",
      "tf=3.#Fall time(in micro sec)\n",
      "e1=8.#Change in voltage for rise time(in volts)\n",
      "e2=-8.#Change in voltage for fall time(in volts)\n",
      "eo1=r*c*0.001*e1/tr\n",
      "print '%s %.1f' %('Amplitude of output waveform for (a)Rise time(in volts)=',eo1)\n",
      "eo2=r*c*0.001*e2/tf\n",
      "print '%s %.2f' %('Amplitude of output waveform for (b)Fall time(in volts)=',eo2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Amplitude of output waveform for (a)Rise time(in volts)= 0.8\n",
        "Amplitude of output waveform for (b)Fall time(in volts)= -0.27\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}