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

MCA MODULE 3 PPT

Uploaded by

jaishuklaaa
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 views40 pages

MCA MODULE 3 PPT

Uploaded by

jaishuklaaa
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
You are on page 1/ 40

CHAPTER 3 8051 INTERFACING

AND APPLICATIONS
OBJECTIVE

◎ To know the importance of different


peripheral devices and their interfacing with
microcontrollers

◎ To know the interfacing of stepper motor,


liquid
crystal display, seven segment display, ADC &
DAC with 8051 Microcontroller.
LCD INTERFACING

Pin diagram
LCD Commands

Program
FEATURES

◎ Low current consumption

◎ The declining prices of LCDs

◎ The ability to display numbers,characters and


graphics

◎ Ease of programming for characters and


graphics
PIN CONFIGURATION
PIN CONFIGRATION

◎ There are two internal registers of LCD


◉ Instruction command register
◉ Data register
◎ RS pin is used to selct one of these two register
◉ If RS=0, the instruction command code register is
selected
◉ If RS=1, the instruction Data register is selected
◎ R/W pin is used to read or write to LCD
◉ R/W=1 when reading
◉ R/W=0 when writing

◎ When data is supplied to data pins,a high to low


pulse must be applied to E pin in order to latch the
data present on data lines
LCD INTERFACING
LCD COMMANDS
LCD INITIALIZATION

◎ The steps that has to be done for initializing the LCD


display is given below and these steps are common
for almost all applications.
◉ Send 38H to the 8 bit data line for initialization
◉ Send 0FH for making LCD ON, cursor ON and
cursor blinking ON.
◉ Send 01H for clearing the display and return
the cursor.
◉ Send 06H for incrementing cursor position.
Cursor should increment after every character is
written
◉ Send 80H to position the cursor at first line ,first
character
◉ issue the data character one by one giving
their ASCII values using data subroutine
SENDING DATA TO THE LCD

◎ The steps for sending data to the LCD module is


given below. LCD module has pins namely RS,
R/W and E. It is the logic state of these pins that
make the module to determine whether a given
data input is a command or data to be displayed.
◉ Make R/W low.
◉ Make RS=0 if data byte is a command and make
RS=1 if the data byte is a data to be displayed.
◉ Place data byte on the data register.
◉ Pulse E from high to low.
◉ Repeat above steps for sending another data.
PROBLEM STATEMENT

◎ Design a microcontroller based system to


interface
LCD with 8051 and display message ‘NO’
MOV A,#38H // Use 2 lines and 5x7 matrix
ACALL CMND
MOV A,#0FH // LCD ON, cursor ON, cursor blinking ON
ACALL CMND
MOV A,#01H //Clear screen
ACALL CMND
MOV A,#06H //Increment cursor
ACALL CMND
MOV A,#80H //Cursor line one , first char
ACALL CMND
ACALL DEALY // give time for LCD
MOV A,#’N’H// Display Letter N
ACALL DATWRT
ACALL DELAY MOV A,#’0’H
ACALL DATWRT
ACALL DEALY
UP: SJMP UP //stay here
CMND MOV P1,A // COPY A to Port 1
CLR P2.0 // RS=0 for command
CLR P2.1 //R/W =0 FOR write
SETB P2.2 // E=1 for high pulse
CLR P2.2 //E=0 for H to L pulse
RET
DATWR MOV P1,A // COPY A to Port 1
T SETB P2.0 // RS=1 for Data
CLR P2.1 //R/W =0 FOR write
SETB P2.2 // E=1 for high pulse
CLR P2.2 //E=0 for H to L pulse
RET
INTERFACING OFSEVEN SEGMENT
DISPLAY (SSD)
SEVEN SEGMENT DISPLAY

◎ 7-segment displays come in 2


configurations:
◉ Common Anode
◉ Common Cathode

◎ A resistor will be needed to control the


current
◉ Case 2 would be more appropriate
◉ Case 1 will produce different
brightness depending on the number
of LEDs turned on.
SEVEN SEGMENT DISPLAY
SEVEN SEGMENT DISPLAY
SEVEN SEGMENT DISPLAY
SEVEN SEGMENT DISPLAY

*Assume that Port 1 pins are connected to the SSD


SEVEN SEGMENT DISPLAY

◎ Design a microcontroller-based system using 8051


to interface 4 seven segment display and display
‘1234’
SEVEN SEGMENT DISPLAY

◎ Port 0 is used to send data on seven segment display


and port 2 is used to control it (Switch ON & OFF
display)
SEVEN SEGMENT DISPLAY
INTERFACING WITH 8051

◎ Four 7-segment displays connected to the same port on the


8051. Because the circuit is connected in this way we have
to multiplex the output.
switch on display 1 and switch off the other 3 displays (2,3,4)
switch on display 2 and switch off the other 3 displays (1,3,4)
switch on display 3 and switch off the other 3 displays
(1,2,4) switch on display 4 and switch off the other 3
displays (1,2,3)
◎ If it is this fast enough, we will not be able to notice that one of
the 7-segment displays is on and other 7-segment displays are
off.

◎ To turn the 7-segment displays off and on. There are two pins
on each of the the 7-segment displays which correspond to
common anode.
◎ If these pins are set to +5V the 7-segment display is on. If these
SEVEN SEGMENT DISPLAY
INTERFACING WITH 8051

◎ The four common anode pins corresponding to


the ports (P2.0, P2.1, P2.2, P2.3). To turn on the
first display set P2.0 to 1. The same applies for
the other displays connected to P2.1, P2.2,
P2.3.
◎ 4 NPN Transistors to drive the 4 common anodes
and the transistors are controlled by the 8051.
STEPPER MOTOR INTERFACING
STEPPER MOTOR

◎ Stepper Motor :- It is an electromagnetic device which


converts digital pulses into discrete mechanical rotational
movements. In rotary stepper motor the output shaft of
the motor rotates in equal increments in response to
train of input pulses.

◎ Every stepper motor has a permanent magnet rotor,


surrounded by a stator. The most common stepper motor
has four stator windings that are paired with a center
tapped common as shown in the figure below. The rotor
is suspended in the stator by means of sealed ball
bearings. In our case motor is basically with 2 phases,
eight salient poles and toothed iron rotor. The step angel
for given stepper motor is 1.8°. The total angel is 360°.
◎ No. of steps = 360°/ 1.8° = 200 steps/revolution
STEP SEQUENCE

Full Step: Red Orange Blue Green


0 1 0 1
0 1 1 0
1 0 1 0
1 0 0 1
The switching sequence is shown above and it is called 4 step switching
sequence. Since after 4 steps the 2 windings will be ON. How much
movement is associated with then will be determined on completion of
every four steps in which rotor moves only on tooth pitch. Therefore
stepper motor with 200 steps / revolution its rotor has 50 teeth since 4
× 50 = 200 steps are needed to complete one revolution.
ALGORITHM

◎ Send the sequence 22h, 28h, 88h, 82h


sequentially on port 3 to rotate the stepper
motor clockwise direction.

◎ Provide a delay to control the speed.

◎ Go back to step 1 to rotate the motor


continuously.
STEP SEQUENCE

◎ Programming port 3 of 8051 depending on


condition of driving the stepper motor:-

P3.5
P3.7 Oran P3.3 P3.1
P3.6 P3.4 P3.2 P3.0 Address
Red g e Blue Green

0 0 1 0 0 0 1 0 22 H
0 0 1 0 1 0 0 0 28 H
1 0 0 0 1 0 0 0 88 H
1 0 0 0 0 0 1 0 82 H
INTERFACING OFSTEPPER MOTOR
PROGRAMME
Label Operand Comments
Here: MOV P3, # 22 H Send 22 H to port 3
ACALL Delay Call Delay subroutine
MOV P3, # 28 H Send 28 H to port 3
ACALL Delay Call Delay subroutine
MOV P3, # 88 H Send 88 H to port 3
ACALL Delay Call Delay subroutine
MOV P3, # 82 H Send 82 H to port 3
ACALL Delay Call Delay subroutine
SJMP Here Jump to level Here

Label Operand Comments


Delay MOV R0, # 02B H Load R0 with 02B H as counter (outer)
UP1: MOV R1, # 02F H Load R1 with 02F H as counter (inner)
UP: DJNZ R1, UP Decrement R1 by 1 and jump to label UP if R1 ≠ 0
DJNZ R0, UP1 Decrement R0 by 1 and jump to label UP if R0 ≠ 0
RET Return back to main program
QUESTIONS

◎ Write a program to generate square wave of 50%


duty cycle (with equal portions high and low) on the
P1.5 bit. Timer 0 is used to generate the time delay.

◎ Interface 16*2 LCD to 8051 through Port 1 and Port


3 and write an assembly language programme to
display NO message on the display

◎ Design a microcontroller-based system using 8051


to interface STEPPER motor and rotate in clockwise
and anti-clock wise direction

◎ Design a microcontroller-based system using 8051


to interface 4 seven segment display and display
‘1234’
INTERFACING OFADC with 8051
INTERFACING OFADC with 8051
INTERFACING OFADC with 8051
INTERFACING OFADC with 8051
INTERFACING OFADC with 8051
INTERFACING OFADC with 8051

BACK MOV P2,#03H


SETB P2.4 ALE LOW TO HIGH
CLR P2.4 ALE HIGH TO L0W
SET P2.3 SOC LOW TO HIGH
CLR P2.3 SOC HIGH TO L0W
LOOP JNB P2.6 LOOP WAIT FOR EOC signal
SET P2.5 OE LOW TO HIGH OE LOW TO HIGH
CLR P2.5 OE HIGH TO L0W OE HIGH TO LOW
MOV A, P1
MOV DPTR # CO50H
MOVX A, @DPTR
SJMP BACK
INTERFACING OFDAC with 8051
INTERFACING OFDAC with 8051
INTERFACING OFDAC with 8051
INTERFACING OFDAC with 8051

You might also like