39
EEE 226 MICROPROCESSOR I 2013/2014 SEMESTER II MINI PROJECT LONG REPORT PROJECT TITLE: ELECTRONIC VOTING MACHINE GROUP 22 (TUESDAY 9AM-11AM SESSION): 1) NEO CHAN SENG 116428 2) SITI FATIMAH BT SHAMSUDIN CHUA 116444

Electronic Voting Machine

Embed Size (px)

Citation preview

Page 1: Electronic Voting Machine

EEE 226 MICROPROCESSOR I

2013/2014 SEMESTER II

MINI PROJECT LONG REPORT

PROJECT TITLE: ELECTRONIC VOTING MACHINE

GROUP 22 (TUESDAY 9AM-11AM SESSION):

1) NEO CHAN SENG 116428

2) SITI FATIMAH BT SHAMSUDIN CHUA 116444

UNDER SUPERVISION OF

EN. AHMAD NAZRI

Page 2: Electronic Voting Machine

CONTENTSNo. Title Page

1 ABSTRACT 3

2 ACKNOWLEDGEMENT 4

3 INTRODUCTION 5

4 OBJECTIVE 6

5 LITERATURE REVIEW 7

6 METHODOLOGY HOW DOES THE SYSTEM WORK?

LIST OF COMPONENT HARDWARE DESCRIPTION

SCHEMATIC DIAGRAM BLOCK DIAGRAM

FLOW CHART

8-16

7 PROBLEM STATEMENT AND ANALYSIS

17

8 RESULT AND DISCUSSION 18-19

8 CONCLUSION 20

9 APPENDIX 21-27

10 REFERENCE 28

2

Page 3: Electronic Voting Machine

AbstractVoting is most pivotal process of democratic society through

which people determine its decision. Nowadays electronic voting machine has become an effective voting tool compare with traditional paper-based voting schemes. Flawless voting is ensure by electronic voting machine. This is the reason it became more widespread. People are make sure that their vote is secured. One more feature is that it avoids any kind of malpractice or invalid votes. Besides that, talking about economic benefits, this system is more economical than traditional paper-based voting schemes since the expenditure incurred on manpower is saved. It is also make voter feels convenient because he or she has to press only one button of the respective candidates to vote. Thus, we are decided to design an electronic voting machine to replace the traditional paper-based voting schemes due to several advantages like security, automatic counting, economic etc.

This project presents a way to develop an electronic voting machine by using a 16x2 LCD. The electronic voting machine contains 4 reset switches which are New Entry switch, 2 switches for 2 candidates, and a Result switch. The New Entry switch is to avoid any kind of malpractice or invalid votes. The New Entry switch is under supervision and control of a conservator and a user can only vote after the New Entry is pressed. Besides that, the electronic voting machine only allow 1 vote for each user. If any user tries to press the switch multiple times to vote more, only the first vote will be registered. The 2 switches represent the respective candidates, voter can vote to the candidate that he or she desired to vote by press the switch that represent the candidate. The result will only display on the LCD screen at the end when the Result switch is press. So that, the result would not affect the decision of the voter during the voting process is on the way. Of course, the Result switch also under supervision and control of a conservator. Finally the number of votes of respective candidate will display on LCD and we can know that which candidate is won when the Result switch is pressed.

3

Page 4: Electronic Voting Machine

Acknowledgement

We would like to express our deepest appreciation to all those who

provided us the possibility to complete this report. A special gratitude

we give to our supervisor, Encik Ahmad Nazri bin Ali, whose contribute

in stimulating suggestions and encouragement, helped us to coordinate

our project especially in writing this report. We also would like to thanks

other lecturers such as Dr. Zaini binti Abdul Halim and Dr. Syed Sahal

Nazli Alhady bin Syed Hassan and the tutors who guide us during lab

sessions so that we applied it in our mini project which is ‘Electronic

Voting Machine’.

Moreover, this mini project makes us realized the value of working

together as a team and as a new experience in working environment,

which challenges us every minute. We would also like to acknowledge

with much appreciation the staff of Microprocessor Laboratory, who

gave the permission to use all required equipment and the necessary

materials, contributed a great amount of time as well as guide us to

complete our project.

The special thanks goes to partner lab members, who collaborate

each other to assemble the parts and gave suggestion for our project.

The whole program really brought us together to appreciate the true

value of friendship and respect of each other. We have to appreciate the

guidance given by our seniors and friends in our project presentation by

giving their comments and advices. Last but not least, we appreciate

everyone who help us either directly or indirectly to complete our mini

project.

4

Page 5: Electronic Voting Machine

IntroductionThis LCD based electronic voting machine is designed for two

candidates. The input part consists of a set of 4 switches. The switches and 16x2 LCD are interfaced to microcontroller for various operations and displays. The provision of casting votes for the candidates has been provided through 2 of these switches (one for each candidate). These switches are made active high and connected to input pins of the controller. The remaining 2 switches are New Entry and Result. The New Entry switch initializes the voting system when pressed, while the Result switch ends the voting and displays the result (total number of votes for respective candidate) and winner on LCD screen. This system is set to 1 vote for each voter. In other word, the voter cannot make the second vote even he or she press the switch as long as the New Entry switch is press. Besides that, each of the switch has connected to a 1k ohm resistor and a LED. The resistor act as a pull down resistor which make the input normal LOW while the LED is to indicate the switch is being press.

The main objective of this project is to design and create a general electronic voting machine to replace the traditional paper-based voting schemes so that we can take an advantages in term of economic and convenient. Electronic voting machine is more economic because less manpower is required and may saves transportation cost due to its compact size. It is also more convenient and time conscious as less time required for voting and counting. Besides that, it is also more secure due to avoid invalid voting such as a people make a vote twice. Other than that, paper-based voting can actually miss ballots due to human mistakes in placing the paper-based ballot in the machine. But, this will be not happen at electronic voting machine.

The following is the advantages of electronic voting machine:1. It is economical2. Less manpower required3. Time conscious4. Avoids invalid voting5. Convenient

5

Page 6: Electronic Voting Machine

Objectives To program the Microprocessor 8051 to create an electronic

voting machine. To interface the Microprocessor 8051 with 2x16 LCD screen. To program the Microprocessor for automatic counting and

secured system

6

Page 7: Electronic Voting Machine

Literature ReviewAccording to the electronic voting machine that designed by

others, we found that it is similar to our design. First of all, their security system has control by 2 buttons. The first switch is New Entry switch to display the “Welcome” from “thanks” after a vote has been casted. While the second switch is Ready switch to indicate the voter ready to cast a vote. Then the voter can only cast a vote after the New Entry is pressed and follow by Ready button. Our security system is only control by one switch which is New Entry switch. After a vote has been casted, our voting machine will be display “Welcome” automatically from “thanks” after some delay. Then the voter can only cast a vote after the New Entry switch has pressed. Otherwise, any vote will not be counted. Besides that, their voting system is designed for 4 candidates and the counter for number of votes for each candidate can reach 3-digits number while we had designed for 2 candidates and the counter for number of votes for each candidate can only reach 2-digits number. But, we can add the number of candidate and also the counter by modified the program as well. Due to the time constraints we designed this as a prototype.

Moreover, we had found that some weakness and flaw in their system. We found that their electronic voting machine will display the number of votes for respective candidates after a vote has been casted. This phenomena may cause an unfair election happen due to the voter could tell the next voter about the result. This may affect the decision of other voters. Besides that, the guideline of the message that shown on LCD display not really clear. The LCD screen will display nothing when the period for voter ready to cast their vote. This may confused the users of this voting machine.

Thus, we are enhance the system by hide the number of votes for each candidates as long as the Result button is pressed. Once the result are out, the voting process is end and the LCD screen will declare the winner. Next, we also enhance the guideline of the system by adding the

7

Page 8: Electronic Voting Machine

message “Please vote” during the period for voter ready to cast a vote. So that the voter would not be confused.

8

Page 9: Electronic Voting Machine

MethodologyHow does it works?

First, the LCD screen will always display “Welcome to vote!” as long as the voting is started by pressing the New Entry switch after which the user is prompted to vote. Then, the LCD screen will display “Please vote…” to indicate the voter could start to cast a vote. The count of votes is stored in two different variables. As soon as the user votes for a candidate by pressing one of the switches, the value of the corresponding variable is increased by one. After this, a Thank you message is displayed on LCD to acknowledge the registration of user’s vote and the LCD screen will be automatically display back “Welcome to vote!” after some delay. The message will be stays on the screen until the next voter come and a conservator presses the New Entry switch. Then the voter have to press the switch to cast another vote and finally the Result switch is pressed to get the poll results. When the Result button is pressed the names of the candidates are displayed along with their vote counts. After some delay, the result is displayed which could be either declaration of the winner candidate or the candidates with a clash of their number of votes.

Component List

Component/Equipment Quantity8051 Development System 1Light Emitted Diode (LED) 4Reset Button Switch 41k ohm Resistor 42x16 LCD Screen 1

9

Page 10: Electronic Voting Machine

Hardware Description

Microcontroller board 8051

The 8051 Microcontroller was designed in 1980’s by Intel. Its foundation was on Harvard Architecture and was developed principally for bringing into play in Embedded Systems. At first it was created by means of NMOS technology but as NMOS technology needs more power to function therefore Intel re-intended Microcontroller 8051 employing CMOS technology and a new edition came into existence with a letter ‘C’ in the title name, for illustration: 80C51. These most modern Microcontrollers need fewer amount of power to function in comparison to their forerunners.

There are two buses in 8051 Microcontroller one for program and other for data. As a result, it has two storage rooms for both program and data of 64K by 8 size. The microcontroller comprise of 8 bit accumulator & 8 bit processing unit. It also consists of 8 bit B register as majorly functioning blocks and 8051 microcontroller programming is done with embedded C language using Keil software. It also has a number of other 8 bit and 16 bit registers.

For internal functioning & processing Microcontroller 8051 comes with integrated built-in RAM. This is prime memory and is employed for storing temporary data. It is unpredictable memory i.e. its data can get be lost when the power supply to the Microcontroller switched OFF.

10

Page 11: Electronic Voting Machine

8051 Pin Diagram & Description

For describing pin diagram and pin configuration of 8051, we are taking into consideration a 40 pin DIP (Dual inline package). Now let’s go

through pin configuration in detail.Pin-40 : Named as Vcc is the main power source. Usually its +5V DC.You may note some pins are designated with two signals (shown in brackets).Pins 32-39: Known as Port 0 (P0.0 to P0.7) – In addition to serving as I/O port, lower order address and data bus signals are multiplexed with this port (to serve the purpose of external memory interfacing). This is a bi directional I/O port (the only one in 8051) and external pull up resistors are required to function this port as I/O.

Pin-31:- ALE aka Address Latch Enable is used to demultiplex the address-data signal of port 0 (for external memory interfacing.) 2 ALE pulses are available for each machine cycle.Pin-30:- EA/ External Access input is used to enable or disallow external memory interfacing. If there is no external memory requirement, this pin is pulled high by connecting it to Vcc.Pin- 29:- PSEN or Program Store Enable is used to read signal from external program memory.Pins- 21-28:- Known as Port 2 (P 2.0 to P 2.7) – in addition to serving as I/O port, higher order address bus signals are multiplexed with this quasi bi directional port.Pin 20:- Named as Vss – it represents ground (0 V) connection.Pins 18 and 19:- Used for interfacing an external crystal to provide system clock.Pins 10 – 17:- Known as Port 3. This port also serves some other functions like interrupts, timer input, control signals for external memory interfacing RD and WR , serial communication signals RxD and TxD etc. This is a quasi bi directional port with internal pull up.Pin 9:- As explained before RESET pin is used to set the 8051 microcontroller to its initial values, while the microcontroller is working or at the initial start of application. The RESET pin must be set high for 2 machine cycles.

11

Page 12: Electronic Voting Machine

Pins 1 – 8:- Known as Port 1. Unlike other ports, this port does not serve any other functions. Port 1 is an internally pulled up, quasi bi directional I/O port.Microcontroller board 8255

The Intel 8255A 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 groups 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 strobed 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.

D0 - D7 These are the data input/output lines for the device. All information read from and written to the 8255 occurs via these 8 data lines. CS (Chip Select Input). If this line is a logical 0, the microprocessor can read and write to the 8255. RD (Read Input) Whenever this input line is a logical 0 and the RD input is a logical 0, the 8255 data outputs are enabled onto the system data bus. WR (Write Input) Whenever this input line is a

logical 0 and the CS input is a logical 0, data is written to the 8255 from the system data bus A0 - A1 (Address Inputs) The logical combination of these two input lines determines which internal register of the 8255 data is written to or read from. RESET 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. PA0 - PA7, PB0 - PB7, PC0 - PC7 These signal lines are used as 8-bit I/O

12

Page 13: Electronic Voting Machine

ports. They can be connected to peripheral devices. The 8255 has three 8 bit I/O ports and each one can be connected to the physical lines of an external device. These lines are labelled PA0-PA7, PB0-PB7, and PC0-PC7. The groups of the signals are divided into three different I/O ports labelled port A (PA), port B (PB), and port C (PC).

LCD2x16

The Serial LCDs are very functional, liquid crystal displays that can be easily interfaced to and controlled by a microcontroller using an I/O pin.

The LCD displays provide basic text wrapping so that your text looks correct on the display. Full control over all of their advanced LCD features allows you to move the cursor anywhere on the display with a single instruction and turn the display on and off in any configuration. They support the same visible characters as the Terminal (ASCII Dec 32-127). In addition, you may define up to eight of your own custom characters to display anywhere on the LCD. This device can be connected to a PC serial port using a MAX232 line driver. The circuit isn't supported by us.

Resistor

Resistor is a passive two terminal

components which widely use in the

circuit. Its function is to limit the current of the circuit. In this

miniproject, we used 4 1kΩ resistors as a pull down resistor for the 4

reset buttons.It also used as a safety mechanism if a circuit exceeds safe

margins.

13

Page 14: Electronic Voting Machine

LED

Light-Emitting Diode (LED) is a basic

component we widely use in the circuit.

It usually connect in series with resistor

to emit light. We used the LED to

indicate the reset buttons have pressed.

Reset Button

In electronics and technology, a reset button is a button that can reset a device. On video game consoles. Reset buttons are found on circuit breakers to reset the circuit. This button can cause data corruption so this button often doesn't exist on many machines. Usually, in computers and other electronic devices, it is present as a small button, possibly recessed into the case or only accessible by a pin or similar thin object, to prevent it being pressed accidentally.

14

Page 15: Electronic Voting Machine

SCHEMATIC DIAGRAM

15

Page 16: Electronic Voting Machine

BLOCK DIAGRAM FOR ELETRONIC VOTING MACHINEA block diagram is drawn to ease the understanding to connection of circuit design. This block diagram explains roughly about the connection of the microcontroller 8051, PPI 8255, 2x16 LCD screen and LEDs. Based on this block diagram, we write the program code according to our circuit design.

16

8051 8255

4 switches/reset buttons

4 LEDs

2x16 LCD screen

Page 17: Electronic Voting Machine

Flow Chart

17

Start

LCD display:“WELCOME TO VOTE!”

LCD display: “PLEASE VOTE…” LCD display:

“C1 C2”“XX YY”

LCD display:“CONGRATULATION!! C1 WINS!!!”

LCD display:“DRAW!! PROCEED TO THE NEXT VOTING...”

LCD display:“CONGRATULATION!! C2 WINS!!!”

Is the New Entry switch being press?

Is the switch that represent C1 being press?

Is the switch thatrepresentC2 being press?

The number of votes for C1 +1

The number of votes for C2 +1

Is the Result switch being press?

LCD display:“THANK YOU…”

AFTER A DELAY

YESNO

NO NO

YESYES

YES

XX<YY

XX=YY

XX>YY

AFTER A DELAY

NO

Page 18: Electronic Voting Machine

Problem Statement and Analysis Problem 1:

When we display those message on LCD screen, we found that the cursor on LCD screen keep on moving and it is too annoying for the user.

Solution:

We change the command to LCD from 0E (display on, cursor on) to 0C (display on, cursor off).

Problem 2:

We are going to display the number of votes of candidate that have stored in register on LCD screen. Then, we realise that the LCD display the other character instead of the number.

Solution:

We found that LCD can only read ASCII code and the number that stored in the register is HEX code. By refer to the table of comparison between ASCII code and HEX code, we found that we could convert the HEX code to ASCII code by adding 30H for the numbering part. In other word, 30H will display 0 on LCD, 31H will display 1 on LCD.

Problem 3:

After we solved the problem 2, we are facing the other problem that we can only display the single digit (0-9) to LCD screen due to only 0-9 available on ASCII code. Double digits such as 17, 23 will display the other characters on LCD.

Solution:

First we move the number that stored in the register to Accumulator and move 10H to register B. After that, we use the function DIV AB and move the content of A and B to another 2 registers follow by add 30H for both registers and finally display on LCD screen.

Example:

23H A, 10H BDIV AB A=2, B=3A R5+30H, B R6+30H

18

Page 19: Electronic Voting Machine

Result And DiscussionFirst of all, the electronic voting machine will be starting by display

“WELCOME TO VOTE!” as shown in figure below as long as the New Entry switch is being pressed. The switch 1 represented New Entry switch and switch 4 represented Result switch. While the switch 2 and 3 represented candidate 2 and 3.

After that, the LCD screen will display “PLEASE VOTE…” immediately to indicate the voter could start to cast their vote. The result is shown in figure below.

19

Switch 1Switch 2Switch 3Switch 4

Page 20: Electronic Voting Machine

After the voting process is ended, the Result switch is being pressed by a conservator. Then all the candidates follow by the number of votes will be display on LCD screen and after some delay it would declare the winner automatically.

Based on the figures above candidate1 (C1) get 18 votes while candidate2 (C2) only 11 votes. So C1 has wins the poll and the LCD screen will make a congratulation and declare that C1 wins! Conversely the LCD screen will display “C2 wins” if the number of votes for C2 is more than C1. In case of the number of votes for both candidates clash, the LCD screen will ask for proceed to another voting.

In this project, we still require to make some improvement to make it more effective for future scope. First, we can make an option initially to choose how much the candidate will be involved. Next, in security system, we could add a finger print scanning to mark down the people who has voted to ensure that a same people cannot vote for the second times. We can also provide several different languages to voters for whom English is not the first language. Finally, there are also advantages when it comes to disabled people, such as blind individuals. Electronic voting machine can provide headphones to read off instructions to blind voters. Additional tools can be incorporated into these voting machines to help with other disabilities and to aid the elderly as well. Due to time constraints we have not been able to implement these features in our project. But it is possible to make it in the future.

20

Result Declare The Winner

Page 21: Electronic Voting Machine

Conclusion This project show that we can use the microcontroller 8051 to design a electronic voting machine which is more secured, convenient, and economic compare with the traditional paper-based voting scheme. We are successfully build up an electronic voting machine which can be used for school and college level council elections or any voting purpose event. The function of the circuit is working according to what are we predicted and the objectives is achieve. This show that our program code and circuit design can be implemented to a real life

In this project, we learned some extra code of microcontroller 8051 which we did not learn from the lab session and we are able to use those code. For an instance, we had used the registers from Bank 1 and the alternative way to display a message on LCD screen. We learned how to interface the microcontroller 8051 with PPI 8255, LCD screen, and LED. We are able to use the ports from PPI 8255 to send an output from microcontroller 8051 or send an input to microcontroller 8051. We learned how to solve the problem that we faced during this project.

We hope that our project will not only work on our circuit design, but also it can work in a real life by do some improvement on it. So that it could be used for voting purpose at any required place.

21

Page 22: Electronic Voting Machine

Appendix Assembly program code:

CPU"8051.TBL"INCL"8051.INC"MOV SP, #030HORG 2000H

PA: EQU 4000HPB: EQU 4001HPC: EQU 4002HPCTR: EQU 4003H

MOV A, #10010000BMOV DPTR, #PCTRMOVX @DPTR, A

MOV A, #38HLCALL COMNWRTLCALL DELAYMOV A, #0CHLCALL COMNWRTLCALL DELAYMOV A, #10HLCALL COMNWRTLCALL DELAYMOV A, #01HLCALL COMNWRTLCALL DELAY

MOV R0, #0HMOV R6, #0HMOV R1, #0HMOV R2, #0HMOV R3, #0HMOV R4, #0HMOV R5, #0HMOV R7, #0HSETB F0;===========================================================================;;===========================================================================START: LCALL BUTTONPRESS

LCALL FIRSTLINELCALL SECONDLINECJNE R0, #2, START1MOV R0, #0LCALL DELAY1LCALL DELAY1LCALL DELAY1

22

Page 23: Electronic Voting Machine

LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1

START1: CJNE R0, #3, STARTLCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL DELAY1LCALL WINNER

AGAIN: SJMP AGAIN;===========================================================================; SCAN BUTTON;===========================================================================BUTTONPRESS: MOV DPTR, #PA

MOVX A, @DPTRANL A, #00001111BCJNE A, #00000001B, RCHECK1MOV R0, #1CLR F0RET

RCHECK1: CJNE A, #00000010B, RCHECK2JB F0, DONTHINC R1MOV R0, #2SETB F0RET

RCHECK2: CJNE A, #00000100B, RCHECK3JB F0, DONTHINC R2MOV R0, #2SETB F0RET

RCHECK3: CJNE A, #00001000B, DONTHMOV R0, #3RET

DONTH: RET

23

Page 24: Electronic Voting Machine

;===========================================================================; DISPLAY MESSAGES ON LCD;===========================================================================FIRSTLINE: LCALL DELAY

MOV A, #80HLCALL COMNWRTLCALL DELAYMOV R4, #0

LOOP1: MOV A, R4LCALL COND0MOVC A, @A+DPTRINC R4JZ PROCEED1LCALL DATAWRTLCALL DELAY

SJMP LOOP1

PROCEED1: RET;===========================================================================; DISPLAY THE TOTAL NUMBER OF VOTES;===========================================================================SECONDLINE: MOV DPTR, #PA

MOVX A, @DPTRANL A, #00001000BCJNE A, #00001000B, DONTH1MOV A, #0C0HLCALL COMNWRTLCALL DELAY

MOV A, R1MOV R7, ALCALL HEXTOBCDMOV A, R5ADD A, #30HLCALL DATAWRTLCALL DELAYMOV A, R6ADD A, #30HLCALL DATAWRTLCALL DELAY

MOV A, #20HLCALL DATAWRTLCALL DELAYMOV A, #20HLCALL DATAWRTLCALL DELAY

24

Page 25: Electronic Voting Machine

MOV A, R2MOV R7, ALCALL HEXTOBCDMOV A, R5ADD A, #30HLCALL DATAWRTLCALL DELAYMOV A, R6ADD A, #30HLCALL DATAWRTLCALL DELAYRET

DONTH1: RET;===========================================================================; DECLARE WINNER;===========================================================================WINNER: CLR C

MOV A, #01HLCALL COMNWRTLCALL DELAYMOV A, #80HLCALL COMNWRTLCALL DELAYMOV R4, #0

LOOP2: MOV A, R1MOV 50H, R2CJNE A, 50H, LOOP3LCALL COND6MOV A, R4MOVC A, @A+DPTRINC R4JZ PROCEED2LCALL DATAWRTLCALL DELAYSJMP LOOP2

LOOP3: JC LOOP4MOV A, R4LCALL COND4MOVC A, @A+DPTRINC R4JZ PROCEED2LCALL DATAWRTLCALL DELAYSJMP LOOP3

LOOP4: MOV A, R4LCALL COND5MOVC A, @A+DPTR

25

Page 26: Electronic Voting Machine

INC R4JZ PROCEED2LCALL DATAWRTLCALL DELAYSJMP LOOP4

PROCEED2: MOV R0, 255MOV A, #18HLCALL COMNWRTLCALL DELAY1LCALL DELAYDEC R0MOV A, R0JNZ PROCEED2RET

;===========================================================================; SELECT WHICH MESSAGE TO BE DISPLAY;===========================================================================COND0: CJNE R0, #0, COND1

MOV DPTR, #MSG0RET

COND1: CJNE R0, #1, COND2MOV DPTR, #MSG1RET

COND2: CJNE R0, #2, COND3MOV DPTR, #MSG2RET

COND3: MOV DPTR, #MSG3RET

COND4: MOV DPTR, #MSG4RET

COND5: MOV DPTR, #MSG5RET

COND6: MOV DPTR, #MSG6RET

26

Page 27: Electronic Voting Machine

;===========================================================================; CONVERT HEX TO BCD;===========================================================================HEXTOBCD: CLR C

MOV A, R7MOV B, #10DIV ABMOV R5, AMOV R6, BRET

;===========================================================================; LCD COMMAND;===========================================================================COMNWRT: MOV DPTR, #PC

MOVX @DPTR, ACLR P1.0 ;RSCLR P1.1 ;RWSETB P1.2;EACALL DELAYCLR P1.2RET

DATAWRT: MOV DPTR, #PCMOVX @DPTR, ASETB P1.0CLR P1.1SETB P1.2ACALL DELAYCLR P1.2 RET

;===========================================================================; DELAY;===========================================================================DELAY: MOV R3, #225HERE1: DJNZ R3, HERE1

RET

DELAY1: SETB PSW.4MOV R7, #255

HERE: MOV R3, #255HERE2: DJNZ R3, HERE2

DJNZ R7, HERECLR PSW.4RET

27

Page 28: Electronic Voting Machine

;===========================================================================; DECLARE MESSAGE TO BE DISPLAY ON LCD;===========================================================================ORG 3800HMSG0: DFB "WELCOME TO VOTE!", 0H

ORG 3830HMSG1: DFB "PLEASE VOTE... ", 0H

ORG 3850HMSG2: DFB "THANK YOU... ", 0H

ORG 3870HMSG3: DFB "C1 C2 ", 0H

ORG 3890HMSG4: DFB "CONGRATULATION!! C1 WINS!!!", 0H

ORG 3910HMSG5: DFB "CONGRATULATION!! C2 WINS!!!", 0H

ORG 3950HMSG6: DFB " DRAW!! PROCEED TO THE NEXT VOTING...", 0HEND

A prototype of electronic voting machine which designed by our group.

28

Page 29: Electronic Voting Machine

REFERENCE

1. http://www.electronics.dit.ie/staff/tscarff/8255PPI/8255.htm

2. http://www.circuitstoday.com/8051-microcontroller

3. http://en.wikipedia.org/wiki/Intel_8255

4.http://www.cdrummond.qc.ca/cegep/informat/professeurs/alain/files/asc ii.htm

5. Laboratory Manual EEE226 Microprocessor I

6. The 8051 Microcontroller and Embedded Systems

7. Appendix 8051 Instructions, Timing, And Registers

29