Unit 5 0-Complete
Unit 5 0-Complete
COURSE HANDLED BY
HEXA
X’ Y X Y’
VALUE
0 0 1 1 03
0 1 1 0 06
1 1 0 0 0C
1 0 0 1 09
Anti Clock wise rotation
HEXA
X’c Y X Y’
VALUE
1 0 0 1 09
1 1 0 0 0C
0 1 1 0 06
0 0 1 1 03
Step Angle
Modes
There are two possible modes:-
1. Mode 1(Full stepping):-
Stepping motors have 200 rotor teeth, or 200 full steps per revolution
of the motor shaft. Dividing the 200 steps into the 360º of rotation
equals a 1.8º full step angle
2. Mode 2(Half stepping):-
Half step simply means that the step motor is rotating at 400 steps
per revolution. In this mode, one winding is energized and then two
windings are energized alternately, causing the rotor to rotate at half
the distance, or 0.9º
8085 microprocessor based stepper motor
control system
Operation of Stepper motor
control system
A two phase or four winding stepper motor is shown in fig
System consist of an 8085 microprocessor as the CPU, EPROM and
RAM memory for program and data storage and for stack.
Using 8279 a Keyboard and 6 number of 7-segment LED display have
been interace in the system.
Through the keyboard user can issue commands to control the
system.
LED display messages to the user
Windings of the stepper motor are connected to the collector of
darlington pair transistors.
Transistors are switched ON/OFF by the microprocessor through the
ports of 8255 and buffer 74LS245
A free-wheeling diode is connected across each winding for fast
switching
Processor has to output a switching sequence and wait for 1 to 5
Flowchart for Stepper Motor Control System
ALGORITHM –STEPPER MOTOR
1. Initialize port A of 8255 as output port.
5. send the 4 step sequence.(reverse the step sequence for anticlock wise)
HEXA
X’ Y X Y’
VALUE
0 0 1 1 03
0 1 1 0 06
1 1 0 0 0C
1 0 0 1 09
Program for full stepping
MVI A,80H
OUT 83H
Address Data
BACK: LXI H,2000H
2000 03
MVI C,04H
2001 06
UP: MOV A,M 2002 0C
OUT 80H 2003 09
CALL DELAY
INX H
DCR C
JNZ UP
JMP BACK
Half step Mode
In mode 2(half stepping) ,the motor moves
by 0.9° to do this 1 bit is changed at a time
and the bit pattern is as:-
A B C D
0 0 0 1 01
0 0 1 1 03
0 0 1 0 02
0 1 1 0 06
0 1 0 0 04
1 1 0 0 0C
1 0 0 0 08
1 0 0 1 09
Program for Half stepping
MVI A,80H
Addres Data
OUT 83H s
BACK: LXI H,2000H 2000 0A
MVI C,08H 2001 08
2001 09
UP: MOV A,M 2002 01
OUT 82H 2003 05
CALL DELAY 2004 04
INX H 2005 06
DCR C 2006 02
JNZ UP
JMP BACK
STEPPER MOTOR-APPLICATIONS
APPLICATIONS -
LCD INTERFACING
LCD Interfacing
• Liquid Crystal Displays (LCDs)
• cheap and easy way to display text
• Various configurations (1 line by 20 char upto 8 lines
X 80 ).
• Integrated controller
• The display has two register
– command register
– data register
• By RS you can select register
• Data lines (DB7-DB0) used to transfer data and
commands
Alphanumeric LCD Interfacing
• Pinout Microcontroller
– 8 data pins D7:D0
– RS: Data or Command E communications
R/W bus
Register Select
RS
– R/W: Read or Write DB7–DB0
– E: Enable (Latch data) 8051
8
• RS – Register Select LCD
controller
– RS = 0 Command Register
LCD Module
– RS = 1 Data Register
• R/W = 0 Write , R/W = 1 Read
• E – Enable
– Used to latch the data present on the data pins.
• D0 – D7
– Bi-directional data/command pins.
– Alphanumeric characters are sent in ASCII format.
LCD Commands
• The LCD’s internal controller can accept several
commands and modify the display accordingly. These
commands would be things like:
– Clear screen
– Return home
– Decrement/Increment cursor
LM015
P3.4
R/W
P3.5 E
P3.3 RS
P1.7-P1.0 D7-D0
Interfacing LCD with 8051
mov A, command
call cmd
delay
mov A, another_cmd
call cmd
delay
mov A, #’A’
call data
delay
mov A, #’B’
call data
delay
….
Command and Data Write Routines
data:mov P1, A ;A is ascii data
setb P3.3 ;RS=1 data
clr P3.4 ;RW=0 for write
setb P3.5 ;H->L pulse on E
clr P3.5
ret
cmd:mov P1,A ;A has the cmd word
clr P3.3 ;RS=0 for cmd
clr P3.4 ;RW=0 for write
setb P3.5 ;H->L pulse on E
clr P3.5
ret
Example
Programs Using Timers
Writing delay program using 8051 timers
While designing delay programs in 8051, calculating the initial value that has to
be loaded into the TH and TL registers forms a very important thing. Let us see
how it is done.
• Assume the processor is clocked by a 12MHz crystal.
• That means, the timer clock input will be 12MHz/12 = 1MHz
• That means, the time taken for the timer to make one increment = 1/1MHz = 1uS
• For a time delay of “X” uS the timer has to make “X” increments.
• 2^16 = 65536 is the maximim number of counts possible for a 16 bit timer.
• Let TH be the value that has to be loaded into TH register and TL be the value
that has to be loaded to TL register.
• Then, THTL = Hexadecimal equivalent of (65536-X+1) where (65536-X+1) is
considered in decimal.
2 KHz Square wave using 8051 timer
1/2 of it for the high and low portions of the pulse is 250 us.
MOV TMOD,#01
MAIN: SETB P1.0
ACALL DELAY
CLR P1.0
ACALL DELAY
SJMP MAIN
DELAY: MOV TH0,#0FFH
MOV TL0,#007H
SETB TR0
HERE:JNB TF0,HERE
CLR TR0
CLR TF0
RET
THANK YOU