{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1: Circuit Configuration for Linear Integrated Ciruits"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 1 Page No:1.81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "adm= -1482.0\n",
      "acm= -1.0\n",
      "cmrr= 76.4838188131 db\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "rc=50000;#ohm\n",
    "re=100000;#ohm\n",
    "rs=10000;#ohm\n",
    "rp=50000;#ohm\n",
    "beta0=2000;\n",
    "r0=400000;#ohm\n",
    "\n",
    "\n",
    "\n",
    "#determine adm,acm,cmrr\n",
    "#calculation\n",
    "rc1=(rc*r0)/(rc+r0);\n",
    "adm=(-(beta0*rc1)/(rs+rp))#differential mode gain\n",
    "acm=(-(beta0*rc1)/(rs+rp+2*re*(beta0+1)))#common mode gain\n",
    "import math\n",
    "cmrr=20*(math.log10((1+((2*re*(beta0+1))/(rs+rp)))))#common mode rejection ratio\n",
    "\n",
    "#result\n",
    "print 'adm=',round(adm,3);\n",
    "print 'acm=',round(acm,3);\n",
    "print 'cmrr=',cmrr,'db'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 2 Page No:1.83"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "maximum peak amplitude at 100khz 3.185 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=0.000001;#volt/sec\n",
    "freq=100000;\n",
    "vsat=12;\n",
    "baw=100000;\n",
    "#determine vx\n",
    "\n",
    "#calculation\n",
    "vx=2*(1/(sr*2*3.14*freq))\n",
    "\n",
    "#result\n",
    "print 'maximum peak amplitude at 100khz',round(vx,3),'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 3 Page No: 1.84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "slew rate= 5 volt/μsec\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "V=20;\n",
    "t=4;\n",
    "#determine slew rate\n",
    "#calculation\n",
    "w=V/t\n",
    "#result\n",
    "print'slew rate=',w,'volt/μsec'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 4 Page No: 1.84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "max frequency of input is  79617.8343949 hz\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "a=50;\n",
    "vi=20e-3;\n",
    "sr=0.5e6;\n",
    "#determine max frequency\n",
    "#calculation\n",
    "vm=a*vi;\n",
    "freq=sr/(2*3.14*vm)\n",
    "#result\n",
    "print 'max frequency of input is ',freq,'hz'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 5 Page No: 1.84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "max peak to peak input signal  0.398089171975 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=0.5e6;\n",
    "freq=40e3;\n",
    "a=10;\n",
    "#determine max peak to peak input signal\n",
    "#calculation\n",
    "vm=sr/(2*3.14*freq);\n",
    "vm=2*vm;\n",
    "v1=vm/a\n",
    "#result\n",
    "print'max peak to peak input signal ',v1,'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "###Example 6 Page No: 1.85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "noise  0.0063247 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "adm=400;\n",
    "cmrr=50;\n",
    "vin1=50e-3;\n",
    "vin2=60e-3;\n",
    "vnoise=5e-3;\n",
    "#calculation\n",
    "v0=(vin2-vin1)*adm;\n",
    "acm=adm/316.22;\n",
    "v1=vnoise*acm\n",
    "print'noise ',round(v1,7),'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 7 Page No: 1.86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time to change from 0 t0 15  4e-07 sec\n",
      "slew rate 1.5 volt/μsec\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=35e6;#volt/sec\n",
    "vsat=15;#volt\n",
    "#determine time to change from 0 to 15V\n",
    "#calculation\n",
    "c=100e-12;#farad\n",
    "i=150e-6;#A\n",
    "w=vsat/sr\n",
    "w1=i/c;\n",
    "#result\n",
    "print'time to change from 0 t0 15 ',round(w,7),'sec'\n",
    "print'slew rate',w1/1000000,'volt/μsec'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 8 Page No: 1.86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bandwidth  21231.4225053 hz\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=2e6;#v/sec\n",
    "vsat=15;#volt\n",
    "#determine bandwidth \n",
    "#calculation\n",
    "\n",
    "bw=sr/(2*3.14*vsat)\n",
    "#result\n",
    "print'bandwidth ',bw,'hz'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 9 Page No: 1.87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "output offset  3.0 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "iin=30e-9;#A\n",
    "a=1e5;\n",
    "rin=1000;#ohm\n",
    "#determine output offset voltage\n",
    "#calculation\n",
    "vid=iin*rin;\n",
    "v0=a*vid\n",
    "#result\n",
    "print'output offset ',v0,'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 10 Page No: 1.86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input offset current  4e-06 A\n",
      "input base current  2.4e-05 A\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "inb1=22e-6;#A\n",
    "inb2=26e-6;#A\n",
    "#determine input offset current input base current\n",
    "#calculation\n",
    "i1=inb2-inb1\n",
    "i2=(inb2+inb1)/2\n",
    "#result\n",
    "print'input offset current ',i1,'A'\n",
    "print'input base current ',i2,'A'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 11 Page No: 1.86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input base current  8e-08 A\n",
      "input offset current  2e-08 A\n",
      "input offset   2.0 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "inb2=90e-9;#A\n",
    "inb1=70e-9;#A\n",
    "a=1e5;\n",
    "#determine input offset current\n",
    "#calculation\n",
    "i1=(inb2+inb1)/2\n",
    "i2=inb2-inb1\n",
    "v1=((inb2-inb1)*1000)*a\n",
    "print'input base current ',i1,'A'\n",
    "print'input offset current ',i2,'A'\n",
    "print'input offset  ',v1,'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 12 Page No: 1.88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "output voltage cmrr  100      0.05125 V\n",
      "output voltage cmrr  200      0.050625 V\n",
      "output voltage cmrr  450      0.0502777777778 V\n",
      "output voltage cmrr  105      0.0511904761905 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "vin1=150e-6;#volt\n",
    "vin2=100e-6;#volt\n",
    "a=1000;\n",
    "from array import *\n",
    "cmrr=array('i',[100,200,450,105])\n",
    "#determine output voltage\n",
    "#calculation\n",
    "vc=(vin1+vin2)/2;\n",
    "vd=(vin1-vin2);\n",
    "j=0;\n",
    "while j<=3 :v0=(a*vd*(1+(vc/(cmrr[j]*vd)))) ;print 'output voltage cmrr ',cmrr[j],'    ',v0,'V';j=j+1;\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 13 Page No: 1.87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "output voltage  0.00316455696203 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "rin=100e3;#ohm\n",
    "rf1=900e3;#ohm\n",
    "vc=1;#volt\n",
    "cmrr=70;\n",
    "#determine the output voltage\n",
    "#calculation\n",
    "v0=(1+(rf1/rin))*vc/3160\n",
    "print 'output voltage ',v0,'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 14 Page No: 1.89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input voltage  0.08 V\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=0.5e6;#volt/sec\n",
    "a=50;\n",
    "freq=20e3;#hz\n",
    "#determine max peak to peak voltage\n",
    "#calculation\n",
    "v1=sr/(2*3.14*freq*a)\n",
    "print'input voltage ',round(v1,3),'V'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Example 15 Page No: 1.90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "max frequency  26.5392781316 Khz\n"
     ]
    }
   ],
   "source": [
    "#given\n",
    "sr=50e6;#volt/sec\n",
    "rin=2;\n",
    "vimax=10;\n",
    "#determine max frequency\n",
    "#calculation\n",
    "vm=vimax*(1+rin);\n",
    "freq=sr/(2*3.14*vm)/10e3;\n",
    "print 'max frequency ',freq,'Khz'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}