Mr. Vinod P. Tayade (M.Tech. VLSI Tech.)Stepper Motor –Interfacing with 8051 Mr. V. P. Tayade,...

Preview:

Citation preview

Mr. Vinod P. Tayade (M.Tech. VLSI Tech.)

LED Interfacing

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

2

LED Program

ORG 0

MOV P0,#00H

MOV A,#0FH

UP: MOV P0,A

ACALL DELAY

SWAP A

SJMP UP

DELAY: MOV R0,#0FFH R0=FFH

L2: MOV R1,#0FFH R1=FFH

L1 : DJNZ R1,L1

DJNZ R0,L2

RET

END

0 0 0 0 1 1 1 1

P0.7 P0.0

LED7 LED0

1 1 1 1 0 0 0 0

2/8/2021

3

Mr. V. P. Tayade, Government Polyechnic, Nashik

LCD-Pins

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

4

LCD-commands

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

5

LCD Interfacing

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

6

LCD-Program

org 0

MOV DPTR,#MYCOM

C1: CLR A

MOVC A,@A+DPTR

JZ SEND_DATA

ACALL COMNWRT

INC DPTR

SJMP C1

SEND_DATA : MOV DPTR,#MYDATA

D1 : CLR A

MOVC A,@A+DPTR

JZ AGAIN

ACALL DATAWRT

INC DPTR

SJMP D1

AGAIN : SJMP AGAIN

COMNWRT: MOV P2,A

CLR P3.7 ; RS=0

CLR P3.6 ; RW=0

SETB P3.5 ; E=1

ACALL DELAY

CLR P3.5 ; E=0

RET

DATAWRT: MOV P2,A

SETB P3.7 ;RS=1

CLR P3.6 ; RW=0

SETB P3.5 ; E=1

ACALL DELAY

CLR P3.5 ; E=0

RET

2/8/2021

7

Mr. V. P. Tayade, Government Polyechnic, Nashik

DELAY: MOV R3,#250

HERE2 : MOV R4,#255

HERE : DJNZ R4,HERE

DJNZ R3,HERE2

RET

ORG 300H

MYCOM : DB 38H,0EH,01H,06H,84H,0

MYDATA: DB ‘ENTC',0

END

7-segment display-Pin diagram

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

8

Interfacing 7-segment with 8051

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

9

Coding Table

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

10

P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0

No Dp G F E D C B A code

0 0 0 1 1 1 1 1 1 3FH

1 0 0 0 0 0 1 1 0 06H

2 0 1 0 1 1 0 1 1 5BH

3 0 1 0 0 1 1 1 1 4FH

4 0 1 1 0 0 1 1 0 66H

5 0 1 1 0 1 1 0 1 6DH

6 0 1 1 1 1 1 0 1 7DH

7 0 0 0 0 0 1 1 1 07H

8 0 1 1 1 1 1 1 1 7FH

9 0 1 1 0 1 1 1 1 6FH

Prog-BCD UP counter

ORG 0

MOV P0,#00H

UP : MOV DPTR,#SEG

UP1 :CLR A

MOVC A,@A+DPTR

JZ UP

MOV P0,A

ACALL DELAY

ACALL DELAY

INC DPTR

SJMP UP1

DELAY : MOV R0,#0FFH

L3 : MOV R1,#0FFH

MOV R2,#0FFH

L1 : DJNZ R2,L1

L2 : DJNZ R1,L2

DJNZ R0,L3

RET

SEG : DB 3FH,06H,5BH, 4FH, 66H,6DH,7DH,07H,7FH,6FH,0

RSEG : DB 6FH,7FH,07FH,7DH,6DH,66H,4FH,5BH,06H,3FH,0

END

2/8/2021

11

Mr. V. P. Tayade, Government Polyechnic, Nashik

DC-Motor Driver IC-L293D

2/8/2021

12

Mr. V. P. Tayade, Government Polyechnic, Nashik

DC-MOTOR-Interfacing with 8051.

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

13

Write ALP to rotate DC motor in clockwise and

Anticlockwise direction with a delay.

ORG 0

MAIN : MOV P1,#0000 0001B

ACALL DELAY

MOV P1,#0000 0010B

ACALL DELAY

SJMP MAIN

DELAY : MOV R0,#0FFH

L3 : MOV R1,#0FFH

MOV R2,#0FFH

L1 : DJNZ R2,L1

L2 : DJNZ R1,L2

DJNZ R0,L3

RET

END

2/8/2021

14

Mr. V. P. Tayade, Government Polyechnic, Nashik

Stepper Motor

2/8/2021

15

Mr. V. P. Tayade, Government Polyechnic, Nashik

Stepper Motor - Sequence

A1 A2 A3 A4 Full

step

seq

1 0 0 0 08h

0 1 0 0 04h

0 0 1 0 02h

0 0 0 1 01h

2/8/2021

16

Mr. V. P. Tayade, Government Polyechnic, Nashik

Step Angle

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

17

The step size of the motor is determined by the

number of phases and the number of teeth on the

rotor. Step size is the angular displacement of the

rotor in one step. If a stepper motor has 4 phases

and 50 teeth, it takes 50×4=200 steps to make

one complete rotation. So step angle will be

360/200=1.8°

Stepper Motor – Interfacing with 8051

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

18

Stepper Motor - Program

A1 EQU P1.0

A2 EQU P1.1

A3 EQU P1.2

A4 EQU P1.3

ORG 00H

MAIN: CLR A1

ACALL DELAY

SETB A1

CLR A2

ACALL DELAY

SETB A2

CLR A3

ACALL DELAY

SETB A3

CLR A4

ACALL DELAY

SETB A4

SJMP MAIN

DELAY : MOV R0,#0FFH

L3 : MOV R1,#0FFH

MOV R2,#0FFH

L1 : DJNZ R2,L1

L2 : DJNZ R1,L2

DJNZ R0,L3

RET

END

2/8/2021

19

Mr. V. P. Tayade, Government Polyechnic, Nashik

DAC0808-Interfacing with 8051.

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

20

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

21

5.12V

FFH - 5.12V

00H-01H = 0v to 20mV

5V / 255 = 0.0196V = 19.6mV=20 mV

Write ALP to generate triangular

waveform at the output of DAC0808.

ORG 0

START : MOV A,#00H

UP : MOV P1,A

INC A

CJNE A,#0FFH,UP

UP1:MOV P1,A

DEC A ;A=00

CJNE A,#00H,UP1

SJMP UP

2/8/2021

22

Mr. V. P. Tayade, Government Polyechnic, Nashik

Write ALP to generate square wave at

the output of DAC0808.

ORG 0

UP:MOV A,#00H

MOV P1,A

ACALL DELAY

MOV A,#0FFH

MOV P1,A

ACALL DELAY

SJAMP UP

2/8/2021

23

Mr. V. P. Tayade, Government Polyechnic, Nashik

ADC0809-Pin Diagram

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

24

Interfacing of ADC0809 with 8051.

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

25

Write an ALP to convert analog voltage of

CH-4 to digital using ADC0809.

ORG 0

MOV P1,#0FFH

BACK:SETB P2.2 ; CH-4

CLR P2.1

CLR P2.0

SETB P2.3 ; ALE

ACALL DELAY

CLR P2.3

SETB P2.5 ; SOC

ACALL DELAY

CLR P2.5

HERE : JB P2.6,HERE ;EOC

SETB P2.4 ; OE=1

MOV A,P1

CLR P2.4 ; OE =0

ACALL DISPLAY

SJMP BACK

END

2/8/2021

26

Mr. V. P. Tayade, Government Polyechnic, Nashik

Keyboard Interfacing with 8051

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

27

Keyboard - Interfacing

2/8/2021Mr. V. P. Tayade, Government Polyechnic, Nashik

28

Recommended