{"id":15424,"date":"2016-08-26T10:00:19","date_gmt":"2016-08-26T17:00:19","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=15424"},"modified":"2016-08-26T15:29:29","modified_gmt":"2016-08-26T22:29:29","slug":"whats-the-point-of-a-dac-and-why-do-i-care","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/whats-the-point-of-a-dac-and-why-do-i-care\/","title":{"rendered":"What&#8217;s the point of a DAC and why do I care?"},"content":{"rendered":"<p>If we all live in a &#8220;digital&#8221; world where seemingly everything is controlled by a computer, why do we still use a digital-to-analog converter (a DAC)?<\/p>\n<p>Isn&#8217;t analog a thing of the past? Why not just use pulse-width modulation (PWM)?<\/p>\n<p>Despite having used <a href=\"https:\/\/digilent.com\/blog\/digilent-pmods-digital-to-analog-converters\/\" target=\"_blank\">DACs<\/a> on multiple occasions, I found myself questioning their true usefulness when I asked those questions. None of Digilent&#8217;s <a href=\"https:\/\/digilent.com\/shop\/fpga-programmable-logic\/\">FPGAs <\/a>or <a href=\"https:\/\/digilent.com\/shop\/embedded-processors\/\">microcontrollers <\/a>have a dedicated DAC that is available for general use. On the other hand, pulse width modulation is a technique that takes relatively few lines of code to implement and is very relevant in the working world. PWM also only takes up one digital output pin to emulate an analog signal while a DAC commonly takes up to 3 or 4 output pins.<\/p>\n<figure id=\"attachment_16448\" aria-describedby=\"caption-attachment-16448\" style=\"width: 366px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16448\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit-366x600.jpg\" alt=\"The PmodDA2 all wired up.\" width=\"366\" height=\"600\" data-wp-pid=\"16448\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit-366x600.jpg 366w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit-768x1259.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit-625x1024.jpg 625w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit-732x1200.jpg 732w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Circuit.jpg 1389w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><figcaption id=\"caption-attachment-16448\" class=\"wp-caption-text\">The PmodDA2 (a DAC) all wired up.<\/figcaption><\/figure>\n<figure id=\"attachment_16451\" aria-describedby=\"caption-attachment-16451\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16451\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/PWM-Circuit-600x432.jpg\" alt=\"A PWM Circuit all wired up.\" width=\"600\" height=\"432\" data-wp-pid=\"16451\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/PWM-Circuit-600x432.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/PWM-Circuit-768x553.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/PWM-Circuit-1024x737.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/PWM-Circuit-800x576.jpg 800w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption id=\"caption-attachment-16451\" class=\"wp-caption-text\">A PWM Circuit all wired up.<\/figcaption><\/figure>\n<p>To explore this, let&#8217;s tackle the first question: isn&#8217;t analog a thing of the past? Before we get too far into this (outside of the short answer, which is no), I think we should define what &#8220;analog&#8221; is. Analog is a way to measure or represent something in an analogous fashion; you get a physically moving object that is a representation of the phenomena you are attempting to measure. Correspondingly, an analog signal is one that represents a physical phenomenon in a smooth and continuous fashion; there is no threshold that needs to be reached in order for the representative value to change.<em>\u00a0<\/em>Digital on the other hand, is either &#8220;on&#8221; or &#8220;off&#8221;\u00a0so you need to send out multiple pulses if you want to represent anything besides on or off. Additionally, you have to send out more pulses to emulate more precise analog values.<\/p>\n<p>But back to the original question.\u00a0While much of the processing of information does solely exist in the digital realm, analog is not a thing of the past. Any sort of motor, whether it&#8217;s in a printer, the one that spins the hard drive on your computer, or the motor in\u00a0a\u00a0small robot, uses analog signals to spin at precise speeds. Any\u00a0dimmable display uses an analog signal to get a variable brightness for your screen. If your processing resources are limited, using a DAC such as the <a href=\"https:\/\/digilent.com\/shop\/pmodda2-two-12-bit-d-a-outputs\/\" target=\"_blank\">PmodDA2<\/a> to set your analog output value (or multiple output values) once and not have to continually send a PWM signal to emulate the analog output, is suddenly a very attractive option.<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" width=\"735\" height=\"413\" src=\"https:\/\/www.youtube.com\/embed\/2n8qEecZhAU?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/div>\n<p>But the biggest thing that analog signals are commonly used for is sound. If you&#8217;ve ever played music or listened to a video on your phone or laptop, a DAC was used (like the <a href=\"https:\/\/digilent.com\/shop\/pmodi2s-stereo-audio-output\/\" target=\"_blank\">PmodI2S<\/a>) to create analog sound that you hear through the speakers. But then the question becomes why not use pulse-width modulation (PWM) over a DAC? After all, pulse width modulation, as mentioned earlier, can emulate an analog signal.<\/p>\n<p><strong>This is the biggest question that doesn&#8217;t have an easy answer<\/strong>. In many cases, PWM will be good enough to suit your needs. If you are re-creating the <a href=\"https:\/\/www.youtube.com\/watch?v=xCHWgpdHZC8\" target=\"_blank\">Pmod Racing Ruler<\/a>,\u00a0motors can easily be controlled by a <a href=\"https:\/\/digilent.com\/shop\/pmoddhb1-dual-h-bridge\/\" target=\"_blank\">PmodDHB1<\/a>\u00a0through PWM. You can also use pulse-width modulation to make an <a href=\"http:\/\/www.instructables.com\/id\/How-to-use-Pulse-Width-Modulation\/\" target=\"_blank\">LED &#8220;breathe,&#8221;<\/a>\u00a0but both of these projects have a single dedicated task or only use a very small amount of processing resources.<\/p>\n<p>With sound,\u00a0you often need to be able to filter out any extraneous noise from the environment without distorting the desired sound. The <a href=\"https:\/\/digilent.com\/shop\/pmodi2s-stereo-audio-output\/\" target=\"_blank\">PmodI2S<\/a>\u00a0accomplishes this with its specialized DAC that takes incoming digital data and uses a function known as noise shaping to adjust low frequency noise so that it is changed to a higher frequency outside\u00a0of the sound we are interested in\u00a0\u2014 something that PWM cannot accomplish.<\/p>\n<p>However, that doesn&#8217;t mean that PWM cannot be used to produce sound; PWM was used to produce the in-game sounds through the <a href=\"https:\/\/digilent.com\/shop\/pmodamp3-stereo-power-amplifier\/\">PmodAMP2 <\/a>in the <a href=\"https:\/\/www.youtube.com\/watch?v=9Nlf6SDlX8w\" target=\"_blank\">February 2016 edition of Pmod Monthly<\/a>. It\u00a0sounds a little fuller than a formal audio DAC because the square wave nature of PWM includes other harmonics that are not the frequency being reproduced. But despite the usefulness of PWM, that does not mean DACs are\u00a0obsolete. It simply depends on what kind of application you\u00a0are trying to implement!<\/p>\n<p>Which one do you find yourself using more often?<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-15424 jlk' data-task='like' data-post_id='15424' data-nonce='5286a1c13f' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-15424 lc'>+1<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-15424 jlk' data-task='unlike' data-post_id='15424' data-nonce='5286a1c13f' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-15424 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-15424 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>James explains the usefulness and relevancy of a DAC!<\/p>\n","protected":false},"author":17,"featured_media":16457,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1563],"tags":[],"ppma_author":[4469],"class_list":["post-15424","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guide"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/08\/DAC-Box.jpg","jetpack_sharing_enabled":true,"authors":[{"term_id":4469,"user_id":17,"is_guest":0,"slug":"jamescolvin","display_name":"James Colvin","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/8aa85f7d11711acc7e571e1ed26c901b614a7064a2e15e522f54d9f26792ea9e?s=96&d=mm&r=g","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/15424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=15424"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/15424\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/16457"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=15424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=15424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=15424"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=15424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}