At first, I was going to write about the analog to digital converter (ADC). I decided to write about the digital to analog converter instead.

Why?

I started gathering information about ADCs. Then it hit me: digital to analog converters (or DACs) are often part of analog to digital converters.

So, the topic this time will be the types of digital to analog converters and a bit (sorry for the pun) on how they work.

This post is an introductory post, so we won’t necessarily cover every single DAC out there, nor will we go into immense detail about how the ones we do discuss work, though we will touch on the basics.

DACs are simpler than ADCs, and unlike ADCs, there are only a few practical ones in use today.

Now, let’s delve into digital to analog converters and their types.

**Digital to Analog Conversion 101**

The function of a digital to analog converter is to convert a sequence of digital bits (usually stored in some sort of register) into an analog signal. That is, a DAC takes a binary number and converts it an analog voltage that is proportional to the binary number. If we feed a DAC with different binary numbers in quick succession a complete analog waveform is created.

If you’re not 100% sure what the difference between digital and analog is, my post Analog vs Digital: What’s the Difference? can help.

A typical DAC is an active circuit in the form of an IC and may consist of a data register, solid state switches, resistors, and op-amps powered by an external supply.

They can be either unipolar or bipolar. A unipolar DAC has a single polarity. A bipolar unit can have positive and negative output signals. These often use either offset binary or 2’s complement code rather than straight binary like DACs in unipolar mode do.

Sometimes, you’ll see a particular type of digital to analog converter listed as a multiplying DAC. These produce an output that is proportional to the product of a varying input reference (like a voltage) times a digital code. These commonly find a place in systems that use ratiometric transducers like position potentiometers, strain gauges, and pressure sensors to help correct errors that may occur.

The full-scale voltage (V_{FS}) of a DAC is the maximum analog level that it can reach when applying the highest binary code (which would be 1111 for a 4-bit DAC). In general, at full scale the analog output of an n-bit DAC is given by the equation below.

Eq 1: max output = ((2^{n}-1) / 2^{n}) V_{ref}

So, assuming a V_{ref }of 5 V, the maximum analog output of an 8-bit DAC would be about 4.98 V.

DACs find a home in op-amp gain control circuits, waveform generators, process control and autocalibration circuits, and consumer electronics such as MP3 players (often as part of a microcontroller).

A few examples of DACs you may use are the 8-bit DAC0808 and the 12-bit DAC8083A. Of course, there are others.

There are two main types of digital to analog converters that we’ll talk about in this post.

**Types of Digital to Analog Converters (DACs)**

**Binary-Weighted Digital to Analog Converter**

Below we have a simple, 4-bit binary-weighted digital to analog converter (a.k.a. weighted resistor DAC).

The picture is a bit simplified as it lacks the digital switches that switch the 4 bits on and off, but the basic gist remains the same.

*Figure 1: a weighted DAC. From Digital Fundamentals, 7 ^{th} Edition.*

The resistor values represent the binary weights of the input bits. I_{f }is the sum of currents I_{0 }through I_{3}. Due to the properties of the op-amp, almost no current flows into it, rather, current flows through the feedback resistor R_{f}. Another property of op-amps is that they try to keep both the inverting and non-inverting inputs at the same potential. Because the non-inverting input is grounded, the inverting input is also at 0 volts. This is known as a virtual ground.

If the input voltage is zero (binary 0000), the current is also obviously zero. If the input voltage is some other value (from a binary number greater than 0), then the amount of current depends on the input resistor value and is different for each resistor.

The values of the resistors are inversely proportional to the binary weights of the corresponding bits. For example, the lowest value resistor R corresponds to the MSB, 2^{3} in this case, which is eight (binary 1000). The other resistors are multiples of R.

This design makes the output voltage V_{out} proportional to the binary input value.

In practice, weighted resistor DACs are seldom used.

For example, if we want an 8-bit weighted resistor DAC, not only would we need 8 resistors, but the values of the resistors would need to be extremely precise (a tolerance less than 0.5% in this case) or conversion errors will result. We’ll touch on some conversion errors later.

These values would range from 1kΩ to 128kΩ (assuming R = 1kΩ).

As far as I know, there is no standard 128kΩ resistor in production, not to mention one with a tolerance of less than 0.5%! This is circuit is obviously difficult to manufacture, and as we’ll see in a minute, there is a better solution.

**The R/2R Ladder Digital to Analog Converter**

The R/2R ladder DAC overcomes the problems inherent with the weighted resistor DAC in that it requires only 2 resistor values. These values are standard values that are in production and usually range from 2kΩ to 10kΩ.

The circuit is expandable to any number of bits simply by adding one resistor of each value for each bit. This is another advantage of the R/2R DAC.

A simplified representation of an R/2R ladder digital to analog converter is shown below.

*Figure 2: an R/2R ladder DAC.* *From Digital Fundamentals, 7 ^{th} Edition.*

The circuit above requires an op-amp with a high slew rate (the rate at which the output changes after a step change in input). If you grab a standard 741 variety op-amp, the circuit will not accurately reproduce changes introduced by large changes in the digital input.

One way to analyze and understand how this circuit works is to replace the R/2R ladder with its Thévenin equivalent circuit, then treat it as an inverting amplifier.

The topic of Thévenin circuit equivalents is a subject that could at least take up another whole post, so I won’t go into any great detail about how or why it works here. Just know that it’s a way to simplify (or complicate, if you ask the average EE student) the analysis of electric circuits.

Looking in on the circuit from its left end, we see two 2R resistors in parallel. This simplifies to R. Now, the parallel combination of R_{1} and R_{2} are in series with R_{4}, giving us yet again 2R. Now this 2R combination is in parallel with R_{3}.

You get the idea.

The process repeats until we reach the op-amp. At this point, the total resistance of the ladder is just R. This is true regardless of how many inputs or bits we have.

In case you still don’t quite understand how this works, the picture below can help. R_{TH} is the Thévenin equivalent resistance.

*Figure 3: derivation of the Thé**venin equivalent of the R/2R circuit. Analysis starts on the left end with 2R ||2R.*

* *

Like the weighted resistor DAC, very little current flows into the op-amp and both terminals are at 0V. Thus, almost all the current flows through the feedback resistor and V_{out} is equal to -IR_{f}.

Because of this, the value of V_{out }DOES depend on the digital code, though the ladder’s total resistance does not. If we make R_{f} = R, then we can calculate the analog output using the equation below. This of course can be expanded for any number of bits.

Eq 2: V_{out} = -[d_{3}/2 + d_{2}/4 + d_{1}/8 + d_{0}/16] V_{ref}

Where V_{ref }is a logic HIGH and d_{x} is either a 1 or a 0.

The R/2R ladder and op-amp are at the heart of most types of digital to analog converters you’ll see today.

In fact, making a digital to analog converter from scratch isn’t worth it. You’re better off buying a DAC IC or using the one built into your microcontroller or ecosystem board.

**Digital to Analog Converter Performance Specs**

Several factors affect the performance of a DAC. Here are a few of the major ones to watch out for. Of course, I can’t cover every single possible spec a DAC could have in one blog post.

**Monotonicity**: Math geeks call a mathematical function monotonic if it is either increasing or decreasing on its entire domain. For example, X^{3} is monotonic (it always gets bigger whether X is negative or positive) and X^{2} is not (it decreases in the left quadrant and increases in the right quadrant). Such is similar with DACs. A DAC is monotonic if the output voltage increases every time the input code increases.

**Resolution**: The resolution of a DAC is the smallest voltage change the device can output for the smallest input change, such as when the LSB of a binary number changes. In other words, it is the measure of how finely its output may change between discrete, binary steps. This metric often results in confusion, for reasons we’ll tackle in a minute.

The resolution of a DAC can also refer to number of bits it can handle.

Resolution is often expressed as either a percentage or a voltage.

When expressing resolution as a percentage, we calculate it with the formula below.

Eq. 3: Resolution = [1 / (2^{n} – 1)] x 100

Where n is the number of bits.

When we want to express resolution as a voltage we can use the formula below.

Eq. 4: Resolution = V_{FS} / 2^{n}

Where n is again the number of bits and V_{FS} is the DAC’s full scale output voltage for the maximum binary input.

Note that sometimes you may see the formula for DAC resolution written as equation 5 below.

Eq.5: Resolution = V_{FS} /(2^{n}-1)

After poring over dozens of websites and books, I could not find any explanation as to why one would pick equation 5 over 4 or vice versa. Regardless, the difference in the answers you get is very small.

Below is my best educated guess as to why this is so. If I’m wrong and you know which formula is correct, please comment and let us know why.

My educated guess: People who use this formula are counting “steps” instead of voltage levels.

Remember that zero is a number and that the highest 8-bit number we can write is actually 255 (binary 1111 1111), not 256. This is because the “missing count” is used by the number zero (binary 0000 0000), so though we can represent 256 different numbers in 8 bits, our range is from 0-255, not 1-256.

Since zero is not a “step” from one level to another, we subtract 1 from the total number of possible values (2^{n}) in equation 5.

Since zero volts is technically a voltage level, many use the formula in equation 4. It really depends on the perspective you use. As always, be consistent with which ever you pick!

**Update: It seems I’m not the only one who’s noticed that there are two different formulas for resolution floating around the ‘Net. In his article Rectifying an A/D Conversion Error (Circuit Cellar, February 2017), David Ludington, a retired electrical engineer, writes about this. David and I seem to agree that what he calls the “Standard Convention” (or equation 4) is indeed the correct one. Though his article focuses on A/D converters, the thinking is the same for DACs. **

**According to David, even big sites like AdaFruit, SparkFun and the Arduino site have an equation similar to equation 5 listed. These are all wonderful resources. In no way am I trying to discredit them, but accuracy — especially in technical writing — is important. Depending on what your goal is, using eq. 5 instead of eq. 4 may not be a big deal. However, if you need high precision small errors can create big problems and the source may be hard to find. This can lead not only to faulty projects which don’t always perform as expected, but also frustration and wasted time.**

Anyway, onward we march…

**Settling time**: This is the time the output needs to switch and settle to within +/- ½ LSB when the input code switches from all 0s to all 1s. As a general rule of thumb, the settling time should be about half of the data arrival time, maybe less.

**Linearity**: A linear error is a deviation from the ideal straight-line output of the DAC. A linearity error of more than +/- ½ LSB can result in a nonmonotonic output. An offset error is a special case of a linear error. It is the amount of output voltage when all input bits are zero. A graph of the ideal output of a DAC looks like a straight line starting at the origin and increasing. Offset errors shift that line up or down so it does not start at the origin.

**Relative accuracy**: This is more frequently used than absolute accuracy (measure of output voltage with respect to its expected value). It measures the deviation of the actual from the ideal output voltage as a fraction of the full-scale voltage. Shoot for an accuracy no worse than +/- ½ LSB when picking a DAC.

You’ve now read over 2000 words, so that’s it for this post on the types of digital to analog converters.

There’s a lot more to say about these devices, so I’m sure we’ll see DACs appear again in a future post. Until next time, comment and tell us what you’re favorite DAC is. Is it a dedicated IC? Does it come as part of the package for a microcontroller or eco board? Let us know.

ig says

I will right away clutch your rss feed as I can not

find your e-mail subscription hyperlink or e-newsletter service.

Do you have any? Kindly allow me understand in order that I could subscribe.

Thanks.

Brian says

Hi, and thanks for your interest. There is a sign up form in the sidebar of the page that contains the actual post, and you get a free gift just for signing up.