18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

different ground symbols for the two ground paths. Also be sure to include decoupling<br />

capacitors at pins 10 and 12.<br />

Measuring Modes<br />

To allow for different circuit requirements, the ADC0848 offers a choice of three softwareselectable<br />

modes of operation: single-ended, differential, and pseudo-differential. Figure<br />

9-5 illustrates.<br />

In single-ended mode, each analog input is referenced to AGND. This is the simplest mode<br />

and will work fine for many applications.<br />

Listing 9-2 causes the ADC to convert each of the eight channels in turn and displays the<br />

results on the host computer. For testing the circuits, you can connect a the wiper of a<br />

potentiometer to each channel, with the other two leads connecting to AGND and VREF. Verify<br />

that the readings for each channel vary from 0 to 255 as you vary the input voltage.<br />

<strong>The</strong> other modes are useful for more critical measurements where you need to reject<br />

background noise or offset voltages.<br />

In differential mode, each channel is paired with an adjacent one, with the voltage on one<br />

channel referenced to the voltage on the other.<br />

For example, you could connect an output from a sensor to channel 2 and a ground or other<br />

reference from that sensor to channel 1. With differential mode selected, channel 1 will read<br />

the difference between channel 1’s and channel 2’s voltage. This mode cancels out errors<br />

due to noise that is common to both channels in the pair, such as 60-cycle power-line<br />

interference. However,because each channel uses two analog inputs, this mode limits you<br />

to four channels.<br />

<strong>The</strong> third mode of operation is pseudo-differential. In this mode, channels 1-7 are all<br />

referenced to channel 8. This allows you to make 7 measurements, all with the same<br />

reference. This mode is useful if you are have multiple sensors in the same location. Also,<br />

if you connect channel 8 to a voltage greater than AGND, the converter’s range will shift to<br />

match, with a 0 output occurring when an input equals channel 8’s voltage.<br />

Reading the ADC<br />

Using Sensors to Detect and Measure<br />

To begin a conversion on the ADC0848, the 8052-BASIC writes to the converter indicating<br />

the desired channel and mode. Bits 0-2 specify the channel (000=1, 001=2, 010=3, etc.),<br />

and bits 3-4 specify the mode of operation (00=differential, 01=single-ended, 11=pseudo<br />

differential). So, for example, in Figure 9-4’s circuit, to begin a single-ended conversion at<br />

channel 5, you would write 0000 1101, or 0Dh, to the converter’s address.<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!