{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 14 Special Function ICs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.1 Pg 415"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage of the adjustable voltage regulator is = 22.25  V \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "\n",
    "# to determine the regulated voltage \n",
    "R1 = 250 # #ohm \n",
    "R2 = 2500 # # ohm \n",
    "Vref = 2 # #V #reference voltage\n",
    "Iadj = 100*10**-6# # A  # adjacent current\n",
    "\n",
    "#the output voltage of the adjustable voltage regulator is defined by\n",
    "Vo = (Vref*((R2/R1)+1)+(Iadj*R2)) #\n",
    "print 'the output voltage of the adjustable voltage regulator is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.2 Pg 416"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the total power dissipation of the IC is = 25.00  mA \n"
     ]
    }
   ],
   "source": [
    "# to determine the current drawn from the dual power supply \n",
    "V = 10 #  # V\n",
    "P = 500 # # mW\n",
    "\n",
    "# we assume that  each power supply provides half power supply to IC\n",
    "P1 = (P/2)#\n",
    "\n",
    "# the total power dissipation of the IC\n",
    "# P1 = V*I #\n",
    "I = P1/V #\n",
    "print 'the total power dissipation of the IC is = %0.2f'%I,' mA '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.3 Pg 416"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage of the adjustable voltage regulator is = 7.50  V \n"
     ]
    }
   ],
   "source": [
    "# to determine the output voltage \n",
    "R1 = 100*10**3 # #ohm \n",
    "R2 = 500*10**3 # # ohm \n",
    "Vref = 1.25 # #V #reference voltage\n",
    "\n",
    "#the output voltage of the adjustable voltage regulator is defined by\n",
    "Vo = Vref*(R1+R2)/R1#\n",
    "print 'the output voltage of the adjustable voltage regulator is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.4 Pg 417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output voltage of switching regulator circuit is = 3.50  V \n"
     ]
    }
   ],
   "source": [
    "# determine the output voltage of the switching regulator circuit\n",
    "d = 0.7 #  # duty cycle\n",
    "Vin = 5 # # V # input voltage\n",
    "\n",
    "# The output voltage of switching regulator circuit is given by\n",
    "Vo = d*Vin #\n",
    "print 'The output voltage of switching regulator circuit is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.5 Pg 417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output voltage of switching regulator circuit is = 0.96   \n"
     ]
    }
   ],
   "source": [
    "# determine the duty cycle of the switching regulator circuit\n",
    "Vo = 4.8 # # V # output voltage\n",
    "Vin = 5 # # V # input voltage\n",
    "\n",
    "# The output voltage of switching regulator circuit is given by\n",
    "# Vo = d*Vin #\n",
    "\n",
    "# Duty cycle is given as\n",
    "d =Vo/Vin #\n",
    "print 'The output voltage of switching regulator circuit is = %0.2f'%d,'  '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.6 Pg 418"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output voltage of switching regulator circuit is = 0.50   \n"
     ]
    }
   ],
   "source": [
    "# determine the duty cycle of the switching regulator circuit\n",
    "T =120 # #msec # total pulse time\n",
    "# T = ton + toff #\n",
    "ton = T/2 #\n",
    "\n",
    "# The duty cycle of switching regulator circuit is given by\n",
    "d = ton/T#\n",
    "print 'The output voltage of switching regulator circuit is = %0.2f'%d,'  '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.7 Pg 418"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output voltage of switching regulator circuit is = 0.67   \n"
     ]
    }
   ],
   "source": [
    "# determine the duty cycle of the switching regulator circuit\n",
    "ton = 12 # #msec # on time of pulse\n",
    "# ton = 2*toff #  given\n",
    "# T = ton + toff #\n",
    "toff = ton/2 #\n",
    "T = ton+toff #  # total time\n",
    "\n",
    "# The duty cycle of switching regulator circuit is given by\n",
    "d = ton/T#\n",
    "print 'The output voltage of switching regulator circuit is = %0.2f'%d,'  '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.8 Pg 419"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The emitter bias voltage is = 3.80  V \n",
      "The output voltage of the IC LM380 is = 7.90  V \n"
     ]
    }
   ],
   "source": [
    " # determine the output voltage of the audio power amplifier IC LM380\n",
    "Vcc = 12 # # V\n",
    "Ic3 = 12*10**-6 #  # A  # collector current of the transistor Q3\n",
    "Ic4 = 12*10**-6 #  # A  # collector current of the transistor Q4\n",
    "R11 = 25*10**3 # # ohm\n",
    "R12 = 25*10**3 #  # ohm\n",
    "\n",
    "# the collector current of Q3 is defined as\n",
    " # Ic3 = (Vcc-3*Veb)/(R11+R12)#\n",
    "Veb = (Vcc-(R11+R12)*Ic3)/3 #\n",
    "print 'The emitter bias voltage is = %0.2f'%Veb,' V '\n",
    "\n",
    "# the output voltage of the IC LM380\n",
    "Vo = (1/2)*Vcc+(1/2)*Veb#\n",
    "print 'The output voltage of the IC LM380 is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.9 Pg 420"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The emitter bias voltage is = 3.33  V \n",
      "The output voltage of the IC LM380 is = 6.67  V \n"
     ]
    }
   ],
   "source": [
    "# determine the output voltage of the audio power amplifier IC LM380\n",
    "Vcc = 10 # # V\n",
    "Ic3 = 0.01*10**-6 #  # A  # collector current of the transistor Q3\n",
    "Ic4 = 0.01*10**-6 #  # A  # collector current of the transistor Q4\n",
    "R11 = 25*10**3 # # ohm\n",
    "R12 = 25*10**3 #  # ohm\n",
    "\n",
    "# the collector current of Q3 is defined as\n",
    " # Ic3 = (Vcc-3*Veb)/(R11+R12)#\n",
    "Veb = (Vcc-(R11+R12)*Ic3)/3 #\n",
    "print 'The emitter bias voltage is = %0.2f'%Veb,' V '\n",
    "\n",
    "# the output voltage of the IC LM380\n",
    "Vo = (1/2)*Vcc+(1/2)*Veb#\n",
    "print 'The output voltage of the IC LM380 is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.10 Pg 421"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The emitter resistor of Q3 is = 52.00  ohm ( at temperature 25 degree celsius) \n",
      "The trans conductance of transistor is = 38.5  mA/V \n",
      "The base emitter resistor rbe is = 1.30  K ohm \n",
      "The emitter capacitor Ce = 7.65  pF \n",
      "The value of resistance RL is = 264.55  ohm \n",
      "The pole frequency fa is = 601.91  M Hz \n",
      "The pole frequency fb is = 1073.74  M Hz \n",
      "The pole frequency fc is = 3060.67  M Hz \n",
      "Hence fa is a dominant pole frequency \n"
     ]
    }
   ],
   "source": [
    "from numpy import inf\n",
    "from math import sqrt, pi\n",
    "# Design a video amplifier of IC 1550 circuit\n",
    "Vcc = 12 # # V\n",
    "Av = -10 #\n",
    "Vagc = 0 # # at bandwidth of 20 MHz\n",
    "hfe = 50 # # forward emitter parameter\n",
    "rbb = 25 #  # ohm  # base resistor\n",
    "Cs = 1*10**-12 #  # F  # source capacitor\n",
    "Cl = 1*10**-12 #  # F  # load capacitor\n",
    "Ie1 = 1*10**-3 # # A # emitter current of Q1\n",
    "f = 1000*10**6 # # Hz\n",
    "fT = 800*10**6 # # Hz\n",
    "Vt = 52*10**-3 #\n",
    "Vt1 = 0.026 #\n",
    "\n",
    "# When Vagc =0 the transistor Q2 is cut-off and the collector current of transistor Q2 flow through the transistor Q3\n",
    "# i.e Ic1=Ie1=Ie3\n",
    "Ie3 = 1*10**-3 # # A # emitter current of Q3\n",
    "Ic1 = 1*10**-3 #  # A  # collector current of the transistor Q1\n",
    "\n",
    "# it indicates that the emitter current of Q2 is zero Ie2 = 0 then the emitter resistor of Q2 is infinite\n",
    "\n",
    "re2 = inf #\n",
    "\n",
    "# emitter resistor of Q3 \n",
    "re3 = (Vt/Ie1)#\n",
    "print 'The emitter resistor of Q3 is = %0.2f'%re3,' ohm ( at temperature 25 degree celsius) '\n",
    "\n",
    "# the trans conductance of transistor is\n",
    "gm = (Ie1/Vt1)#\n",
    "print 'The trans conductance of transistor is = %0.1f'%(gm*1000),' mA/V ' # Round Off Error\n",
    "\n",
    "# the base emitter resistor rbe\n",
    "rbe = (hfe/gm)#\n",
    "print 'The base emitter resistor rbe is = %0.2f'%(rbe/1000),' K ohm ' # Round Off Error\n",
    "\n",
    "# the emitter capacitor Ce \n",
    "\n",
    "Ce = (gm/(2*pi*fT))#\n",
    "print 'The emitter capacitor Ce = %0.2f'%(Ce*1e12),' pF ' # Round Off Error\n",
    "\n",
    "# the voltage gain of video amplifier is\n",
    "# Av = (Vo/Vin) #\n",
    "# Av = -((alpha3*gm)/(rbb*re3)*((1/rbb)+(1/rbe)+sCe)*((1/re2)+(1/re3)+sC3)*((1/Rl)+(s(Cs+Cl)))) \n",
    " # At Avgc = 0 i.e s=0 in the above Av equation\n",
    "alpha3 = 1 #\n",
    "s = 0 #\n",
    "# Rl = -((alpha3*gm)/(rbb*re3)*(((1/rbb)+(1/rbe))*((1/re2)+(1/re3))*(Av)))# \n",
    "\n",
    "# After solving above equation for Rl We get Rl Equation as\n",
    "Rl = 10/(37.8*10**-3)#\n",
    "print 'The value of resistance RL is = %0.2f'%Rl,' ohm '\n",
    "\n",
    "# there are three poles present in the transfer function of video amplifier each pole generate one 3-db frequency \n",
    "Rl = 675 #\n",
    "# fa = 1/(2*pi*Rl*(Cs+Cl))#\n",
    "# after putting value of Rl ,Cs and Cl we get\n",
    "fa = 1/(2*3.14*264.55*1*10**-12)#\n",
    "print 'The pole frequency fa is = %0.2f'%(fa*10**-3/1000),' M Hz '# Round Off Error\n",
    "\n",
    "\n",
    "#fb = 1/(2*pi*Ce*((rbb*rbe)/(rbb+rbe)))#\n",
    "# after putting value of Ce rbb and rbe we get\n",
    "fb = 1/(2*pi*6.05*10**-12*24.5)#\n",
    "print 'The pole frequency fb is = %0.2f'%(fb*10**-3/1000),' M Hz '\n",
    "\n",
    "fc = 1/(2*pi*Cs*re3)#\n",
    "print 'The pole frequency fc is = %0.2f'%(fc*10**-3/1000),' M Hz '\n",
    "\n",
    "print 'Hence fa is a dominant pole frequency '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.11 Pg 423"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The emitter resistor of Q3 is = 52.00  ohm \n",
      "The trans conductance of transistor is = 38.5  mA/V \n",
      "The base emitter resistor rbe is = 1.3  kohm \n",
      "The emitter capacitor is = 6.12  pF \n",
      "The value of resistance RL is = 5.00  ohm \n",
      "The pole frequency fa is = 600.58 MHz \n",
      "The pole frequency fb is = 1060.00 MHz \n",
      "The pole frequency fc is = 3060.67 MHz \n",
      "Hence fa is a dominant pole frequency \n"
     ]
    }
   ],
   "source": [
    "# Design a video amplifier of IC 1550 circuit\n",
    "Vcc = 12 # # V\n",
    "Av = -10 #\n",
    "Vagc = 0 # # at bandwidth of 20 MHz\n",
    "hfe = 50 # # forward emitter parameter\n",
    "rbb = 25 #  # ohm  # base resistor\n",
    "Cs = 1*10**-12 #  # F  # source capacitor\n",
    "Cl = 1*10**-12 #  # F  # load capacitor\n",
    "Ie1 = 1*10**-3 # # A # emitter current of Q1\n",
    "f = 1000*10**6 # # Hz\n",
    "Vt = 52*10**-3 #\n",
    "Vt1 = 0.026 #\n",
    "\n",
    "# When Vagc =0 the transistor Q2 is cut-off and the collector current of transistor Q2 flow through the transistor Q3\n",
    "# i.e Ic1=Ie1=Ie3\n",
    "Ie3 = 1*10**-3 # # A # emitter current of Q3\n",
    "Ic1 = 1*10**-3 #  # A  # collector current of the transistor Q1\n",
    "\n",
    "# it indicates that the emitter current of Q2 is zero Ie2 = 0 then the emitter resistor of Q2 is infinite\n",
    "re2 = inf #\n",
    "\n",
    "# emitter resistor of Q3 \n",
    "re3 = (Vt/Ie1)#\n",
    "print 'The emitter resistor of Q3 is = %0.2f'%re3,' ohm '\n",
    "\n",
    "# the trans conductance of transistor is\n",
    "gm = (Ie1/Vt1)#\n",
    "print 'The trans conductance of transistor is = %0.1f'%(gm*1e3),' mA/V '\n",
    "\n",
    "# the base emitter resistor rbe\n",
    "rbe = (hfe/gm)#\n",
    "print 'The base emitter resistor rbe is = %0.1f'%(rbe/1e3),' kohm '\n",
    "\n",
    "# the emitter capacitor Ce \n",
    "Ce = (gm/(2*pi*f))#\n",
    "print 'The emitter capacitor is = %0.2f'%(Ce*1e12),' pF '\n",
    "\n",
    "# the voltage gain of video amplifier is\n",
    "# Av = (Vo/Vin) #\n",
    "# Av = -((alpha3*gm)/(rbb*re3)*((1/rbb)+(1/rbe)+sCe)*((1/re2)+(1/re3)+sC3)*((1/Rl)+(s(Cs+Cl)))) \n",
    " # At Avgc = 0 i.e s=0 in the above Av equation\n",
    "alpha3 = 1 #\n",
    "s = 0 #\n",
    "Av =-10 #\n",
    "Rl = -((alpha3*gm)/((rbb*re3)*(((1/rbb)+(1/rbe))*((1/re2)+(1/re3))*(Av))))# \n",
    "Rl = (1/Rl)#\n",
    "print 'The value of resistance RL is = %0.2f'%Rl,' ohm '\n",
    "\n",
    "# there are three poles present in the transfer function of video amplifier each pole generate one 3-db frequency \n",
    "Rl = 265\n",
    "fa = 1/(2*pi*Rl*(Cs))/1e6#\n",
    "print 'The pole frequency fa is = %0.2f'%fa,'MHz '\n",
    "\n",
    "\n",
    "fb = 1/(2*pi*Ce*((rbb*rbe)/(rbb+rbe)))/1e6\n",
    "print 'The pole frequency fb is = %0.2f'%fb,'MHz '\n",
    "\n",
    "fc = 1/(2*pi*Cs*re3)/1e6\n",
    "print 'The pole frequency fc is = %0.2f'%fc,'MHz '\n",
    "\n",
    "print  'Hence fa is a dominant pole frequency '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.12 Pg 425"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input current is = 0.50 mA \n",
      "The output of an op-amp is = 27.50  V \n"
     ]
    }
   ],
   "source": [
    "# Determine the output voltage of an isolation amplifier IC ISO100\n",
    "Vin = 5.0 # # V\n",
    "Rin = 10*10**3 # \n",
    "Rf = 55*10**3 # # ohm # feedback resistance\n",
    "\n",
    "# the input voltage of an amplifier 1\n",
    "# Vin = Rin*Iin\n",
    "Iin = Vin/Rin # \n",
    "print 'The input current is = %0.2f'%(Iin*1e3),'mA '\n",
    "\n",
    "# In isolation amplifier ISO 100 the input current Iin is equal to the output current Iout , but both are opposite in direction\n",
    "# Iin = -Iout\n",
    "# the output of an op-amp\n",
    "# Vo = -Rf*Iout\n",
    "Vo = Rf*Iin#\n",
    "print 'The output of an op-amp is = %0.2f'%Vo,' V '"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.13 Pg 426"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input current is = 12 mA \n",
      "The output of an op-amp is = 204  V \n"
     ]
    }
   ],
   "source": [
    "# Determine the output voltage of an isolation amplifier IC ISO100\n",
    "Vin = 12.0 # # V\n",
    "Rin = 1*10**3 # \n",
    "Rf = 17*10**3 # # ohm # feedback resistance\n",
    "\n",
    "# the input voltage of an amplifier 1\n",
    "# Vin = Rin*Iin\n",
    "Iin = Vin/Rin # \n",
    "print 'The input current is = %0.f'%(Iin*1e3),'mA '\n",
    "\n",
    "# In isolation amplifier ISO 100 the input current Iin is equal to the output current Iout , but both are opposite in direction\n",
    "# Iin = -Iout\n",
    "# the output of an op-amp\n",
    "# Vo = -Rf*Iout\n",
    "Vo = Rf*Iin#\n",
    "print 'The output of an op-amp is = %0.f'%Vo,' V '"
   ]
  }
 ],
 "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
}