0% found this document useful (0 votes)
5 views

Eee 4705 Report

The document is an assignment submission for the course EEE 4705, focusing on Microcontroller Based System Design. It includes a detailed code section for a complex engineering problem involving LCD and keypad functionalities, as well as various subroutines for handling input and output. Additionally, it features schematic diagrams illustrating circuit designs and operational scenarios for an oven system.

Uploaded by

Ashraful Azam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Eee 4705 Report

The document is an assignment submission for the course EEE 4705, focusing on Microcontroller Based System Design. It includes a detailed code section for a complex engineering problem involving LCD and keypad functionalities, as well as various subroutines for handling input and output. Additionally, it features schematic diagrams illustrating circuit designs and operational scenarios for an oven system.

Uploaded by

Ashraful Azam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

NAME : ASHRAFUL AZAM STUDENT ID : 200021121

DEPARTMENT : EEE SECTION: A

DATE OF SUBMISSION : 17/03/25

COURSE NO. : EEE 4705

COURSE TITLE : Microcontroller Based System Design

ASSIGNMENT : COMPLEX ENGINEERING PROBLEM


CODE SECTION

MOV A, #06H ;shift cursor right


ORG 00H ACALL COMNWRT ;call command
RS EQU P0.0 subroutine
RW EQU P0.1 ACALL DELAY ;give LCD some time
E EQU P0.2 MOV A, #80H ;cursor at line 1 postion
LED_PORT EQU P0.6 4
SWITCH EQU P0.7 ACALL COMNWRT ;call command
KP_PORT EQU P3 subroutine
BUZZ EQU P3.7 ACALL DELAY ;give LCD some time
SEG7_OUTPUT EQU P2
MSG_CNT EQU 60H MOV DPTR,#MSG1
LCD_INITIAL_MSG: CLR A
MAIN: MOVC A,@A+DPTR
MOV SP,#70H JZ EXIT_INITIAL_MSG
MOV PSW,#00H LCALL DATAWRT
MOV R0,#60H ;ADRESS OF DIGITS LCALL DELAY
STORES INC DPTR
MOV SEG7_OUTPUT,#00H SJMP
CLR P0.3;MAKING THE CONTROL LCD_INITIAL_MSG
PINS FOR 7 SEGMENT AS OUTPUTS
CLR P0.4 EXIT_INITIAL_MSG:
CLR P0.5
CLR LED_PORT ;----------------------------------------------------
SETB SWITCH -------KEYBORAD
CLR BUZZ CODE-------------------------------------;
KEYBOARD_STARTS:MOV
;-----------------LCD KP_PORT,#0FH
PROMPTING------------------------------------ K1:CLR KP_PORT.6
----; CLR KP_PORT.5
LCD_IN: MOV A, #38H ;init. LCD 2 CLR KP_PORT.4
lines, 5x7 matrix MOV A,KP_PORT
ACALL COMNWRT ;call command ANL A,#00001111B
subroutine CJNE A,#00001111B,K1
ACALL DELAY ;give LCD some time
MOV A, #0FH ;dispplay on, cursor on K2:LCALL DELAY
ACALL COMNWRT ;call command MOV A,KP_PORT
subroutine ANL A,#00001111B
ACALL DELAY ;give LCD some time CJNE A,#00001111B,OVER
MOV A, #01 ;clear LCD SJMP K2
ACALL COMNWRT ;call command
subroutine OVER:LCALL DELAY
ACALL DELAY ;give LCD some time MOV A,KP_PORT
ANL A,#00001111B BRINGING THE NUMBER TO A IF
CJNE A,#00001111B,OVER1 GETS MODIFIED
SJMP K2 CJNE A,#'C',START_PRESSED
LJMP MAIN
OVER1:CLR KP_PORT.6
SETB KP_PORT.5 START_PRESSED: CJNE
SETB KP_PORT.4 A,#'S',NEXT_KEY
MOV A,KP_PORT SJMP OVEN_START
ANL A,#00001111B
CJNE A,#00001111B,ROW_0
NEXT_KEY: CLR C
CLR KP_PORT.5 SUBB A,#30H
SETB KP_PORT.6 MOV @R0,A ; STORING THE
SETB KP_PORT.4 TIME DIGITS STARTING FROM 70H
MOV A,KP_PORT INC R0
ANL A,#00001111B LJMP K1
CJNE A,#00001111B,ROW_1 ;---------------------------------------------
KEYPAD CODE
CLR KP_PORT.4 END-----------------------------------------------
SETB KP_PORT.6 ----;
SETB KP_PORT.5
MOV A,KP_PORT ;--------------------------------------------CODE
ANL A,#00001111B FOR CHECKING WHETHER DATA IS
CJNE A,#00001111B,ROW_2 STORED---------------------------;
; CLR A
ROW_0:MOV DPTR,#KCODE0 ; MOV A,#0C0H
SJMP FIND ; ACALL COMNWRT
ROW_1:MOV DPTR,#KCODE1 ; ACALL DELAY
SJMP FIND ;
ROW_2:MOV DPTR,#KCODE2 ; CLR A
SJMP FIND ; MOV A,60H
;MSB
FIND: RRC A ; ADD A,#30H
JNC MATCH ; ACALL DATAWRT
INC DPTR ; ACALL DELAY
SJMP FIND ;
; CLR A
MATCH: CLR PSW.3 ;BANK 0 ; MOV A,61H
SELECTED ;MID-BIT
CLR PSW.4 ; ADD A,#30H
CLR A ; ACALL DATAWRT
MOVC A,@A+DPTR ; ACALL DELAY
LCALL DATAWRT ;
; CLR A
CLR A ; MOV A,62H
MOVC A,@A+DPTR ;AGAIN ;LSB
; ADD A,#30H
; ACALL DATAWRT EXIT_LESS_SIXTY: SJMP SHOW_NUM
; ACALL DELAY
;-------------------------------------
END----------------------------------------------- OTHER_MSG:
----;
MOV DPTR,#FACT
;-------------------------------------------- CLR A
OVEN-CODE- MOV A, #01 ;clear LCD
START------------------------------------------- ACALL COMNWRT ;call
---------; command subroutine
OVEN_START: FACT_MSG: CLR A
CLR PSW.3 MOVC A,@A+DPTR
CLR PSW.4 JZ EXIT_FACT_MSG
MOV R3,61H LCALL DATAWRT
MOV R4,60H LCALL DELAY
;SELECTING BANK 0 INC DPTR
MOV R2,62H SJMP FACT_MSG
MOV R5,#0 ;TRACK OF
EVERY 20s
MOV EXIT_FACT_MSG: SJMP SHOW_NUM
MSG_CNT,#0 ;TRACK OF MESSAGES
CLR BUZZ
SETB LED_PORT
SJMP START_COUNT

START_COUNT:

LESS_SIXTY_CHECK: CJNE CLR C


R3,#6,CHECK1 CJNE
CHECK1: JNC OTHER_MSG R4,#0,OTHER_MSG
SJMP
MOV DPTR,#MSG3 LESS_SIXTY_CHECK
CLR A
MOV A, #01 ;clear LCD SHOW_NUM: JNB SWITCH,DISP
ACALL COMNWRT ;call SJMP
command subroutine EMERGENCY_SWITCH
LESS_SIXTY_MSG: CLR A DISP: ACALL
MOVC A,@A+DPTR SEG7_DISP_FUNC
JZ EXIT_LESS_SIXTY INC R5
LCALL DATAWRT ACALL CHECK_20_MSG
LCALL DELAY
INC DPTR CHECK_R2: CJNE R2,#0,DEC_R2
SJMP SJMP CHECK_R3
LESS_SIXTY_MSG
DEC_R2: DEC R2 OVEN-CODE-
SJMP SHOW_NUM END-----------------------------------------------
-------;
CHECK_R3: CJNE R3,#0,DEC_R3
SJMP CHECK_R4
EMERGENCY_SWITCH: CLR
DEC_R3: DEC R3 LED_PORT
MOV R2,#9
SJMP SHOW_NUM MOV DPTR,#MSG4
CLR A
CHECK_R4: CJNE R4,#0,DEC_R4 MOV A, #01 ;clear LCD
SJMP DONE_COUNT ACALL COMNWRT ;call
command subroutine
EMERGENCY_MSG: CLR A
DEC_R4: DEC R4 MOVC A,@A+DPTR
MOV R2,#9 JZ
MOV R3,#9 EXIT_EMERGENCY_MSG
SJMP SHOW_NUM LCALL DATAWRT
LCALL DELAY
DONE_COUNT: INC DPTR
SJMP
EMERGENCY_MSG

EXIT_EMERGENCY_MSG: SJMP
MOV DPTR,#MSG2 EXIT_EMERGENCY_MSG
CLR A
MOV A, #01 ;clear LCD ;--------------------------------------------
ACALL COMNWRT ;call SUBROUTINES--------------------------------
command subroutine ------------------------;
LCD_COUNT_MSG: CLR A COMNWRT: LCALL READY ;send
MOVC A,@A+DPTR command to LCD
JZ EXIT_COUNT_MSG MOV P1, A ;copy reg A to port 1
LCALL DATAWRT CLR RS ;RS=0 for command
LCALL DELAY CLR RW ;R/W=0 for write
INC DPTR SETB E ;E-1 for high pulse
SJMP ACALL DELAY ;give LCD some time
LCD_COUNT_MSG CLR E ;E=0 for H-to-L pulse
RET

EXIT_COUNT_MSG:
DATAWRT: LCALL READY ;write data
CLR LED_PORT to LCD
SETB BUZZ MOV P1, A ;copy reg A to port1
SJMP EXIT_COUNT_MSG SETB RS ;RS=1 for data
CLR RW ;R/W=0 for write
;-------------------------------------------- SETB E ;E=1 for high pulse
;ACALL DELAY ;give LCD SETB P0.3
some time CLR P0.5
CLR E ;E=0 for H-to-L pulse MOV A,R2
RET MOVC A,@A+DPTR
MOV SEG7_OUTPUT,A
READY: SETB P1.7 ACALL DELAY1
CLR RS ACALL DELAY
SETB RW
WAIT: CLR E
LCALL DELAY SETB P0.5
SETB E SETB P0.3
JB P1.7, WAIT CLR P0.4
RET MOV A,R3
MOVC A,@A+DPTR
DELAY: SETB PSW.3 MOV SEG7_OUTPUT,A
SETB PSW.4 ACALL DELAY1
MOV R3, #30 ;50 or higher for fast ACALL DELAY
CPUs
H1: MOV R4, #255 ;R4=255 SETB P0.4
H2: DJNZ R4, H2 ;stay untill R4 SETB P0.5
becomes 0 CLR P0.3
DJNZ R3, H1 MOV A,R4
CLR PSW.3 MOVC A,@A+DPTR
CLR PSW.4 MOV SEG7_OUTPUT,A
RET ACALL DELAY1
ACALL DELAY
;CREATING 1ms DELAY:
DELAY1: SETB PSW.3 DJNZ R6,LOOP
SETB PSW.4
MOV R3, #4 RET
H3: MOV R4, #132
H4: DJNZ R4, H4 ;stay untill R4 CHECK_20_MSG:
becomes 0 CLR C
DJNZ R3, H3 CJNE
CLR PSW.3 R5,#20,RAND_MSG_CHECK
CLR PSW.4 MOV R6,MSG_CNT
RET INC R6
SJMP PRINT_MSG

SEG7_DISP_FUNC:
MOV R6,#20 RAND_MSG_CHECK:
LOOP: JC LESS_20
MOV R5,#0
MOV SJMP FINISH
DPTR,#DIGIT_DRIVE_PATTERN
SETB P0.4
LESS_20: SJMP FINISH FINISH:
MOV MSG_CNT,R6
RET

;------------------------------------------------
PRINT_MSG: LOOK UP
TABLE-------------------------------------------
CJNE R6,#01,NEXT_ONE -------;
SJMP PRINT_1 ;ASCII LOOK-UP TABLE FOR EACH
ROW
KCODE0: DB '6','7','8','9' ;ROW 0
NEXT_ONE: KCODE1: DB '2','3','4','5' ;ROW 1
KCODE2: DB 'C','S','0','1' ;ROW 2
PRINT_1:
DIGIT_DRIVE_PATTERN: DB 3FH,
MOV R5,#0 06H,5BH, 4FH, 66H, 6DH, 7DH, 07H,
MOV DPTR,#MSG5 7FH, 6FH
CLR A
MOV A, #01 ;clear LCD MSG1: DB 'INPUT TIME: ',0
ACALL COMNWRT ;call FACT: DB 'GREATER THAN 60s',0
command subroutine MSG5: DB 'HUMANS EAT',0
PMSG5: CLR A MSG2: DB 'DONE-COOKING!!',0
MOVC A,@A+DPTR MSG3: DB 'LESS THAN 60s',0
JZ EXIT_PMSG5 MSG4: DB 'EMERGENCY STOP!',0
LCALL DATAWRT END
LCALL DELAY
INC DPTR
SJMP PMSG5

EXIT_PMSG5: SJMP FINISH

SCHEMATIC AND SIMULATION


Figure 1 (CIRCUIT SCHEMATIC)

Figure 2 (OVEN NORMAL OPERATION)


Figure 3 (EMERGENCY STOP)

You might also like