Design Assignment on
Microwave Oven
For the partial fulfillment of the course
INSTR F241 - Microprocessor Programming & Interfacing
BITS Pilani, Pilani Campus
Designed By:
Arpit Mudgal - 2017A8PS0600P
Sakshi Paliwal - 2017A8PS0607P
Mohit Bhatia - 2017A8PS0611P
Nagesh Samane- 2017A8PS0612P
Problem Statement
System to be Designed : Microwave Oven (P5)
Description: A Simple Microwave Oven without grill.
User Interface: Is shown in the following Figure
● User can cook at 3 different Power levels: 90%, 60%, 30%
● Press of a Power Button decrements the power level by 30 %
● 1 Press - 90%; 2 Presses – 60%; 3 Presses – 30%; 4 Presses – 100 %;
● 4 Presses – Brings the power level back to 100 %
● The Default power level is 90%
● Power Level is varied by controlling the amount of time for which the microwave is turned on.
● Time of cooking is broken up into 10 sec slots, if power is 60% then for 6 seconds the microwave
is on and rest of the 4 seconds the microwave is off.
● Time is set as multiples of 10 Mins, 1 Min, 10 Secs. For e.g. if the cooking time is 12 Minutes and
40 secs- the 10 Minutes button has to be pressed once, 1 Minute Button has to be pressed
Twice and 10 seconds button has to be pressed four times.
● Once Time has been set Power cannot be modified.
● When user is setting power level or Time, the value being pressed should be displayed, and
when user presses the Start button, the cooking process begins and the time left for cooking to
complete is displayed.
● Once the cooking begins the door gets locked and should open only when cooking process is
terminated.
● User can terminate cooking anytime by pressing the STOP button. When Stop button is pressed
once cooking is aborted, timer is stopped, not cleared; cooking can be resumed by pressing
Start.
● When stop is pressed twice, cooking is aborted and timer is also cleared.
● When cooking time elapses, a buzzer is sounded; pressing the Stop Button stops the buzzer.
● A Quick Start mode is available where timer or power need not be set, just Start button needs to
be pressed, the default power value is taken and time is set as 30 secs, for every press of the
start button time is incremented by 30 seconds.
2
Assumptions
● Maximum time for cooking user can set is 9999 seconds.
● Time Display format - SS-SS
● Power Display format - PPPP
● There is mechanism by which the door will be locked if LED LOCK is on and
open if LED LOCK is off. The door will automatically get locked once the user
presses start/quick start and will open when the process gets completed.
● Multiple keys cannot be pressed simultaneously
● A clock frequency of 2MHz and 1Hz is available to be given to TIMER 2 and
TIMER1 respectively.
● The time required for loading the latched values into counters of 8253 after giving
the gate trigger has been taken as negligible in comparison to total time.
● Key must be pressed only after display is off.
● OVEN STATUS button shows time for which oven is on. Glowing of LED indicates
ON status otherwise its OFF status. This mechanism is used for dividing 10s cooking
time according to the power level.
3
List of Important Components Used
Chip Chip No. of Use
Number Chips
used
8086 Microprocessor 1 CPU
2732 ROM 2 Read Only Memory
74LS373 8 - BIT latch 3 To latch Address Bus
74541 8 - BIT Buffer 1 Unidirectional Buffer
8255 Programmable 2 Connected to various I/O devices
Peripheral Interface
8253 Timer 2 To keep count for
countdown and dividing
time for on-off status of
oven
8284A Clock generator 1 Generate CLK for 8086 and
8254. Crystal Frequency - 5
MHz
74HC138 3:8 Decoder 3 For selecting between the
various components like
ROM, RAM, TIMER1
6116 RAM - 2K 2 Random Access Memory
7447 BCD to Hex converter 1 To convert BCD count to
hexadecimal format of seven
segment display
74LS245 8 - BIT Buffer 2 Bi-directional Buffer
4
Other Components Used
1. Buzzer - To Indicate the end of cooking of time
2. Resistors (10 k) - To limit current in the components
3. Multiplexed 7 Segment Display - To Display Time and Power
4. AND Gates
5. LOGIC NOT
6. LOGIC OR
7. Push Buttons - To input the power, time, start and stop signals from the
user.
8. NPN transistor
9. Relay mechanism
10. VCC, Ground, LED’s
5
Hardware Specifications
Ports of 8255 (1) Address Mode Function of port
Port A 5000h - -
Port B 5002h - -
Port C 5004h Mode 0 - Signals sent to buzzer, lock, select lines of 7
Output segment display
Control Register 5006h - Programming of PPI
Ports of 8255 (2) Address Mode Function of Port
Port A 6000h Mode 0 - Output Output for 7 segment display
Port B 6002h Mode 1 - Input Takes input from the 6 buttons and the
timer
Port C 6004h - -
Control Register 6006h - Programming of PPI
8253 - TIMER 1 Address Mode Count Loaded/Function
Counter A 2000h Mode 3 20,000 Decimal
Counter B 2002h Mode 3 1000 Decimal
Counter C 2004h Mode 1 Count Loaded as per Power
Control Register 2006h - Used for Programming Timer
8253 - TIMER 2 Address Mode Count Loaded/Function
Counter A 3000h Mode 3 20,000 Decimal
Counter B 3002h Mode 3 100 Decimal
Counter C 3004h - -
Control Register 3006h - Used for Programming Timer
6
MEMORY MAPPING
ROM: 00000H - 00FFFH
ROM A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
(even)
From
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00000h
To
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0
00FFEh
ROM A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
(odd)
From
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
00001h
To
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
00FFFh
RAM: 01000H - 01FFFH
RAM A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
(even)
From
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
01000h
To
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0
01FFEh
RAM A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
(odd)
From
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
01001h
To
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
01FFFh
7
Flowchart
8
8
CODE:
.model tiny
.data
sec equ 1010h ;Stores the total time left for the countdown
power equ 1012h ;Stores the number of power presses
start equ 1013h ;Stores the number of start button presses
stop equ 1014h ;Stores the number of stop button presses
disp equ 1015h ;Next 4 bytes will be stored for 4-digit BCD count
inp equ 1019h ;Stores the input from the port - to check which button is
pressed
time_loop equ 1020h
.code
.startup
;Initializing the values at the following addresses:
mov si,sec
mov word ptr [si],0 ;Time remaining=0
mov si,power
mov byte ptr [si],-1 ;No. of times Power is pressed= -1
mov si, start
mov byte ptr [si],0 ;No. of times start is pressed= 0
mov si,stop
mov byte ptr [si],0 ;No. of times stop is pressed= 0
;Initializing 8255(1)
mov al,10000000b ;I/O Mode: All ports are output ports
mov dx,5006h ;5006h is address of CREG
out dx,al
;Initializing 8255(2)
mov ax,10000010b ;Port B input, Port A as output, Port C output
mov dx,6006h ;address of CREG=6006h
out dx,al
mov al,00011111b ; PC0-PC3=not connected, PC4=1 Countdown can't be started
mov dx,5004h ; PC5=0 Buzzer Indicator OFF, PC6=0 Power input can be
taken, PC7=0 door locked
out dx,al
;Set up Timer1
mov al,00110110b ;TIMER1:COUNTER0, Loading Control Word, mode 3
mov dx,2006h
out dx,al
10
mov al,20h ;TIMER1:COUNTER0 Loading count
mov dx,2000h
out dx,al
mov al,4Eh
mov dx,2000h
out dx,al
mov al,01110110b ;TIMER1:COUNTER1, loading Control Word, mode 3
mov dx,2006h
out dx,al
mov al,0E8h ;TIMER1:COUNTER1 Loading count
mov dx,2002h
out dx,al
mov al,03h
mov dx,2002h
out dx,al
mov al,10010010b ;TIMER1:COUNTER2, oading Control Word; Mode 1
mov dx,2006h
out dx,al
;Count will be loaded to TIMER1 COUNTER2 Later
;Set up Timer2
mov ax,00110110b ;TIMER2:COUNTER0 Control Word, mode 3
mov dx,3006h
out dx,al
mov ax,20h ;TIMER2:COUNTER0 Loading count
mov dx,3000h
out dx,al
mov ax,4Eh
mov dx,3000h
out dx,al
mov ax,01010110b ;TIMER2:COUNTER1 Control Word, mode 3
mov dx,3006h
out dx,al
mov al,19h ;TIMER2:COUNTER 1 Loading count
mov dx,3002h
out dx,al
get_press: call button ;to get which button is pressed and number of presses of that button
11
is stored at location
mov si,start ;loads if start is pressed or not
mov al,[si] ;al has that count
cmp al,0
je n
call display
n: jmp get_press
add_10min: mov ax,600 ;Increment the time by 600 seconds i.e 10
minutes
mov si,sec ;sec keeps the time remained for cooking
add [si],ax
mov cl,1 ;just a flag
jmp show_num
add_1min: mov ax,60 ;Increment the time by 60 seconds i.e 1 minute
mov si,sec
add [si],ax
mov cl,2 ;just a flag
jmp show_num
add_10sec: mov ax,10 ;Increment the time by 10 seconds
mov si,sec
add [si],ax
mov cl,3 ;just a flag
jmp show_num
show_num:mov di,time_loop
mov ax,50 ;50 moved to word sized location time_loop
mov [di],ax
mov si,start ;start keeps the count of number of presses of start
mov al,[si]
cmp al,0
jne dontdisplay ;if start is not pressed go on checking for next
button pressed
timedisplay: call display ;This is executed only if Start button is not even
pressed once
dec byte ptr [time_loop];if start is not pressed the display time
without decrement
jnz timedisplay
mov al,00h ;Dispaly Clear
12
mov dx,6000h
out dx,al
dontdisplay: nop
cmp cl,1
jz B1
cmp cl,2
jz B2
cmp cl,3
jz B3
POW: mov si,sec
mov ax,[si]
cmp ax,0
jnz powerdisplay
mov si,power ;Setting up the power according to number of presses of
power button
mov al,[si] ;loading present number of presses of power
add al,1
cmp al,04
jne x2
mov al,0
x2: mov [si],al
mov di,time_loop
mov ax,50
mov [di],ax
mov si,start
mov al,[si]
cmp al,0
jnz dontdisplay4
powerdisplay: call display_power ;This is executed only if Start button is not even
pressed once
dec byte ptr [time_loop]
jnz powerdisplay
mov al,00h ;Dispaly Clear
mov dx,6000h
out dx,al
dontdisplay4: nop
13
jmp B4
;START BUTTON IS Pressed
STRT: mov di,start
add byte ptr [di],1 ;number of start presses added
mov si,power
mov al,[si] ;AL has number of power button presses
xor ah,ah ;ah=0, want only al content which is #power presses
;Defining quick start mode
cmp al,-1 ;ensure power button is not pressed till now
jnz m1
mov dl,[sec] ;ensure time is not entered till now
cmp dl,0
jnz m1
add_30sec: mov si,sec
mov ax,[si] ;ax has current time remaining for cooking
add ax,30 ;Incrementing counter by 30 seconds everytime
Start is pressed
mov [si],ax
set_power: mov al,0 ;al=0 corresponds to power level 90%
;mov cl,3 ;flag for confirming quick start mode
m1: ;cmp cl,3
;jne m2
mov dl,[start]
cmp dl,1
je m2
mov si,sec
mov ax,[si] ;ax has current time remaining for cooking
add ax,30 ;Incrementing counter by 30 seconds everytime Start is
pressed
mov [si],ax
m2: mov bl,3
mul bl ;number of power presses*3 = stored in AX
mov cl,09h
sub cl,al ;cl=9-3n
mov si,stop ;Number of stops pressed is made equal to zero
mov al,0
mov byte ptr [si],al
14
mov ax,00001000b ;Input fron Timer (1SC) is enabled;
mov dx,5006h ;Port1 ka PC4=0; sec=0
out dx,al
mov dx,2004h ;Count loaded into Timer1:Counter2
mov ax,cx
out dx,al ;al=cl=9-3n
mov ax,00001101b ;Power input can't be taken once start is pressed PC6=1
mov dx,5006h
out dx,al
mov ax,00001111b ;Set up Lock PC7=1
out dx,al
jmp B5
STP: mov ax,00001001b ;Input from Timer blocked, PC4=1
mov dx,5006h
out dx,al
mov ax,00001100b ;Power input can be taken, PC6=0
out dx,al
mov ax,00001010b ;Buzzer LED Off, PC5=0
out dx,al
mov si,stop
inc byte ptr [si]
mov al,[si]
cmp al,2 ;If Stop is Pressed twice, then only execute all these
steps
jl x1 ;jump if count is lower than 2
mov di,sec
mov word ptr [di],0 ;time remaining is made zero
mov byte ptr [si],0 ;number of stop presses is made zero
mov byte ptr [start],0;number of start presses is made zero
mov al,00h ;Dispaly Clear
mov dx,6000h
out dx,al
x1: mov dx,5006h
mov ax,00001110b ;Opening the lock
out dx,al
jmp B6
TIMER: mov si,sec
dec word ptr [si] ;Decrement the count
15
mov ax,[si] ;Check the count
cmp ax,0
jg dontexecute ;If count is still greater than zero, then no need to
execute the given instructions
mov dx,5006h
mov ax,00001001b ;No further countdown, PC4=1
out dx,al
mov ax,00001100b ;Power input enabled, PC6=0
out dx,al
mov ax,00001110b ;Lock opened, PC7=0
out dx,al
mov ax,00001011b ;countdown is over, buzzer is on
out dx,al
dontexecute: nop
jmp B7
.exit
;********************************************** ALL PROCEDURES definations
****************************************************
display proc near
mov si,disp ;disp contains next four digits to display
mov di,sec
mov ax, [di] ;Current number of seconds is stored in AX now
mov bx,10
xor dx,dx ;mov dx,0
div bx
mov [si],dl ;Remainder is in DL as remainder is not greater than 9, so no need to
consider DH - Hence we extract the last digit
xor dx,dx ;Digit at Tens place
div bx
mov [si+1],dl
xor dx,dx ;Digit at Hundredth place
div bx
mov [si+2],dl
xor dx,dx ;Digit at Thousandth place
div bx
mov [si+3],dl
16
mov al,[si] ;display units place
and al,0fh
add al,10h
mov dx,6000h
out dx,al
call delay
mov al,[si+1] ;display tens place
and al,0fh
add al,20h
mov dx,6000h
out dx,al
call delay
mov al,[si+2] ;display hundreds place
and al,0fh
add al,40h
mov dx,6000h
out dx,al
call delay
mov al,[si+3] ;display thousands place
and al,0fh
add al,80h
mov dx,6000h
out dx,al
call delay
mov al,00h ;Dispaly Clear
mov dx,6000h
out dx,al
ret
endp
button proc near
mov dx,6002h
in al,dx
;Checking which of the inputs is 0, which means the corresponding switch is pressed
;The mapping to switches is:
; PB0 - 10 MIN BUTTON
; PB1 - 1 MIN BUTTON
; PB2 - 10 SEC BUTTON
17
; PB3 - POWER BUTTON
; PB4 - START BUTTON
; PB5 - STOP BUTTON
; PB6 - TIMER INTERRUPT HANDLING
mov [inp],al
cmp al,0ffh
je pl7
mov al,[inp]
and al,01h
jnz pl1 ;jump for checking next button press: if that bit is 0
jmp add_10min
B1: call delayss
pl1: mov al,[inp]
and al,02h
jnz pl2
jmp add_1min
B2: call delayss
pl2: mov al,[inp]
and al,04h
jnz pl3
jmp add_10sec
B3: call delayss
pl3: mov al,[inp]
and al,08h
jnz pl4
jmp POW
B4: call delayss
pl4: mov al,[inp]
and al,10h
jnz pl5
jmp STRT
B5: call delayss
pl5: mov al,[inp]
and al,20h
jnz pl6
jmp STP
B6: call delayss
18
pl6: mov al,[inp]
and al,40h
jnz pl7
jmp TIMER
B7: call delayss
pl7: ret
endp
;POLLING ENDS
display_power proc near
mov si,disp
mov di,power
mov al,[di]
cmp al,00 ;Loading Power value according to the number of power presses
jnz j1
mov ax,90
jmp j0
j1: cmp al,01
jnz j2
mov ax,60
jmp j0
j2: cmp al,02
jnz j3
mov ax,30
jmp j0
j3: cmp al,03
jnz j0
mov ax,100
j0: nop
mov bx,10
xor dx,dx
div bx
mov [si],dl ;Remainder is in DL as remainder is not greater than 9, so no need to
consider DH - Hence we extract the last digit
xor dx,dx ;Digit at Tens place
19
div bx
mov [si+1],dl
xor dx,dx ;Digit at Hundredth place
div bx
mov [si+2],dl
xor dx,dx ;Digit at Thousandth place
div bx
mov [si+3],dl
;Display Last Digit
mov al,[si] ;display units place
and al,0fh
add al,10h
mov dx,6000h
out dx,al
call delay
mov al,[si+1] ;display tens place
and al,0fh
add al,20h
mov dx,6000h
out dx,al
call delay
mov al,[si+2] ;display hundreds place
and al,0fh
add al,40h
mov dx,6000h
out dx,al
call delay
mov al,[si+3] ;display thousands place
and al,0fh
add al,80h
mov dx,6000h
out dx,al
call delay
mov al,00h ;Dispaly Clear
mov dx,6000h
out dx,al
ret
endp
20
;DELAY PROCEDURES
delay proc near
mov cx, 200
l5: nop
loop l5
ret
endp
delayss proc near
mov cx, 60000
l6: dec cx
loop l6
ret
endp
delay1s proc near ;calling delayss four times
mov ax, 4
delay2: nop
dec ax
call delayss
cmp ax,0
jnz delay2
ret
endp
end
21