




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Aim: To blink the LED and generate 50% duty cycle square wave using 8051 microcontroller. Requirements: Proteus Simulation and Keil Software Theory: Square waves of any frequency can be generated using the 8051. Write up a delay subroutine with delay equal to half the time period of the square wave. Make any port pin high and call the delay subroutine. After the delay subroutine is finished, make the corresponding port pin low and call the delay subroutine gain. After the subroutine is finished, repeat the cycle again. The result will be a square wave of the desired frequency at the selected port pin. The diagrams are shown below and it can be used for any square wave.
Program: ; Reset Vector org 0000h ;==================================================================== ; CODE SEGMENT ;==================================================================== org 0100h HERE: SETB P1.0 ;set to high bit 0 of port 1 LCALL DELAY ;call the delay subroutine CLR P1.0 ;P1.0=
Program: ; Reset Vector org 0000h ;==================================================================== ; CODE SEGMENT ;==================================================================== org 0100h HERE: MOV A,#00H MOV P1,A LCALL DELAY CPL A MOV P1,A LCALL DELAY SJMP HERE DELAY: MOV R2, # LOOP1: MOV R1,# LOOP2: MOV R0,# LOOP3: DJNZ R0,LOOP DJNZ R1,LOOP DJNZ R2, LOOP RET END i. Change one second delay to 5 seconds. ii. Insert the register accumulator with AAH. What happen to the port pins after that instruction ( mov a, #aah)? iii. According to the above diagram, Is it sinking or sourcing current? EXPERIMENT NO. 3 Aim: To display the decimal number 0 to 9 via 7 segment decoder using 8051 microcontroller. Requirements: Proteus Simulation and Keil Software Theory: Write up a delay subroutine with delay one second. After the delay subroutine is finished, make the corresponding port pins low and call the delay subroutine gain. After the subroutine is finished, repeat the cycle again. The schematic diagram is shown below.
Program: ;==================================================================== ; RESET and INTERRUPT VECTORS ;==================================================================== ; Reset Vector org 0000h jmp Start org 0050h DECIMAL_CODES: DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 12H, 02H, 0F8H, 80H, 90H ;==================================================================== ; CODE SEGMENT ;==================================================================== org 0100h MOV P2, #0FFH MOV SP, #08H MOV DPTR, #0050H RE: CLR A MOV R7,A
Aim: To response the status (sense value) of sensor using 8051 microcontroller. Requirements: Proteus Simulation and Keil Software Condition: bit P2.3 is an input and represents the condition of an oven. If it goes high, it means that the oven is hot. Monitor the bit continuously. Whenever it goes high, send a high-to-low pulse to port P1.5 to turn on a buzzer. Program: ;==================================================================== ; RESET and INTERRUPT VECTORS ;==================================================================== HERE: JNB P2.3, HERE ; keep monitoring for high SETB P1.5 ; set bit P1.5= CLR P1.5 ; make high-to-low SJMP HERE ; keep repeating EXPERIMENT NO. 6 Aim: To control the unipolar stepper motor using 8051 microcontroller. Requirements: Proteus Simulation and Keil Software Condition: Implement full step, wave step, half step motor as shown in the following figure. Program:
; Reset Vector org 0000h ;==================================================================== ; CODE SEGMENT ;==================================================================== mov p1, #00h mov sp, #08h mov a, #08h repeat: mov p1,a rr a acall delay jmp repeat delay: mov r2, # loop1: mov r1, # loop2: mov r0, # loop3: djnz r0, loop djnz r1, loop djnz r2, loop ret END