Page 121 - Embedded Microprocessor Systems Real World Design
P. 121

If  the  three  switches are  treated  as  a  %bit digital  word  with  ON  =  1 and
                OFF = 0, the output voltage is  an analog representation of  a digital input. This
                three-switch digital-teanalog converter (DAC) has eight possible states, and each
                voltage step is VR/8.
                   We  could add more R/2R  pairs and switches for more resolution. Four switches
                would give us 16 steps of VR/16 volts each. Eight switches would give us 256 steps
                of VR/256 volts each. If we  replace the mechanical switches in the schematic with
                electronic switches, we  have a true DAC.









                Analog-todigital converters (ADCs) do the exact opposite of DACs-they  output a
                binary word  that is  a digital representation of  an analog voltage or current. An
                &bit ADC converts an input into 256 steps. A 10-bit ADC produces 1024 steps.
                   DACs  and ADCs  interface to a microprocessor just like other  peripheral ICs.
                Parts are available with different bus interface types, including SPI and 1%. While
                the microprocessor side of a DAC or an ADC is the same as other parts, there are
                some special considerations when dealing with these analog devices, which we’ll
                discuss in this section.



                Reference Voltage
                The reference voltage is the maximum value that the ADC or DAC can convert. An
                &bit ADC can convert values from OV to the reference voltage. This voltage range
                is divided into 256 values, or steps. The size of  the step is given by  the following
                equation:

                                                   5V
                                Reference Voltage  - --  = .0195V, or 19.5mV
                                      256         256

                This is the step size of the converter. It also defines the converter’s resolution. Note
                that no ADC or DAC can be more accurate than its reference. If your reference is
                a zener diode with a 10 percent tolerance, it doesn’t matter how many bits of res-
                olution you have, your product will have a 10 percent variation between units unless
                you perform some kind of calibration as part of production.
                   Some microcontrollers have internal ADCs. Many of these permit you to provide
                an external reference, or they let you use the supply voltage as the reference. This
                typically frees the reference pin for use as another analog input. Microchip 16C7xx
                parts have this feature.


                Hardware Design 2                                                    103
   116   117   118   119   120   121   122   123   124   125   126