Lab 7a: Digital-to-Analog Converter (DAC)
We live in a digital world. No wait... We live in an analog world.
Which is it? Perhaps the fairest statement is that we have formed a digital
interface to our fundamentally analog world. So any time we want to express
an analog quantity (typically voltage, even if the voltage represents some
other thing like temperature, time interval, etc.) in a digital form
consumable by a computer, we need an Analog-to-Digital Converter (ADC).
Likewise, when we need the computer to present an analog quantity to the
world, we need a Digital-to-Analog Converter (DAC).
DACs are in some sense more fundamental, as most implementations of ADCs
employ a DAC. In one form, the DAC output is compared against the analog
quantity (via a comparator, of course), and the digital input to the DAC is
swept through a range of numbers until the two match (or the sign of the
comparison changes).
We'll build our own 8-bit DAC capable of converting a value from
0255 into a voltage (perhaps from 0.0 V to 2.55 V, with 10 mV per
step, but this "gain" is easily arranged/modified). We'll build
the DAC out of three op-amp stages in summing configurations. One op-amp
handles the lowest four bits, another the upper four bits, and the final
op-amp combines the output of these two into a final value. Part of the
point of this lab is to familiarize yourself with the use of op-amps, though
this is a very limited exposure compared to the diversity of their
applications.
Ultimately (in Lab 7b), we will supply the 8 digital bits using the
Raspberry Pi's GPIO. Because we can't trust the pin-to-pin voltage
consistency of the GPIO output, we will use the logic signal from
each pin to control a FET switch within our circuit that routes a clean and
consistent zero or 5 volts to the summing inputs of the op-amps. We will
use the lab power supplies to provide the 5 V source, but a real stickler
would use an on-board regulator or even a voltage reference (possibly
buffered with an op-amp) to set the inputs.
The Actual Lab
Some of the instructions below are less than fully descriptive. You are
left to figure some things out on your own.
WARNINGS: Important!
Examine and double-check all your connections before turning on the power
supply. Also, set the voltage on the power supply (to ±15 V) prior
to the final hook-up and turn-on.
Lab Procedure
- Study the circuit diagram to familiarize yourself
with the components you'll be using, how they're rigged up, and how the
circuit works. Identify which leads will be the most significant bit, least
significant bit, etc.
- Prepare your breadboard to support ±15 V, ground, and 5 V power.
Pay attention to the pinout of the op-amps to decide where to put +15 and
where to put −15. Think about where you will need 5 V and where
you'll need ground. A little thought up front can save a messy criss-cross
arrangement later. The power supply may have a dedicated (non-adjustable)
5 V supply, which is preferable to using an adjustable one.
- Start with the input stages, including LEDs and FETs Use
5% resistors for the 10k terminating resistor and the LED
current-limiting resistor—we do not need to consume our precision resistors for these functions.
For a brighter LED, 220 Ω may be a better choice given
the 3.3 V Raspberry Pi GPIO output vs. the 750 Ω
resistors chosen for a 5 V parallel port, originally.
- Install the resistors for the summing junctions. If you
measure the actual resistor values for your summing network, you can perhaps
later explain any imprecesion in the DAC output.
- Temporarily connect the source pins on the FETs to ground, and
verify that each bit works when you fling 5 V at the input. Test by
probing the lower end of the relevant summing resistor, where it meets the
FET (also verify that the LEDs work).
- Install the two four-bit summing op-amps and verify that the summing
works according to the bit pattern that each sees. At this stage, the two
groups of four should behave identically. Test each thoroughly enough that
you're confident that you are ready to go on. This involves predicting
what the proper behavior is:
- Measure the voltage at the output of each op-amp stage. You already
have two (identical) four-bit DACs. Verify that the output voltage matches
expectations given your bit pattern. To do this, calculate the
current into the summing node, and the resulting voltage developed across
the feedback resistor.
- Now arrange the final summing op-amp, with appropriate resistors.
The summing resistors should be in a 16:1 ratio (make sure you understand
why this is desired).
- Tune the final feedback resistor to give you the desired
"gain." You may want full scale to be 10.0 V. Or 5.0 V. Or 2.55
V (conveniently 10 mV/step). Take your pick, and actually
calculate the resistance that will do the job. To do this, imagine
all eight bits are lit. From this, you can figure out the currents at each
of the first two summing nodes and thus the voltages presented to the
second-stage summing node, and thus the feedback resistance that would
result in full-scale voltage. Choose an appropriate potentiometer (pot) to
give you the right range, then tune for full scale. We have 1k and 2k pots available; pick the one that gives you the finest tunability for your chosen gain.
- Now the DAC is done, and you should put it through its paces to build
trust that it works as advertised. Pick a few input bit patterns (spanning
the range of possibilities) and record the output voltage, verifying that
the results make sense. Also, target specific output voltages: figure out
the appropriate digital input, configure, and see if you get close to your
target. Vary the least significant bit to make sure this is the closest you
can get to your target. By the end of the lab, you want to be 100% sure
that your DAC does what it's supposed to.
Tips
- LEDs care about polarity: the longer leg goes on the + side; and usually
there is a little flat on the rim: this goes to the − side
(corresponds to the bar on the diode symbol).
- Arrange the 8 bits in a way that will be convenient for jumpering 5 V to
each of the inputs in any 8-bit combination.
- A nice way to arrange resistors on a breadboard is to bend one leg
around 180° so that it is parallel with the unbent leg. Then trim
the unbent leg to be the same length as the bent leg. Now the resistor
can be inserted into the breadboard taking up limited space.
Lab 7a Write-up
The write-up for this lab will be deferred until next week, when you
complete the second phase of this project. But don't be lazy about
it! Record all the relevant information now, and write-up the description
of your circuit now, along with any choices you made, tests you performed,
etc. This way you've got a good head start, and put words down on paper
while the memories are fresh. Include a description of the theory behind
this particular circuit implemntation. How does it work? Convince the
reader that the DAC is 100% operational by including tables of inputs and measured outputs, etc.
Back to Physics 122 page