{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 11: Digital to Analog converter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.10: determine_the_analog_output_voltage_and_feed_back_current_If.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.10 // determine the analog output voltage and feed back current If\n", "clc;\n", "clear;\n", "close;\n", "Vref = 15 ; \n", "BI = 1000 ;\n", "Rf = 40 ; // K ohm\n", "R = 0.4*Rf ;\n", "\n", "// by using voltage divider rule Vin can be calculated as\n", " Vin = -(Vref*2*R)/(2*R+2*R) ;\n", " \n", "// The output voltage of given R-2R ladder D/A converter is defined as\n", "\n", "// Vo = -(Rf*Vin/R)\n", "\n", "Vo = (Vref*Rf)/(2*R)\n", "disp('for the binary input 1000 output voltage is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.11: EX11_11.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.11 // to find the resolution and analog output voltage of 8-bit D/A converter\n", "clc;\n", "clear;\n", "close;\n", "VFS = 10 ;\n", "N = 8 ;\n", "BI = 10101111 ; BI = 11100011 ; BI = 00101001 ; BI = 01000110\n", "\n", "// the resolution of 8-bit D/A converter is defined as\n", "Resolution = VFS/(2^N-1) ;\n", "\n", "// An analog output voltage of D/A converter is given by\n", "// Vo = Resolution*(2^-0*b0+2^-1*b1+....+2^-N*bn-1)\n", "// Vo = Resolution*(2^-0*b0+2^-1*b1+2^-2*b2+2^-3*b3+2^-4*b4+2^-5*b5+2^-6*b6+2^-7*b7);\n", "\n", "// For the BI 10101111 output analog voltage is\n", "BI = '10101111';\n", "BI = bin2dec(BI);\n", "Vo = Resolution*BI ;\n", "disp('For the BI 10101111 output analog voltage is = '+string(Vo)+ ' V ');\n", "\n", "// For the BI 11100010 output analog voltage is\n", "BI = '11100010';\n", "BI = bin2dec(BI);\n", "Vo = Resolution*BI ;\n", "disp('For the BI 11100010 output analog voltage is = '+string(Vo)+ ' V ');\n", "\n", "// For the BI 00101001 output analog voltage is\n", "BI = '00101001';\n", "BI = bin2dec(BI);\n", "Vo = Resolution*BI ;\n", "disp('For the BI 00101001 output analog voltage is = '+string(Vo)+ ' V ');\n", "\n", "// For the BI 01000110 output analog voltage is\n", "BI = '01000110';\n", "BI = bin2dec(BI);\n", "Vo = Resolution*BI ;\n", "disp('For the BI 01000110 output analog voltage is = '+string(Vo)+ ' V ');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.1: to_determine_the_full_scale_voltage_of_Digital_to_analog_converter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.1 // to determine the full scale voltage of D/A\n", "clc;\n", "clear;\n", "close;\n", "Vref = 12 ;\n", "Rf = 10 ; // K ohm\n", "R = 5 ; // K ohm\n", "\n", "// the full scale voltage of D/A converter \n", "VFS = Vref*(Rf/R) ;\n", "disp('the full scale voltage of D/A converter VFS is = '+string(VFS)+ ' V ');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.2: EX11_2.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.2 // determine the output voltage of D/A converter for the binary inputs a) 10101010 b) 11001100 c) 11101110 d) 00010001 \n", "clc;\n", "clear;\n", "close;\n", "del = 12*10^-3 ; // mA\n", "\n", "// the input voltage of D/A converter \n", " //Vo = del*binary input (BI)\n", "\n", "// For BI 10101010 the output\n", "BI = '10101010' ;\n", "BI = bin2dec(BI);\n", "Vo = del*BI ;\n", "disp('For BI 10101010 the output of D/A converter is = ' +string(Vo)+ ' V ');\n", "\n", "// For BI 11001100 the output\n", "BI = '11001100' ;\n", "BI = bin2dec(BI);\n", "Vo = del*BI ;\n", "disp('For BI 11001100 the output of D/A converter is = ' +string(Vo)+ ' V ');\n", "\n", "// For BI 11101110 the output\n", "BI = '11101110' ;\n", "BI = bin2dec(BI);\n", "Vo = del*BI ;\n", "disp('For BI 11101110 the output of D/A converter is = ' +string(Vo)+ ' V ');\n", "\n", "// For BI 00010001 the output\n", "BI = '00010001' ;\n", "BI = bin2dec(BI);\n", "Vo = del*BI ;\n", "disp('For BI 00010001 the output of D/A converter is = ' +string(Vo)+ ' V ');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.3: determine_the_resolution_of_4_bit_digital_to_analog_converter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.3 // determine the resolution of 4-bit D/A converter\n", "clc;\n", "clear;\n", "close;\n", "VFS = 12 ;\n", "N = 4 ;\n", "\n", "// the resolution of 4-bit D/A converter is defined as\n", "Resolution = VFS/(2^N-1) ;\n", "disp('the resolution of 4-bit D/A converter is = '+string(Resolution)+ ' V ');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.4: EX11_4.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.4 // determine the number of bit required to design a 4-bit D/A converter\n", "clc;\n", "clear;\n", "close;\n", "VFS = 5 ;\n", "Resolution = 10*10^-3 ; // A\n", "\n", "// the resolution of 4-bit D/A converter is defined as\n", "// Resolution = VFS/(2^N-1) ;\n", "N = (VFS/Resolution)+1 ; \n", "N = log10(N)/log10(2);\n", "disp('the number of bit required to design a 4-bit D/A converter is = '+string(N)+ ' = 9 ');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.5: determine_the_analog_output_voltage.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.5 // determine the analog output voltage\n", "clc;\n", "clear;\n", "close;\n", "Vref = 12 ; \n", "BI = 101 ; BI = 111 ; BI = 011 ; BI = 001 ; BI = 100 ;\n", "Rf = 40*10^3 ;\n", "R = 0.25*Rf ;\n", "\n", "// The output voltage of given binary weighted resistor D/A converter is defined as\n", "\n", "// Vo = -(Rf*Vref/R)*(2^0*b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// Vo = -(Rf*Vref/R)*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the given value Rf,R and Vref the output voltage\n", "\n", "// Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the binary input 101 analog output is\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 101 analog output is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 111 analog output is\n", "b2 = 1 ;\n", "b1 = 1 ;\n", "b0 = 1 ;\n", "Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 111 analog output is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 011 analog output is\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 1 ;\n", "Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 011 analog output is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 001 analog output is\n", "b2 = 0 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 001 analog output is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 100 analog output is\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 0 ;\n", "Vo = -48*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 100 analog output is = '+string(Vo)+ ' V');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.6: determine_the_analog_output_voltage_and_feed_back_current_If.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.6 // determine the analog output voltage and feed back current If\n", "clc;\n", "clear;\n", "close;\n", "Vref = 12 ; \n", "BI = 1001 ; BI = 1101 ; BI = 1010 ; BI = 0011 ;\n", "Rf = 25 ; // K ohm\n", "R = 0.25*Rf ;\n", "\n", "// The output voltage of given binary weighted resistor D/A converter is defined as\n", "\n", "// Vo = -(Rf*Vref/R)*(2^0*b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// Vo = -(Rf*Vref/R)*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// for the given value Rf,R and Vref the output voltage\n", "\n", "// Vo = -60*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// for the binary input 1001 analog output is\n", "b3 = 1 ;\n", "b2 = 0 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "Vo = -60*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1001 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 1101 analog output is\n", "b3 = 1 ;\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "Vo = -60*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1101 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 1010 analog output is\n", "b3 = 1 ;\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 0 ;\n", "Vo = -60*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1010 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 0011 analog output is\n", "b3 = 0 ;\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 1 ;\n", "Vo = -60*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 0011 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.7: determine_the_feed_back_current_If_and_analog_output_voltage.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "\n", "//Example11.7 // determine the feed back current If and analog output voltage\n", "clc;\n", "clear;\n", "close;\n", "Vref = 8 ; // V\n", "BI = 001 ; BI = 010 ; BI = 110 ;\n", "Rf = 25*10^3 ; // Hz\n", "R = 0.2*Rf ;\n", "\n", "// The output current of given binary weighted resistor D/A converter is defined as\n", "\n", "// If = -(Vref/R)*(2^0*b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// If = -(Vref/R)*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the given value Rf,R and Vref the output current\n", "\n", "// If = -(1.6*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the binary input 001 the feedback current If is given by\n", "b2 = 0 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "If = (1.6*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 001 analog output is = '+string(If*1000)+ ' mA ');\n", "\n", "// An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 010 the feedback current If is given by\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 0 ;\n", "If = (1.6*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 010 analog output is = '+string(If*1000)+ ' mA');\n", "\n", "// the An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 110 the feedback current If is given by\n", "b2 = 1 ;\n", "b1 = 1 ;\n", "b0 = 0 ;\n", "If = (1.6*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 110 analog output is = '+string(If*1000)+ ' mA ');\n", "\n", "// the An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.8: determine_the_feed_back_current_If_and_analog_output_voltage.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.8 // determine the feed back current If and analog output voltage\n", "clc;\n", "clear;\n", "close;\n", "Vref = 5 ; \n", "BI = 101 ; BI = 011 ; BI = 100 ; BI = 001 ;\n", "Rf = 25*10^3 ; \n", "R = 0.2*Rf ;\n", "\n", "// The output current of given R-2R ladder D/A converter is defined as\n", "\n", "// If = -(Vref/2*R)*(2^0*b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// If = -(Vref/2*R)*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the given value Rf,R and Vref the output current\n", "\n", "// If = (0.5*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "\n", "// for the binary input 101 the feedback current If is given by\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "If = (0.5*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 101 analog output is = '+string(If)+ ' A ');\n", "\n", "// An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 011 the feedback current If is given by\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 1 ;\n", "If = (0.5*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 011 analog output is = '+string(If)+ ' A');\n", "\n", "// the An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "\n", "\n", "// for the binary input 100 the feedback current If is given by\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 0 ;\n", "If = (0.5*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 100 analog output is = '+string(If)+ ' A ');\n", "\n", "// the An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "\n", "// for the binary input 001 the feedback current If is given by\n", "b2 = 0 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "If = (0.5*10^-3)*(b0+2^-1*b1+2^-2*b2) ;\n", "disp('for the binary input 001 analog output is = '+string(If)+ ' A ');\n", "\n", "// the An analog output voltage Vo is\n", "Vo = -If*Rf ;\n", "disp('An analog output voltage Vo is = '+string(Vo)+ ' V ');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.9: determine_the_analog_output_voltage_and_feed_back_current_If.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//Example11.9 // determine the analog output voltage and feed back current If\n", "clc;\n", "clear;\n", "close;\n", "Vref = 10 ; \n", "BI = 1001 ; BI = 1100 ; BI = 1010 ; BI = 0011 ;\n", "Rf = 50 ; // K ohm\n", "R = 0.4*Rf ;\n", "\n", "// The output voltage of given R-2R ladder D/A converter is defined as\n", "\n", "// Vo = -(Rf*Vref/2R)*(2^0*b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// Vo = -(Rf*Vref/2R)*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// for the given value Rf,R and Vref the output voltage\n", "\n", "// Vo = -12.5*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "\n", "// for the binary input 1001 analog output is\n", "b3 = 1 ;\n", "b2 = 0 ;\n", "b1 = 0 ;\n", "b0 = 1 ;\n", "Vo = -12.5*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1001 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 1100 analog output is\n", "b3 = 1 ;\n", "b2 = 1 ;\n", "b1 = 0 ;\n", "b0 = 0 ;\n", "Vo = -12.5*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1100 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 1010 analog output is\n", "b3 = 1 ;\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 0 ;\n", "Vo = -12.5*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 1010 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "\n", "\n", "// for the binary input 0011 analog output is\n", "b3 = 0 ;\n", "b2 = 0 ;\n", "b1 = 1 ;\n", "b0 = 1 ;\n", "Vo = -12.5*(b0+2^-1*b1+2^-2*b2+2^-3*b3) ;\n", "disp('for the binary input 0011 analog output is = '+string(Vo)+ ' V ');\n", "\n", "// the feedback current If is given by\n", "If = -(Vo/Rf) ;\n", "disp('the feedback current If is = '+string(If)+ ' mA ');\n", "" ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }