The Resistor Ladder: An Easy to build Digital to Analog Converter

What is the Resistor Ladder?

The resistor ladder is a simple to build circuit that functions as a digital to analog converter (DAC). So what are DACs used for? Well the most common use is audio generation. The media files on your phone (or iPod, MP3 player, what have you) are stored digitally on the devices memory. When the music is played, the microprocessor in the device outputs a string of bits to the DAC. That string of bits represents the amplitude of sound at a specific point in time. Now you headphones don't work off binary; they need varying voltages in order to make sound. This is where the DAC comes in; it's purpose is to systematically convert the binary value into a voltage value that can then drive the speaker.

2 Resistor ladders implemented on a PCB to generate Audio and Video
2 Resistor ladders implemented on a PCB to generate Audio and Video

Just like audio, video signals can be represented as binary values, so DACs are used for that as well. However that is becoming a rare thing with the advent of technology like HDMI, which send signals in a completely digital manner.

Now, why did I choose to write about resistor ladders, rather than DACs as a whole? Well, the cool thing about resistor ladders, is they are simple in every aspect. Simple to build. Simple to interface with. Simple to do circuit analysis with. There are a few drawbacks which we'll get to later, but first let's take a look at how the circuit works.

A 6 bit resistor ladder built on a breadboard using only 1KΩ resistors
A 6 bit resistor ladder built on a breadboard using only 1KΩ resistors


How do they work?

The resistor ladder works by dividing the input voltage at each bit by a certain ratio, such that the smallest bit (the least significant bit or LSB) changes the output very little, and the largest bit (the most significant bit (MSB)) effects the output the greatest. The anatomy of the circuit is fairly simple, and can be seen below. Note that any value of resistors can be used as long as the 2R resistors are twice as large as the R resistors. The configuration can expand for any number of bits. It also should be noted that as resoluton increases (more bits), you're going to want hire accuracy resistors, otherwise it may not operate linearly.

A 4 bit resistor ladder
A 4 bit resistor ladder

1 Bit Example

Let's take a look at the lowest resolution resistor ladder possible; a single bit. The analysis for this circuit is pretty simple, if the B0 is off, there is no current through the circuit, and therefore the output will be 0 volts. When B0 is on, or at 5V, the circuit is acting as a voltage divider, and will follow the standard equation:
$$\small{OUTPUT = 5V*\frac{2R}{2R+2R} = 2.5V}$$

A 1 bit resistor ladder
A 1 bit resistor ladder

Anything seem weird here? What good is this doing? Well, to be honest it's not a very good DAC right now, because it is at a very low resolution. In fact it's as low as you can go. One thing to take note of in this example however, is that the circuit does not output the full "swing" of the possible voltage. Meaning, you'd like your signal to be able to range from 0V to 5V, but it's falling short. This is a problem that comes up with this DAC regardless of resolution. However, as resolution increases, the max output of the DAC approaches the supply voltage asymptotically.

Digital Input Output
B0=0 0V
B0=1 2.5V

2 Bit Example

Let's look at the next step up in resolution: 2 bits. The circuit analysis becomes a bit more difficult, but nothing too extreme. Let's look at all of the cases.

A 2 bit resistor ladder
A 2 bit resistor ladder

  • Input = "00b"
    When the input is 00or simply "0", there is no current flowing through the circuit, and therefore no voltages present at any point. The Output would be equal to 0V.
  • Input = "01b"
    When the input is a decimal value of 1, B0 is at 5V and B1 is at 0V or GND. Since B1 is at GND, the 2R and R resistor connected to it are now in parallel with the 2R resistor connecting to the GND reference. We can find the voltage ($V_A$) at the end of the B0 2R resistor:
    $$\small{V_A= 5V *\frac{2R||(R+2R)}{2R+2R||(R + 2R)} =1.875V}$$
    This is not yet the end result as the 1.875V at $V_A$ is now divided across an R and 2R resistor. We apply the voltage divider equation to get the output
    $$\small{OUTPUT = 1.875*\frac{2R}{R + 2R} = 1.25V}$$
  • Input = "10b"
    For a decimal input of 2, B0 is 0V, and B1 is at 5V. The 2R resistor connection to B0 and the 2R resistor connecting to GND are in parallel, turning this problem into a voltage divider problem to find the output:
    $$\small{OUTPUT = 5V*\frac{R+2R||2R}{2R + R+2R||2R} = 2.5V}$$
  • Input = "11b"
    Lastly for a decimal input of 3, both B0 and B1 is at 5V. We can apply a similar trick as we did for an input of "1." The 2R and R resistor connected to B1 are in parallel to the 2R resistor connected to B0. So we can find the voltage ($V_A$) at the 2R resistor connecting to GND by the following Equation:
    $$\small{V_A=5V*\frac{2R}{(2R+R)||2R + 2R)} = 3.125V}$$
    Now to get the output, we know the voltage across B1's 2R resistor and the R resistor must equal 5V-3.125V, or 1.875V. To get the output, Now taking that voltage across the divider made by 2R and R, we get 0.625V. Adding this to it's reference of 3.125V yields the output as 3.75V.
Binary Input Decimal Input Voltage Output
00 0 0V
01 1 1.25V
10 2 2.5V
11 3 3.75V
 A graph showing the output of a 2 bit resistor ladder with 5V Logic level inputs
 A graph showing the output of a 2 bit resistor ladder with 5V Logic level inputs

There's definitely a trend going on here. Despite the fact that the analysis steps were pretty different for each configuration, we see that each time the input increases by "1", the voltage increases by 1.25V. This is a linear relationship, that is modeled by a standard equation:
$$\small{V_{out}=IN_B*\frac{V_{ref}}{2^N}}$$
Where $IN_B$ is the value of the binary input, $V_{ref}$ is your logic level (I used 5V for all of the examples), and $N$ is the the bit resolution of the resistor ladder.

Notice our maximum voltage output (3.75V) got closer than the 1 bit DAC's maximum (2.5V) to the absolute maximum ot 5V. This is a known problem that one must deal with in the circuit. The other problem is that the circuit cannot directly be connected to a load. If it is, the resistance of the load will throw off the balance of the circuit, causing faulty operation. This can be fixed fairly simply, by hooking the circuit's output to some sort of voltage follower amplifier (Be it a transistor, or an op-amp). The last problem that all DACs have at their route level is that the voltage levels are discrete. This means that as the voltage is changes, it does no do so in a strait line. Instead it must increase in steps, as seen in the figure below. This problem can be solved by some simple filtering

An Oscilloscope of a resistor ladder output. Note the stair step pattern of increase
An Oscilloscope of a resistor ladder output. Note the stair step pattern of increase