Hello

Welcome lekule blog

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation.
together in the world. #lekule86
Join us on

Major Electronic Peripherals Interfacing to Microcontroller 8051

Interfacing is one of the important concepts in microcontroller 8051 because the microcontroller is a CPU that can perform some operation on a data and gives the output. However to perform the operation we need an input device to enter the data and in turn output device displays the results of the operation. Here we are using keyboard and LCD display as input and output devices along with the microcontroller.
Microcontroller 8051 Peripheral devices
Microcontroller 8051 Peripheral devices

Interfacing is the process of connecting devices together so that they can exchange the information and that proves to be easier to write the programs. There are different type of input and output devices as for our requirement such as LEDs, LCDs, 7segment, keypad, motors and other devices.
Here is given some important modules interfaced with microcontroller 8051.

1. LED Interfacing to Microcontroller:

Description:
LEDs are most commonly used in many applications for indicating the output. They find huge range of applications as indicators during test to check the validity of results at different stages. They are very cheap and easily available in a variety of shape, color and size.

Light Emitting Diode
Light Emitting Diode


The principle of operation of LEDs is very easy. A simple LEDs also servers as a basic display devices, it On and OFF state express meaning full information about a device. The common available LEDs have a 1.7v voltage drop that means when we apply above 1.7V, the diode conducts. The diode needs 10mA current to glow with full intensity. 

The following circuit describes “how to glow the LEDs”.

LEDs can be interfaced to the microcontroller in either common anode or common cathode configuration. Here the LEDs are connected in common anode configuration because the common cathode configuration consumes more power.

Circuit Diagram
LED Interfacing to Microcontroller
LED Interfacing to Microcontroller.


Source code:
#include
void main()
{
unsigned int i;
while(1)
{
P0=0x00;
for(i=0;i<30000 br="" i=""> P0=0xff;
for(i=0;i<30000 br="" i=""> }
}

2. 7-Segment Display interfacing circuit

Description:
A Seven segment display is the most basic electronic display. It consists of eight LEDs which are associated in a sequence manner so as to display digits from 0 to 9 when proper combinations of LEDs are switched on. A 7-segment display uses seven LEDs to display digits from 0 to 9 and the 8th LED is used for dot. A typical seven segment looks likes as shown in figure below.
7-Segment Display
7-Segment Display

The 7-segment displays are used in a number of systems to display the numeric information. They can display one digit at a time. Thus the number of segments used depends on the number of digits to display. Here the digits 0 to 9 are displayed continuously at a predefined time delay.

The 7-segment displays are available in two configurations which are common anode and common cathode. Here common anode configuration is used because output current of the microcontroller is not sufficient enough to drive the LEDs. The 7-segment display works on negative logic, we have to provide logic 0 to the corresponding pin to make on LED glow.

7-Segment Display Configurations
7-Segment Display Configurations

The following table shows the hex values used to display the different digits.
7-Segment Display Table
7-Segment Display Table

Circuit Diagram
7-Segment Display interfacing
7-Segment Display interfacing

Source Code:
#include
sbit a= P3^0;
void main()
{
unsigned char n[10]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0xE00,0x10};
unsigned int i,j;
a=1;
while(1)
{
for(i=0;i<10 br="" i=""> {
P2=n[i];
for(j=0;j<60000 br="" j=""> }
}
}

3. LCD Interfacing to Microcontroller

LCD stands for liquid crystal display which can display the characters per line. Here 16 by 2 LCD display can display 16 characters per line and there are 2 lines. In this LCD each character is displayed in 5*7 pixel matrix.
LCD Display
LCD Display

LCD is very important device which is used for almost all automated devices such as washing machines, an autonomous robot, power control systems and other devices. This is achieved by displaying their status on small display modules like 7-seven segment displays, multi segment LEDs etc. The reasons being, LCDs are reasonably priced, easily programmable and they have a no limitations of displaying special characters.

It consists of two registers such as command/instruction register and data register.
The command/instruction register stores the command instructions given to the LCD. A command is an instruction which is given to the LCD that perform a set of predefined tasks like initializing, clearing the screen, setting the cursor posing, controlling display etc.
The data register stores the data to be displayed on LCD. The data is an ASCII value of the characters to be displayed on the LCD.

Operation of LCD is controlled by two commands. When RS=0, R/W=1 it reads the data and when RS=1, R/W=0, it writes (print) the data.


LCD uses following command codes:
LCD Display Commands
LCD Display Commands


Circuit Diagram:
LCD Interfacing to Microcontroller
LCD Interfacing to Microcontroller

Source code:
#include
#define kam P0
sbit rs= P2^0;
sbit rw= P2^1;
sbit en= P2^2;
void lcd_initi();
void lcd_dat(unsigned char );
void lcd_cmd (unsigned char );
void delay(unsigned int );
void display(unsigned char *s, unsigned char r);
void main()
{
lcd_initi();
lcd_cmd(0x80);
delay(100);
display(“EDGEFX TECHLNGS”, 15);
lcd_cmd(0xc0);
display(“KITS & SOLTIONS”,15);
while(1);
}
void display(unsigned char *s, unsigned char r)
{
unsigned int w;
for(w=0;w {
lcd_dat(s[w]);
}
}
void lcd_initi()
{
lcd_cmd(0x01);
delay(100);
lcd_cmd(0x38);
delay(100);
lcd_cmd(0x06);
delay(100);
lcd_cmd(0x0c);
delay(100);
}
void lcd_dat(unsigned char dat)
{
kam = dat;
rs=1;
rw=0;
en=1;
delay(100);
en=0;
}
void lcd_cmd(unsigned char cmd)
{
kam=cmd;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void delay( unsigned int n)
{
unsigned int a;
for(a=0;a }

4. Stepper motor interfacing circuit

Types of Stepper Motors-1
Unipolar Stepper Motor


A stepper motor is one of the most commonly used motor for precise angular movement. The advantage of using a stepper motor is that the angular position of the motor can be controlled without any feedback mechanism. The stepper motors are widely used in industrial and commercial applications. They are also commonly used as in drive systems such as robots, washing machines etc.
Types of Stepper Motors-2
Bipolar Stepper Motor


Stepper motors can be unipolar or bipolar and here we are using unipolar stepper motor. The unipolar stepper motor consists of six wires out of which four are connected to coil of the motor and two are common wires. Each common wire is connected to a voltage source and remaining wires are connected to the microcontroller.


Circuit Diagram:
Stepper motor interfacing circuit
Stepper motor interfacing circuit


Source code:
#include
sbit a=P3^0;
sbit b=P3^1;
sbit c=P3^2;
sbit d=P3^3;
void delay();
void main()
{
while(1)
{
a=0;
b=1;
c=1;
d=1;
delay();
a=1;
b=0;
c=1;
d=1;
delay();
a=1;
b=1;
c=0;
d=1;
delay();
a=1;
b=1;
c=1;
d=0;
}
}
void delay()
{
unsigned char i,j,k;
for(i=0;i<6 br="" i=""> for(j=0;j<255 br="" j=""> for(k=0;k<255 k="" p="">
}

5. Matrix keypad interfacing to 8051

Description:
Matrix Keypad
Matrix Keypad

Keypad is a widely used input device with lot of applications such as telephone, computer, ATM, electronic lock etc. A keypad is used to take input from the user for further processing. Here a 4 by 3 matrix keypad consisting of switches arranged in rows and columns is interfaced to the microcontroller. A 16 by 2 LCD is also interfaced for displaying the output.

The interfacing concept of keypad is very simple. Every number of keypad is assigned two unique parameters that are row and column (R, C). Hence every time a key is pressed the number is identifying by detecting the row and column numbers of keypad.
Keypad Internal Diagram
Keypad Internal Diagram

Initially all the rows are set to zero (‘0’) by the controller and columns are scanned to check if any key is pressed. In case of no key is pressed the output of all columns will be high (‘1’).


Circuit Diagram
Matrix keypad interfacing to 8051
Matrix keypad interfacing to 8051


Source Code:
#include
#define kam P0
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit c1=P1^4;
sbit c2=P1^5;
sbit c3=P1^6;
sbit r1=P1^0;
sbit r2=P1^1;
sbit r3=P1^2;
sbit r4=P1^3;
void lcd_initi();
void lcd_dat(unsigned char );
void lcd_cmd (unsigned char );
void delay(unsigned int );
void display(unsigned char *s, unsigned char r);
void main()
{
lcd_initi();
lcd_cmd(0x80);
delay(100);
display(“0987654321”, 10);
while(1);
}
void display(unsigned char *s, unsigned char r)
{
unsigned int w;
for(w=0;w {
lcd_dat(s[w]);
}
}
void lcd_initi()
{
lcd_cmd(0x01);
delay(100);
lcd_cmd(0x38);
delay(100);
lcd_cmd(0x06);
delay(100);
lcd_cmd(0x0c);
delay(100);
}
void lcd_dat(unsigned char dat)
{
kam = dat;
rs=1;
rw=0;
en=1;
delay(100);
en=0;
}
void lcd_cmd(unsigned char cmd)
{
kam=cmd;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void delay( unsigned int n)
{
unsigned int a;
for(a=0;a }
}


We hope we have been able to provide ample knowledge about the basic yet important interfacing circuits of microcontroller 8051. These are the most basic circuits required in any embedded system application and we hope we have provided you with a good revision.


A further query or feedback related to this topic is welcome to be mentioned in the comment section below.

Share this:

ABOUTME

Hi all. This is deepak from Bthemez. We're providing content for Bold site and we’ve been in internet, social media and affiliate for too long time and its my profession. We are web designer & developer living India! What can I say, we are the best..

Post a Comment
My photo

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation. I believe everyday can become a Electrician with the right learning materials.
My goal with BLOG is to help you learn Electrical.

Labels

LEKULE TV EDITORIALS ARTICLES DC ROBOTICS DIGITAL SEMICONDUCTORS GENERATOR AC EXPERIMENTS MANUFACTURING-ENGINEERING REFERENCE FUNDAMENTAL OF ELECTRICITY ELECTRONICS ELECTRICAL ENGINEER MEASUREMENT TRANSDUCER & SENSOR VIDEO ARDUINO RENEWABLE ENERGY AUTOMOBILE TEARDOWN SYNCHRONOUS GENERATOR DIGITAL ELECTRONICS ELECTRICAL DISTRIBUTION CABLES AUTOMOTIVE MICROCONTROLLER SOLAR PROTECTION DIODE AND CIRCUITS BASIC ELECTRICAL ELECTRONICS MOTOR SWITCHES CIRCUIT BREAKERS CIRCUITS THEORY PANEL BUILDING ELECTRONICS DEVICES MIRACLES SWITCHGEAR ANALOG MOBILE DEVICES WEARABLES CAMERA TECHNOLOGY COMMUNICATION GENERATION BATTERIES FREE CIRCUITS INDUSTRIAL AUTOMATION SPECIAL MACHINES ELECTRICAL SAFETY ENERGY EFFIDIENCY-BUILDING DRONE CONTROL SYSTEM NUCLEAR ENERGY SMATRPHONE FILTER`S POWER BIOGAS BELT CONVEYOR MATERIAL HANDLING RELAY ELECTRICAL INSTRUMENTS ENERGY SOURCE PLC`S TRANSFORMER AC CIRCUITS CIRCUIT SCHEMATIC SYMBOLS DDISCRETE SEMICONDUCTOR CIRCUITS WIND POWER C.B DEVICES DC CIRCUITS DIODES AND RECTIFIERS FUSE SPECIAL TRANSFORMER THERMAL POWER PLANT CELL CHEMISTRY EARTHING SYSTEM ELECTRIC LAMP FUNDAMENTAL OF ELECTRICITY 2 BIPOLAR JUNCTION TRANSISTOR 555 TIMER CIRCUITS AUTOCAD BLUETOOTH C PROGRAMMING HOME AUTOMATION HYDRO POWER LOGIC GATES OPERATIONAL AMPLIFIER`S SOLID-STATE DEVICE THEORRY COMPUTER DEFECE & MILITARY FLUORESCENT LAMP INDUSTRIAL ROBOTICS ANDROID ELECTRICAL DRIVES GROUNDING SYSTEM CALCULUS REFERENCE DC METERING CIRCUITS DC NETWORK ANALYSIS ELECTRICAL SAFETY TIPS ELECTRICIAN SCHOOL ELECTRON TUBES FUNDAMENTAL OF ELECTRICITY 1 INDUCTION MACHINES INSULATIONS USB ALGEBRA REFERENCE HMI[Human Interface Machines] INDUCTION MOTOR KARNAUGH MAPPING USEUL EQUIATIONS AND CONVERSION FACTOR ANALOG INTEGRATED CIRCUITS BASIC CONCEPTS AND TEST EQUIPMENTS DIGITAL COMMUNICATION DIGITAL-ANALOG CONVERSION ELECTRICAL SOFTWARE GAS TURBINE ILLUMINATION OHM`S LAW POWER ELECTRONICS THYRISTOR BOOLEAN ALGEBRA DIGITAL INTEGRATED CIRCUITS FUNDAMENTAL OF ELECTRICITY 3 PHYSICS OF CONDUCTORS AND INSULATORS SPECIAL MOTOR STEAM POWER PLANTS TESTING TRANSMISION LINE C-BISCUIT CAPACITORS COMBINATION LOGIC FUNCTION COMPLEX NUMBERS CONTROL MOTION ELECTRICAL LAWS INVERTER LADDER DIAGRAM MULTIVIBRATORS RC AND L/R TIME CONSTANTS SCADA SERIES AND PARALLEL CIRCUITS USING THE SPICE CIRCUIT SIMULATION PROGRAM AMPLIFIERS AND ACTIVE DEVICES APPS & SOFTWARE BASIC CONCEPTS OF ELECTRICITY CONDUCTOR AND INSULATORS TABLES CONDUITS FITTING AND SUPPORTS ELECTRICAL INSTRUMENTATION SIGNALS ELECTRICAL TOOLS INDUCTORS LiDAR MAGNETISM AND ELECTROMAGNETISM PLYPHASE AC CIRCUITS RECLOSER SAFE LIVING WITH GAS AND LPG SAFETY CLOTHING STEPPER MOTOR SYNCHRONOUS MOTOR AC METRING CIRCUITS BECOME AN ELECTRICIAN BINARY ARITHMETIC BUSHING DIGITAL STORAGE MEMROY ELECTRICIAN JOBS HEAT ENGINES HOME THEATER INPECTIONS LIGHT SABER MOSFET NUMERATION SYSTEM POWER FACTORS REACTANCE AND IMPEDANCE INDUCTIVE RECTIFIER AND CONVERTERS RESONANCE SCIENTIFIC NOTATION AND METRIC PREFIXES SULFURIC ACID TROUBLESHOOTING TROUBLESHOOTING-THEORY & PRACTICE 12C BUS APPLE BATTERIES AND POWER SYSTEMS DC MOTOR DRIVES ELECTROMECHANICAL RELAYS ENERGY EFFICIENCY-LIGHT INDUSTRIAL SAFETY EQUIPMENTS MEGGER MXED-FREQUENCY AC SIGNALS PRINCIPLE OF DIGITAL COMPUTING QUESTIONS REACTANCE AND IMPEDANCE-CAPATIVE SEQUENTIAL CIRCUITS SERRIES-PARALLEL COMBINATION CIRCUITS SHIFT REGISTERS WIRELESS BUILDING SERVICES COMPRESSOR CRANES DIVIDER CIRCUIT AND KIRCHHOFF`S LAW ELECTRICAL DISTRIBUTION EQUIPMENTS 1 ELECTRICAL DISTRIBUTION EQUIPMENTS B ELECTRICAL TOOL KIT ELECTRICIAN JOB DESCRIPTION INDUSTRIAL DRIVES LAPTOP SCIENCE THERMOCOUPLE TRIGONOMENTRY REFERENCE UART oscilloscope BIOMASS CONTACTOR ELECTRIC ILLUMINATION ELECTRICAL SAFETY TRAINING ELECTROMECHANICAL FEATURED FILTER DESIGN HARDWARE JUNCTION FIELD-EFFECT TRANSISTORS NASA NUCLEAR POWER VALVE COLOR CODES ELECTRIC TRACTION FLEXIBLE ELECTRONICS FLUKE GEARMOTORS INTRODUCTION LASSER PID PUMP SEAL ELECTRICIAN CAREER ELECTRICITY SUPPLY AND DISTRIBUTION MUSIC NEUTRAL PERIODIC TABLES OF THE ELEMENTS POLYPHASE AC CIRCUITS PROJECTS REATORS SATELLITE STAR DELTA VIBRATION WATERPROOF