Professional Documents
Culture Documents
27
• Stepper motor is an electromechanical device that
rotates through fixed angular steps when digital
inputs are applied. It is suitable for precise position,
speed and direction control which are required in
automation system.
• The angle through which stepper motor rotates with a
fixed angle for each digital data is called step angle.
• Different stepper motor has different step angle. The
more frequently used stepper motor has step angle of
0.9 degrees and 1.8 degrees.
Depending on the sequence applied to stepper motor,
it can be classified in two category:
a. 4- Step sequence or full step sequence
b. 8- Step sequence or half step sequence
28
Calculations:
1. Total no. of steps for 360 degree completion
if step angle = 1.8 degree then 360/1.8 = 200
i.e. 200 steps are required to complete one rotation
2. RPM = revolution per minute ( i.e how many
rotation per minute of 200 steps)
Ex: 50 RPM hence
Time of one revolution in msec = (1/RPM) * 60*1000
= (1/50)*60*1000
= 1200msec
3. Step Sequence –
a) Half step b) full step
29
HALF STEP
30
FULL STEP
31
Interfacing with 8051
Debug the code…
org 0000h
jmp Start
org 0100h
Start: mov r3,#50
mov a,#00110011b
l1: mov p2,a
rr a
acall delay
djnz r3,l1
here: sjmp here
delay: mov r0,#255
l2: mov r1,#255
l3: djnz r1,l3
djnz r0,l2
ret
END
org 0000h
jmp Start
org 0100h
Start: mov r3,#20
mov r4,#10
mov a,#00110011b
l1: mov p2,a
rr a
acall delay
djnz r3,l1
l4: rl a
Debug the code… mov p2,a
acall delay
djnz r4,l4
here: sjmp here
delay: mov r0,#255
l2: mov r1,#255
l3: djnz r1,l3
djnz r0,l2
ret
END
DAC (Digital to analog Conversion)
35
Interfacing circuit example
Proteus Circuit (TVref=+12V)
Debug the output Window WRT code!!
Calculations –Vref=+6V i.e total VREF = 12V
a square wave 2V per division*6 div = 12V PtoP
starting at 00H = -6V & ending at FFH = 255D =
255*0.047V = 12V
Time division 5 DIV * 50us = 250(TON/TOFF)us
total time = 500us
Frequency = 1/500us = 2Khz.
39
Homework
Considering VREF as 12 volts and DAC is interfaced at
PORT 2. Write an assembly language program to
a) Forward saw tooth wave of 12v peak to peak
b) Reverse saw tooth wave of 12v peak to peak
c) Triangular Wave of 12V peak to peak
d) Square wave of 5v peak to peak clammed at 5V OF 1KHZ
FREQUENCY
E) Sine wave
40
ADC0808/0809
IN0-IN7: Analog Input channels
D0-D7: Data Lines
A, B, C: Analog Channel select lines;
A is LSB and C is MSB
OE: Output enable signal
ALE: Address Latch Enable
EOC: End of Conversion signal
Vref+/Vref-: Differential Reference
voltage input
Clock: External ADC clock input
Clock Circuit
• The ADC 0808 IC requires clock
signal of typically 550 kHz,
which can be easily derived
from an Astable multi-vibrator
constructed using the shown
circuit
Interfacing of ADC0808 with 8051 in Proteus
Debug the code!!
start equ P3.5 setb start
eoc equ P3.6 acall delay
sel_a equ P3.1 clr start
sel_b equ P3.2 jnb eoc, $ ; $ means jump to same location
sel_c equ P3.3
mov A, adc_data
mov p2,A
adc_data equ P1
acall delay
org 0H
acall delay
setb eoc
sjmp main_loop
clr start delay: mov r0,#255
djnz r0,$
main_loop: mov adc_data, #0FFH ret
setb sel_a end
clr sel_b
clr sel_c
Memory Mapping of 8051
• Memory interfacing is used to provide more memory space to
accommodate complex programs for more complicated systems.
• Types of memories which are most commonly used to interface with
8051 are RAM, ROM, and EEPROM.
• 8051 can access 64kB of external memory. It can be explained as-
total number of address lines in 8051 are 16, therefore it can access
2^16 = 65535 locations i.e. 64kB