Sie sind auf Seite 1von 13

Microprocessor 12 - 1/13

CHAPTER 12 Real-World Interfacing I: LCD, ADC, and Sensors

12.1 Interfacing an LCD to the 8051


* LCD Operation
– LCD is gaining popular and replacing LEDs (7-segment …), due to
1. declining price
2. the ability to display numbers, characters, and graphics
3. relieving the CPU task by incorporating a refreshing controller
4. ease of programming for characters and graphics
(OLED is the coming display)
* LCD Pin Descriptions
– 14-pin LCD module is discussed here, table 12-1 lists pin’s function, Fig
12-1 shows the pin positions for various LCDs
Microprocessor 12 - 2/13
– Vcc, Vss provide +5V and ground
– Vee is used for contrast controlling
– RS (register select) is used to select the instruction command code
register (RS = 0) or data register (RS = 1)
– LCD command codes is listed at table 12-2
– R/W (read/write) allows user to write to (R/W = 0) or read from (R/W = 1)
information
– E (enable) latch information at data pins; when data is supplied to data
pins, a high-to-low pulse must be applied to this pin
– D0-D7 are the 8-bit data pins; send information to LCD (R/W = 0) and
read contents of LCD internal registers (R/W = 1)
– to display letters and numbers, ASCII codes are sent while RS = 1
– RS = 0, the command code register is selected, we can send instruction
to LCD to perform clear, shift, blink …

– when RS = 0, and R/W = 1, D7 is busy flag, when D7 = 0, LCD is ready


to receive new information; it is recommended to check the busy flag
before writing any data to the LCD
Microprocessor 12 - 3/13
Microprocessor 12 - 4/13
Microprocessor 12 - 5/13
Microprocessor 12 - 6/13
Microprocessor 12 - 7/13
Microprocessor 12 - 8/13
12.2 8051 Interfacing to ADC, Sensors
* ADC Devices
– analog-to-digital converter (ADC) is the most widely used data
acquisition device
– In physical world, most quantities are in analog (continuous) form,
transducers (or sensors) are transforming them into electrical (voltage,
current) signals; then ADCs are used to sample and quantize them into
binary code, so the computer can store and process

* ADC804 Chip
– 8-bit ADC works with +5V from National Semiconductor
– conversion time is 110µs
– it can be tested by free running configured as shown in Fig 12-5

– CS (chip select): an active low input to activate the ADC804


– RD (read): active low to get the converted data out of the ADC; when CS
Microprocessor 12 - 9/13
= 0, a high-to-low pulse applied to RD, D0-D7 output the 8-bit digital data
– WR (write, or start conversion): active low to inform the ADC to start the
conversion; if CS = 0 when WR makes a low-to-high transition, the ADC
starts converting the Vin analog input to an 8-bit digital number; the
conversion time varies depending on the CLK IN and CLK R; when
conversion complete, the INTR pin is forced to low
– CLK IN is for an external clock source; ADC804 has an internal clock
generator, to used it by connecting a capacitor and a resistor with the
CLK R and CLK IN, the clock frequency will be f = 1/1.1RC ; typical
values are R = 10K, C = 150p, to get f = 606 kHz, the conversion time is
110us
– INTR (interrupt, or end of conversion): active low output, goes low when
conversion is complete; after INTR goes low, we make CS = 0 and send
a high-to-low pulse to the RD pin to get the data out of the ADC
– Vin(+) and Vin(-): differential analog inputs where Vin = Vin(+) – Vin(-);
often the Vin(-) is connected to ground
– Vcc: +5V power supply; also used as a reference voltage when Vref/2 is
open
– Vref/2: reference voltage; table 12-5 lists its range

– D0-D7: the digital data (code) output pins; tri-state buffered, accessed
only when CS = 0 and RD is low; Dout = Vin / (Vref/256)
– Analog GND and Digital GND are used to isolate the analog and digital
Microprocessor 12 - 10/13
power to improve the output accuracy

– Fig 12-6 shows the Read and Write timing for ADC804
1. make CS = 0 and send a low-to-high pulse to WR to start the
conversion
2. keep monitoring the INTR, if INTR is low, the conversion is finished
3. after INTR becomes low, make CS = 0 and send a high-to-low pulse
to RD to get the data out of the ADC804

* Testing the ADC804


Microprocessor 12 - 11/13

– the clock is coming from the crystal of 8051, however, it is too high for
ADC, so two D flip-flops are used to divide it down by 4
Microprocessor 12 - 12/13
* Interfacing a Temperature Sensor to the 8051
– table 12-6 shows a thermistor resistance change with temperature, it is
very non-linear, increase the software complexity
– many linear temperature sensors are introduced, such as LM34, LM35
from National Semiconductor Corp.
– LM34 & LM35 are precision
integrated-circuit temperature sensors
whose output voltage is linearly
proportional to the temperature; table 12-7
and 12-8 are their selection guide
Microprocessor 12 - 13/13

* Signal Conditioning and Interfacing the LM35 to the 8051


– data acquisition need to perform signal
conditioning on the sensor to convert its output
signal to appropriate one; for ADC, a voltage in a
adequate range is needed
– for LM35, it produces 10mV for every degree of
temperature change; ADC804 has 8-bit
resolution with a maximum of 256 steps
– to produce the full-scale Vout of 256x10mV =
2.56 V, we need to set Vref/2 = 1.28 V; thus the
Vout (D0-D7) value is directly correspond to the
temperature monitored by LM35

– Fig 12-10 is the connection of 8051 with ADC and temperature sensor

Das könnte Ihnen auch gefallen