Beruflich Dokumente
Kultur Dokumente
Acknowledgement
Throughout this project, we have learnt more about the 8051 development system and
the assembly language. We would like to express our greatest gratitude and
appreciation to all the technicians that helped us throughout the process to finish this
mini project. Hereby, we would like to express our deepest appreciation to our lecturers
that guided us to successfully complete our project.
Introduction
This project can be used in any general quiz competition system. This circuit
can be used for maximum of 4 players who are involved in the quiz competition. The
circuit will have 4 Light Emitted Diode (LED) to indicate who has pressed the button first
and the number which represents the corresponding participant will be displayed on a 7
Segment. Then, for different quiz question, different time duration can be set and
displayed on another 7-Segement to be given to the particular participant to answer the
quiz. A switch (RESET Switch) can be pressed to start the countdown of the timer. If the
participant cannot answer the question within the time given, the circuit will be reset.
The reset switch can also be used to stop the countdown and reset the circuit as well as
the value displayed in the 7 Segment.
The main objective of this project is to design and create a general
electronic quiz system so that it can be used and utilized in any general quiz competition
globally. Most of the quiz competitions are conducted manually such as the candidates
have to compete among themselves by raising their hands to grab to chance of
answering the question to get marks and time given to each candidate to answer a
question is counted by using an external timer. Thus, we design a more effective
electronic quiz system to help to improve and eliminate the problems and weaknesses
of the way of the competitions are being conducted so that the competitions can be
conducted effectively and productively.
Objectives
Literature Review
Based on the electronic quiz system which is designed developed by
the others had been found to have some weaknesses and lack of some important
features of the system. They designed the electronic quiz system by using a
microprocessor 8085 which is slower to read and run an assembly program code and
lack of internal timer compared to microprocessor 8051. Other than that, the system is
designed and developed without a countdown timer which is very important in
conducting a quiz competition so that the organizer can set a time given to the
participants to answer the questions.
Thus, our group has decided to design and create a more complete and
efficient quiz system for any general quiz competition. First of all, we have designed the
system for a maximum of 4 participants or teams to be involved in the competition.
When the first person presses the button, the representative number of the person will
be displayed on a 7 segment. Then, we add in a keypad for the design of the countdown
timer so that the organizer can set the time given to the participant to answer a
question. Other than that, a buzzer is connected to indicate when the button is pressed
or the time given is already over. A reset switch which is also the countdown switch has
been designed by using the same switch for the convenient of the organizer and it can
be used to start the countdown of the timer after the time given is set by using the
keypad and also reset the system to the beginning stage when the participant can
answer the given question within the time given. The system will reset automatically by
itself when the time given is over. A system which consist the above features will be
more effective and productive to conduct a quiz competition and it is also the
advantages of the system that we design and program.
Methodology
The circuit system is controlled and monitored by the Microprocessor 8051
and using of Ports of 8255. The microprocessor will be continuously monitoring the
circuit and the 4 switches. When one of the switches is pressed, the microprocessor will
check the switch and display the corresponding value on a 7 Segment display. A buzzer
will be triggered to indicate that one of the switches is pressed. Then, the keypad can be
used to set the time of the timer for countdown. A countdown switch (which is also the
RESET switch) can be pressed to start the countdown of the time given to the
participant who is answering the quiz. The buzzer will be triggered if the time is over and
the system will be automatically reset to the beginning state. Reset switch can also be
used to reset the system if the participant can answer the quiz within the time given.
Component List
Components/Equipment
8051 Development System
Light Emitted Diode (LED)
7-Segment Display
Mini Push Button Switch
Buzzer
Resistor (1 k)
Quantity
1
4
2
5
1
5
Microprocessor 8051
Use to run the programmes and process data.
Keypad
Used to key in the number that been choose.
7-Segment DISPLAY
Use to display the corresponding number and time given.
Buzzer
Use to buzz when its fit.
LED
Use to tell us which number it represents for.
Resistance
Use to reduce the current voltage and protect the hardware.
Block Diagram
To write the program for the electronic quiz system, the correct and
accurate circuit connection is required to prevent connection error
with the program running. A block diagram is drawn to ease the
understanding of the schematic circuit and the circuit design in the
form of rough sketch. The block diagram explains roughly about the
connection of 8051 development system with the computer, I/O
interfacing 8255, the mini push-button switches, reset switch, keypad,
light emitted diode (LED), 7-Segment displays and also the buzzer.
4 Switches
8051
8255
Keypad
4 LEDs
7 - Segments
Buzzer
HARDWARE DESCRIPTION
Keypad
Keypad was used in this project to set the time given to the participant to answer a quiz
question. The keypad we used was built up from switches which arranged in the form of 4X4
(Column X Row) matrix. Every button we press will generate 8 bit binary code itself. In order to
interpret data from keypad, all the three columns (C0-C2) have to connect to the output port C
from PC4 to PC6 and all the four rows (R0-R3) have to connect to the input port from PC0 to PC3.
The way to interpret the data from the keypad is through the key-switch scanning technic. Logic
1 will send in turns to the column and every row will be scan one by one to determine the
connection that is formed. Therefore logic 1 will be detected for the row and column that are
pressed. Finally, all the keys will represent by specify 8 bit binary codes.
Number
1
2
3
4
5
6
7
8
9
0
*
#
Binary Number
0001 0001
0010 0001
0100 0001
0001 0010
0010 0010
0100 0010
0001 0100
0010 0100
0100 0100
0010 1000
0001 1000
0100 1000
Hexadecimal Number
11H
21H
41H
12H
22H
42H
14H
24H
44H
28H
18H
48H
7-segmen display
7-segment display always use with the digital electronic device to display the
information that related with a process. The common cathode 7-segment display was
used in this project. For common cathode, the particular segment will light up when logic
1 (5V) is supplied and will off when logic 0 is supplied (0). Therefore Table1 will
show the codes that are required to display the particular number for common cathode 7segment display.
Number
Common Cathode
g
Hexadecimal
3FH
06H
5BH
4FH
66H
6DH
7DH
07H
7FH
67H
*The hexadecimal code is used in the program code for the Declaration of TABLE.
7
APPLICATIONS
8051 chips are used in a wide variety of :
control systems
telecom applications
robotics
automotive industry
By some estimations, 8051 family chips make up over 50% of the embedded chip
market.
10
BASIC PINS
PIN
9
FUNCTION
Reset pin which is used to reset the microcontrollers internal
registers and ports upon starting up.
18 & 19
20 & 40
29
30
31
This pin is called ALE (address latch enable), which is used when
multiple memory chips are connected to the controller and only one
of them needs to be selected.
11
PORTS
PORT
FUNCTION
P0 (PIN 32-39)
P1 (PIN 1-8)
P2 (PIN 21-28)
P3 (PIN 10-17)
12
INTEL 8255
INTRODUCTION
The Intel 8255 Programmable Peripheral Interface (PPI) chip is a peripheral chip
originally developed for the Intel 8085 microprocessor, and as such is a member of a
large array of such chips, known as the MCS-85 Family. This chip was later also used
with the Intel 8086 and its descendants. It was later made (cloned) by many other
manufacturers.
The Intel 8255 is a general purpose programmable I/O device which is designed for use
with all Intel and most other microprocessors. It provides 24 I/O pins which may be
individually programmed in 2 groups of 12 and used in 3 major modes of operation.
In MODE 0, each group of 12 I/O pins may be programmed in sets of 4 and 8 to be
inputs or outputs. In MODE 1, each group may be programmed to have 8 lines of input
or output. 3 of the remaining 4 pins are used for handshaking and interrupt control
signals. MODE 2 is a strobe bi-directional bus configuration.
The 8255 is a 40 pin integrated circuit (IC), designed to perform a variety of interface
functions in a computer environment. The 8255 wasn't originally designed to be
connected to the Z80. It was manufactured by Intel for the 8080 microprocessor.
APPLICATION
The 8255 is widely used not only in many microcomputer/microcontroller systems
especially Z-80 based, home computers such as SV-328 and all MSX, but also in the
system board of the best known original IBM-PC.
13
PIN
FUNCTION
D0-D7
CS
(CHIP SELECT
INPUT)
RD
(READ INPUT)
WR
(WRITE
INPUT)
A0-A1
(ADDRESS
INPUT)
RESET
PA0-PA7,
PB0-PB7 &
PC0-PC7
The 8255 is placed into its reset state if this input line is a logical
1.
All peripheral ports are set to the input mode.
15
Two control groups, labeled group A control and group B control define how the
three I/O ports operate.
There are several different operating modes for the 8255 and these modes must
be defined by the CPU writing programming or control words to the device 8255.
The line group of port C consists of two 4 bit ports.
One of the 4 bit group is associated with group A control and the other 4 bit
group with group B control device signals.
The upper 4 bits of port C are associated with group A control while the lower 4
bits are associated with group B control.
The final logic blocks are read/write control logic and data bus buffer.
These blocks provide the electrical interface between the Z80 and the 8255.
The data bus buffer buffers the data I/O lines to/from the Z80 data bus.
The read/write control logic routes the data to and from the correct internal
registers with the right timing.
The internal path being enabled depends on the type of operation performed by
the Z80.
The type of operation can be I/O read or I/O write.
16
SCHEMATIC DIAGRAM
17
Flow Chart
Start
Switch off the buzzer
No
Yes
No
18
CLEAR
Move 0 to accumulator
ACALL DELAY
START
19
START
A=0
A=0?
A 0
DISPLAY1
A 01H
A=01H?
DISPLAY2
A = 01H
Move data 06H to Accumulator
BUZZER1
20
DISPLAY2
A 02H
DISPLAY3
A=02H?
A = 02H
Move data 5BH to Accumulator
BUZZER1
DISPLAY3
A 04H
A=04H?
DISPLAY4
A = 04H
Move data 4FH to Accumulator
BUZZER1
21
DISPLAY4
BUZZER1
BUZZER1
ACALL DELAY
NOP
SCAN
22
SCAN
A=0
A=0?
A0
Move data 3 to R6
SCAN_NEXT
SCAN _NEXT
A=0
A=0?
NEXT_COL
A0
OR with R7
23
S0
S0
A 28H
S1
A = 28H
Move data 01H to Accumulator
Store data from Accumulator to address 2100H
PRESS
S1
A 11H
S2
A = 11H
Move data 02H to Accumulator
PRESS
24
S2
A 21H
S3
A = 21H
Move data 03H to Accumulator
PRESS
S3
A 41H
S4
A = 41H
Move data 04H to Accumulator
PRESS
25
S4
A 12H
S5
A = 12H
Move data 05H to Accumulator
PRESS
S5
A 22H
S6
A = 22H
Move data 06H to Accumulator
PRESS
26
S6
A 42H
S7
A = 42H
Move data 07H to Accumulator
PRESS
S7
A 14H
S8
A = 14H
Move data 08H to Accumulator
PRESS
27
S8
A 24H
S9
A = 24H
Move data 09H to Accumulator
PRESS
S9
A 44H
SCAN
A = 44H
Move data 01H to Accumulator
PRESS
28
PRESS
A=0
A=0?
A =1
PRESS1
A=1
A=0?
A =0
COUNT
29
COUNT
NEXT
Decrement R0
ACALL DELAY
Decrement R1
R1=0?
?
R1 0
RESET
R1 = 0
BUZZER2
30
RESET
A=0
A=0?
NEXT
A0
RESET1
A0
A=0?
A=0
CLEAR
31
BUZZER2
ACALL DELAY
CLEAR
32
Problem 2:
When we use the upper output Port C (PC4-PC7) to
produce current to flow through the resistor for the detection of signal
of lower input Port C (PC0-PC3), we notice that the pin PC4 do not
produce enough current flow through the resistor and hence the lower
input Port C cannot detect the signal with the low potential difference
across the resistor.
Solution:
We program to use Port B PB7 which is not used originally
to produce a current to flow through the resistor so that now there is
enough current flow through the resistor and higher potential difference
across the resistor for the signal detection of lower input Port C.
33
Result
34
Discussion
For the design of the circuit connections, we have to
consider the amount of components that we use and also the total
number of pins of the components needed to be connected to the
Programmable Peripheral Interface 8255 since there are only 3 8-bits
ports (Port A, Port B and Port C) which have only total of 24 pins can
be used for connection. Since we are using two 7-Segment Displays in
this circuit with each of them has 7 pins need to be connected to the 8bits output Port A and Port B, the only port left is Port C which can be
separately programmed as input and output (input PC0-PC3, output
PC4-PC7). Thus, we have no choice but to design the circuit
connections with the reset switch, LED, participants number
representative switches, resistors as well as keypad all connected to
Port C. Lastly, the buzzer is connected to the Port A (PA7) which is the
only pin left for connection. After the design of the circuit connection,
we can start to write the assembly code for the function of our circuit so
that it can function as a general electronic quiz system without error.
Other than that, since we are using time delay with the
software delay instead of the internal timer of microprocessor 8051, we
have to calculate the time delay of around 1 second for every Absolute
Call DELAY (ACALL) with the formula:
Delay = [1 + (R2){1 + (R3)[1 + (R4)(2) + 2] + 2} + 2] x 1/(
= 0.9936 s
1.0 s
35
Conclusion:
The assembly program and the circuit design can be used in
any general quiz competition with the function that who has pressed the
switch first and the number which represents the corresponding
participant will be displayed on a 7-segment display. Different time
given to answer the questions can be set and displayed on another 7segment display by using a keypad. A switch (which is also the RESET
switch) can be used to start the countdown of the timer. If the question
is not answered within the time given, the circuit will be reset. If the
question is answered within the time given, the RESET switch to stop
the countdown timer and the circuit will be reset to the beginning stage.
In conclusion, we have gained more knowledge regarding the
microprocessor 8051 through this mini project. We have learnt to
interface the Microprocessor 8051with PPI 8255, keypad, 7-segment
displays, and switches. Thus, microprocessor 8051 interfaced with PPI
8255 can be used to produce an electronic quiz system which can be
used for any general quiz competition.
36
Appendix
Assembly Program Code:
CPU"8051.TBL"
INCL"8051.INC"
ORG 2000H
MOV SP, #030H
PA: EQU 4000H
PB: EQU 4001H
PC: EQU 4002H
PCTR: EQU 4003H
MOV A, #10000001B
MOV DPTR, #PCTR
MOVX @DPTR, A
37
; Data 6H is moved to A
; Load Data Pointer with Port A
; Move A to external RAM
; Jump to BUZZER1
; Move A to R5
; Add 10000000B to A
; Load Data Pointer with Port A
; Move A to external RAM
; Absolute call DELAY
; Move R5 to A
; Load Data Pointer with Port A
; Move A to external RAM
; No operation
38
SCAN_NEXT: MOV A, R7
MOV DPTR, #PC
MOVX @DPTR, A
MOV DPTR, #PC
MOVX A, @DPTR
ANL A, #00001111B
JZ NEXT_COL
ORL A, R7
LJMP S0
; Move R7 to A
; Load Data Pointer with Port C
; Move A to external RAM
; Load Data Pointer with Port C
; Move external RAM to A
; AND 00001111B to A
; Jump to NEXT_COL if A is zero
; OR R7 to A
; Jump to S0
NEXT_COL: MOV A, R7
RL A
MOV R7, A
DEC R6
MOV A, R6
JNZ SCAN_NEXT
; Move R7 to A
; Rotate A left
; Move A to R7
; Decrement R6
; Move R6 to A
; Jump to SCAN_NEXT if A is not zero
39
; Jump to SCAN
40
41
42
END
Electronic quiz device that our group has designed and programed
43
Reference
1. http://www.slideshare.net/SubhashiniSundaram/micro-processormini-project
2. http://en.wikipedia.org/wiki/Light-emitting_diode
3. http://en.wikipedia.org/wiki/Keypad
4. https://www.sparkfun.com/products/97
5. http://en.wikipedia.org/wiki/Intel_8255
6. http://www.electronics.dit.ie/staff/tscarff/8255PPI/8255.htm
7. http://www.circuitstoday.com/8051-microcontroller
8. http://en.wikipedia.org/wiki/Intel_MCS-51
9. http://jap.hu/electronic/8255.pdf
44