8051 experiments1

16,001 views
15,568 views

Published on

8051 experiments1

Published in: Technology, Business
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
16,001
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
814
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

8051 experiments1

  1. 1. 8051- Microcontroller ExperimentsExp No: 17AIM: To perform 8 bit arithmetic operations using 8051 microcontroller. A) Addition B) Subtraction C) Multiplication D) DivisionADDITION MOV R0,#00 MOV A,#DATA1 ADD A, #DATA2 JNC LABEL INC R0LABEL: MOV DPTR,#4150 MOVX @DPTR,A INC DPTR MOV A,R0 MOVX @DPTR,AHERE: SJMP HERESUBTRACTION CLR C MOV B,#00 MOV A,#DATA1 SUBB A,#DATA2 JNC LABEL CPL A INC A INC BLABEL: MOV DPTR,#4150 MOVX @DPTR, A INC DPTR MOV A,B MOVX @DPTR,AHERE: SJMP HERE
  2. 2. 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, ALOOP: SJMP LOOPDIVISION MOV A, #DATA1 MOV B,A MOV A, #DATA2 DIV AB MOV DPTR, #4150 MOVX @DPTR, A INC DPTR MOV A, B MOV @DPTR, ALOOP SJMP LOOP
  3. 3. EXP NO: 18) INTERFACING OF DAC (Digital to Analog Converter)FORGENERATIG WAVEFORMS18 A) SQUARE WAVE GENERATIONAIM. 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 waveAim To create a sawtooth wave using DACProgram MOV DPTR, #FFC8 MOV A,#00 LOOP: MOVX @DPTR,A INC A SJMP LOOP
  4. 4. 18 C) Generation of triangular waveAIM 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
  5. 5. Exp No: 19 ) Stepper Motor InterfacingAimTo interface the stepper motor with 8051 and run it in clockwise and anticlockwisedirections.ProgramStart: MOV DPTR,#4500 MOV R0,#04HJO : MOVX A,@DPTR PUSH DPH PUSH DPL MOV DPTR,#FFC0 MOV R2,#04 MOV R1,#0FDLY1: MOV R3,#0FDLY: DJNZ R3,DLY DJNZ R1,DLY1 DJNZ R2,DLY1 MOVX @DPTR,A POP DPL POP DPH INC DPTR DJNZ R0,JO SJMP STARTAddress For Clockwise For Rotation Anticlockwise Rotation4500 08 084501 01 024502 04 044503 02 01
  6. 6. Clock wise Anticlock wiseStep A1 A2 B1 B2 Step A1 A2 B1 B21 1 0 0 0 8 1 1 0 0 0 82 0 0 0 1 1 2 0 0 1 0 23 0 1 0 0 4 3 0 1 0 0 44 0 0 1 0 2 4 0 0 0 1 1

×