Upload
others
View
30
Download
0
Embed Size (px)
Citation preview
Microprocessors and Microcontrollers – 11EC311
Interfacing with 8051
22/09/15 8051 Interfacing - Copyleft 2
LED Interfacing
● Output Control (Pin or Port)
– SETB PX.Y– CLR PX.Y– MOV P1,A
● Input Reading (Switch)
– JB PX.Y,label– JNB PX.Y,label– MOV A,P1
22/09/15 8051 Interfacing - Copyleft 3
7 Segment Interfacing
MOV A,#06H
MOV P1,A
22/09/15 8051 Interfacing - Copyleft 4
LCD Interfacing
22/09/15 8051 Interfacing - Copyleft 5
LCD Pin Description
22/09/15 8051 Interfacing - Copyleft 6
LCD Command Codes
22/09/15 8051 Interfacing - Copyleft 7
LCD Interfacing with 8051
P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7
8051UC
P3.0P3.1P3.2
D1D2D3D4D5D6D7
22/09/15 8051 Interfacing - Copyleft 8
Programming LCD
● List out Inputs and Outputs from LCD Pin Diagram
● Allot Pins of 8051 to above and List down
● Programming Command Mode (Configuring LCD)
● Send a Value to Port● RS = 0● RW = 0● EN = HIGH TO LOW
● Programming Data Mode (Printing Data on LCD)
● Send a Value to Port● RS = 1● RW = 0● EN = HIGH TO LOW
22/09/15 8051 Interfacing - Copyleft 9
Program to print KLU on LCDMOV A,#38HACALL CMDMOV A,#06HACALL CMDMOV A,#01HACALL CMDMOV A,#0EHACALL CMDMOV A,#80HACALL CMDMOV A,#'K'ACALL DATMOV A,#'L'ACALL DATMOV A,#'U'ACALL DATSJMP $
22/09/15 8051 Interfacing - Copyleft 10
Program to print KLU on LCD(cont.)
CMD:MOV P1,ACLR P3.0CLR P3.1SETB P3.2ACALL DELAYCLR P3.2RETDAT:MOV P1,ASETB P3.0CLR P3.1SETB P3.2ACALL DELAYCLR P3.2RETEND
22/09/15 8051 Interfacing - Copyleft 11
Example : LCD Program
22/09/15 8051 Interfacing - Copyleft 12
LTC Programs on LCD Interfacing
● Display “CSE” on Line 1 of LCD
● Display “Hello World” on Line 2 of LCD using Indexed
● Display “Success” on Middle of Line 1 of LCD Display if a switch connected to P2.1 is Pressed
22/09/15 8051 Interfacing - Copyleft 13
Keypad Interfacing with 8051
1422/09/15
Keypad Interfacing
1522/09/15 Sripath Roy
Keypad Interfacing Flowchart
1622/09/15 Sripath Roy
Keypad Interfacing Flowchart
17
Keypad Interfacing Program
18
Keypad Interfacing Program(cont.)
19
Keypad Interfacing Program(cont.)
20
Analog to Digital Converter(ADC) Interfacing With 8051
21
Analog to Digital Convereter
● Sensors takes the environmental change and converts into Analog Electrical Signal
● Microcontroller Understand only Digital Logic
● ADC Converts Analog Signal to Digital Signal
● Voltage is Coverted into Bits of Data
● High the resolution of ADC more the data samples
● 8 Bit ADC = 256 Samples
22
ADC0804 Interfacing Diagram
23
ADC0804 Pin Description
● WR● Start of Conversion (O/P for 8051)● Low to High Transaction● Converts Analog Input into 8 bit Digital
● INTR● End of Conversion(I/P for 8051)● Active Low
● RD● Output Enable (I/P for 8051)● To get the 8-bit data from ADC out of D0-D7 Lines
22/09/15 8051 Interfacing - Copyleft 24
ADC0804 Timing Diagram
22/09/15 8051 Interfacing - Copyleft 25
Program for ADC0804
RD BIT P2.5WR BIT P2.6INTR BIT P2.7MYDATA EQU P1MOV P1,#0FFHSETB INTRCLR WR
SETB WRHERE: JB INTR, HERECLR RDMOV A,MYDATA
SETB RDSJMP BACK
22/09/15 8051 Interfacing - Copyleft 26
Digital to Analog(DAC) Interfacing with 8051
22/09/15 8051 Interfacing - Copyleft 27
Digital to Analog(DAC Converter)
● Converts Digital Signal to Analog
● Binary Data of n-bit into Voltages
● To control Analog Devices
● Example : DC Motor Speed Control etc
22/09/15 8051 Interfacing - Copyleft 28
DAC0808 Interfacing Diagram
22/09/15 8051 Interfacing - Copyleft 29
Generation of Square Wave using DAC0808
BACK:
MOV A,#0FFH
MOV P1,A
ACALL DELAY
MOV A,#00H
MOV P1,A
ACALL DELAY
SJMP BACK
END
22/09/15 8051 Interfacing - Copyleft 30
Generation of Triangular Wave using DAC0808
BACK:MOV A,#00H
INCRE:MOV P1,A
INC A
CJNE A,#0FFH,INCRE
DECRE:MOV P1,A
DEC A
CJNE A,#00H,DECRE
SJMP BACK
END
22/09/15 8051 Interfacing - Copyleft 31
Generation of Sawtooth Wave using DAC0808
BACK:MOV A,#00H
INCRE:MOV P1,A
INC A
CJNE A,#0FFH,INCRE
SJMP BACK
END
22/09/15 8051 Interfacing - Copyleft 32
Generation of Step Wave using DAC0808
BACK:MOV A,#00H
INCRE:MOV P1,A
ADD A,#51D
ACALL DELAY
CJNE A,#255D,INCRE
DECRE:MOV P1,A
SUBB A,#55D
ACALL DELAY
CJNE A,#00D,DECRE
SJMP BACK
END
22/09/15 8051 Interfacing - Copyleft 33
Stepper Motor Interfacing with 8051
22/09/15 8051 Interfacing - Copyleft 34
Stepper Motor
● Rotor – Permanent Magnet
● Stator – 4 Windings
● Rotation of Current in Windings
Rotates the Motor
● 4 Phase Stepper Motor
● Poles or Teeth changes in Stator
● Step Angle(in Degrees) = 360/no.of Teeth
● Ex: Disk Drives, Dot Matrix Printers, Robots
● Working of Stepper Motor - Video
22/09/15 8051 Interfacing - Copyleft 35
Normal 4-Step Sequence
CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE
1 1 1 0 0
2 0 1 1 0
3 0 0 1 1
4 1 0 0 1
22/09/15 8051 Interfacing - Copyleft 36
Half Step 8-Step Sequence
CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE
1 1 0 0 1
2 1 0 0 0
3 1 1 0 0
4 0 1 0 0
5 0 1 1 0
6 0 0 1 0
7 0 0 1 1
8 0 0 0 1
22/09/15 8051 Interfacing - Copyleft 37
Wave Drive 4-Step Sequence
CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE
1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
22/09/15 8051 Interfacing - Copyleft 38
Stepper Motor Interfacing Diagram
22/09/15 8051 Interfacing - Copyleft 39
Program to Rotate Stepper Motor Clock Wise
Using Wave Drive Sequence Continuously
START:
MOV A,#08H
MOV P2,A
ACALL DELAY
MOV A,#04H
MOV P2,A
ACALL DELAY
MOV A,#02H
MOV P2,A
ACALL DELAY
MOV A,#01H
MOV P2,A
ACALL DELAY
SJMP START
22/09/15 8051 Interfacing - Copyleft 40
Program to Rotate Stepper Motor Clock Wise
Using Normal 4 Step Sequence for 50 Steps
MOV R0,#50D
MOV A,#33H
BACK:
MOV P2,A
ACALL DELAY
RR A
DJNZ R0,BACK
END
22/09/15 8051 Interfacing - Copyleft 41
Program to Rotate Stepper Motor Anti Clock Wise
Using 200 Poles Stepper Motor for 180 Degrees MOV R0,#100D
MOV A,#33H
BACK:
MOV P2,A
ACALL DELAY
RL A
DJNZ R0,BACK
END
Calculations:Step Angle = 360/200 = 1.8Required Steps = 180/1.8 = 100
22/09/15 8051 Interfacing - Copyleft 42
Stepper Motor LTC Programs
● Rotate the stepper Motor having 180 Poles 90 Degrees Clockwise using wave drive sequence
● Rotate the Stepper Motor having 90 Poles using Normal 4 Step Sequence 270 Degrees Anti Clock Wise and then 720 Degrees Clock Wise
● Program to run the stepper Motor Clock wise if a switch connected to P1.1 is Pressed and Anti-Clock Wise if Switch Connected to P1.0 is Pressed
22/09/15 8051 Interfacing - Copyleft 43
References
● https://www.sites.google.com/site/sripathroykoganti/my-forms
● The 8051 Microcontroller, 3rd Edition, Ayala, CENGAGE Learning
● Microcontrollers[Theory and Applications], Ajay V Deshmukh, Tata McGraw Hill
● The 8051 Microcontroller and Embedded Systems, Muhammad Ali Mazidi, Pearson Education
22/09/15 8051 Interfacing - Copyleft 44
Thank You