{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 14:Digital to analog Converters" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.1 Page no 403" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "n=8 #An 8-bit DAC wire\n", "V1=0 #Voltage range\n", "V2=5.12\n", "\n", "#Calculation\n", "R=2**n\n", "dvo=V2/R\n", "Vfs=V2*(1-1/R)\n", "\n", "#Result\n", "print\"(a)The resolution is\",R\n", "print\"(b)The output change per bit is\",dvo*1000,\"mV/bit\"\n", "print\"(c)the ideal full scale output voltage is\",Vfs,\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(a)The resolution is 256\n", "(b)The output change per bit is 20.0 mV/bit\n", "(c)the ideal full scale output voltage is 5.12 V\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.2 Page no 404" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "Res=20 #mV/bit\n", "#From the given code 00010110 and 10000000\n", "#The binary weighted code for unipolar operation\n", "b7=0\n", "b6=0\n", "b5=0\n", "b4=1\n", "b3=0\n", "b2=1\n", "b1=1\n", "b0=0\n", "#For part (b)\n", "b7_=1\n", "b6_=0\n", "b5_=0\n", "b4_=0\n", "b3_=0\n", "b2_=0\n", "b1_=0\n", "b0_=0\n", "\n", "#Calculation\n", "D=b7*2**7+b6*2**6+b5*2**5+b4*2**4+b3*2**3+b2*2**2+b1*2**1+b0*2**0\n", "Vo=D*Res*10**-3\n", "D_=b7_*2**7+b6_*2**6+b5_*2**5+b4_*2**4+b3_*2**3+b2_*2**2+b1_*2**1+b0_*2**0\n", "Vo_=D_*Res*10**-3\n", "\n", "#Resul\n", "print\"(a)The output voltage is\",Vo,\"V\"\n", "print\"(b)The output voltage is\",Vo_,\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(a)The output voltage is 0.44 V\n", "(b)The output voltage is 2.56 V\n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.3 Page no 404" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "#From Example 14.1\n", "n=8 #An 8-bit DAC wire\n", "V1=0 #Voltage range\n", "V2=5.12\n", "\n", "#Calculation\n", "dvo=2*V2/2**n \n", "\n", "#Result\n", "print\"The full scale output voltage range\",dvo*1000,\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The full scale output voltage range 40.0 V\n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.4 Page no 405" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "Vref=10.24 #V, input ref voltage\n", "p=0.05 #Percentage error\n", "n=12 #12 bit unipolar DAC\n", "\n", "#Calculation\n", "Voff=0.05/100*Vref\n", "dvo=Vref/(2**n)\n", "a=Voff/dvo\n", "\n", "#REsult\n", "print\"The offset voltage is\",Voff*1000,\"mV\"\n", "print\"Interms of least significant bit(s) it is\",dvo*1000,\"mV/bit\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The offset voltage is 5.12 mV\n", "Interms of least significant bit(s) it is 2.5 mV/bit\n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.5 Page no 407" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "n=8.0 #8-bit DAC\n", "error=0.2 #percent\n", "Vref=5.12 #V\n", "Vos=0\n", "\n", "#Calculation\n", "V11=(((-error/100.0))+1)*(Vref)+Vos\n", "\n", "#REsult\n", "print\"The minimum output voltage is\",round(V11,1),\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The minimum output voltage is 5.1 V\n" ] } ], "prompt_number": 7 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.6 Page no 411" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "n=4.0 #4 bit resistance ladder\n", "R=10.0 #kohm\n", "Vref=10.0 #V\n", "\n", "#Calculation\n", "Res=Vref/(2**n*R*10**3)\n", "\n", "#From dicimal value of binary 1111\n", "D=15\n", "Iout=Res*D\n", "\n", "#Result\n", "print\"The resolution of 1 LSB is\",Res*10**6,\"microA\"\n", "print\"output current is\",Iout*1000,\"microA\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The resolution of 1 LSB is 62.5 microA\n", "output current is 0.9375 microA\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.7 Page no 412" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "Io=62.5 #microA, from ex. 14.6\n", "Rf=10 #kohm , from fig.14.7\n", "Vref=10 #V, reference voltage\n", "R=Rf\n", "n=4 #no of bits\n", "\n", "#Calculation\n", "VR=Io*Rf*10**-3\n", "D=15 #For a digital input of 1111\n", "Vo=-VR*D\n", "\n", "#REsult\n", "print\"The voltage resolution of 1 LSB is\",VR,\"V\"\n", "print\"When digital input is 1111 , Vo is\",Vo,\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The voltage resolution of 1 LSB is 0.625 V\n", "When digital input is 1111 , Vo is -9.375 V\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.8 Page no 416" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "Vref=10.0 #V, from fig. 14.8. reference voltage\n", "Rref=5.0 #kohm\n", "n=8.0 #no of bits\n", "\n", "#Calculation\n", "Iref=Vref/Rref\n", "I=Vref/(Rref*2**n)\n", "\n", "#Result\n", "print\"The ladder input current is\",Iref,\"mA\"\n", "print\"Current value of 1 LSB is\",round(I*1000,3),\"microA\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The ladder input current is 2.0 mA\n", "Current value of 1 LSB is 7.813 microA\n" ] } ], "prompt_number": 30 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.9 Page no 417" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "I=7.812 #Current resolution from ex 14.8\n", "\n", "\n", "#Calculation\n", "Ifs=I*10**-3*255 #From eq. 14-15(a)\n", "#The value of D for part (a),(b),(c)\n", "D1=1 #for digital input 00000001\n", "D2=128\t\t#for digital input 10000000\n", "D3=255\t\t#for digital input 11111111\n", "Iout1=I*D1\n", "Iout2=I*D2\n", "Iout3=I*D3\n", "Iout_1=Ifs-Iout1*10**-3\n", "Iout_2=Ifs-Iout2*10**-3\n", "Iout_3=Ifs-Iout3*10**-3\n", "\n", "#Result\n", "print\"(a) The Iout is\",Iout1,\"mA and Iout_ is\",round(Iout_1,3),\"mA\"\n", "print\"(b) The Iout is\",Iout2,\"mA and Iout_ is\",round(Iout_2,3),\"mA\"\n", "print\"(c) The Iout is\",Iout3,\"mA and Iout_ is\",Iout_3,\"mA\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(a) The Iout is 7.812 mA and Iout_ is 1.984 mA\n", "(b) The Iout is 999.936 mA and Iout_ is 0.992 mA\n", "(c) The Iout is 1992.06 mA and Iout_ is 0.0 mA\n" ] } ], "prompt_number": 35 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.10 Page no 417" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "#From fig 14.8 (a)\n", "Vref=10 #V\n", "Rf=5\t\t#kohm\n", "Rref=5.0\t\t#kohm\n", "n=8\t\t#\n", "\n", "#Calculation\n", "VR=Vref*Rf/(Rref*2**n)\n", "D1=1\t\t#Value of D for 00000001\n", "D2=255\t\t#Value of D for 11111111\n", "Vo1=VR*1000*D1\n", "Vo2=VR*1000*D2\n", "\n", "#Result\n", "print\"(a) Vo is \",round(Vo1,0),\"V\"\n", "print\"(b) Vo is \",round(Vo2/1000,3),\"V\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(a) Vo is 39.0 V\n", "(b) Vo is 9.961 V\n" ] } ], "prompt_number": 43 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 14.11 Page no 418" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given\n", "#From fig 14.9(a)\n", "I=8 #microA, value of 1 LSB\n", "Rf=5\t\t# kohm\n", "\n", "#Calculation\n", "#from eq 14-15(a)\n", "Ifs=I*10**-3*255\n", "D1=0 \t\t#Value of D for 00000000\n", "Iout1=I*D1\n", "Iout_1=Ifs-Iout1\n", "Vo1=(Iout1-Iout_1)*Rf\n", "\n", "D2=127 #From digital value(b)\n", "Iout2=I*D2\n", "Iout_2=Ifs-Iout2/1000.0\n", "Vo2=(Iout2/1000.0-Iout_2)*Rf\n", "\n", "D3=128 \t\t#Value of D for 00000000\n", "Iout3=I*D3\n", "Iout_3=Ifs-Iout3/1000.0\n", "Vo3=(Iout3/1000.0-Iout_3)*Rf\n", "\n", "D4=255 \t\t#Value of D for 00000000\n", "Iout4=I*D4\n", "Iout_4=Ifs-Iout4/1000\n", "Vo4=(Iout4/1000-Iout_4)*Rf\n", "\n", "#Result\n", "print\"(a)Vo is \",Vo1,\"V . (b)Vo is \",round(Vo2,3),\"V. (c)Vo is \",Vo3,\"V .(d)Vo is \",round(Vo4,0),\"V\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 2.04\n", "(a)Vo is -10.2 V . (b)Vo is -0.04 V. (c)Vo is 0.04 V .(d)Vo is 10.0 V\n" ] } ], "prompt_number": 35 } ], "metadata": {} } ] }