{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 12 Analog To Digital Converter(A/D Converter)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 12.2 Pg 350" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Normalized step size of A/D converter is = 0.00390625\n", "Actual step size of A/D converter is = 0.046875\n", "Normalized maximum quantization level of A/D converter is = 0.9961\n", "Actual maximum quantization level of A/D converter is = 11.9531\n", "Normalized peak quantization error of A/D converter is = 0.001953\n", "Actual peak quantization error of A/D converter is = 0.023438 V \n", "Percentage of quantization error of A/D converter is = 0.1953\n" ] } ], "source": [ "from __future__ import division\n", "# Determine the following parameter of 8-bit A/D converter a) Normalized step size b) Actual step size c) Normalized maximum quantization level d) Actual maximum quantization e) Normalized peak quantization error f) Actual peak quantization error g) Percentage of quantization error\n", "N = 8 #\n", "Vin = 12 #\n", "\n", "#a) Normalized step size of A/D converter\n", "Ns = 2**-N #\n", "print 'Normalized step size of A/D converter is = %0.8f'%Ns\n", "\n", "# b) Actual step size of A/D converter\n", "As = Vin*Ns #\n", "print 'Actual step size of A/D converter is = %0.6f'%As\n", "\n", "# c) Normalized maximum quantization level of A/D converter\n", "Qmax = 1-2**-N #\n", "print 'Normalized maximum quantization level of A/D converter is = %0.4f'%Qmax\n", "\n", "# d) Actual maximum quantization level of A/D converter\n", "QAmax = Qmax*Vin #\n", "print 'Actual maximum quantization level of A/D converter is = %0.4f'%QAmax\n", "\n", "# e) Normalized peak quantization error of A/D converter\n", "Qp = 2**-(N+1)#\n", "print 'Normalized peak quantization error of A/D converter is = %0.6f'%Qp\n", "\n", "# f) Actual peak quantization error of A/D converter\n", "Qe = Qp*Vin #\n", "print 'Actual peak quantization error of A/D converter is = %0.6f'%Qe,' V '#\n", "\n", "# g) Percentage of quantization error of A/D converter\n", "per_Qp = 2**-(N+1)*100 #\n", "print 'Percentage of quantization error of A/D converter is = %0.4f'%per_Qp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 12.3 Pg 351" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "charging time of capacitor is = 128.00 u sec\n", "the integrator output is = -5.44 V\n", "the decimal output of a dual slope A/D converter is = 217.60 = 218\n", "The binary output of a dual slope A/D converter is = 11011010\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the binary output of the 8-bit dual slope A/D converter\n", "Vin = 8.5 #\n", "VR = 10 #\n", "f = 2 # #MHz\n", "N = 8 #\n", "C = 0.1*10**-6 #\n", "R = 2*10**3 #\n", "\n", "# the output of integrator is defined as \n", "# Viao(T1) = -(Vin/R*C)*T1 #\n", "\n", "# charging time of capacitor \n", "T1 = 2**N/f #\n", "print 'charging time of capacitor is = %0.2f'%T1,' u sec'\n", "\n", "# the integrator output\n", "T1 = T1*10**-6 #\n", "Viao =-(Vin/(R*C))*T1#\n", "print 'the integrator output is = %0.2f'%Viao,' V'\n", "\n", "# the binary output of a dual slope A/D converter\n", "Bn = (2**N*Vin)/VR#\n", "print 'the decimal output of a dual slope A/D converter is = %0.2f'%Bn,' = 218'#\n", "\n", "Bn=218#\n", "Bn = bin(Bn) #\n", "print 'The binary output of a dual slope A/D converter is =',Bn[2:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 12.4 Pg 352" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Resolution of an A/D converter is = 0.0037 V \n" ] } ], "source": [ "from __future__ import division\n", "# to determine the resolution of 12-bit A/D converter\n", "N =12 #\n", "Vin = 15 #\n", "\n", "# Resolution of an A/D converter\n", "Resolution = Vin/(2**N-1)#\n", "print 'Resolution of an A/D converter is = %0.4f'%Resolution,' V '\n", "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 12.5 Pg 352" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The output time of a V/T converter is = 0.15 msec\n", "The duty cycle of V?T converter is = 2.00\n", "The output voltage of an integrator is is = -0.75 V\n" ] } ], "source": [ "from __future__ import division\n", "# to determine the output time and duty cycle of V/T converter\n", "Vin = 5 #\n", "C = 0.1*10**-6 # \n", "R = 10*10**3 #\n", "C1 = 100*10**-6 #\n", "\n", "# The output time of a V/T converter is given as\n", "T = (7.5*C1)/(Vin) #\n", "print 'The output time of a V/T converter is =',T*1000,' msec'\n", "\n", "TH = 0.075 #\n", "TL=TH # # we consider\n", "# The duty cycle of V?T converter\n", "D = (TL+TH)/(TH) #\n", "print 'The duty cycle of V?T converter is = %0.2f'%D\n", "\n", "# The output voltage of an integrator is define as\n", "Vio = -(Vin)/(R*C)*T #\n", "print 'The output voltage of an integrator is is = %0.2f'%Vio,' 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 }