INTRODUCTION TO MICROPROCESSOR-BASED CONTROL 33
Figure 2.5 Vref = 10 Vdc
A digital-to-analog
converter (DAC)
block diagram.
Op-amp
Digital
DAC Vout (analog voltage)
input
255
9.96 V
"steps"
0V
In other applications, the controller may use a parallel interface to connect to an
analog device—for example, driving a variable-speed DC motor. In such a case, the
binary output of the controller must first be converted into an analog voltage before it
can drive the motor. This operation is performed by a special circuit called a digital-to-
analog converter.
Digital-to-Analog Conversion
The digital-to-analog converter (DAC) is a circuit that converts a digital word into an
analog voltage. It is not within the scope of this text to describe the internal workings
of the DAC, but a general understanding of the operating parameters is appropriate.
Figure 2.5 shows the block diagram of a typical 8-bit DAC. The input is an 8-bit
digital word. The output is a current that is proportional to the binary input value and
must be converted to a voltage with an op-amp. A stable reference voltage (Vref) must
be supplied to the DAC. This voltage defines the maximum analog voltage—that is, for
a digital input of 11111111, Vout is essentially Vref. If the input is 00000000, the Vout
will be 0 Vdc. For all values in between, the output voltage is a linear percentage of
Vref. Specifically, the output voltage for any digital input (for the 8-bit DAC) is
input × Vref
Vout = ᎏᎏ (2.1)
256
where
Vout = DAC output analog voltage
input = decimal value of the binary input
Vref = reference voltage to the DAC
EXAMPLE 2.2
An 8-bit DAC has a Vref of 10 V. The binary input is 10011011. Find the ana-
log output voltage.
34 CHAPTER 2
SOLUTION
The binary input of 10011011 has a decimal value of 155. Applying Equation 2.1,
we can calculate the analog output voltage:
input × Vref 155 × 10 V
Vout = ᎏ ᎏ = ᎏᎏ = 6.05 V
256 256
Therefore, 6.05 V is the voltage we would expect on the analog output pin. [It is
interesting to note that if the input were all 1s (which is a decimal value of 255),
the output would be (255/256) × 10 V = 9.96 V, not 10 V as you might expect. This
is a characteristic of the DAC.]
An important consideration of digital-to-analog conversion is resolution. The res-
olution of a DAC is the worst case error that is introduced when converting between
digital and analog. This error occurs because digital words can only represent discrete
values, as indicated by the stair-step diagram in Figure 2.5. For example, the maximum
value of an 8-bit number is 255 decimal, which means there are 255 possible “steps”
of the output voltage. The difference between steps is the value of the least significant
bit (LSB). Because the smallest increment is one step, the resolution (for 8-bit data) is
1 part in 255, or 0.39%. This resolution is adequate for many applications, but if more
is needed, two (or more) 8-bit ports can be used together. Two ports provide 16 bits of
data. The maximum decimal value of 16 bits is 65,535. Being able to divide an analog
number into 65,535 parts means that each part will be much smaller, so we can more
precisely represent that number.
EXAMPLE 2.3
A computer uses a DAC to create a voltage that represents the position of an
antenna. The antenna can rotate 180° and must be positioned to within 1°. Can
an 8-bit port be used?
SOLUTION
The resolution required is 1 part in 180. Because 8 bits provide a resolution
of 1 part in 255, an 8-bit port is certainly adequate. In fact, we have a choice:
We could have the LSB = 1°, in which case the input values would range from
0 to 180, or we could equate 180° with 255, which makes the LSB = 0.706°.
The latter makes maximum use of the 8 bits to give a better resolution, but if
the system really doesn’t need it, the clear, simple relationship of LSB = 1° is
desirable.
INTRODUCTION TO MICROPROCESSOR-BASED CONTROL 35
Figure 2.6 shows a data sheet for an 8-bit DAC (DAC0808). This device comes as
a 16-pin DIP (dual in-line package) and uses an external op-amp (such as the LF 351),
two resistors, and a capacitor to complete the circuit. It requires plus and minus power-
supply voltages. The time to complete a conversion is a fast 150 ns (nanoseconds). (The
circuit shown in Figure 2.6 has a Vref of 10 Vdc.)
Figure 2.6
The data sheet
for the DAC0808,
an 8-bit digital-to-
analog converter.
(Courtesy of
National
Semiconductor
Corp.)