Lab Report 02

Microprocessors and Interfacing
ECX 4236

Name Reg.No Center

: S.A.D.L. Janaka : 50564695 : Colombo

Write AL program to detect DC motor direction. Identify DC motor operating state using 8051 microcontroller. Write AL program to display the motor RPM on LCD. Writing ASM program to generate PWM signals. Study to write assembly language programs to display values on LCD display in the 8051 development board.Aim: • • Study to write assembly language programs using 8051 microcontroller timers and counters. Equipments Used: • • • • • AES-51 Development board Power Adaptor 6-Foot serial ribbon cable DC motor Computer Software Tools used: • • • • Note pad ASM-51 Assembler 8052 Simulator Terminal Emulator Procedure: • • • • • Connect the power adaptor to the AES-51 development board Power up the board Write AL program to generate duty cycle of 25% PWM signal which has 40Hz frequency. Identify to connect DC motor to 8051 microcontroller.ASM) file . Familiar with the use of LCD display on the 8051 development board. • Connect the PC to the AES-51 Board using serial ribbon cable and power up the PC • Write the source code (ALP) in Notepad and save it as ASM (File name . Objectives: • • • • • Familiar with the use of the 8051 timer and counter in 8051.

* Program 1: AL program that generate duty cycle of 25% PWM signal which has 40 Hz frequency P1_4 BIT 94H P1_5 BIT 95H TMOD DATA 89H addressable TR0 BIT 8CH addressable TF0 BIT 8DH addressable TL0 DATA 8AH TH0 DATA 8CH ORG 7000H HERE: CLR P1_4 SETB P1_5 ACALL DELAY SETB P1_4 CLR P1_5 ACALL DELAY ACALL DELAY ACALL DELAY SJMP HERE . Enable TR0 bit in TCON register bit .4 bit addressable . Enable TF0 bit in TCON register bit . Enable TH0 data addressable .BACK CLR TR0 CLR TF0 RET . Return from Delay subroutine BACK: JNB TF0. select Timer0 as 16 bit mode .#01H TH0. Stay Back until timer over flow . Enable port 1.4 .#0E7H TL0.25ms timer delay . Clear port 1. Enable TMOD register data .5 bit addressable . Enable port 1. Clear port 1. Clear timer overflow flag bit . load Timer value to get 6.************************** Timer delay *********************** DELAY: MOV MOV MOV SETB TMOD. Start timer . Enable TL0 data addressable .• Use ASM-51 Assembler to produced HEX file (Which contains machine codes in hex format plus address) and LST file (Which contains detail records of both the source file and the hex machine code) • Using LST (List) file check whether is there any errors in the program • Use 8052 Simulator to simulate our program • Use Terminal Emulator (TE) to download the program to the AES-51 Development board and execute assembly language programs.5 . Stop timer .#96H TR0 .

8051 T1 PIN IS SET AS BIT ADDRESIBLE FOR .clockwise detection .#00110000B .END * Program 2: AL program that detect DC motor direction and give a signal to the P1 using counter TMOD DATA 89H T0 BIT 0B4H FOR CHANNEL A T1 BIT 0B5H CHANNEL B P_1 DATA 90H TR0 BIT 8CH TF0 BIT 8DH TL0 DATA 8AH TH0 DATA 8CH ORG 7000H . Stay hear until counter overflow . Load counter value MOV TH0. Enable Enable Enable Enable Enable port P1 data addressable TR0 bit in TCON register bit addressable TF0 bit in TCON register bit addressable TL0 data addressable TH0 data addressable COUNTER: MOV TMOD. Detect falling edge of channel B .$ JB T1.Signal by on most left LED in port 1 after clockwise .detection CLR TR0 CLR TF0 SJMP COUNTER CCW: MOV P_1. Start counter JNB TF0.#0FEH . 8051 TO PIN IS SET AS BIT ADDRESIBLE . .#00000100B . Select timer0 as 8 bit counter MOV TL0. Signal by on most left LED in port 1 after counter . Enable TMOD register data addressable .#00H SETB TR0 . . . .CCW SJMP CW CW: MOV P_1.#11000000B .

CLR TF0 CLR TR0 SJMP COUNTER RET END ∗ Program 3: AL program that detect the motor direction and display on LCD TMOD DATA 89H T0 BIT 0B4H FOR CHANNEL A T1 BIT 0B5H CHANNEL B P_1 DATA 90H TR0 BIT 8CH TF0 BIT 8DH TL0 DATA 8AH TH0 DATA 8CH ORG 7000H COUNTER: .$ JB T1.#00000100B . Start counter JNB TF0.#9 . 8051 TO PIN IS SET AS BIT ADDRESIBLE . . . Detect falling edge of channel B MOV DPTR. Enable Enable Enable Enable Enable port P1 data addressable TR0 bit in TCON register bit addressable TF0 bit in TCON register bit addressable TL0 data addressable TH0 data addressable MOV TMOD. . 8051 T1 PIN IS SET AS BIT ADDRESIBLE FOR .CW SJMP CCW CW: call 4100h . Stay hear until counter overflow .#00H SETB TR0 .#0FEH . .#7504h MOV R1. Load counter value MOV TH0. Select timer0 as 8 bit counter MOV TL0. Enable TMOD register data addressable .

A MOV 21h.displayable INC DPTR DJNZ R1.R0 CALL 4104h 21h to LCD .@A+DPTR MOV R0.move code address to accumulator MOV R0.#7500h MOV R1.R0 CALL 4104h INC DPTR DJNZ R1.display2 RET .#13 display2:CLR A MOVC A.display1 RET CCW: call 4100h MOV DPTR.Send the ascii codes in internal memory location .display1: CLR A MOVC A.@A+DPTR .A MOV 21h.

ORG 7500h db'anticlockwise' END .

Sign up to vote on this title
UsefulNot useful