Mup Project
Mup Project
Microwave Oven
By
An assignment submitted in
Partial fulfillment of the requirement of the course
ES C263: MICROPROCESSOR PROGRAMMING
AND
INTERFACING
2) The CS: IP values corresponding to the interrupts INT 127 and INT 191 are stored
in addresses 001FCh and 002FCh respectively.
3) There is mechanism already in place whereby door will get unlocked if pc1 of
8255A is high and locked if pc1 is low.
5) 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.
8) User cannot operate in quick start mode if he is working in normal start mode and
vice versa.
System Description:
The system operates in 2 modes: QUICK START mode and NORMAL START
mode. In quick start mode system takes default value of power i.e. 100% and time as
30 sec. For every press of start button time is incremented by 30 sec. Timers are set
and countdown begins and the time left for cooking is shown on seven segment
display. The user can terminate cooking anytime by pressing STOP button which
resumes on pressing START button. Cooking is aborted by pressing stop button
twice.
In normal start mode user can set desired value of power and time. Time of
cooking is broken up into ten seconds slots. For e.g. -- If power is 80% then for 8
seconds the microwave oven is on and for the remaining two seconds it is off.
When cooking time elapses buzzer is sounded. When the user presses the STOP
button the buzzer stops.
Hardware Description:
2) Resistors:
Resistors are used to control voltages and currents at various parts of the system.
3) 7-segment displays:
Seven segment displays are used to display the user entered values.4 segment displays
are used to display the four digits of the time remaining/ power/ time set.
4) Relay:
It is used to connect the heating-element of the microwave oven with the out pin of
the timer C0 of 8253A.
5) Buzzer:
The buzzer is set on after the cooking time elapses and is connected via an n-p-n
transistor to out-pin of C0 of 8253B.
6) Push Buttons:
They are used to input the power, time, start and stop signals from the user.
8255-A
The input and output devices of the system are connected using 8255
Programmable peripheral Interfacing controllers. Here we connect the A0 and A1 of
8255 to the A1 and A2 of the 8086 address bus respectively.
8253 A
TO THE BUZZER
COUNTER0 40H 3 (SPEAKER)
MEMORY ADDRESSES:
DEVICE A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
4016 SRAM
From 01000h 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
To 01FFFh 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
2716 ROM
From 00000h 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
To 00FFFh 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
The system uses 4KB of RAM and 4KB of ROM. Both consist of two chips of
2KB size each. They are organized into odd and even bank to facilitate both byte and
word size data transfers. Code starts at address 00400h.
FOLD BACK ADDRESSING IS BEING USED FOR ROM. FF000h-FFFFFh ARE
THE ADDRESSES FOLDED BACK ONTO 00000h-00FFFh.
Software Algorithm:
1. The timer modes of 8253A and 8253B are set to appropriate values.
3. The counter values in the counter modes are set corresponding to quick start
mode
.
4. If the user presses start or stop button the corresponding interrupts INT 191
and INT 127 respectively are invoked.
5. If the user presses start button at this juncture microwave start operating in
quick start mode. The gates of all the counters and the trigger pin of 555 timer
are triggered and also the door is locked.
6. Else user can set desired values of power and time for cooking and then press
the start button. Once time has been set power cannot be modified.
7. For every press of start button during quick start mode countdown timer gets
incremented by 30.
8. While user is setting the power values or time the value being pressed should
be displayed on seven segment display simultaneously.
9. Say the user has set power value 60%, then C0 is set as 6 and C1 as 10. Each
clock corresponds to 0.1 second. The out-pin of C0 remains high for 0.6
seconds then becomes low for 0.4 seconds. Meanwhile C1 remains low for 1
second and gives trigger to C0 after 1 sec so that countdown starts again. The
output pin is connected to heating element of microwave oven.
10. The total count is stored in C2. The C2 value is latched and read after every
one second and displayed on seven segment display.
11. When C2 counter value reaches 0 it triggers c1 counter of 8253B which then
generates the square wave which is connected to the buzzer. The buzzer can
be stopped by pressing the stop button which unlocks the door and the
program restarts.
12. When the user presses stop-button the clock inputs to the timers are removed
and the door is unlocked.
13. For two consecutives stops, the cooking is aborted, door is unlocked and the
program restarts.
ALP USED FOR THE SYSTEM:
; Data in RAM
POWER DB 10
TIME DW 0
QFLAG DB 0
SFLAG DB 0
TRIG DB 0
COUNT DW 0
; Code in ROM
STPRO:
MOV SFLAG,0
MOV AL,13H
OUT 66H,AL
MOV AL,55H
OUT 66H,AL ; SETTING TIMER MODES
MOV AL,0B3H
OUT 66H,AL
MOV AL,17H
OUT 46H,AL
MOV AL,80H
OUT 26H,AL ; CR OF 8255B
MOV AL,92H
OUT 86H,AL ;CR OF 8255A
MOV AL,10H
OUT 60H,AL
MOV AL,10H
OUT 62H,AL
MOV AL,0
OUT 64H,AL
OUT 64H,AL
MOV AL,10
OUT 40H,AL ;SET COUNTER VALUE ,SET C1=10,C0=10 AND C2=0 AND
8253B C0=10
X3:IN AL,82H
AND AL,20H
CMP AL,20H
JNZ X1 ; CHECKING FOR POWER
JMP X3
X1:
JUMP DELAY1
X4:IN AL,82H
AND AL,20H
CMP AL,0
JZ X4 ; WAITING FOR KEY RELEASE
JUMP DELAY1
JUMP PDISP
A3:JUMP PDISP
IN AL,82H
AND AL,20H
CMP AL,20H
JNZ A1 ;TIMER AND POWER INPUT
IN AL,80H
AND AL,0E0H
CMP AL,0E0H
JNZ A2
JMP A3
A1:
JUMP DELAY1
KO:IN AL,82H
AND AL,20H
CMP AL,0
JZ KO
JUMP DELAY1
JNZ A3
JMP A3
A2:
JUMP DELAY1
IN AL,80H
CMP AL,60H
JNZ R1
ADD WORD PTR TIME,600
R1:
CMP AL,0A0H
JNZ R2:
ADD WORD PTR TIME,60
R2:
ADD WORD PTR TIME,10
HO:IN AL,80H
AND AL,0E0H
CMP AL,0E0H ; KEY RELEASE WAIT
JNZ HO
JUMP TDISP
RED:
PO:IN AL,80H
AND AL,0E0H
CMP AL,0E0H ;CHECKING FOR TIMER
JNZ K1
JMP PO
K1:
JUMP DELAY1
IN AL,80H
CMP AL,60H
JNZ R1
ADD WORD PTR TIME,600
R1:
CMP AL,0A0H ;TIMER INPUT
JNZ R2:
ADD WORD PTR TIME,60
R2:
ADD WORD PTR TIME,10
HOL:IN AL,80H
AND AL,0E0H
CMP AL,0E0H ;WAITING FOR KEY RELEASE
JNZ HOL
JUMP DELAY1
JUMP TDISP
RED:MOV DX,0
MOV AX,TIME
MOV BX,1000
DIV BX
MOV DI,AX
MOV CL,12
SHL DI,CL
MUL BX
MOV SI,TIME
SUB SI,AX
MOV AX,SI
MOV BL,100 ; THIS BLOCK CONVERTS BIN TO BCD
DIV BL
MOV BX,DI
ADD BH,AL
MOV DI,BX
MOV BL,100
MUL BL
SUB SI,AX
MOV AX,SI
MOV BL,10
DIV BL
MOV BX,DI
ADD BL,AL
MOV CL,4
SHL BL,CL
MOV DI,BX
MOV BL,10
MUL BL
SUB SI,AX
ADD DI,SI
MOV BX,DI
MOV AL,BL
OUT 64H,AL
MOV AL,BH
OUT 64H,AL ; SET 8253A C2=TIMER
JMP PO
NIO:
MOV AL,80H
OUT 66H,AL
IN AL,64H
MOV BL,AL ;LATCHING AND READING C2 OF 8253A
IN AL,64H
MOV BH,AL
CMP BX,0
JNZ GOAT ;CHECKING IF BUZZER HAS BEEN STOPPED
CMP SFLAG,1
JNZ GOAT
MOV SFLAG,0
MOV AL,03H
OUT 86H,AL ;DOOR UNLOCK
JMP STPRO
GOAT:OUT 20H,BH
OUT 22H,BH ;COUNTDOWN DISPLAY
MOV CX,46729
E1:NOP
NOP
MOV CX,4
E2:NOP ; DELAY OF 1s approx.
NOP
LOOP E2
LOOP E1
JMP NIO
end
.ORG 00900h
DELAY1:
MOV CX,4348
DELP:NOP
NOP ; DELAY OF 20ms approx.
LOOP DELP
RET
.ORG 00800h
PDISP:
CMP BYTE PTR POWER,10
JZ ETW
MOV BL,POWER
MOV CL,4
SHL BL,CL
MOV AL,0
OUT 20H,AL
MOV AL,BL
OUT 22H,AL
JMP EFG
ETW:
MOV AL,1
OUT 20H,AL
MOV AL,0
OUT 22H,AL
EFG:RET
.ORG 00880h
TDISP:
MOV DX,0
MOV AX,TIME
MOV BX,1000
DIV BX
MOV DI,AX
MOV CL,12
SHL DI,CL
MUL BX
MOV SI,TIME
SUB SI,AX
MOV AX,SI
MOV BL,100 ; THIS BLOCK CONVERTS BIN TO BCD
DIV BL
MOV BX,DI
ADD BH,AL
MOV DI,BX
MOV BL,100
MUL BL
SUB SI,AX
MOV AX,SI
MOV BL,10
DIV BL
MOV BX,DI
ADD BL,AL
MOV CL,4
SHL BL,CL
MOV DI,BX
MOV BL,10
MUL BL
SUB SI,AX
ADD DI,SI
MOV BX,DI
MOV AL,BH
OUT 20H,AL ; DISPLAY TIME REMAINING
MOV AL,BL
OUT 22H,AL
RET
ISR START
JUMP DELAY1
JOY:IN AL,82H
AND AL,80H
CMP AL,0 ;KEY RELEASE WAIT
JZ JOY
JUMP DELAY1
MOV AL,80H
OUT 66H,AL
IN AL,64H
MOV BL,AL ; LATCH C2
IN AL,64H
MOV BH,AL
CMP BX,0
JZ PCO
CMP BYTE PTR QFLAG,1
JZ PCO
MOV AL,06H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO 555
LOOP SE
MOV AL,07H
OUT 86H,AL
MOV CX,3
SE:NOP
LOOP SE
MOV AL,06H
OUT 86H,AL
MOV AL,04H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO TIMER GATES
LOOP SE
JMP BLUE
ROE:
MOV AL,06H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO 555
LOOP SE
MOV AL,07H
OUT 86H,AL
MOV CX,3
SE:NOP
LOOP SE
MOV AL,06H
OUT 86H,AL
BLUE:
MOV BYTE PTR SFLAG,0
MOV AL,02H
OUT 86H,AL ;DOOR LOCK
PCO:
MOV BYTE PTR QFLAG,1
MOV AL,80H
OUT 66H,AL
IN AL,64H
MOV BL,AL ; BX NOW CONTAINS LATCH C2
IN AL,64H
MOV BH,AL
MOV CX,00
MOV CL,BL
AND CL,0FH
ADD COUNT, CX
MOV CL,BL
AND CL,0F0H
MOV DL,CL
MOV CL,04H
ROR DL,CL
MOV CL,DL
MOV AL,0AH
MUL CL
MOV CL,AL
ADD COUNT,CX
MOV CL,BH ;ADD 30 TO C2(BX)
AND CL,0FH
MOV AL,100
MUL CL
MOV CX,AX
ADD COUNT, CX
MOV CX,00
MOV CL,BH
AND CL,0F0H
MOV DL,CL
MOV CL,04H
ROR DL,CL
MOV CL,DL
MOV AX,1000
MUL CX
MOV CX,AX
ADD COUNT,CX
ADD COUNT,30
MOV DX,0
MOV AX,COUNT
MOV BX,1000
DIV BX
MOV DI,AX
MOV CL,12
SHL DI,CL
MUL BX
MOV SI,COUNT
SUB SI,AX
MOV AX,SI
MOV BL,100
DIV BL
MOV BX,DI
ADD BH,AL
MOV DI,BX ;CONVERT COUNT TO BCD STORE IN BX
MOV BL,100
MUL BL
SUB SI,AX
MOV AX,SI
MOV BL,10
DIV BL
MOV BX,DI
ADD BL,AL
MOV CL,4
SHL BL,CL
MOV DI,BX
MOV BL,10
MUL BL
SUB SI,AX
ADD DI,SI
MOV BX,DI
MOV AL,BL ; MOVE BX TO C2 (C2 INCREMENTED BY 30)
OUT 64H,AL
MOV AL,BH
OUT 64H,AL
MOV AL,06H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO 555
LOOP SE
MOV AL,07H
OUT 86H,AL
MOV CX,3
SE:NOP
LOOP SE
MOV AL,06H
OUT 86H,AL
MOV AL,04H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO TIMER GATES
LOOP SE
COOL:
MOV AL,02H
OUT 86H,AL ;DOOR LOCK
J1:
MOV AL,02H
OUT 86H,AL ;DOOR LOCK
MOV AL,06H
OUT 86H,AL
MOV CX,3
SE:NOP ;TRIGGER TO 555
LOOP SE
MOV AL,07H
OUT 86H,AL
MOV CX,3
SE:NOP
LOOP SE
MOV AL,06H
OUT 86H,AL
ISR STOP
JUMP DELAY1
TOY:IN AL,82H
AND AL,40H
CMP AL,0 ;KEY RELEASE WAIT
JZ TOY
JUMP DELAY1
MOV AL,03H
OUT 86H,AL ;DOOR UNLOCK
JMP STPRO
VOX:
MOV AL,01H
OUT 86H,AL
MOV CX,3
SE:NOP ;RESET TO 555(WAIT OF APPROX 10uS)
LOOP SE
MOV AL,00H
OUT 86H,AL