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.

10 REM use single-ended mode<br />

20 REM set A to address of ADC<br />

30 A=0C000H<br />

40 FOR I=1 TO 8<br />

50 XBY(A)=8+I-1<br />

60 PRINT “Channel ”,I," = “, : PH0. XBY(A)<br />

70 NEXT I<br />

80 END<br />

Writing to the converter causes the conversion to begin automatically. When the conversion<br />

is complete, a read operation to the converter’s address causes the the converted value to<br />

appear at DB0-DB7, where the 8052-BASIC reads it.<br />

<strong>The</strong> INTR pin indicates when a conversion is complete, and can be used to trigger a read<br />

operation. INTR is low when a conversion has occurred that has not yet been read. It goes<br />

high after a read and remains high until the next conversion is completed. BASIC-52 is slow<br />

enough that you don’t have to worry about waiting the maximum 60 microseconds between<br />

requesting a conversion and reading the result, so you can ignore INTR and read the result<br />

any time after a write.<br />

Packaging Options<br />

<strong>The</strong> ADC0848 comes in a 24-pin “skinny” DIP, with the pin rows spaced 0.3" apart as on<br />

a 14-pin DIP. Sockets of this size, especially wire-wrap, can be hard to find, but in a pinch<br />

you can place a 16-pin and 8-pin socket end to end. If you need only four analog inputs, use<br />

the ADC0844, in a 20-pin skinny DIP.<br />

Sensor Examples<br />

Now let’s look a couple of examples of sensors that you can connect to the ADC0848.<br />

Temperature<br />

Using Sensors to Detect and Measure<br />

Listing 9-2. Displays measurements of channels 1 through 8 on the<br />

ADC0848.<br />

<strong>The</strong> first is an LM34 temperature sensor. Unlike many other temperature sensors, the LM34<br />

requires no calibration. Its output is a simple 10 millivolts per degree Fahrenheit. As Figure<br />

9-6 shows, it’s available in several versions. <strong>The</strong> ones with a narrower range or lower<br />

resolution are cheaper. If you prefer Celsius readings, use the LM35.<br />

Figure 9-7 shows how to use an LM385-2.5 voltage reference to set the ADC’s VREF to 2.5V.<br />

<strong>The</strong> converter then can measure temperatures from 0 to 250 degrees, and each bit in the<br />

ADC0848’s output represents a 9.8 millivolt change in the sensor’s output.<br />

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

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

Saved successfully!

Ooh no, something went wrong!