{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 Biasing Methods"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_1 PG 5.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Refer to the figure-5.5 shown\n",
      "i) When Rb=300 kohm\n",
      "   Base emitter junction is not reverse biased \n",
      "   Assume transistor is operating in active region\n",
      "   We know that Vcc=Ib*Rb+Vbe \n",
      "\n",
      "    base current Ib is: 31.00 microA \n",
      "\n",
      "\n",
      "    Collector current is 3.1 mA \n",
      "\n",
      "   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce\n",
      "\n",
      "    Now Vce= 3.8 V \n",
      "\n",
      "\n",
      "   Since Vce=3.8 V collector to base junction is reverse biased and we can say \n",
      "   that our assumption that transistor is in active region is justified\n",
      "\n",
      "\n",
      " ii)When Rb=150 kohm\n",
      "\n",
      "\n",
      "   base emitter junction is not reverse biased \n",
      "   assume transistor is operating in active region\n",
      "   Applying KVL around base loop ie Vcc=Ib*Rb+Vbe\n",
      "\n",
      "    base current Ib is: 62 microA \n",
      "\n",
      "\n",
      "    Collector current is 6.2 mA \n",
      "\n",
      "   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce\n",
      "\n",
      "    Therefore Vce= -2.4 V \n",
      "\n",
      "\n",
      "    Collector voltage Vce has to be +ve or zero but Vce=-2.4 V hence \n",
      "    transistor is not in active region but it is in saturation region\n",
      "\n",
      " \n",
      "   Applying KVL around base loop ie Vcc=Ib*Rb+Vbe_sat\n",
      "\n",
      "    base current Ib is: 61 microA \n",
      "\n",
      "   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce_sat\n",
      "\n",
      "    Collector current is 4.9 mA \n",
      "\n",
      "    To justify transistor is in saturation then \n",
      "    Ib must be greater than (Ic/Beta)\n",
      "\n",
      "\n",
      "    Now Ib=61 microA \n",
      " \n",
      "   (Ic/Beta)=49 microA \n",
      "\n",
      "   Hence transistor in saturation region is satisfied \n"
     ]
    }
   ],
   "source": [
    "print \"  Refer to the figure-5.5 shown\"\n",
    "print \"i) When Rb=300 kohm\"\n",
    "print \"   Base emitter junction is not reverse biased \"\n",
    "print \"   Assume transistor is operating in active region\"\n",
    "Rb=300e3#\n",
    "Rc=2e3##collector resistance\n",
    "Vcc=10##supply voltage\n",
    "Vbe=0.7##base emitter voltage\n",
    "print \"   We know that Vcc=Ib*Rb+Vbe \"\n",
    "Ib=(Vcc-Vbe)/Rb##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n    base current Ib is: %.2f microA \\n\"%(Ib*1e6)\n",
    "Beta=100#\n",
    "Ic=Beta*Ib##colector current in active region\n",
    "print \"\\n    Collector current is %.1f mA \\n\"%(Ic*1e3)\n",
    "print \"   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce\"\n",
    "Vce=Vcc-Ic*Rc##since Vcc=Ic*Rc+Vce\n",
    "print \"\\n    Now Vce= %.1f V \\n\\n\"%(Vce)\n",
    "print \"   Since Vce=3.8 V collector to base junction is reverse biased and we can say \\n   that our assumption that transistor is in active region is justified\"\n",
    "print \"\\n\\n ii)When Rb=150 kohm\\n\\n\"\n",
    "print \"   base emitter junction is not reverse biased \"\n",
    "Rb=150e3#\n",
    "print \"   assume transistor is operating in active region\"\n",
    "print \"   Applying KVL around base loop ie Vcc=Ib*Rb+Vbe\"\n",
    "Ib=(Vcc-Vbe)/Rb##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n    base current Ib is: %.0f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib##colector current in active region\n",
    "print \"\\n    Collector current is %.1f mA \\n\"%(Ic*1e3)\n",
    "print \"   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce\"\n",
    "Vce=Vcc-Ic*Rc##since Vcc=Ic*Rc+Vce\n",
    "print \"\\n    Therefore Vce= %.1f V \\n\\n\"%(Vce)\n",
    "print \"    Collector voltage Vce has to be +ve or zero but Vce=-2.4 V hence \\n    transistor is not in active region but it is in saturation region\\n\\n \"\n",
    "Vbe_sat=0.8##base saturation voltage\n",
    "Vce_sat=0.2##collector saturation voltage\n",
    "print \"   Applying KVL around base loop ie Vcc=Ib*Rb+Vbe_sat\"\n",
    "Ib=(Vcc-Vbe_sat)/Rb##since Vcc=Ib*Rb+Vbe_sat\n",
    "print \"\\n    base current Ib is: %.0f microA \\n\"%(Ib*1e6)\n",
    "print \"   Applying KVL around collector loop ie Vcc=Ic*Rc+Vce_sat\"\n",
    "Ic=(Vcc-Vce_sat)/Rc#since Vcc=Ic*Rc+Vce_sat\n",
    "print \"\\n    Collector current is %.1f mA \\n\"%(Ic*1e3)\n",
    "print \"    To justify transistor is in saturation then \\n    Ib must be greater than (Ic/Beta)\"\n",
    "x=Ic/Beta\n",
    "print \"\\n\\n    Now Ib=%.0f microA \\n \\n   (Ic/Beta)=%.0f microA \\n\"%(Ib*1e6,x*1e6)\n",
    "if (Ib>x) :\n",
    "    x=(Ic/Beta)\n",
    "    print \"   Hence transistor in saturation region is satisfied \"    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_2 PG-5.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " base current is 0.00007533 A \n",
      "\n",
      "\n",
      " for hFE_min=50\n",
      "\n",
      " Ic=3.767 A \n",
      "\n",
      " Vce=4.4667 V \n",
      "\n",
      "\n",
      "\n",
      " for hFE_max=60\n",
      "\n",
      " Ic=4.52 A \n",
      "\n",
      " Vce=3 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=12##supply voltage\n",
    "Rb=150e3#\n",
    "Rc=2e3\n",
    "hFE_min=50##minimum voltage gain\n",
    "hFE_max=60##maximum voltage gain\n",
    "Ib=(Vcc-Vbe)/Rb##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n base current is %.8f A \\n\"%(Ib)\n",
    "print \"\\n for hFE_min=50\"\n",
    "Ic=hFE_min*Ib\n",
    "print \"\\n Ic=%.3f A \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-Ic*Rc\n",
    "print \" Vce=%.4f V \\n\"%(Vce)\n",
    "print \"\\n\\n for hFE_max=60\"\n",
    "Ic=hFE_max*Ib\n",
    "print \"\\n Ic=%.2f A \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-Ic*Rc\n",
    "print \" Vce=%.0f V \\n\"%(Vce)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_3 PG5.8 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.8 shown\n",
      "\n",
      " base current is 10.18 microA \n",
      "\n",
      "\n",
      " Ic=1.018 mA \n",
      "\n",
      "\n",
      " Vce=1.7180 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.8 shown\"\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=12##supply voltage\n",
    "Rb=100e3#\n",
    "Rc=10e3#\n",
    "Beta=100##voltage gain\n",
    "Ib=(Vcc-Vbe)/((1+Beta)*Rc+Rb)##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n base current is %.2f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib\n",
    "print \"\\n Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-(Ib+Ic)*Rc\n",
    "print \"\\n Vce=%.4f V \\n\"%(Vce)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_4 PG-5.9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i) for hFE_min=50\n",
      "\n",
      "    base current is 44.84 microA \n",
      "\n",
      "    Ic=2.242 mA \n",
      "\n",
      "    Vce=7.426 V \n",
      "\n",
      "\n",
      "    for hFE_max=60\n",
      "\n",
      "    base current is 41.54 microA \n",
      "\n",
      "    Ic=2.493 mA \n",
      "\n",
      "    Vce=6.932 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=12##supply voltage\n",
    "Rb=150e3#\n",
    "Rc=2e3\n",
    "hFE_min=50#\n",
    "hFE_max=60#\n",
    "print \"i) for hFE_min=50\"\n",
    "Beta=hFE_min##minimum voltage gain\n",
    "Ib=(Vcc-Vbe)/((1+Beta)*Rc+Rb)##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n    base current is %.2f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib\n",
    "print \"    Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-(Ib+Ic)*Rc\n",
    "print \"    Vce=%.3f V \\n\"%(Vce)\n",
    "print \"\\n    for hFE_max=60\"\n",
    "Beta=hFE_max##maximum voltage gain\n",
    "Ib=(Vcc-Vbe)/((1+Beta)*Rc+Rb)##since Vcc=Ib*Rb+Vbe\n",
    "print \"\\n    base current is %.2f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib\n",
    "print \"    Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-(Ib+Ic)*Rc\n",
    "print \"    Vce=%.3f V \\n\"%(Vce)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_5 PG-5.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.13 shown\n",
      "\n",
      " Vb=3.33 V\n",
      "\n",
      "\n",
      " Ve=2.63 V \n",
      "\n",
      "\n",
      " Ie=5.27 mA \n",
      "\n",
      "\n",
      " Ib=52.08 microA \n",
      "\n",
      "\n",
      " Ic=5.208 mA \n",
      "\n",
      "We apply KVL to the collector circuit\n",
      "Vcc-Ic*Rc-Vce-Ie*Re=0\n",
      "\n",
      " Vce=2.16 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.13 shown\"\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=10##supply voltage\n",
    "R1=10e3#\n",
    "Rc=1e3#\n",
    "R2=5e3#\n",
    "Re=500#\n",
    "Beta=100##voltage gain\n",
    "Vb=R2*Vcc/(R1+R2)##base voltage\n",
    "print \"\\n Vb=%.2f V\\n\"%(Vb)\n",
    "Ve=Vb-Vbe##emitter voltage\n",
    "print \"\\n Ve=%.2f V \\n\"%(Ve)\n",
    "Ie=Ve/Re#\n",
    "print \"\\n Ie=%.2f mA \\n\"%(Ie*1e3)\n",
    "Ib=5.26e-3/(1+Beta)##Ie=0.00526 A=5.26 mA\n",
    "print \"\\n Ib=%.2f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib#\n",
    "print \"\\n Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "print \"We apply KVL to the collector circuit\"\n",
    "print \"Vcc-Ic*Rc-Vce-Ie*Re=0\"\n",
    "Vce=Vcc-Ic*Rc-Ie*Re##since Vcc-Ic*Rc-Vce-Ie*Re=0\n",
    "print \"\\n Vce=%.2f V \\n\"%(Vce)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_6 PG-5.12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.13 shown in the question no 5.5\n",
      "\n",
      "\n",
      " Vt=3.33 V\n",
      "\n",
      "\n",
      " Rb=3333 ohm \n",
      "\n",
      "\n",
      " Ib=48.916 microA \n",
      "\n",
      "\n",
      " Ic=4.89 mA \n",
      "\n",
      "\n",
      " Vce=2.638 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.13 shown in the question no 5.5\\n\"\n",
    "#We must find the value of Ic,Ve,Vce using exact analysis\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=10##supply voltage\n",
    "R1=10e3#\n",
    "Rc=1e3#\n",
    "R2=5e3#\n",
    "Re=500#\n",
    "Beta=100##voltage gain\n",
    "Vt=R2*Vcc/(R1+R2)##thevenin's voltage\n",
    "print \"\\n Vt=%.2f V\\n\"%(Vt)\n",
    "Rb=R1*R2/(R1+R2)#\n",
    "print \"\\n Rb=%.0f ohm \\n\"%(Rb)\n",
    "Ib=(Vt-Vbe)/(Rb+(1+Beta)*Re)#\n",
    "print \"\\n Ib=%.3f microA \\n\"%(Ib*1e6)\n",
    "Ic=Beta*Ib#\n",
    "print \"\\n Ic=%.2f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-Ic*Rc-(Ic+Ib)*Re##since Vcc-Ic*Rc-Vce-Ie*Re=0\n",
    "print \"\\n Vce=%.3f V \\n\"%(Vce)\n",
    "#the ans for Ve in the book is 2.648V whereas in output it is 2.638V because\n",
    "# in the book the values has been rounded off so that the final answer is \n",
    "#2.648V same is the case for Rb,Ib andIc "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_7 PG-5.13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Vb=2 V\n",
      "\n",
      "\n",
      " Ve=1.3 V \n",
      "\n",
      "\n",
      " Ie=2.77 mA \n",
      "\n",
      "\n",
      "i) for hFE_min=50\n",
      "\n",
      "   Ic=2.712 mA \n",
      "\n",
      "   Vce=5.277 V \n",
      "\n",
      "ii)for hFE_max=60\n",
      "    Ic=2.721 mA \n",
      "\n",
      "    Vce=5.26 V \n",
      "\n"
     ]
    }
   ],
   "source": [
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=12##supply voltage\n",
    "R1=10e3#\n",
    "R2=2e3\n",
    "Re=470#\n",
    "Rc=2e3\n",
    "hFE_min=50#\n",
    "hFE_max=60#\n",
    "Vb=R2*Vcc/(R1+R2)##base voltage\n",
    "print \"\\n Vb=%.0f V\\n\"%(Vb)\n",
    "Ve=Vb-Vbe##emitter voltage\n",
    "print \"\\n Ve=%.1f V \\n\"%(Ve)\n",
    "Ie=Ve/Re#\n",
    "print \"\\n Ie=%.2f mA \\n\"%(Ie*1e3)\n",
    "print \"\\ni) for hFE_min=50\"\n",
    "Beta=hFE_min#\n",
    "Ib=Ie/(Beta+1)#\n",
    "Ic=Beta*Ib#\n",
    "print \"\\n   Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-Ic*Rc-Ve#\n",
    "print \"   Vce=%.3f V \\n\"%(Vce)\n",
    "print \"ii)for hFE_max=60\"\n",
    "Beta=hFE_max#\n",
    "Ib=Ie/(Beta+1)#\n",
    "Ic=Beta*Ib#\n",
    "print \"    Ic=%.3f mA \\n\"%(Ic*1e3)\n",
    "Vce=Vcc-Ic*Rc-Ve#\n",
    "print \"    Vce=%.2f V \\n\"%(Vce)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_8 PG-5.16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "refer to the figure-5.17 shown\n",
      "We apply KVL to the collector circuit ie Vcc-Vce-Ic*Rc=0\n",
      "\n",
      " Rc=1 kohm \n",
      "\n",
      "\n",
      " Ib=50.00 microA \n",
      "\n",
      "We apply KVL to the base circuit ie Vcc-Vbe-Ib*Rb=0\n",
      "\n",
      " Rb=186 kohm \n",
      "\n",
      "the standard value of Rb=200k ohm\n"
     ]
    }
   ],
   "source": [
    "print \"refer to the figure-5.17 shown\"\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=10##supply voltage\n",
    "Beta=100##voltage gain\n",
    "Vce=5##colector to emitter voltage \n",
    "Ic=5e-3##collector current\n",
    "print \"We apply KVL to the collector circuit ie Vcc-Vce-Ic*Rc=0\"\n",
    "Rc=(Vcc-Vce)/Ic##since Vcc-Vce-Ic*Rc=0\n",
    "print \"\\n Rc=%.0f kohm \\n\"%(Rc*1e-3)\n",
    "Ib=Ic/Beta##base current\n",
    "print \"\\n Ib=%.2f microA \\n\"%(Ib*1e6)\n",
    "print \"We apply KVL to the base circuit ie Vcc-Vbe-Ib*Rb=0\"\n",
    "Rb=(Vcc-Vbe)/Ib##since Vcc-Vbe-Ib*Rb=0\n",
    "print \"\\n Rb=%.0f kohm \\n\"%(Rb*1e-3)\n",
    "print \"the standard value of Rb=200k ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_9 PG-5.17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "refer to the figure-5.19 shown\n",
      "\n",
      " Ib=50 microA \n",
      "\n",
      "\n",
      " Rc=2.178 kohm \n",
      "\n",
      "Rc=2 kohm standard value\n",
      "We apply KVL to the input circuit ie Vce-Vbe-Ib*Rb=0\n",
      "\n",
      " Rb=86 kohm \n",
      "\n",
      "the standard value of Rb=91 kohm\n"
     ]
    }
   ],
   "source": [
    "print \"refer to the figure-5.19 shown\"\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=16##supply voltage\n",
    "Beta=100##voltage gain\n",
    "Vce=5##colector to emitter voltage \n",
    "Ic=5e-3##collector current\n",
    "Ib=Ic/Beta##base current\n",
    "print \"\\n Ib=%.0f microA \\n\"%(Ib*1e6)\n",
    "Rc=(Vcc-Vce)/(Ic+Ib)##since Vcc-Vce-Ic*Rc=0\n",
    "print \"\\n Rc=%.3f kohm \\n\"%(Rc*1e-3)\n",
    "print \"Rc=2 kohm standard value\"\n",
    "print \"We apply KVL to the input circuit ie Vce-Vbe-Ib*Rb=0\"\n",
    "Rb=(Vce-Vbe)/Ib##since Vce-Vbe-Ib*Rb=0\n",
    "print \"\\n Rb=%.0f kohm \\n\"%(Rb*1e-3)\n",
    "print \"the standard value of Rb=91 kohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_10 PG-5.18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.20 shown\n",
      "\n",
      " Ib=30 microA \n",
      "\n",
      "\n",
      " Ie=3.03 mA \n",
      "\n",
      "\n",
      " Re=990 ohm \n",
      "\n",
      " the standard value of Re=910 ohm\n",
      "\n",
      "\n",
      " Ve=2.757 V \n",
      "\n",
      "\n",
      " Rc=1414 ohm \n",
      "\n",
      " the lower side standard value is selected to reduce Ic*Rc and increase Vce \n",
      "\n",
      "\n",
      " Therefore Vb=3.45730 V \n",
      "\n",
      "\n",
      " I=0.3 mA \n",
      "\n",
      "\n",
      " R2=11524 ohm \n",
      "\n",
      " the standard value of R2=11 kohm\n",
      "\n",
      "the lower side standard is selected to satisfy I>=10*Ib\n",
      "\n",
      " I=0.3143 mA \n",
      "\n",
      "\n",
      " R1=24.812 kohm \n",
      "\n",
      " the standard value of R1=22kohm\n",
      "\n",
      "The lowest standard value is selected to satisfy I>=10*Ib\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.20 shown\"\n",
    "Vbe=0.7##base emitter voltage for silicon\n",
    "Vcc=12##supply voltage\n",
    "Beta=100##voltage gain\n",
    "Vce=5##colector to emitter voltage \n",
    "Ve=3##assumption\n",
    "Ic=3e-3##collector current\n",
    "Ib=Ic/Beta##base current\n",
    "print \"\\n Ib=%.0f microA \\n\"%(Ib*1e6)\n",
    "Ie=Ic+Ib##emitter current\n",
    "print \"\\n Ie=%.2f mA \\n\"%(Ie*1e3)\n",
    "Re=Ve/Ie#\n",
    "print \"\\n Re=%.0f ohm \\n\"%(Re)\n",
    "print \" the standard value of Re=910 ohm\"\n",
    "Re=910##standard value\n",
    "Ve=Ie*Re#\n",
    "print \"\\n\\n Ve=%.3f V \\n\"%(Ve)\n",
    "Rc=(Vcc-Ve-Vce)/Ic\n",
    "print \"\\n Rc=%.0f ohm \\n\"%(Rc)\n",
    "print \" the lower side standard value is selected to reduce Ic*Rc and increase Vce \"\n",
    "Vb=Ve+Vbe\n",
    "print \"\\n\\n Therefore Vb=%.5f V \\n\"%(Vb)\n",
    "I=10*Ib\n",
    "print \"\\n I=%.1f mA \\n\"%(I*1e3)\n",
    "R2=Vb/I#\n",
    "print \"\\n R2=%.0f ohm \\n\"%(R2)\n",
    "print \" the standard value of R2=11 kohm\\n\"\n",
    "print \"the lower side standard is selected to satisfy I>=10*Ib\"\n",
    "R2=11e3#\n",
    "I=Vb/R2#\n",
    "print \"\\n I=%.4f mA \\n\"%(I*1e3)\n",
    "R1=(Vcc-Vb)/(I+Ib)\n",
    "print \"\\n R1=%.3f kohm \\n\"%(R1*1e-3)\n",
    "print \" the standard value of R1=22kohm\\n\"\n",
    "print \"The lowest standard value is selected to satisfy I>=10*Ib\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_11 PG-5.26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " For base bias: stability factor=101 \n",
      "\n",
      "\n",
      " For collector to base bias: stability factor=10 \n",
      "\n",
      "\n",
      " For voltage divider bias: stability factor=7.19 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "#for base bias take the figure as shown the Example5.1\n",
    "Beta=100#\n",
    "S=1+Beta##stability factor\n",
    "print \"\\n For base bias: stability factor=%.0f \\n\"%(S)\n",
    "#for collector to base bias the figure as shown the Example5.3\n",
    "Beta=100#\n",
    "Rc=10e3#\n",
    "Rb=100e3\n",
    "S=(1+Beta)/(1+Beta*(Rc/(Rc+Rb)))#\n",
    "print \"\\n For collector to base bias: stability factor=%.0f \\n\"%(S)\n",
    "#for voltage divider  bias take the figure as shown the Example5.5\n",
    "Re=500#\n",
    "R1=10e3#\n",
    "R2=5e3#\n",
    "Rb=R1*R2/(R1+R2)##R1 and R2 are in parallel\n",
    "S=(1+Beta)/(1+Beta*(Re/(Re+Rb)))#\n",
    "print \"\\n For voltage divider bias: stability factor=%.2f \\n\"%(S)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_12 PG-5.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.25 shown\n",
      "Icbo doubles for every 10 degree Celsius\n",
      "\n",
      " Therefore Icbo2=64.00 microA \n",
      "\n",
      "Apply KVL to the base circuit Vbb=Vbe+Icbo2*Rb we get\n",
      "\n",
      " Rb=76.563 kohm \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.25 shown\"\n",
    "Icbo1=2e-6##at a temperature T1=25 degree celsius\n",
    "Vbb=5#\n",
    "Vbe=0.1\n",
    "print \"Icbo doubles for every 10 degree Celsius\"\n",
    "T1=25##temperature in degree celsius\n",
    "T2=80##temperature in degree celsius\n",
    "Icbo2=Icbo1*2**((T2-T1)/10)##at a temperature T2=80 degree celsius\n",
    "print \"\\n Therefore Icbo2=%.2f microA \\n\"%(Icbo2*1e6)\n",
    "print \"Apply KVL to the base circuit Vbb=Vbe+Icbo2*Rb we get\"\n",
    "Rb=(Vbb-Vbe)/Icbo2#\n",
    "print \"\\n Rb=%.3f kohm \\n\"%(Rb*1e-3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_13 PG-5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.26 shown\n",
      "\n",
      " Apply KVL to the collector side Vcc=Ic*R3+Vce+Ie*R4\n",
      "\n",
      " Therefore R3=5.394 kohm \n",
      "\n",
      "\n",
      " Apply KVL to the base side I*R2=Vbe+Ie*R4\n",
      "\n",
      " Therefore I=0.1812 mA \n",
      "\n",
      "\n",
      " Apply KVl to the potential divider side we get Vcc=(I+Ib)*R1+I*R2\n",
      "\n",
      " therefore R1=65.547 kohm \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.26 shown\"\n",
    "Vcc=15##supply voltage\n",
    "Beta=100##voltage gain\n",
    "Vbe=0.6##base emitter voltage \n",
    "Ic=2e-3\n",
    "Vce=3#\n",
    "R4=600#\n",
    "R2=10e3#\n",
    "Ib=Ic/Beta#\n",
    "Ie=Ic+Ib##collector current\n",
    "print \"\\n Apply KVL to the collector side Vcc=Ic*R3+Vce+Ie*R4\"\n",
    "R3=(Vcc-Vce-Ie*R4)/Ic##since Vcc=Ic*R3+Vce+Ie*R4\n",
    "print \"\\n Therefore R3=%.3f kohm \\n\"%(R3*1e-3)\n",
    "print \"\\n Apply KVL to the base side I*R2=Vbe+Ie*R4\"\n",
    "I=(Vbe+Ie*R4)/R2##since I*R2=Vbe+Ie*R4\n",
    "print \"\\n Therefore I=%.4f mA \\n\"%(I*1e3)\n",
    "print \"\\n Apply KVl to the potential divider side we get Vcc=(I+Ib)*R1+I*R2\"\n",
    "R1=(Vcc-I*R2)/(I+Ib)##since  Vcc=(I+Ib)*R1+I*R2\n",
    "print \"\\n therefore R1=%.3f kohm \\n\"%(R1*1e-3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_14 PG-5.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.27 shown\n",
      "apply KVl to the potential divider side we get Vcc-(I+Ib)*R1-I*R2=0 we get\n",
      "\n",
      " Re=148.51 ohm \n",
      "\n",
      "Apply KVL to the collector side Vcc-Ic*Rc-Vce+Ie*Re=0\n",
      "\n",
      " Therefore Vce=7.7 V \n",
      "\n",
      "\n",
      " stability factor=24.256 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.27 shown\"\n",
    "Vcc=12##supply voltage\n",
    "Beta=100##voltage gain\n",
    "Vbe=0.7##base emitter voltage \n",
    "Ic=2e-3#\n",
    "Ib=Ic/Beta#\n",
    "R1=50e3#\n",
    "R2=5e3#\n",
    "Rc=2e3#\n",
    "print \"apply KVl to the potential divider side we get Vcc-(I+Ib)*R1-I*R2=0 we get\"\n",
    "I=(Vcc-R1*Ib)/(R1+R2)##since Vcc-(I+Ib)*R1-I*R2=0\n",
    "Vb=R2*I#\n",
    "Ie=Ib+Ic#\n",
    "Re=(Vb-Vbe)/(Ib+Ic)##Vb=Vbe+Re*Ie\n",
    "print \"\\n Re=%.2f ohm \\n\"%(Re)\n",
    "print \"Apply KVL to the collector side Vcc-Ic*Rc-Vce+Ie*Re=0\"\n",
    "Vce=Vcc-Ic*Rc-Ie*Re##since Vcc-Ic*Rc-Vce+Ie*Re=0\n",
    "print \"\\n Therefore Vce=%.1f V \\n\"%(Vce)\n",
    "Rb=R1*R2/(R1+R2)##R1 and R2 are in parallel\n",
    "S=(1+Beta)/(1+Beta*(Re/(Re+Rb)))#\n",
    "print \"\\n stability factor=%.3f \\n\"%(S)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 5_15 PG-5.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refer to the figure-5.28 shown\n",
      "at T1=25 degree celsius, applying KVL to the base circuit we get\n",
      "Vcc-Ib*Rb-Vbe=0\n",
      "\n",
      " Therefore Ic=11.3 mA \n",
      "\n",
      "Apply KVL to the collector side Vcc-Ic*Rc-Vce=0\n",
      "\n",
      " Therefore Vce=5.22 V \n",
      "\n",
      "\n",
      " At 75 degree celsius Vce=3.525\n",
      "\n",
      "\n",
      " change in Ic=25 % (an increase)\n",
      "\n",
      "\n",
      " change in Vce=-32.47 % (a decrease) \n",
      "\n"
     ]
    }
   ],
   "source": [
    "print \"Refer to the figure-5.28 shown\"\n",
    "Vbe=0.7#\n",
    "Rb=100e3#\n",
    "Rc=600#\n",
    "Vcc=12##supply voltage\n",
    "T1=25##temperature in degree celsius\n",
    "T2=75##temperature in degree celsius\n",
    "print \"at T1=25 degree celsius, applying KVL to the base circuit we get\"\n",
    "print \"Vcc-Ib*Rb-Vbe=0\"\n",
    "Beta=100##voltage gain at T1=25 degree celsius\n",
    "Ib=(Vcc-Vbe)/Rb##since Vcc-Ib*Rb-Vbe=0\n",
    "Ic=Beta*Ib#\n",
    "print \"\\n Therefore Ic=%.1f mA \\n\"%(Ic*1e3)\n",
    "print \"Apply KVL to the collector side Vcc-Ic*Rc-Vce=0\"\n",
    "Vce=Vcc-Ic*Rc##since Vcc-Ic*Rc-Vce=0\n",
    "print \"\\n Therefore Vce=%.2f V \\n\"%(Vce)\n",
    "Beta=125##voltage gain at T1=25 degree celsius\n",
    "Ic1=Beta*Ib#\n",
    "Vce1=Vcc-Ic1*Rc##since Vcc-Ic*Rc-Vce=0\n",
    "print \"\\n At 75 degree celsius Vce=%.3f\\n\"%(Vce1)\n",
    "Ic_change=(Ic1-Ic)*100/Ic##percentage in Ic \n",
    "print \"\\n change in Ic=%.0f %% (an increase)\\n\"%(Ic_change)\n",
    "Vce_change=(Vce1-Vce)*100/Vce##percentage in Vce\n",
    "print \"\\n change in Vce=%.2f %% (a decrease) \\n\"%(Vce_change)"
   ]
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
