{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3 - Bipolar Junction Transistor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_1 Page No. 64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Vcc = 15.00  volts\n",
      "VBB = 1.00  volts\n",
      "VBE = 0.70  volts\n",
      "resistance,RB = 5000.00 ohm\n",
      "resistance,RL = 650.00 ohm\n",
      "Gain,Bf = 200.00 \n",
      "IB =(VBB-VBE)/RB = 6.00e-05  ampere\n",
      "IC =IB*Bf= 0.01  ampere\n",
      "IE = IB+IC=0.01  ampere\n",
      "VCE =Vcc-IC*RL= 7.20  volts\n",
      "VCB = VCE-VBE=6.50  volts\n",
      "resistance,RB =(Vcc-VBE)/IB= 2.38e+05 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "Vcc=15\n",
    "print \"Vcc = %0.2f\"%(Vcc),\" volts\"   #initialization\n",
    "VBB=1\n",
    "print \"VBB = %0.2f\"%(VBB),\" volts\"  #initialization\n",
    "VBE=0.7\n",
    "print \"VBE = %0.2f\"%(VBE),\" volts\"  #initialization\n",
    "RB=5*(10**3)\n",
    "print \"resistance,RB = %0.2f\"%(RB)+ \" ohm\"  #initialization\n",
    "RL=650\n",
    "print \"resistance,RL = %0.2f\"%(RL)+ \" ohm\"  #initialization\n",
    "Bf=200\n",
    "print \"Gain,Bf = %0.2f\"%(Bf)+ \" \"  #initialization\n",
    "IB=(VBB-VBE)/RB #Formulae\n",
    "print \"IB =(VBB-VBE)/RB = %0.2e\"%(IB),\" ampere\" #calculation\n",
    "IC=IB*Bf  #Formulae\n",
    "print \"IC =IB*Bf= %0.2f\"%(IC),\" ampere\"#calculation\n",
    "IE=IB+IC  #Formulae\n",
    "print \"IE = IB+IC=%0.2f\"%(IE),\" ampere\"#calculation\n",
    "VCE=Vcc-IC*RL #Formulae\n",
    "print \"VCE =Vcc-IC*RL= %0.2f\"%(VCE),\" volts\" #calculation\n",
    "VCB=VCE-VBE  #Formulae\n",
    "print \"VCB = VCE-VBE=%0.2f\"%(VCB),\" volts\"#calculation\n",
    "RB=(Vcc-VBE)/IB  #Formulae\n",
    "print \"resistance,RB =(Vcc-VBE)/IB= %0.2e\"%(RB)+ \" ohm\" #calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_2 Page No. 65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Vbe1 = 0.03  volts\n",
      "Vbe2 = -0.03  volts\n",
      "ib1 = 2.00e-05  ampere\n",
      "ib2 = -2.00e-05  ampere\n",
      "IBQ = 6.00e-05  ampere\n",
      "ICP = 0.02  ampere\n",
      "ICR = 0.01  ampere\n",
      "VCEP = 5.00  volts\n",
      "VCER = 9.00  volts\n",
      "change_IC = 0.01  ampere\n",
      "change_VCE = 4.00  volts\n",
      "AV = 80.00  \n",
      "AI = 175.00  \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "Vbe1=0.025\n",
    "print \"Vbe1 = %0.2f\"%(Vbe1),\" volts\" # value of base-emitter voltage1\n",
    "Vbe2=(-0.025)\n",
    "print \"Vbe2 = %0.2f\"%(Vbe2),\" volts\" # value of base-emitter voltage2\n",
    "ib1=20*10**(-6)\n",
    "print \"ib1 = %0.2e\"%(ib1),\" ampere\" # value of base current1\n",
    "ib2=(-20*10**(-6))\n",
    "print \"ib2 = %0.2e\"%(ib2),\" ampere\"# value of base current2\n",
    "IBQ=60*10**(-6)\n",
    "print \"IBQ = %0.2e\"%(IBQ),\" ampere\" # operating point\n",
    "ICP=15.5*10**(-3)\n",
    "print \"ICP = %0.2f\"%(ICP),\" ampere\" # initialization\n",
    "ICR=8.5*10**(-3)\n",
    "print \"ICR = %0.2f\"%(ICR),\" ampere\" # initialization\n",
    "VCEP=5\n",
    "print \"VCEP = %0.2f\"%(VCEP),\" volts\" # value of collector-emitter voltage1\n",
    "VCER=9\n",
    "print \"VCER = %0.2f\"%(VCER),\" volts\" # value of collector-emitter voltage2\n",
    "change_IC=ICP-ICR  #change in collector current\n",
    "print \"change_IC = %0.2f\"%(change_IC),\" ampere\"\n",
    "change_VCE=VCER-VCEP #change in collector voltage\n",
    "print \"change_VCE = %0.2f\"%(change_VCE),\" volts\" \n",
    "change_VBE=Vbe1-Vbe2\n",
    "change_IB=ib1-ib2\n",
    "AV=(change_VCE/change_VBE) #formulae voltage gain\n",
    "print \"AV = %0.2f\"%(AV),\" \"#voltage gain\n",
    "AI=change_IC/change_IB #formulae current gain\n",
    "print \"AI = %0.2f\"%(AI),\" \""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_3 Page No. 68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ICQ = 0.01  ampere\n",
      "B = 200.00  \n",
      "capacitance,Cbe = 1.00e-10  F \n",
      "VT = 0.03  volts\n",
      "gm =(ICQ/VT)= 0.46  A/V\n",
      "hie =(B/gm)= 433.33  ohm\n",
      "fT =((1/2)*(gm/Cbe)*(1/pi))= 7.35e+08  hertz\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "from __future__ import division  \n",
    "ICQ=12*10**(-3)\n",
    "print \"ICQ = %0.2f\"%(ICQ),\" ampere\" # collector current\n",
    "B=200\n",
    "print \"B = %0.2f\"%(B),\" \" #BJT gain\n",
    "Cbe=100*10**(-12)# capacitance\n",
    "print \"capacitance,Cbe = %0.2e\"%(Cbe),\" F \"\n",
    "VT=26*10**(-3)\n",
    "print \"VT = %0.2f\"%(VT),\" volts\" # thermal voltage\n",
    "gm=(ICQ/VT) #transconductance\n",
    "print \"gm =(ICQ/VT)= %0.2f\"%(gm),\" A/V\"\n",
    "hie=B/gm #forward resistance hybrid parameter\n",
    "print \"hie =(B/gm)= %0.2f\"%(hie),\" ohm\"\n",
    "fT=((1/2)*(gm/Cbe)*(1/pi)) #unity gain frequency formulae\n",
    "print \"fT =((1/2)*(gm/Cbe)*(1/pi))= %0.2e\"%(fT),\" hertz\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_4 Page No. 71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VCC = 20.00  volts\n",
      "RL= 5000.00 ohm\n",
      "RB = 9.65e+05 ohm\n",
      "VBE = 0.70  volts\n",
      "BF = 50.00  \n",
      "ICO = 1.00e-08  ampere\n",
      "Vi = 0.00e+00  volts\n",
      "IBQ = 2.00e-05  ampere\n",
      "ICQ =BF*IBQ= 1.00e-03  ampere\n",
      "VCEQ =VCC-ICQ*RL = 15.00  volts\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VCC=20\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "VBB=VCC\n",
    "RL=5*(10**3)\n",
    "print \"RL= %0.2f\"%(RL)+ \" ohm\"  #resistance\n",
    "RB=965*(10**3)\n",
    "print \"RB = %0.2e\"%(RB)+ \" ohm\"  #initialization base resistance\n",
    "VBE=(0.7)\n",
    "print \"VBE = %0.2f\"%(VBE),\" volts\" # value of base-emitter voltage\n",
    "BF=50\n",
    "print \"BF = %0.2f\"%(BF),\" \" #BJT gain\n",
    "ICO=10*10**(-9)\n",
    "print \"ICO = %0.2e\"%(ICO),\" ampere\" # collector reverse bias current\n",
    "Vi=0\n",
    "print \"Vi = %0.2e\"%(Vi),\" volts\" # value of input\n",
    "IBQ=(VCC-VBE)/RB #base current as operating point\n",
    "print \"IBQ = %0.2e\"%(IBQ),\" ampere\"\n",
    "ICQ=BF*IBQ #operating point (collector current)\n",
    "print \"ICQ =BF*IBQ= %0.2e\"%(ICQ),\" ampere\" # calculation\n",
    "VCEQ=VCC-ICQ*RL #  collector-emitter voltage as operating point\n",
    "print \"VCEQ =VCC-ICQ*RL = %0.2f\"%(VCEQ),\" volts\" #calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_5 Page No. 74"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BF1 = 100.00  \n",
      "VCC = 20.00  volts\n",
      "resistance,RL= 5.00e+03 ohm\n",
      "resistance,RB = 9.65e+05 ohm\n",
      "VBE = 0.70  volts\n",
      "ICO = 1.00e-08  ampere\n",
      "Vi = 0  volts\n",
      "IBQ = 2.00e-05  ampere\n",
      "ICQ1 =BF1*IBQ= 2.00e-03  ampere\n",
      "VCEQ1 =VCC-ICQ1*RL = 10.00  volts\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "BF1=100\n",
    "print \"BF1 = %0.2f\"%(BF1),\" \" #BJT gain\n",
    "VCC=20\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "VBB=VCC\n",
    "RL=5*(10**3)\n",
    "print \"resistance,RL= %0.2e\"%(RL)+ \" ohm\"  #initialization\n",
    "RB=965*(10**3)\n",
    "print \"resistance,RB = %0.2e\"%(RB)+ \" ohm\"  #initialization\n",
    "VBE=(0.7)\n",
    "print \"VBE = %0.2f\"%(VBE),\" volts\" # value of base-emitter voltage\n",
    "ICO=10*10**(-9)\n",
    "print \"ICO = %0.2e\"%(ICO),\" ampere\" # collector reverse bias current\n",
    "Vi=0\n",
    "print \"Vi = %0.f\"%(Vi),\" volts\" # value of input\n",
    "IBQ=(VCC-VBE)/RB #base current as operating point\n",
    "print \"IBQ = %0.2e\"%(IBQ),\" ampere\"\n",
    "ICQ1=BF1*IBQ #operating point (collector current)\n",
    "print \"ICQ1 =BF1*IBQ= %0.2e\"%(ICQ1),\" ampere\" # calculation\n",
    "VCEQ1=VCC-ICQ1*RL #  collector-emitter voltage as operating point\n",
    "print \"VCEQ1 =VCC-ICQ1*RL = %0.2f\"%(VCEQ1),\" volts\" #calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_6 Page No. 75"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VBE2 = 0.50  volts\n",
      "VCC = 20.00  volts\n",
      "BF2 = 150.00  \n",
      "ICO2 = 5.00e-07  ampere\n",
      "RB = 9.65e+05 ohm\n",
      "RL= 5.00e+03 ohm\n",
      "IBQ2 = (VCC-VBE2)/RB=2.02e-05  ampere\n",
      "ICQ2 =BF2*IBQ2= 3.03e-03  ampere\n",
      "dICQ2 =BF2*ICO2= 7.50e-05  ampere\n",
      "ICQ3 =ICQ2+dICQ2= 3.11e-03  ampere\n",
      "VCEQ3 =VCC-ICQ3*RL = 4.47  volts\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VBE2=(0.5)\n",
    "print \"VBE2 = %0.2f\"%(VBE2),\" volts\" # value of base-emitter voltage\n",
    "VCC=20\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "BF2=150\n",
    "print \"BF2 = %0.2f\"%(BF2),\" \" #BJT gain\n",
    "ICO2=500*10**(-9)\n",
    "print \"ICO2 = %0.2e\"%(ICO2),\" ampere\" # collector reverse bias current\n",
    "RB=965*(10**3)\n",
    "print \"RB = %0.2e\"%(RB)+ \" ohm\"  #initialization base resistance\n",
    "RL=5*(10**3)\n",
    "print \"RL= %0.2e\"%(RL)+ \" ohm\"  # load resistance\n",
    "IBQ2=(VCC-VBE2)/RB   #base current as operating point\n",
    "print \"IBQ2 = (VCC-VBE2)/RB=%0.2e\"%(IBQ2),\" ampere\"\n",
    "ICQ2=(BF2*IBQ2)   #operating point (collector current)\n",
    "print \"ICQ2 =BF2*IBQ2= %0.2e\"%(ICQ2),\" ampere\" # \n",
    "dICQ2=BF2*ICO2  # increase in reverse bias current\n",
    "print \"dICQ2 =BF2*ICO2= %0.2e\"%(dICQ2),\" ampere\" # \n",
    "ICQ3=ICQ2+dICQ2\n",
    "print \"ICQ3 =ICQ2+dICQ2= %0.2e\"%(ICQ3),\" ampere\" # calculation\n",
    "VCEQ3=VCC-ICQ3*RL #  collector-emitter voltage as operating point\n",
    "print \"VCEQ3 =VCC-ICQ3*RL = %0.2f\"%(VCEQ3),\" volts\" #calculation\n",
    "#NOTE: Calculated ans for VCEQ3=4.4695596 volts but in book it is given as 4.625volts(due to approximations done in)   \n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_7 Page No. 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VCC = 20.00  volts\n",
      "resistance,RL= 5000.00 ohm\n",
      "resistance,R1 = 90000.00 ohm\n",
      "resistance,R2 = 10000.00 ohm\n",
      "resistance,Rc = 1000.00 ohm\n",
      "VBEmax = 0.70  volts\n",
      "VBEmin = 0.50  volts\n",
      "BFmax = 150.00  \n",
      "BFmin = 50.00  \n",
      "ICOmax = 5.00e-07  ampere\n",
      "ICOmin = 1.00e-08  ampere\n",
      "VBB = 2.00  volts\n",
      "RB = (R1*R2)/(R1+R2)=9000.00 ohm\n",
      "ICmin = 0.00  ampere\n",
      "VCEQmax =VCC-ICmin*RL = 14.58  volts\n",
      "ICmax = 1.41e-03  ampere\n",
      "VCEQmin =VCC-ICmax*RL = 12.95  volts\n",
      "change_IC= 3.28e-04  ampere\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VCC=20\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "RL=5*(10**3)\n",
    "print \"resistance,RL= %0.2f\"%(RL)+ \" ohm\"  #initialization\n",
    "R1=90*(10**3)\n",
    "print \"resistance,R1 = %0.2f\"%(R1)+ \" ohm\"  #initialization\n",
    "R2=10*(10**3)\n",
    "print \"resistance,R2 = %0.2f\"%(R2)+ \" ohm\"  #initialization \n",
    "Rc=1*(10**3)\n",
    "print \"resistance,Rc = %0.2f\"%(Rc)+ \" ohm\"  # resistance at collector\n",
    "VBEmax=(0.7)\n",
    "print \"VBEmax = %0.2f\"%(VBEmax),\" volts\" # maximum base-emitter voltage\n",
    "VBEmin=(0.5)\n",
    "print \"VBEmin = %0.2f\"%(VBEmin),\" volts\" # minimum base-emitter voltage\n",
    "BFmax=150\n",
    "print \"BFmax = %0.2f\"%(BFmax),\" \" #BJT gain maximum\n",
    "BFmin=50\n",
    "print \"BFmin = %0.2f\"%(BFmin),\" \" #BJT gain minimum\n",
    "ICOmax=500*10**(-9)\n",
    "print \"ICOmax = %0.2e\"%(ICOmax),\" ampere\" # maximum collector reverse bias current\n",
    "ICOmin=10*10**(-9)\n",
    "print \"ICOmin = %0.2e\"%(ICOmin),\" ampere\" # minimum collector reverse bias current\n",
    "VBB=(VCC*R2)/(R1+R2)\n",
    "print \"VBB = %0.2f\"%(VBB),\" volts\" # Base supply voltage \n",
    "RB=(R1*R2)/(R1+R2)\n",
    "print \"RB = (R1*R2)/(R1+R2)=%0.2f\"%(RB)+ \" ohm\" # eqivalent base resistance\n",
    "ICmin=((BFmin*(VBB-VBEmax)+(RB+Rc)*(1+BFmin)*ICOmin)/(RB+Rc*(1+BFmin))) # minimum collector  current\n",
    "print \"ICmin = %0.2f\"%(ICmin),\" ampere\"\n",
    "VCEQmax=VCC-ICmin*RL #  maximum collector-emitter voltage (d.c value)\n",
    "print \"VCEQmax =VCC-ICmin*RL = %0.2f\"%(VCEQmax),\" volts\" #calculation\n",
    "ICmax=((BFmax*(VBB-VBEmin)+(RB+Rc)*(1+BFmax)*ICOmax)/(RB+Rc*(1+BFmax))) # maximum collector  current\n",
    "print \"ICmax = %0.2e\"%(ICmax),\" ampere\"\n",
    "VCEQmin=VCC-ICmax*RL # minimum collector-emitter voltage (d.c value)\n",
    "print \"VCEQmin =VCC-ICmax*RL = %0.2f\"%(VCEQmin),\" volts\" #calculation\n",
    "change_IC=ICmax-ICmin\n",
    "print \"change_IC= %0.2e\"%(change_IC),\" ampere\" # extreme variation in collector current\n",
    "# ERROR - NOTE: Extreme variation in collector current given in book is 0.397 mA but calculated correct ans is 0.3276 mA \n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_8 Page No. 79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VCC = 20.00  volts\n",
      "RL= 2000.00 ohm\n",
      "R1 =R2= 100000.00 ohm\n",
      "VBE = 0.70  volts\n",
      "BF = 100.00  \n",
      "VBB = 10.00  volts\n",
      "RB = (R1*R2)/(R1+R2)=50000.00 ohm\n",
      "IC = 3.69e-03  ampere\n",
      "VE = 7.38  volts\n",
      "VB = 8.08  volts\n",
      "VCB = 11.92  volts\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VCC=20\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "RL=2*(10**3)\n",
    "print \"RL= %0.2f\"%(RL)+ \" ohm\"  #resistance\n",
    "R1=100*(10**3)\n",
    "R2=R1\n",
    "print \"R1 =R2= %0.2f\"%(R1)+ \" ohm\"  #resistance\n",
    "VBE=(0.7)\n",
    "print \"VBE = %0.2f\"%(VBE),\" volts\" #  base-emitter voltage\n",
    "BF=100\n",
    "print \"BF = %0.2f\"%(BF),\" \" #BJT gain\n",
    "ICO=0\n",
    "VBB=(VCC*R2)/(R1+R2)\n",
    "print \"VBB = %0.2f\"%(VBB),\" volts\" # Base supply voltage \n",
    "RB=(R1*R2)/(R1+R2)\n",
    "print \"RB = (R1*R2)/(R1+R2)=%0.2f\"%(RB)+ \" ohm\" # eqivalent base resistance\n",
    "IC=((BF*(VBB-VBE))/(RB+RL*(1+BF))) # collector  current\n",
    "print \"IC = %0.2e\"%(IC),\" ampere\"\n",
    "VE=IC*RL\n",
    "print \"VE = %0.2f\"%(VE),\" volts\" #  emitter voltage\n",
    "VB=VBE+VE\n",
    "print \"VB = %0.2f\"%(VB),\" volts\" #  base voltage\n",
    "VCB=VCC-VB\n",
    "print \"VCB = %0.2f\"%(VCB),\" volts\" #  collector-base voltage\n",
    "#hence BJT in active region."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_9 Page No. 84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VCC = 5.00  volts\n",
      "RL= 250.00 ohm\n",
      "RB =25000.00 ohm\n",
      "VCS = 0.20  volts\n",
      "BF = 200.00  \n",
      "VBS = 0.80  volts\n",
      "VI = 5.00  volts\n",
      "VCON = 0.30  volts\n",
      "ICON = (VCC-VCON)/RL=0.02  ampere\n",
      "IBON = (ICON)/BF=9.40e-05  ampere\n",
      "IBS = (VI-VBS)/RB=1.68e-04  ampere\n",
      "ICS = (VCC-VCS)/RL=1.92e-02  ampere\n",
      "Bforced = ICS/IBS=114.29  \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VCC=5\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "RL=250\n",
    "print \"RL= %0.2f\"%(RL)+ \" ohm\"  #initialization\n",
    "RB=25*10**(3)\n",
    "print \"RB =%0.2f\"%(RB)+ \" ohm\" #  base resistance\n",
    "VCS=(0.2)\n",
    "print \"VCS = %0.2f\"%(VCS),\" volts\" #   voltage\n",
    "BF=200\n",
    "print \"BF = %0.2f\"%(BF),\" \" #BJT gain\n",
    "VBS=(0.8)\n",
    "print \"VBS = %0.2f\"%(VBS),\" volts\" #  base-emitter voltage for BJT switch\n",
    "VI=5\n",
    "print \"VI = %0.2f\"%(VI),\" volts\"# input voltage\n",
    "VCON=0.3\n",
    "print \"VCON = %0.2f\"%(VCON),\" volts\"\n",
    "ICON=(VCC-VCON)/RL\n",
    "print \"ICON = (VCC-VCON)/RL=%0.2f\"%(ICON),\" ampere\"#collector current for saturated BJT\n",
    "IBON=(ICON)/BF\n",
    "print \"IBON = (ICON)/BF=%0.2e\"%(IBON),\" ampere\"#Base current for saturated BJT\n",
    "IBS=(VI-VBS)/RB\n",
    "print \"IBS = (VI-VBS)/RB=%0.2e\"%(IBS),\" ampere\"#Base-emitter current for  saturated BJT\n",
    "ICS=(VCC-VCS)/RL\n",
    "print \"ICS = (VCC-VCS)/RL=%0.2e\"%(ICS),\" ampere\"#Collector-emitter current for  saturated BJT\n",
    "Bforced=ICS/IBS\n",
    "print \"Bforced = ICS/IBS=%0.2f\"%(Bforced),\" \" #BJT forced gain\n",
    "#IBS>>IBON hence BJT in saturation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_10 Page No. 85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TJmax= 175.00 degree celsius\n",
      "theta= 0.50 degree celsius/mW \n",
      "at 25 degree celsius,PDmax=(TJmax-25 )/theta = 300.00 mW \n",
      "at 75 degree celsius,PDmax2= (TJmax-75)/theta = 200.00 mW \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "TJmax=175\n",
    "print \"TJmax= %0.2f\"%(TJmax),\"degree celsius\"  #maximum allowed junction temperature\n",
    "theta=0.5\n",
    "print \"theta= %0.2f\"%(theta),\"degree celsius/mW \"  #thermal resistances b/w junction to ambient\n",
    "change_T=TJmax-25#temperature difference\n",
    "PDmax=change_T/theta\n",
    "print \"at 25 degree celsius,PDmax=(TJmax-25 )/theta = %0.2f\"%(PDmax)+ \" mW \"  #maximum allowed power dissipation at TA=25 degree celsius\n",
    "change_T=TJmax-75\n",
    "PDmax2=change_T/theta\n",
    "print \"at 75 degree celsius,PDmax2= (TJmax-75)/theta = %0.2f\"%(PDmax2)+ \" mW \"  #maximum allowed power dissipation at TA=75 degree celsius"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_11 Page No. 85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TJmax= 175.00  degree celsius\n",
      "theta= 0.10  degree celsius/mW \n",
      "at 25 degree celsius,PDmax=(TJmax-25 )/theta = 1500.00 mW \n",
      "at 75 degree celsius,PDmax= (TJmax-75)/theta = 1000.00 mW \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "TJmax=175\n",
    "print \"TJmax= %0.2f\"%(TJmax),\" degree celsius\"  #maximum allowed junction temperature\n",
    "theta=0.1\n",
    "print \"theta= %0.2f\"%(theta),\" degree celsius/mW \"  #thermal resistances b/w junction to ambient\n",
    "change_T=TJmax-25 #temperature difference\n",
    "PDmax=change_T/theta\n",
    "print \"at 25 degree celsius,PDmax=(TJmax-25 )/theta = %0.2f\"%(PDmax)+ \" mW \"  #maximum allowed power dissipation at TA=25 degree celsius\n",
    "change_T=TJmax-75 #temperature difference\n",
    "PDmax=change_T/theta\n",
    "print \"at 75 degree celsius,PDmax= (TJmax-75)/theta = %0.2f\"%(PDmax)+ \" mW \"  #maximum allowed power dissipation at TA=75 degree celsius"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_12 Page No. 86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VBE = 0.70  volts\n",
      "VCC = 10.00  volts\n",
      "IREF =IQ= 0.01  ampere\n",
      "R=(VCC-VBE)/(IREF)= 1860.00 ohm\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VBE=(0.7)\n",
    "print \"VBE = %0.2f\"%(VBE),\" volts\" # value of base-emitter voltage\n",
    "VCC=10\n",
    "print \"VCC = %0.2f\"%(VCC),\" volts\" # collector supply voltage \n",
    "IREF=5*10**(-3)\n",
    "print \"IREF =IQ= %0.2f\"%(IREF),\" ampere\" #  current mirror source current\n",
    "R=(VCC-VBE)/(IREF)# formulae\n",
    "print \"R=(VCC-VBE)/(IREF)= %0.2f\"%(R)+ \" ohm\"  #resistance"
   ]
  }
 ],
 "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
}