0% found this document useful (0 votes)
54 views

MIC Unit 05

notes

Uploaded by

kheldarpranav03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

MIC Unit 05

notes

Uploaded by

kheldarpranav03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Unit 05:Interfacing With 8051 MIC (5ETC01)

UNIT 05:Interfacing With 8051


Question 1: Draw the interfacing of DAC 0808 with 8051 & write an 8051 C program to
generate a Triangular Wave.
Solution:

Figure 1:Interfacting Diagram

C Program:-
#include< reg51.h>
unsigned char d;
void main(void)
{
while(1)
{
for(d=0; d<255; d++)
{
P1 = d;
}
for(d=255; d>0; d--)
{
P1 = d;
}

November 8, 2023 1
Unit 05:Interfacing With 8051 MIC (5ETC01)

}
}
Question 2: Draw the interfacing of DAC 0808 with 8051 & write an 8051 C program to
generate a Sign Wave.
Solution:

Figure 2:Interfacing Diagram

C Program:-
#include<reg51.h>
sfr DAC = 0x80; //Port P0 address

November 8, 2023 2
Unit 05:Interfacing With 8051 MIC (5ETC01)

void main()
{
int sin_value[12] = {128,192,238,255,238,192,128,64,17,0,17,64};
int i;
while(1){
//infinite loop for LED blinking
for(i = 0; i<12; i++){
DAC = sin_value[i];
}
}
}
Question 2: Draw the interfacing of DAC 0808 with 8051 & write an 8051 C program to
generate a Staircase Wave.
Solution:

November 8, 2023 3
Unit 05:Interfacing With 8051 MIC (5ETC01)

Question 3: What is Opto-isolator? What is the advantage of using it for interfacing the
devices
Solution:
• An opto-isolator, also known as an optocoupler, is an electronic component that
provides electrical isolation between two separate electrical circuits using light. It
typically consists of a light-emitting diode (LED) and a photosensitive transistor or
photodiode enclosed in a single package.
• Here's how it works:
1. Input Side: The input side of the opto-isolator consists of an LED. When a
voltage is applied to the LED's anode (positive side) and cathode (negative side),
the LED emits light. The amount of light emitted is directly proportional to the
input voltage applied.
2. Output Side: The output side contains a photosensitive transistor or photodiode.
When light from the LED falls on the phototransistor or photodiode, it conducts
electricity, allowing current to flow through the output circuit. The output circuit
is electrically isolated from the input circuit, ensuring that there is no direct
electrical connection between them.
• Advantages of using opto-isolators for interfacing devices:
1. Electrical Isolation: Opto-isolators provide complete electrical isolation between
the input and output circuits. This isolation prevents the transfer of electrical noise,
voltage spikes, and ground loops from one circuit to the other. It helps protect
sensitive components and digital devices from potential damage or interference.
2. Safety: Opto-isolators are commonly used to provide safety in high-voltage and
high-current applications. They protect operators and sensitive equipment by
ensuring that there is no direct electrical connection between potentially hazardous
or noisy environments and control circuits.
3. Compatibility: Opto-isolators can be used to interface devices with different
voltage levels or signal types. They allow you to connect circuits operating at
different voltage potentials without risk of damaging the connected components.
4. Noise Immunity: Opto-isolators are immune to electromagnetic interference
(EMI) and radio-frequency interference (RFI). They can be used in noisy industrial
environments without experiencing signal degradation.
5. High Reliability: Opto-isolators have no moving parts and are solid-state devices,
which makes them reliable and durable. They have a long operational life and are
less prone to wear and tear.
6. Voltage and Current Level Shifting: Opto-isolators can be used to shift voltage
and current levels between different parts of a circuit, making them versatile for a
wide range of applications.
7. Reduced Cross-Talk: By preventing direct electrical connections, opto-isolators
minimize the risk of cross-talk and interference between circuits.

November 8, 2023 4
Unit 05:Interfacing With 8051 MIC (5ETC01)

Question 4: Draw the interfacing of DC motor to 8051 through Opto-isolator. A Switch is


connected on pin P2.7. Write a C program to monitor the status of SW and perform the
following: a) If SW = 0, the DC motor moves with 50% duty cycle pulse. b) If SW = 1, the DC
motor moves with 25% duty cycle pulse.
Solution:-

Figure 3:Interfacing Diagram of DC Motor With 8051

C Program:-

November 8, 2023 5
Unit 05:Interfacing With 8051 MIC (5ETC01)

Question 5: Draw the interfacing of a Stepper Motor to 8051 through Opto-isolator. A Switch
is connected on pin P2.7. Write a C program to monitor the status of SW & perform, a) If SW
= 0, the stepper motor moves clockwise & (b) If SW = 1, it moves counter clockwise
Solution:-

Figure 4:Interfacing Stepper Motor With 8051

C Program:-

November 8, 2023 6
Unit 05:Interfacing With 8051 MIC (5ETC01)

Question 6: . Explain any five commands of LCD.


Solution:-
16x2 LCDs (Liquid Crystal Displays) are commonly used in various electronic devices
and microcontroller-based projects for displaying information. Here are explanations of
five commonly used commands for controlling a 16x2 LCD:
1. Clear Display (0x01):
- Command: `0x01`
- Function: Clears the entire display and moves the cursor to the home position, which
is the first row, first column (0, 0).
- Usage: This command is typically used at the beginning of a program to clear the
display before writing new content.
2. Return Home (0x02):
- Command: `0x02`
- Function: Returns the cursor to the home position without clearing the display. It
sets the cursor at the first row, first column (0, 0).
- Usage: This command is used when you want to return the cursor to the starting
position without erasing the displayed content.
3. Set Cursor Position (0x80 + Address):
- Command: `0x80 + Address`
- Function: Sets the cursor to the specified position on the LCD. The address ranges
from 0x00 to 0x27 for the first row and 0x40 to 0x67 for the second row.
- Usage: It allows you to position the cursor at a specific location on the display to
start writing or reading data.
4. Display ON/OFF Control (0x08 - 0x0F):
- Command: `0x08`, `0x09`, `0x0A`, `0x0B`, `0x0C`, `0x0D`, `0x0E`, `0x0F`

November 8, 2023 7
Unit 05:Interfacing With 8051 MIC (5ETC01)

- Function: This command controls the display and cursor settings:


- `0x08`: Display off, cursor off, and blinking off (default).
- `0x09`: Display on, cursor off, and blinking off.
- `0x0A`: Display on, cursor on, and blinking off.
- `0x0B`: Display on, cursor off, and blinking on.
- `0x0C`: Display on, cursor off, and blinking off.
- `0x0D`: Display on, cursor off, and blinking on.
- `0x0E`: Display on, cursor on, and blinking on.
- `0x0F`: Display on, cursor on, and blinking on.
- Usage: You can use these commands to control the display, cursor, and blinking
attributes according to your application's requirements.
5. Entry Mode Set (0x04 - 0x07):
- Command: `0x04`, `0x05`, `0x06`, `0x07`
- Function: This command sets the text entry direction and display shift.
- `0x04`: Increment cursor (right to left), no display shift.
- `0x05`: Increment cursor (right to left), display shift.
- `0x06`: Decrement cursor (left to right), no display shift (default).
- `0x07`: Decrement cursor (left to right), display shift.
- Usage: These commands allow you to control how the cursor moves after writing a
character and whether the display shifts when writing beyond the visible area.

Question 7: . Draw & explain the interfacing of LCD with 8051.


Solution:-
1. Data Bus (D0-D7): Connect the data lines (D0-D7) of the LCD to the data lines of
the 8051 microcontroller (Port P0 or any other available port). Make sure to connect
D0 to D7 as per your data bus configuration. Usually, you’d connect D0-D3 to the
lower nibble of the data bus and D4-D7 to the upper nibble.
2. Control Pins:
- RS (Register Select): Connect RS of the LCD to a pin on the 8051 (e.g., P2.0). RS
is used to select between the command register (RS = 0) and data register (RS = 1).
- RW (Read/Write):Connect RW of the LCD to ground (GND) to set the LCD in
write mode.
- E (Enable): Connect E of the LCD to another pin on the 8051 (e.g., P2.1). The
Enable pin is used to latch data into the LCD.

November 8, 2023 8
Unit 05:Interfacing With 8051 MIC (5ETC01)

3. Control Lines:
- VSS (Ground):Connect VSS to ground (GND).
- VDD (Supply Voltage):Connect VDD to +5V.
- V0 (Contrast Control): Connect V0 to a potentiometer for contrast control, or you
can connect it to ground if you don’t need contrast adjustment.
- A (Anode) and K (Cathode): Connect A to +5V and K to ground for backlighting if
your LCD has a backlight.

Figure 5:Interfacing of LCD with 8051

Question 8 : Draw & explain in brief about the interfacing of (a) Opto-isolator & b) Relay to
any port pin of 8051.
Solution :-
a) Opto-isolator:-

Figure 6:Interfacing of Opto-isolater with 8051

November 8, 2023 9
Unit 05:Interfacing With 8051 MIC (5ETC01)

• An optoisolator has an LED (light-emitting diode) transmitter and a


photosensor receiver, separated from each other by a gap
• When current flows through the diode, it transmits a signal light across the
gap and the receiver produces the same signal with the same phase but a
different current and amplitude.
• Opto-isolators are also widely used in communication equipment such as
modems.
b) Relay

• The contacts can be normally open (NO) or normally closed (NC). In the
NC type, the contacts are closed when the coil is not energized. In the NO,
the contacts are open when the coil is unenergized.
• There can one or more contacts. For example, we can have SPST (single
pole, single throw), SPDT (single pole, double throw), and DPDT (double
pole, double throw) relays.
• The voltage and current needed to energize the coil. The voltage can vary
from a few volts to 50 volts, while the current can be from a few mA to 20
mA. The relay has a minimum voltage, below which the coil will not be
energized
• While the relay's coil needs around 10 mA to be energized, the
microcontroller's pin can provide a maximum of 1-2 mA current. For this
reason, we place a driver, such as the ULN2803, or a power transistor
between the microcontroller and the relay.

November 8, 2023 10
Unit 05:Interfacing With 8051 MIC (5ETC01)

Question 11 : Draw the interfacing of a 4 x 4 Matrix Key board to 8051 & Give the Flow
chart to Read a “key pressed” from keyboard
Solution:-

November 8, 2023 11

You might also like