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
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 9<br />
line. Digital outputs DB0-DB7 connect to the data bus (D0-D7). DB0-DB4 also function as<br />
control inputs MA0-MA4.<br />
Up to eight analog inputs can connect to pins 2-9 on the ADC0848. <strong>The</strong> voltage at VREF<br />
determines the converter’s full-scale voltage, which is the input that results in an output of<br />
11111111, or FFh. For maximum range, connect VREF to the +5V supply or to a more precise<br />
5-volt reference like an LM336-5.0 reference diode. <strong>The</strong> analog inputs can then range from<br />
0 to +5 volts.<br />
Adjusting the Range<br />
If your sensor’s output is much less than 5 volts, you can increase the resolution of the<br />
converter by connecting VREF to a voltage slightly larger than the highest voltage you expect<br />
to measure.<br />
To illustrate, consider a sensor whose output ranges from 0 to 0.5 volt. <strong>The</strong> 8-bit digital<br />
output of the converter represents a number from 0 to 255. If VREF is 5 volts, each count<br />
equals 5/255, or 19.6 millivolts. A 0.2-volt analog input results in a count of 10, while a<br />
0.5-volt input results in a count of 26. If your input goes no higher than 0.5 volt, your count<br />
will never go higher than 26, and the measured values will be accurate only to within 20<br />
millivolts, or 1/255 of full-scale.<br />
But if you adjust VREF down to 0.5 volts, each count now equals 0.5/255, or 2 millivolts. A<br />
0.2-volt input gives a count of 102, a 0.5-volt input gives a count of 255, and the measured<br />
values can be accurate to within 2 millivolts.<br />
However, if you decrease VREF as described above, you also increase the converter’s<br />
sensitivity to noise. With VREF at 5 volts, a 20-millivolt noise spike will cause at most a 1-bit<br />
error in the output. If you decrease VREF to 0.5 volt, the same spike can cause an error of<br />
10 bits, since each bit now represents 2 millivolts, not 20.<br />
Minimizing Noise<br />
<strong>The</strong> rapid switching of digital circuits can cause voltage spikes in the ground lines, and these<br />
can cause errors in analog measurements. Good routing of ground wires or pc-board traces<br />
can minimize noise in circuits that mix analog and digital circuits.<br />
To minimize noise, provide separate ground paths for analog and digital signals. In Figure<br />
9-4, this means that AGND and any ground connections related to the analog inputs or VREF<br />
should be wired together, but kept separate from the ground connections for the digital<br />
circuits, including logic chips, the 8052-BASIC, and memory chips. <strong>The</strong> two grounds are<br />
tied together at one place only, as near to the power supply as possible. <strong>The</strong> schematic uses<br />
160 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>