{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter : 12 - D/A and A/D Converters" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.1 : Page No - 444\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "n = 8 \n", "Resolution = 2**n \n", "print \"Part (ii) : The resolution = %0.f\" %Resolution \n", "print \"That is, the output voltage can have\",int(Resolution),\"different values including zero\"\n", "V_OFS = 2.55 # in V\n", "Resolution= V_OFS/(2**n - 1)*10**3 \n", "print \"\\nPart (i) : The resolution =\",int(round(Resolution)),\" mV/1LSB\"\n", "print \"That is, an input change of 1 LSB causes the output to change by \",round(Resolution),\" mV\"\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Part (ii) : The resolution = 256\n", "That is, the output voltage can have 256 different values including zero\n", "\n", "Part (i) : The resolution = 10 mV/1LSB\n", "That is, an input change of 1 LSB causes the output to change by 10.0 mV\n" ] } ], "prompt_number": 8 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.2 : Page No - 444\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "n = 4 \n", "V_OFS = 15 # in V\n", "digital_input = '0110' # in binary\n", "D= int(digital_input , 2) \n", "Resolution = V_OFS/((2**n)-1) # in V/LSB\n", "V_out = Resolution*D # in V\n", "print \"Final output voltage = %0.f V\" %V_out" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Final output voltage = 6 V\n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.3 : Page No - 445\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "n = 8 \n", "Resolution = 20 # in mV/LSB\n", "digital_input= '10000000' # in binary\n", "D= int(digital_input , 2) # in decimal\n", "Resolution=Resolution*10**-3 # in V/LSB\n", "V_OFS = Resolution * ((2**n)-1) # in V\n", "print \"The value of V_OFS = %0.1f V\" %V_OFS \n", "V_out = Resolution*D # in V\n", "print \"The value of V_out = %0.2f V\" %V_out " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The value of V_OFS = 5.1 V\n", "The value of V_out = 2.56 V\n" ] } ], "prompt_number": 12 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.4 : Page No - 445\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "#Given data\n", "n = 4 \n", "V_OFS = 5 # in V\n", "digital_input= '1000' # in binary\n", "D= int(digital_input , 2) # in decimal\n", "Resolution = V_OFS/((2**n)-1) \n", "V_out = Resolution * D # in V\n", "print \"When input is 1000 then, the output = %0.4f V\" %V_out \n", "# When\n", "digital_input= '1111' # in binary\n", "D= int(digital_input , 2) # in decimal\n", "V_out= Resolution * D # in V\n", "print \"When input is 1111 then , the output =%0.f V\" %V_out" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "When input is 1000 then, the output = 2.6667 V\n", "When input is 1111 then , the output =5 V\n" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.5 : Page No - 445\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "n=12 \n", "digital_input= '010101101101' # in binary\n", "D= int(digital_input , 2) # in decimal\n", "step_size= 8 # in mV\n", "step_size=step_size*10**-3 # in V\n", "VoFS= step_size*(2**n-1) # in V\n", "print \"The full scale output voltage = %0.2f V\" %VoFS\n", "Per_resolution= step_size/VoFS*100 # in %\n", "print \"Percentage resolution is = %0.5f\" %Per_resolution\n", "Vout= step_size*D # in V\n", "print \"The output voltage in V %0.3f\" %Vout" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The full scale output voltage = 32.76 V\n", "Percentage resolution is = 0.02442\n", "The output voltage in V 11.112\n" ] } ], "prompt_number": 17 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.6 : Page No - 450\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "V_R = 10 # in V\n", "n = 4 \n", "Resolution = 0.5 # in V\n", "R_F = 10 # in k ohm\n", "R = (1/2**n)*(V_R/Resolution)*R_F # in k ohm\n", "print \"The value of resistor = %0.1f k\u03a9\" %R " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The value of resistor = 12.5 k\u03a9\n" ] } ], "prompt_number": 19 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.7 : Page No - 456\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "V_i = 5.1 # in V\n", "n = 8 \n", "Re = 2**n \n", "Resolution = V_i/(2**n-1) # in V/LSB\n", "print \"The Resolution = %0.f mV/LSB\" %(Resolution*10**3) \n", "\n", "# When\n", "V_i = 1.28 # in V\n", "D = int(round(V_i/Resolution) )\n", "D_in_binary= bin(D) # in binary\n", "print \"The digital output = \",D_in_binary" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The Resolution = 20 mV/LSB\n", "The digital output = 0b1000000\n" ] } ], "prompt_number": 21 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.8 : Page No - 457\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "V_i = 4.095 #input voltage in V\n", "n = 12 \n", "Q_E = V_i/( ((2**n)-1)*2 ) # in V\n", "Q_E = Q_E * 10**3 # in mV\n", "print \"The quantizing error = %0.1f mV\" %Q_E" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The quantizing error = 0.5 mV\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.9 : Page No - 460\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "print \"Part (i)\"\n", "V_i = 100 # in mV\n", "V_R = 100 # in mV\n", "t1 = 83.33 # in ms\n", "t2 = (V_i/V_R)*t1 # in ms\n", "print \"The value of t2 = %0.2f ms\" %t2 \n", "print \"Part (ii)\"\n", "Vi = 200 # in mV\n", "t_2 = (Vi/V_R)*t1 # in ms\n", "print \"The value of t_2 = %0.1f ms\" %t_2" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Part (i)\n", "The value of t2 = 83.33 ms\n", "Part (ii)\n", "The value of t_2 = 166.7 ms\n" ] } ], "prompt_number": 25 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.10 : Page No - 460\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Given data\n", "C_F = 12 #clock frequency in kHz\n", "C_F = C_F * 10**3 # in Hz\n", "V_i = 100 # in mV\n", "V_R = 100 # in mV\n", "t1 = 83.33*10**-3 # in sec\n", "D = C_F * t1*(V_i/V_R) # in counts\n", "print \"The Digital output is : \",int(round(D,1)),\" counts\" \n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The Digital output is : 1000 counts\n" ] } ], "prompt_number": 26 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12.12 : Page No - 463\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from numpy import pi\n", "#Given data\n", "n = 8 \n", "T_C = 9 #in \u00b5sec\n", "T_C = T_C * 10**-6 # in sec\n", "f_max = 1/(2*pi*T_C*(2**n)) # in Hz\n", "print \"Maximum frequency = %0.2f Hz\" %f_max" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Maximum frequency = 69.08 Hz\n" ] } ], "prompt_number": 28 } ], "metadata": {} } ] }