What’s the point of a DAC and why do I care?

If we all live in a “digital” world where seemingly everything is controlled by a computer, why do we still use a digital-to-analog converter (a DAC)?

Isn’t analog a thing of the past? Why not just use pulse-width modulation (PWM)?

Despite having used DACs on multiple occasions, I found myself questioning their true usefulness when I asked those questions. None of Digilent’s FPGAs or microcontrollers 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.

The PmodDA2 all wired up.
The PmodDA2 (a DAC) all wired up.
A PWM Circuit all wired up.
A PWM Circuit all wired up.

To explore this, let’s tackle the first question: isn’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 “analog” 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. Digital on the other hand, is either “on” or “off” so 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.

But back to the original question. While 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’s in a printer, the one that spins the hard drive on your computer, or the motor in a small robot, uses analog signals to spin at precise speeds. Any dimmable 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 PmodDA2 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.

But the biggest thing that analog signals are commonly used for is sound. If you’ve ever played music or listened to a video on your phone or laptop, a DAC was used (like the PmodI2S) 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.

This is the biggest question that doesn’t have an easy answer. In many cases, PWM will be good enough to suit your needs. If you are re-creating the Pmod Racing Ruler, motors can easily be controlled by a PmodDHB1 through PWM. You can also use pulse-width modulation to make an LED “breathe,” but both of these projects have a single dedicated task or only use a very small amount of processing resources.

With sound, you often need to be able to filter out any extraneous noise from the environment without distorting the desired sound. The PmodI2S accomplishes 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 of the sound we are interested in — something that PWM cannot accomplish.

However, that doesn’t mean that PWM cannot be used to produce sound; PWM was used to produce the in-game sounds through the PmodAMP2 in the February 2016 edition of Pmod Monthly. It sounds 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 obsolete. It simply depends on what kind of application you are trying to implement!

Which one do you find yourself using more often?

Author

  • James Colvin

    A local Digilent employee who is sometimes tricked into making other content besides documentation and supporting customers on the Digilent Forum, but then I get to write a little more informally so that's a plus. A sassy engineer, lover of puns and dad jokes, father and husband. I know both way too much and simultaneously almost nothing about a number of nerdy topics. If you want to hear me rant, ask me what data rate USB C operates at.

About James Colvin

A local Digilent employee who is sometimes tricked into making other content besides documentation and supporting customers on the Digilent Forum, but then I get to write a little more informally so that's a plus. A sassy engineer, lover of puns and dad jokes, father and husband. I know both way too much and simultaneously almost nothing about a number of nerdy topics. If you want to hear me rant, ask me what data rate USB C operates at.

View all posts by James Colvin →

Leave a Reply

Your email address will not be published. Required fields are marked *