0% found this document useful (0 votes)
12 views4 pages

LM35 and ADC0808 with 8051 Interfacing

The document explains interfacing techniques for microcontrollers and microprocessors, including LED and keyboard interfacing with the 8051 microcontroller, traffic light control with the 8086 microprocessor, and basic arithmetic operations in assembly language. It provides working principles, connection details, program flow, and example code for each interfacing method. Additionally, it covers finding the largest number in an array using 8086 assembly language.

Uploaded by

ssppace002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

LM35 and ADC0808 with 8051 Interfacing

The document explains interfacing techniques for microcontrollers and microprocessors, including LED and keyboard interfacing with the 8051 microcontroller, traffic light control with the 8086 microprocessor, and basic arithmetic operations in assembly language. It provides working principles, connection details, program flow, and example code for each interfacing method. Additionally, it covers finding the largest number in an array using 8086 assembly language.

Uploaded by

ssppace002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Interfacing Explained

1) LED Interfacing with 8051 Microcontroller


LED interfacing is a fundamental concept to understand how microcontrollers control
output devices. The 8051 microcontroller has parallel I/O ports used to connect LEDs.

Working Principle: Each pin of the 8051 can act as an output pin. When a logic low (0) is
sent to an LED connected through a current-limiting resistor to Vcc, the LED turns ON.
Sending logic high (1) turns it OFF.

Connection:
- Anode (+) of LED to Vcc via 330Ω resistor.
- Cathode (-) to a port pin (e.g., P1.0).
- To glow LED, set port bit to 0.

Program Flow:
1. Set port direction as output.
2. Send 0 to turn ON the LED.
3. Send 1 to turn OFF the LED.
4. Use delay for blinking.

Example Code:

#include<reg51.h>
sbit LED = P1^0;
void delay() {
int i, j;
for(i=0; i<1000; i++)
for(j=0; j<1275; j++);
}
void main() {
while(1) {
LED = 0;
delay();
LED = 1;
delay();
}
}
2) Keyboard Interfacing with 8051 Microcontroller
A 4x4 matrix keyboard is often used for input. Rows are connected to output pins and
columns to input pins.

Working:
1. Microcontroller sends 0 to one row.
2. It reads columns to detect keypress.
3. If a column reads 0, key is pressed.

Flow:
1. Initialize port.
2. Send 0 to each row and scan columns.
3. Detect pressed key.
4. Use delay for debounce.

Example Code:

#include <reg51.h>
void main() {
while(1) {
P1 = 0xFE; // Row 1 LOW
if(P1 != 0xFE) {
// Key Pressed
}
}
}

3) Traffic Light Interfacing with 8086 Microprocessor


Used to control RED, YELLOW, and GREEN LEDs. Implemented using timers and delays.

Control Logic:
1. GREEN ON (10s)
2. YELLOW ON (2s)
3. RED ON (10s)
4. Repeat

Interface: LEDs via decoder or output port (e.g., 8255 PPI).

Pseudocode:

MOV AL, 01H ; Green ON


OUT PORT, AL
CALL DELAY

MOV AL, 02H ; Yellow ON


OUT PORT, AL
CALL DELAY

MOV AL, 04H ; Red ON


OUT PORT, AL
CALL DELAY

4) Finding Largest Number in an Array (8086 Assembly)


Steps:
1. Load count in CX
2. Load first element in AL
3. Compare with other elements
4. Update AL if greater

Code:

MOV CX, 05H


LEA SI, ARRAY
MOV AL, [SI]
INC SI

LOOP1:
CMP AL, [SI]
JAE NEXT
MOV AL, [SI]

NEXT:
INC SI
LOOP LOOP1

AL contains the largest number.

5) Arithmetic in Microprocessor (8086)


Addition:
MOV AL, 05H
ADD AL, 03H ; AL = 08H
Subtraction:
MOV AL, 09H
SUB AL, 04H ; AL = 05H

Multiplication:
MOV AL, 02H
MOV BL, 03H
MUL BL ; AX = 06H

Division:
MOV AX, 0006H
MOV BL, 02H
DIV BL ; AL = 03H, AH = 0

Use AX for results in MUL and dividend in DIV.

Common questions

Powered by AI

The assembly language operations involved in controlling traffic lights include MOV to set the specific light state (e.g., green, yellow, red) and OUT to send this state to an output port that controls the light. Calls to delay routines ensure timed transitions between signals. By executing a controlled sequence—green, yellow, then red using delay calls—the microprocessor accurately regulates traffic light timing, ensuring smooth and predictable traffic flow. The cycle repeats to maintain continuous operation .

Sending a logic low (0) from an 8051 microcontroller pin to an LED connected to Vcc via a current-limiting resistor turns the LED ON by allowing current to flow through the diode. Conversely, sending a logic high (1) stops current flow, turning the LED OFF. This electronic toggling via specific logic levels effectively controls the LED's operational state, providing a simple binary ON/OFF control mechanism .

Implementing a traffic light system using an 8086 microprocessor involves: 1) Turning the GREEN LED ON for a set duration (e.g., 10 seconds), 2) Then, the YELLOW LED is activated for a shorter time (e.g., 2 seconds), and 3) Finally, the RED LED is ON for the same duration as the green (e.g., 10 seconds). Timers and delays are essential to control the duration each light is on, ensuring proper traffic control cycles. The sequence repeats continuously, managing traffic flow at an intersection. The system can be implemented by sending control signals via output ports, such as through an 8255 PPI interface .

When interfacing a keyboard with an 8051 microcontroller, debouncing is critical to ensure reliable keypress detection. Mechanical switches can generate multiple signals (or bounces) when pressed or released, which the microcontroller might interpret incorrectly. To overcome this, a delay is introduced after detecting a keypress, allowing any excess signals to dissipate before reading the final state. This filter distinguishes between genuine and false switch closures, enhancing input accuracy .

Managing port direction is crucial before interfacing devices with an 8051 microcontroller because the ports can operate as either input or output. Setting a port as output ensures it can drive external devices like LEDs. Incorrectly configuring port direction may lead to unexpected behavior or hardware conflicts, as the microcontroller may try to read signals where it should send outputs. Proper configuration ensures reliable data transfer and device control .

Keyboard interfacing with an 8051 microcontroller works by connecting the rows of a 4x4 matrix keyboard to output pins and the columns to input pins. The microcontroller sends a logic low (0) to one row at a time, allowing it to check which column reads a low signal. This indicates a pressed key. The process involves initializing the port, sending a 0 to each row sequentially, and reading the columns to detect a keypress. A delay is used to handle key debounce, ensuring inputs are stable and accurately registered. This design enables a row-by-row and column-by-column scan to identify specific keys pressed .

The necessary steps for interfacing an LED with an 8051 microcontroller are: 1) Set the port direction as output to ensure the port pin can send signals. 2) Send a logic low (0) to the port pin connected to the LED's cathode to turn the LED ON, which allows current to flow from Vcc through the LED, illuminating it. 3) Send a logic high (1) to turn the LED OFF, stopping the current flow and extinguishing the LED. 4) Introduce a delay function to create a blinking effect by controlling the ON and OFF durations. These steps ensure the microcontroller can effectively toggle the LED's state, providing simple visual feedback .

A 4x4 matrix keyboard structure facilitates key press detection by organizing its keys into intersecting rows and columns. When interfaced with a microcontroller, it sends a logic low signal to one row at a time while checking each column for a low signal. When a key is pressed, it connects a specific row and column, returning a low signal to the microcontroller's respective input pin. By systematically scanning rows and reading columns, the microcontroller pinpoints the exact key pressed, providing a simple yet effective method for tracking input .

To find the largest number in an array using 8086 assembly, you load the count of elements into the CX register and the first array element into AL. The instructions compare each subsequent element with AL using CMP. If the current element is greater, AL is updated with the new value. The loop continues until all elements are checked. Critical instructions include MOV (to move data), LEA (to load effective address), CMP (for comparison), and JAE (jump if above or equal), which controls whether AL is updated. This process uses efficient looping and conditional branching to iterate and compare elements, resulting in AL holding the largest number after execution .

In 8086 microprocessor arithmetic operations, the AX and AL registers play crucial roles. For multiplication, AL typically holds one operand and another is in a different register (e.g., BL). The result is stored in AX, which accommodates the potentially larger result of multiplying two byte values. In division, AX serves as the combined dividend when dividing a word (16 bits); AL receives the quotient, while AH, the high byte of the quotient, stores the remainder. This ensures precise multiplication and division handling, critical for larger data values or operations involving division .

You might also like