0% found this document useful (0 votes)
229 views6 pages

8051 Experiments1

The document describes experiments performed with an 8051 microcontroller to execute various arithmetic operations and generate different waveforms using a DAC. It includes programs to add, subtract, multiply and divide two data values. Additional programs generate square, sawtooth and triangular waves by writing output values to the DAC. A final program interfaces a stepper motor with the 8051 and runs it in clockwise and counter-clockwise directions by writing different output patterns to control pins.

Uploaded by

krishps
Copyright
© Attribution Non-Commercial (BY-NC)
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)
229 views6 pages

8051 Experiments1

The document describes experiments performed with an 8051 microcontroller to execute various arithmetic operations and generate different waveforms using a DAC. It includes programs to add, subtract, multiply and divide two data values. Additional programs generate square, sawtooth and triangular waves by writing output values to the DAC. A final program interfaces a stepper motor with the 8051 and runs it in clockwise and counter-clockwise directions by writing different output patterns to control pins.

Uploaded by

krishps
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 6

8051- Microcontroller Experiments

Exp No: 17

AIM:

To perform 8 bit arithmetic operations using 8051 microcontroller.


A) Addition
B) Subtraction
C) Multiplication
D) Division

ADDITION

MOV R0,#00
MOV A,#DATA1
ADD A, #DATA2
JNC LABEL
INC R0
LABEL: MOV DPTR,#4150
MOVX @DPTR,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
HERE: SJMP HERE

SUBTRACTION

CLR C
MOV B,#00
MOV A,#DATA1
SUBB A,#DATA2
JNC LABEL
CPL A
INC A
INC B
LABEL: MOV DPTR,#4150
MOVX @DPTR, A
INC DPTR
MOV A,B
MOVX @DPTR,A
HERE: SJMP HERE
MULTIPLICATION

MOV A, #DATA1
MOV B, A
MOV A, #DATA2
MUL AB
MOV DPTR, #4150
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A
LOOP: SJMP LOOP

DIVISION

MOV A, #DATA1
MOV B,A
MOV A, #DATA2
DIV AB
MOV DPTR, #4150
MOVX @DPTR, A
INC DPTR
MOV A, B
MOV @DPTR, A
LOOP SJMP LOOP
EXP NO: 18) INTERFACING OF DAC (Digital to Analog Converter)FOR
GENERATIG WAVEFORMS

18 A) SQUARE WAVE GENERATION

AIM.

To generate square wave using DAC.

PROGRAM

START MOV DPTR,#FFC8


MOV A,#00
MOVX @DPTR,A
LCALL DELAY
MOV A,#FF
MOVX @DPTR,A
LCALL DELAY
LJMP START
DELAY MOV R1, #05
LOOP MOV R2, #FF
HERE DJNZ R2, HERE
DJNZ R1, LOOP
RET
.

18 B) Generation of sawtooth wave

Aim

To create a sawtooth wave using DAC

Program

MOV DPTR, #FFC8


MOV A,#00
LOOP: MOVX @DPTR,A
INC A
SJMP LOOP
18 C) Generation of triangular wave

AIM

To generate triangular waveform using DAC.

Program

MOV DPTR, #FFC8


START MOV A, #00
LOOP1 MOV @DPTR,A
INC A
JNZ LOOP1
MOV A, #FF
LOOP2 MOVX @DPTR,A
DEC A
JNZ LOOP2
LJMP START
Exp No: 19 ) Stepper Motor Interfacing

Aim

To interface the stepper motor with 8051 and run it in clockwise and anticlockwise
directions.

Program

Start: MOV DPTR,#4500


MOV R0,#04H
JO : MOVX A,@DPTR
PUSH DPH
PUSH DPL
MOV DPTR,#FFC0
MOV R2,#04
MOV R1,#0F
DLY1: MOV R3,#0F
DLY: DJNZ R3,DLY
DJNZ R1,DLY1
DJNZ R2,DLY1
MOVX @DPTR,A
POP DPL
POP DPH
INC DPTR
DJNZ R0,JO
SJMP START

Address For Clockwise For


Rotation Anticlockwise
Rotation
4500 08 08

4501 01 02

4502 04 04

4503 02 01
Clock wise Anticlock wise
Step A1 A2 B1 B2 Step A1 A2 B1 B2
1 1 0 0 0 8 1 1 0 0 0 8
2 0 0 0 1 1 2 0 0 1 0 2
3 0 1 0 0 4 3 0 1 0 0 4
4 0 0 1 0 2 4 0 0 0 1 1

You might also like