226 8. ATMEL AVR OPERATING PARAMETERS AND INTERFACING
velocity, the number of detector pulses are counted in a fixed amount of time. Since the number of
pulses per encoder revolution is known, velocity may be calculated.
The quadrature encoder contains two tracks shifted in relationship to one another by 90
degrees. This allows the calculation of both velocity and direction. To determine direction, one
would monitor the phase relationship between Channel A and Channel B as shown in Figure
8.6(b). The absolute encoder is equipped with multiple data tracks to determine the precise location
of the encoder disk [Sick Stegmann].
8.4.5.2 Analog Sensors
Analog sensors provide a DC voltage that is proportional to the physical parameter being measured.
As discussed in the analog to digital conversion chapter, the analog signal may be first preprocessed by
external analog hardware such that it falls within the voltage references of the conversion subsystem.
The analog voltage is then converted to a corresponding binary representation.
An example of an analog sensor is the flex sensor shown in Figure 8.7(a). The flex sensor
provides a change in resistance for a change in sensor flexure. At 0 degrees flex, the sensor provides
10k ohms of resistance. For 90 degrees flex, the sensor provides 30-40k ohms of resistance. Since
the microcontroller can not measure resistance directly, the change in flex sensor resistance must be
converted to a change in a DC voltage.This is accomplished using the voltage divider network shown
in Figure 8.7(c). For increased flex, the DC voltage will increase. The voltage can be measured using
the ATmega328’s analog to digital converter subsystem. The flex sensor may be used in applications
such as virtual reality data gloves, robotic sensors, biometric sensors, and in science and engineering
experiments [Images Company].
8.4.6 LM34 TEMPERATURE SENSOR EXAMPLE
Temperature may be sensed using an LM34 (Fahrenheit) or LM35 (Centigrade) temperature trans-
ducer. The LM34 provides an output voltage that is linearly related to temperature. For example,
the LM34D operates from 32 degrees F to 212 degrees F providing +10mV/degree Fahrenheit
resolution with a typical accuracy of ±0.5 degrees Fahrenheit [National]. This sensor is used in the
automated cooling fan example at the end of the chapter. The output from the sensor is typically
connected to the ADC input of the microcontroller.
8.5 OUTPUT DEVICES
As previously mentioned, an external device should not be connected to a microcontroller without
first performing careful interface analysis to ensure the voltage, current, and timing requirements of
the microcontroller and the external device. In this section, we describe interface considerations for
a wide variety of external devices. We begin with the interface for a single light emitting diode.

Get Arduino Microcontroller, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.