Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 63

AN INDUSTRY ORIENTED MINI PROJECT REPORT

On
ELECTRONIC VOTING MACHINE
Submitted in partial fulfillment of requirements

For the award of the degree of

BACHELOR OF TECHNOLOGY
In

ELECTRONICS & COMMUNICATION ENGINEERING


By

A.V.KARTHIK PRASAD (Regd No: 15891A0462)


A. HARINI REDDY (Regd No: 15891A0463)
C.HARIKA (Regd No: 15891A0472)

Under the guidance of

Mrs. R.B.KALYANI
(Assistant Professor)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

2018-2019

1
DECLARATION
I hereby declare that project entitled “ELECTRONIC VOTING MACHINE” is

bonafide work duly completed by us. It does not contain any part of project or thesis

submitted by any other candidate to this or any other institute of the university.

All such material that have been obtained from other sources have been duly

acknowledged.

A.V.KARTHIK PRASAD

Regd No: 15891A0462

A.HARINI REDDY

Regd No: 15891A0463

C. HARIKA

Regd No: 15891A0472

i
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CERTIFICATE
This is to certify that the thesis work titled “ELECTRONIC VOTING MACHINE” submitted

by A.V.KARTHIK PRASAD (Regd No: 15891A0462), A.HARINI REDDY (Regd No:

15891A0463), C.HARIKA (Regd No: 15891A0472) in partial fulfillment of the requirements for

the award of the degree of Bachelor of Technology in Electronics & Communication Engineering to

the Vignan Institute Of Technology And Science, Deshmukhi is a record of bonafide work carried

out by him/her under my guidance and supervision.

The results embodied in this project report have not been submitted in any university for the award

of any degree and the results are achieved satisfactorily.

Mrs.R.B. Kalyani Dr. N Dinesh Kumar


(Asst. Professor) (Head of the department)

ii
PREFACE
The complete thesis is segregated into chapters and well described below. Each
chapter of this thesis follows a specific format and is discussed below.

Chapter 1: This chapter provides details regarding the idea and introduction of the
project. It also contains the list of components and their cost approximately.

Chapter 2: This chapter contains the information regarding the problem domain and
need of this project. It gives information about the research done in the problematic
situations that are being faced. It explains how do this project would overcome these
things and come up with a solution.

Chapter 3: This chapter contains block diagram and its explanation, a brief content
describing about the hardware components used in this project with figures. It also
contains detailed description about the software requirements.

Chapter 4: This chapter gives the final output of the project and result is discussed
with images.

Chapter 5: This chapter draws a final conclusion and the future scope of the project.

iii
ACKNOWLEDGEMENT
Every project big or small is successful largely due to the effort of a number of
wonderful people who have always given their valuable advice or lent a helping hand. We
sincerely appreciate the inspiration ; support and guidance of all those people who have been
instrumental in making this project a success.

We thank our beloved Chairman , Dr. L Rathaiah, who gave us great encouragement
to work.

We thank our beloved CEO , Mr. Boyapati Shravan, We remember him for his
valuable ideas and facilities available in college during the development of the project.

We convey our sincere thanks to Dr. G Durga Sukumar, Principal of our institution
for providing us with the required infrastructure and a very vibrant and supportive staff.

We would like to thank our Head of the Department of Electronics and


Communication Engineering, Dr. N Dinesh Kumar, a distinguished and eminent personality ,
whose strong recommendation , immense support and constant encouragement has been great
help to us. We intensely thank him for the same.

We would like to thank our guide of the project , Mrs.R.B Kalyani (Asst. Professor)
who has invested his full effort in guiding the team in achieving the goal.

Special thanks goes to my team mates, who helped me to assemble the parts and
gave suggestions in making this project .We have to appreciate the guidance given by other
supervisor as well as the panels especially in our project presentation that has improved our
presentation skills thanks to their comment and advices . We take this opportunity to thank
all our lecturers who have directly or indirectly helped our project . We pay our respects
and love to our parents and all other family members and friends for their love and
encouragement throughout our career.

iv
ABSTRACT
This is an interesting project which uses 8051 microcontroller as its brain. Voters can poll
their vote to any one of the contestant. In this project, one port is dedicated for 4 push-button
switches for four contestants, and a master switch for polling officer.

A simple yet powerful program is written in C language and is burnt onto the
microcontroller to accept votes and to keep counting the total votes polled. A Polling-officer switch
(master) is provided to avoid multiple polling by a single voter. Every voter gets approval from the
polling officer. If the polling officer issues approval with his control switch, then only the voter can
poll his vote. This issuance of approval is indicated by a long buzzer beep. Vote count is displayed
on LCD display is provided to display the total number of votes polled and individual contestant-
vise votes polled.

This project uses regulated 5V, 500mA power supply. Unregulated 12V DC is used for
relay. 7805 three terminal voltage regulator is used for voltage regulation. Full wave bridge rectifier
is used to rectify the ac output of secondary of 230/12V step down transformer.

v
CONTENTS
S.no Contents page .no
1. Chapter -1 1

Introduction

2. Chapter -2 3

Literature survey

3. Chapter -3 5

Block diagram

Hardware implementation 7

Software implementation 31

4. Chapter – 4 41

Results and conclusion

5. Chapter -5 44

Conclusion and future scope

6. References 46

7. Appendix-1 47

vi
LIST OF FIGURES
S.no Label name Page. No

3.2.1 AT89S52 Microcontroller 7

3.2.2 Block diagram of 8051 microcontroller 8

3.2.3 Pin diagram of AT89S52 9

3.2.4 Timer 2 in baud rate generator mode 18

3.2.5 Timer 2 in clock out mode 19

3.2.6 Step-down transformer 22

3.2.7 Bridge rectifier 23

3.2.8 Output at the capacitor 23

3.2.9 Block diagram of voltage regulator 24

3.2.10 Zener diode as voltage reference 24

3.2.11 Voltage regulator 7805 25

3.2.12 LCD Display 25

3.2.13 LCD pin diagram 26

3.2.14 Circuit diagram of keyboard interfacing to 8051 30

3.2.15 Piezo buzzer and its circuit 31

vii
LIST OF TABLES
S.no Label name Page. No
1.1 List of components used 2

3.2.1 Functions of port 1 pins 10

3.2.2 Functions of port 3 pins 11

3.2.3 Timer 2 operating modes 16

3.2.4 Interrupt enable table 20

3.2.5 LCD pin description 26

3.2.6 LCD command table 28

viii
CHAPTER - 1
INTRODUCTION
Fundamental right to vote or simply voting in elections forms the basis of
democracy. All earlier elections be it state elections or centre elections a voter used to cast
his/her favorite candidate by putting the stamp against his/her name and then folding the
ballot paper as per a prescribed method before putting it in the Ballot Box.

This is a long , time-consuming process and very much prone to errors . This
situation continued till election scene was completely changed by electronic voting machine .
No more ballot paper , ballot boxes, stamping, etc. all this condensed into a simple box called
ballot unit of the electronic voting machine.

In order to prevent all the malpractices that are being occurred due to ballot
papers in the process of elections we have come up with the idea of electronic voting
machine. The electronic voting machine is an electronic device which uses the current
technology of microcontrollers.

This method of implementation will reduce the time of counting the number of
votes and increase the accuracy . The program used in this project will avoid unauthorized
voting. Due to the high security provided there is no scope for the duplication of votes .
Hence right will be elected by the people.

The electronic voting machine is hence a time efficient and space efficient
unlike the traditional method of voting through ballot papers and ballot boxes . The ballot
papers method of voting limits the efficiency and accuracy for more number of people .
This is a major drawback for the increasing population. Hence this problem is being
overcome by this electronic voting machine through which numerous people can cast their
votes at a time.

1
Table 1.1 :- List of components used

S.NO Name of the components Cost of the component

1 AT89S52 Microcontroller 110

2 Crystal oscillator ( 11Mhz) 30

3 LCD Display HD44780 130

4 Push buttons 85

5 Buzzer (5v- 12v DC) 40

6 Power supply

7 Step down transformer 12v 350

8 Filter 15

9 5v Voltage regulator 100

2
CHAPTER - 2
LITERATURE SURVEY
Earlier, elections were used to follow the traditional method of ballot papers and ballot
boxes. This method was in practice due to less advancement in the technology. It used to be a very
tedious process and requires a lot of human effort. This is also a time consuming and space
consuming even for a less number of people.

There are many chances of occurrence of malpractices. Some of the people who are likely
to support their representative and in their greed to make them win, they bribe the polling officers
and other authorized people.

A single person will cast multiple votes showing the fake identity to the officer due which
a wrong person is being elected. Due to this many problems are being aroused. This is because of
the lack of proper identity check and no proper technology to detect the errors.

Since the voters cast their votes by stamping on the ballot paper and dropping it in the
ballot box. But there is a chance of faking these ballot papers if once the person gets a copy of it.

Since there is no proper system or mechanism to count the votes, the casted votes are being
counted by the human which may lead to error. Even a single vote can make a major difference in
deciding which representative has to win in the election.

After casting the votes the ballot boxes has to be shifted to the nearest election office for
the counting process. In case there no proper security, there is a chance of robbery or destroy of the
ballot boxes by the favored persons of their leaders.

To overcome these problems we have come up with the electronic voting machine which
replaces the use of stamping ballot papers and ballot boxes. This project does not require large
space and much time.

3
It is even more efficient in the case where more number of people has to vote. Since no
man power is required to count the votes we acquire the accurate results. It does not require much
human effort. It does not require any supervision while the activity is going on. For every voter to
cast his vote he/she must acquire permission from the polling officer.

The voter is sent inside the polling booth only after the proper identity check. Because of
this process there are less chances of casting multiple votes. Since the information of number of
votes casted contained in the voting machine is encrypted there is no chance of hacking it or
changing the number of votes casted.

Every voting machine is being perfectly sealed and is kept in a secured locker while shifting them
to the election commission office so there is no chance of manipulating the votes casted.

4
CHAPTER - 3
3.1 BLOCK DIAGRAM

REGULATED

POWER SUPPLY

16X2 LCD

MASTER SWITCH 8051

(POLLING OFFICER) MICROCONTROLLER DRIVER


BOARD CIRCUIT

SWITCH ARRAY
(CONTESTANTS) BUZZER

3.1.1 POWER SUPPLY BLOCK DIAGRAM

STEP DOWN BRIDGE FILTER REGULATOR


TRANSFORMER
RECTIFIER

OUTPUT

5
3.1.2 DESCRIPTION
Basically in this electronic voting machine we used AT89S52 microcontroller which is a
low power and high performance microcontroller. The LCD display and push buttons are connected
to the input/output ports of the microcontroller. The buzzer is also connected to the microcontroller.

The power supply that we use here is 230V AC. Since this is very high and the circuit
cannot withstand for such high voltage. In order to reduce the power we use a step down
transformer that gives an output voltage of 12V. This output voltage is actually alternating current.

To convert the ac current to dc we use a bridge rectifier. The bridge rectifier consists of 4
diodes which are connected in the form of a bridge. It converts the alternating current to pulsating
dc. To obtain pure dc current a capacitor is used as a filter. Since the microcontroller requires only
5V power supply a voltage regulator is used to provide a constant supply of 5V.

Whenever a voter has to cast his vote he should get permission from the polling officer.
Hence an acceptance button is given to him so that, after checking the details of the voter
thoroughly the polling officer will press this button. A long beep sound is heard then the voter is
allowed to cast his vote. To cast the next vote again permission is required from the polling officer.
Therefore because of this the voter cannot cast multiple votes and there is no chance of malpractice.

After the completion of the process of voting, to check how many votes are being casted
there is a master switch which can be accessed only by the polling officer. When this button is
pressed the LCD display will show how many votes are being recorded and it also gives
information about the individual number of votes that a contestant has got. This information is only
visible to the polling officer but not the voters. Whenever the voter casted his vote a beep sound is
heard from the buzzer indicating that the person has given his vote. The permission from the polling
officer is given a long beep and after casting a vote it gives a short beep sound.

6
3.2 HARDWARE IMPLEMENTATION
1. Microcontroller

2. Step-down transformer

3. Bridge rectifier

4. Voltage regulator

5. LCD Display

6. Buzzer

3.2.1 MICROCONTROLLER
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with
8K bytes of in system programmable Flash memory. The device is manufactured using Atmel’s
high density nonvolatile memory technology and is compatible with the industry-standard 80C51
instruction set and pin out.

The on-chip Flash allows the program memory to be reprogrammed in-system or


by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU within
system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many embedded
control applications.

3.2.1 AT89S52 MICROCONTROLLER

7
The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of
RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector
two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In
addition, the AT89S52 is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes.

3.2.2 Block diagram of 8051 microcontroller

The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM contents but freezes the
oscillator, disabling all other chip functions until the next interrupt or hardware reset.

8
3.2.1.1 Pin description

3.2.3 Pin diagram of AT89S52

Port 0:

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink
eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs.
Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to
external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the
code bytes during Flash programming and outputs the code bytes during program verification.

9
Port 1:

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs , Port 1 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be
configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger
input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order
address bytes during Flash programming and verification.

TABLE 3.2.1: Functions of port 1 pins

Port 2

In port 2, when 1s are written to Port 2 pins, they are pulled high by the internal pull-ups
and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source
current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to external data memory that uses 16-
bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port
2 emits the contents of the P2 Special Function Register.

10
Port 3

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal
pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will
source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash
programming and verification. Port 3 also serves the functions of various special features of the
AT89S52, as shown in the following table.

TABLE 3.2.2: Functions of port 3

RST

Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The
DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of
bit DISRTO, the RESET HIGH out feature is enabled.

11
ALE/PROG

Address Latch Enable (ALE) is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency
and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is
skipped during each access to external data memory. If desired, ALE operation can be disabled by
setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode

PSEN

Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activations are skipped during each access to external data memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however,
that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to
VCC for internal program executions. This pin also receives the 12-volt programming enable
voltage (VPP) during Flash programming.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplify

12
Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR) space.
Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented
on the chip. Read accesses to these addresses will in general return random data, and write accesses
will have an indeterminate effect. User software should not write 1s to these unlisted locations,
since they may be used in future products to invoke new features. In that case, the reset or inactive
values of the new bits will always be 0.

Timer 2 Registers:

Control and status bits are contained in registers T2CON and T2MOD for Timer 2. The
register pair (RCAP2H, RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture
mode or 16-bit auto-reload mode.

Interrupt Registers:

The individual interrupt enable bits are in the IE register. Two priorities can be set for
each of the six interrupt sources in the IP register. Memory Organization MCS-51 devices have a
separate address space for Program and Data Memory. Up to 64K bytes each of external Program
and Data Memory can be addressed.

Program Memory

If the EA pin is connected to GND, all program fetches are directed to external
memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H
through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are
to external memory.

Data Memory

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a
parallel address space to the Special Function Registers. This means that the upper 128 bytes have
the same addresses as the SFR space but are physically separate from SFR space.

13
When an instruction accesses an internal location above address 7FH, the address mode used
in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR
space. Instructions which use direct addressing access the SFR space. For example, the following
direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the
following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at
address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack
operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as
stack space.

Watchdog Timer (One-time Enabled with Reset-out)

The WDT is intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog Timer Reset
(WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT, a user
must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H). When the
WDT is enabled, it will increment every machine cycle while the oscillator is running. The WDT
timeout period is dependent on the external clock frequency. There is no way to disable the WDT
except through reset (either hardware reset or WDT overflow reset). When WDT over-flows, it will
drive an output RESET HIGH pulse at the RST pin.

Using the WDT

To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST
register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by writing
01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter overflows when it
reaches 16383 (3FFFH), and this will reset the device. When the WDT is enabled, it will increment
every machine cycle while the oscillator is running. This means the user must reset the WDT at
least every 16383 machine cycles. To reset the WDT the user must write 01EH and 0E1H to
WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written. When
WDT overflows, it will generate an output RESET pulse at the RST pin.

14
The RESET pulse duration is 98xTOSC, where TOSC = 1/FOSC. To make the best use of the
WDT, it should be serviced in those sections of code that will periodically be executed within the
time required to prevent a WDT reset.

WDT during Power-down and Idle

In Power-down mode the oscillator stops, which means the WDT also stops. While in
Power-down mode, the user does not need to service the WDT. There are two methods of exiting
Power-down mode: by a hardware reset or via a level-activated external interrupt which is enabled
prior to entering Power-down mode. When Power-down is exited with hardware reset, servicing the
WDT should occur as it normally does whenever the AT89S52 is reset.

Exiting Power-down with an interrupt is significantly different. The interrupt is held


low long enough for the oscillator to stabilize. When the interrupt is brought high, the interrupt is
serviced. To prevent the WDT from resetting the device while the interrupt pin is held low, the
WDT is not started until the interrupt is pulled high. It is suggested that the WDT be reset during
the interrupt service for the interrupt used to exit Power-down mode.

To ensure that the WDT does not overflow within a few states of exiting Power-down,
it is best to reset the WDT just before entering Power-down mode. Before going into the IDLE
mode, the WDIDLE bit in SFR AUXR is used to determine whether the WDT continues to count if
enabled. The WDT keeps counting during IDLE (WDIDLE bit = 0) as the default state. To prevent
the WDT from resetting the AT89S52 while in IDLE mode, the user should always set up a timer
that will periodically exit IDLE, service the WDT, and reenter IDLE mode. With WDIDLE bit
enabled, the WDT will stop to count in IDLE mode and resumes the count upon exit from IDLE.

UART

The UART in the AT89S52 operates the same way as the UART in the AT89S52 and
AT89C52.

15
Timer 0 and 1

Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in
the AT89S52 and AT89C52.

Timer 2

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event


counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has three
operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes
are selected by bits in T2CON, as shown in Table 10-1. Timer 2 consists of two 8-bit registers, TH2
and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a
machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

Table 3.2.3: Timer 2 operating modes

In the Counter function, the register is incremented in response to a 1-to-0 transition at


its corresponding external input pin, T2. In this function, the external input is sampled during S5P2
of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the
count is incremented. The new count value appears in the register during S3P1 of the cycle
following the one in which the transition was detected. Since two machine cycles (24 oscillator
periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the
oscillator frequency. To ensure that a given level is sampled at least once before it changes, the
level should be held for at least one full machine cycle.

16
Capture Mode

In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,
Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit can then
be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation, but a 1-to-0
transi-tion at external input T2EX also causes the current value in TH2 and TL2 to be captured into
RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in
T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt.

Auto-reload (Up or Down Counter)

Timer 2 can be programmed to count up or down when configured in its 16-bit auto-
reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR
T2MOD. Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN
is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

Baud Rate Generator

Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON.
Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver
or transmitter and Timer 1 is used for the other function. Setting RCLK and/or TCLK puts Timer 2
into its baud rate generator mode. The baud rate generator mode is similar to the auto-reload mode,
in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in
registers RCAP2H and RCAP2L, which are preset by software. The baud rates in Modes 1 and 3 are
determined by Timer 2’s overflow rate according to the following equation.

The Timer can be configured for either timer or counter operation. In most applications,
it is con-figured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when
it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at 1/12
the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2
the oscillator frequency). The baud rate formula is given below. Where (RCAP2H, RCAP2L) is the
content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer. This figure is valid only if
RCLK or TCLK = 1 in T2CON.

17
Note that a rollover in TH2 does not set TF2 and will not generate an inter-rupt. Note too, that if
EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload from
(RCAP2H, RCAP2L) to (TH2, TL2). Thus, when Timer 2 is in use as a baud rate generator, T2EX
can be used as an extra external interrupt. Note that when Timer 2 is running (TR2 = 1) as a timer in
the baud rate generator mode, TH2 or TL2 should not be read from or written to.

Under these conditions, the Timer is incremented every state time, and the results of a
read or write may not be accurate. The RCAP2 registers may be read but should not be written to,
because a write might overlap a reload and cause write and/or reload errors. The timer should be
turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.

3.2.4 Timer 2 in baud rate generator mode

Programmable Clock Out

A 50% duty cycle clock can be programmed to come out on P1.0. This pin, besides
being a regular I/O pin, has two alternate functions. It can be programmed to input the external
clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz (for a
16-MHz operating frequency). To configure the Timer/Counter 2 as a clock generator, bit C/T2

18
(T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and
stops the timer. The clock-out frequency depends on the oscillator frequency and the reload value of
Timer 2 capture registers (RCAP2H, RCAP2L), as shown in the following equation. In the clock-
out mode, Timer 2 roll-overs will not generate an interrupt.

This behavior is similar to when Timer 2 is used as a baud-rate generator. It is possible


to use Timer 2 as a baud-rate generator and a clock generator simultaneously. Note, however, that
the baud-rate and clock-out frequencies cannot be determined independently from one another since
they both use RCAP2H and RCAP2L.

3.2.5 Timer 2 in clock-out mode

Interrupts

The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and
INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are
all shown in Figure 13-1. Each of these interrupt sources can be individually enabled or disabled by
setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA,
which disables all interrupts at once. Note that the bit position IE.6 is unimplemented. User
software should not write a 1 to this bit position, since it may be used in future AT89 products.

19
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither
of these flags is cleared by hardware when the service routine is vectored to.

In fact, the service routine may have to determine whether it was TF2 or EXF2 that
generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and Timer 1
flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then
polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is
polled in the same cycle in which the timer overflows.

Table 3.2.4 Interrupt enable table

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
that can be configured for use as an on-chip oscillator, as shown in Figure 16-1. Either a quartz
crystal or ceramic resonator may be used. To drive the device from an external clock source,
XTAL2 should be left unconnected while XTAL1 is driven. There are no requirements on the duty
cycle of the external clock signal, since the input to the internal clocking circuitry is through a
divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must
be observed.

20
Idle Mode

In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain
active. The mode is invoked by software. The content of the on-chip RAM and all the special
functions registers remain unchanged during this mode. The idle mode can be terminated by any
enabled interrupt or by a hardware reset. Note that when idle mode is terminated by a hardware
reset, the device normally resumes pro-gram execution from where it left off, up to two machine
cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal
RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an
unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the
one that invokes idle mode should not write to a port pin or to external memory

Power-down Mode

In the Power-down mode, the oscillator is stopped, and the instruction that invokes
Power-down is the last instruction executed. The on-chip RAM and Special Function Registers
retain their values until the Power-down mode is terminated. Exit from Power-down mode can be
initiated either by a hardware reset or by an enabled external interrupt. Reset redefines the SFRs but
does not change the on-chip RAM. The reset should not be activated before VCC is restored to its
normal operating level and must be held active long enough to allow the oscillator to restart and
stabilize.

3.2.2 STEPDOWN TRANSFORMER


The step-down transformer is used for converting the high voltage into low voltage. The
converter with output voltage less than the input voltage is called as a step-down converter, and the
converter with output voltage greater than the input voltage is called as step-up converter. There are
step-up and step-down transformers which are used to step up or step down the voltage levels. 230V
AC is converted into 12V AC using a step-down transformer.

The 12V output of step down transformer is an RMS value and its peak value is given by the
product of square root of two with RMS value, which is approximately 17V.

21
3.2.6 Step-down transformer

Step-down transformer consists of two windings, namely primary and secondary windings
where primary can be designed using a less-gauge wire with more number of turns as it is used for
carrying low-current high-voltage power, and the secondary winding using a high-gauge wire with
less number of turns as it is used for carrying high-current low-voltage power. Transformer works
on the principle of Faraday’s laws of electromagnetic induction.

3.2.3 BRIDGE RECTIFIER

Bridge rectifier consists of four diodes which are connected in the form a bridge. We know
that the diode is an uncontrolled rectifier which will conduct only forward bias and will not conduct
during the reverse bias. If the diode anode voltage is greater than the cathode voltage then the diode
is said to be in forward bias. During positive half cycle, diodes D2 and D4 will conduct and during
negative half cycle diodes D1 and D3 will conduct. Thus, AC is converted into DC; here they
obtained is not a pure DC as it consists of pulses. Hence, it is called as pulsating DC power. But
voltage drop across the diodes is (2*0.7V) 1.4V; therefore, the peak voltage at the output of this
rectifier circuit is 15V (17-1.4) approx.

22
3.2.7 Bridge rectifier

15V DC can be regulated into 5V DC using a step-down converter, but before this, it is
required to obtain pure DC power. The output of the diode bridge is a DC consisting of ripples also
called as pulsating DC. This pulsating DC can be filtered using an inductor filter or a capacitor filter
or a resistor-capacitor-coupled filter for removing the ripples. Consider a capacitor filter which is
frequently used in most cases for smoothing.
The capacitor is an energy storing element. In the circuit, capacitor stores energy while the
input increases from zero to a peak value and, while the supply voltage decreases from peak value
to zero, capacitor starts discharging. This charging and discharging of the capacitor will make the
pulsating DC into pure DC.

3.2.8 Output at the capacitor

3.2.4 VOLTAGE REGULATOR


15V DC voltage can be stepped down to 5V DC voltage using a DC step-down converter
called as voltage regulator IC7805. The first two digits ‘78’ of IC7805 voltage regulator represent

23
positive series voltage regulators and the last two digits ‘05’ represents the output voltage of the
voltage regulator.

3.2.9 Block diagram of voltage regulator

The block diagram of IC7805 voltage regulator is shown in the figure consists of an
operating amplifier acting as error amplifier, zener diode used for providing voltage reference, as
shown in the figure.

3.2.10 Zener Diode as Voltage Reference


Transistor as a series pass element used for dissipating extra energy as heat; SOA
protection (Safe Operating Area) and heat sink are used for thermal protection in case of excessive
supply voltages. In general, an IC7805 regulator can withstand voltage ranging from 7.2V to 35V
and gives maximum efficiency of 7.2V voltage and if the voltage exceeds 7.2V, then there is loss of
energy in the form of heat. To protect the regulator from over heat, thermal protection is provided
using a heat sink. Thus, a 5V DC is obtained from 230V AC power.

24
3.2.11 Voltage regulator 7805

3.2.5 LCD Interfacing:

3.2.12 LCD DISPLAY

LCD OPERATION

In recent years the LCD is finding widespread use replacing LEDs (seven-segment LEDs or
other multisegment LEDs). This is due to the following reasons:

1. The declining prices of LCDs.


2. The ability of display numbers, characters, and graphics. This is ain contrast to LEDs, which
are limited to numbers and a few characters.

25
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task
of refreshing the LCD. In contrast, the LED must be refreshed by the CPU (or in some other
way) to keep displaying the data.
4. Ease of programming for characters and graphics.

Interfacing an LCD to the Microcontroller

LCD pin descriptions:


The LCD discussed in this section has 14 pins. The function of each pin is given in table.

3.2.13 LCD Pin diagram


Table 3.2.5: LCD Pin description

26
Vcc, Vss, and VEE:

While Vcc and Vss provide +5V and ground, respectively, VEE is used for controlling LCD
contrast.

RS – register select:

There are two very important registers inside the LCD. The RS pin is used for their
selection as follows. If RS = 0, the instruction command code register is selected, allowing the user
to send a command such as clear display, cursor at home, etc. If RS = 1 the data register is selected,
allowing the user to send data to be displayed on the LCD.

R/W – read/write:

R/W input allows the user to write information to the LCD or read information from it.
R/W = 1 when reading; R/W =0 when writing.

E – Enable:

The enable pin is used by the LCD to latch information presented to its data pins. When
data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to
latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide.

D0 – D7:

The 8 bit data pins, D0 – D7, are used to send information to the LCD or read the
contents of the LCD’s internal registers.

To display letters and numbers, we send ASCII codes for the letters A – Z, a – z, and
numbers 0 – 9 to these pins while making RS = 1.

There are also instructions command codes that can be sent to the LCD to clear the display or force
the cursor to the home position or blink the cursor. Table below lists the instruction command
codes.

27
TABLE 3.2.6: LCD Command table

We also use RS = 0 to check the busy flag bit to see if the LCD is ready to receive
information. The busy flag is D7 and can be read when R/W =1 and RS = 0, as follows: if R/W =1,
RS =0. When D7 = 1(busy flag = 1), the LCD busy taking care of internal operations and will not
accept any new information. When D7 = 0, the LCD is ready to receive new information. Note: It is
recommended to check the busy flag before writing any data to the LCD.

3.2.6 Keypad interfacing:

The key board here we are interfacing is a matrix keyboard. This key board is designed
with a particular rows and columns. These rows and columns are connected to the microcontroller
through its ports . We normally use 8*8 matrix key boards. So only two ports of 8051 can be easily
connected to the rows and columns of the key board.

28
Whenever a key is pressed, a row and a column gets shorted through that pressed key and
all the other keys are left open. When a key is pressed only a bit in the port goes high. This
indicates microcontroller that the key is pressed. By this high on the bit key in the corresponding
column is identified.

Once we are sure that one of key in the key board is pressed next our aim is to identify
which key it is. To do this we firstly check for particular row and then we check the corresponding
column on the key board.

To check the row of the pressed key in the keyboard, one of the rows is made high by
making one of bit high in the output port of 8051. This is done until the row is found out. Once we
get the row next thing is to find out the column of the pressed key. The column is detected by
contents in the input ports with the help of a counter. The content of the input port is rotated with
carry until the carry bit is set.

Keyboard Microcontroller Display

The contents of the counter is then compared and displayed in the display. This display is
designed using a seven segment display and a BCD to seven segment decoder IC 7447.

The BCD equivalent number of counter is sent through output part of 8051 displays the
number of pressed key.

29
3.2.14 Circuit diagram of keyboard interfacing to 8051

3.2.7 Buzzer:
Buzzer is an electronic device commonly used to produce sound. Light weight, simple
construction and low price make it usable in various applications like car/truck reversing indicator,
computers, call bells etc. Piezo buzzer is based on the inverse principle of piezo electricity
discovered in 1880 by Jacques and Pierre Curie. It is the phenomena of generating electricity when
mechanical pressure is applied to certain materials and the vice versa is also true. Such materials are
called piezo electric materials. Piezo electric materials are either naturally available or manmade.
Piezo ceramic is class of manmade material, which poses piezo electric effect and is widely used to
make disc, the heart of piezo buzzer. When subjected to an alternating electric field they stretch or
compress, in accordance with the frequency of the signal thereby producing sound.
Diaphragm is connected to the rest of the electronic components which is the source of
producing sound. It consists of a metal plate made up of brass or stainless steel and a piezoceramic
disc (white colored disc) of smaller radius connected to each other with a conductive adhesive. The
metal plate is used because the resonance frequency of the piezo ceramic material is too high to
produce audible sound.

30
3.2.15 Piezo buzzer and its circuit

When a small DC voltage is applied to the input pins, it is first converted to an


oscillating signal using the combination of resistor and transistor. These oscillating signals are
amplified using the inductor coil. When high voltage alternating signals are applied to the piezo
ceramic disc, it causes mechanical expansion and contraction in radial direction. This causes the
metal plate to bend in opposite direction. When metal plate bends and shrinks in opposite direction
continuously it produces sound waves in the air.

3.3 SOFTWARE IMPLEMENTATION

3.3.1 Keil IDE

The Keil 8051 Development Tools are designed to solve the complex problems facing
embedded software developers.

Keil compiler is software used where the machine language code is written and
complied. After compilation, the machine source code is converted into hex code which is to be
dumped into the microcontroller for further processing. Keil compiler also supports C language
code. The microvision IDE and debugger integrates complete device simulation, interfaces to many
target debug adapters, and provides various monitor debug solutions. Simulation helps you
understand hardware configurations and avoids time wasted on setup problems.

31
Additionally, with simulation, you can write and test applications before target hardware is
available. Microvision is easy to use and accelerates your embedded software development.

The embedded C is the most popular programming language in the software field for
developing electronic gadgets. Each processor is associated with embedded software. Embedded
C Programming plays a major role in performing specific functions by the processor. The embedded
system designers must know about the hardware architecture to write programs. These programs
play prominent role in monitoring and controlling external devices. They also directly operate and
use the internal architecture of the microcontroller, such as interrupt handling, timers, serial
communication and other available features.

Steps to create a project

1. Click on the Keil uVision Icon on Desktop


2. The following fig will appear

3. Click on the Project menu from the title bar


4. Then Click on New Project

32
5. Save the Project by typing suitable project name with no extension in u r own folder sited in
either C:\ or D:\

6. Then Click on Save button above.


7. Select the component for u r project. i.e. Philips……
8. Click on the + Symbol beside of Philips

33
9. Select AT89S52 as shown below

10. Then Click on “OK”

11. The following fig will appear

34
12. Then Click either YES or NO………mostly “NO”

13. Now your project is ready to USE


14. Now double click on the Target1, you would get another option “Source group 1”

15. Click on the file option from menu bar and select “new”

35
16. The next screen will be as shown in next page, and just maximize it by double clicking on its
blue boarder.

17. Now start writing program in either in “C” or “ASM”

18. For a program written in Assembly, then save it with extension “. asm” and for “C” based
program save it with extension “ .C”

36
19. Now right click on Source group 1 and click on “Add files to Group Source”

20. Now you will get another window, on which by default “C” files will appear.

37
21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error will appear if so happen.

24. If the file contains no error, then press Control+F5 simultaneously.


25. The new window is as follows

38
26. Then Click “OK”
27. Now Click on the Peripherals from menu bar, and check your required port

28. Drag the port a side and click in the program file.

39
29. Now keep Pressing function key “F11” slowly and observe.
30. You are running your program successfully

40
CHAPTER 4
Result and discussion
The objective of the project has been achieved by proper implementation of hardware
and software that allows us to vote in a proper manner. From our observation it is clear that
whenever a voter press the push button his vote to that particular candidate will be recorded and
saved in the memory of the microcontroller. The number of votes received by each candidate can be
viewed by using the master switch.’

The above image shows the physical connections of the electronic voting machine. The
power supply is connected to the circuit through the step down transformer.

 Step1: when we switch on the power supply the LCD displays “electronic voting machine”.

41
 Step2: in this step the microcontroller seeks for the permission of the polling officer. The
message “waiting for polling officer” is displayed on the LCD to notify the polling officer.

 Step3: After verifying the details of the voter the polling officer gives permission to the
voter to vote by pressing the polling officer switch. Then the message “press sw to vote “ is
displayed on the LCD asking the voter to vote.
 Step 4: Voter is now permitted to vote to his favorite candidate.
For example, if the voter casted his vote to the candidate 1, then the message “C1 gets vote”
is displayed on the LCD.

 Similarly another voter can cast the vote to his favorite candidate after receiving the
permission from the polling officer following the same procedure.

42
 Any number of voters can cast their votes to their favorite candidates following the same
procedure.

 Once the voting has been finished, the EVM machines will be sent to the election
commission office to count the number of votes being casted to the particular candidates. To
know the number of votes polled by the voters ,the authorized person will press the master
switch. Then the message “Total no. of votes polled: xx” is displayed on the LCD.

 The LCD further displays the number of votes being polled to individual candidates who
participated in the election. This ends the election procedure, the information regarding the
votes is stored in the memory of the microcontroller. To erase the stored data we have to
press the reset button.

43
CHAPTER 5
Conclusion and future scope
Advantages:
The electronic voting machine is even more efficient in the case where more number of
people has to vote. Since no man power is required to count the votes we acquire the accurate
results. It does not require much human effort. It does not require any supervision while the activity
is going on.

Using electronic voting machine there are less chances of casting multiple votes. Since the
information of number of votes polled contained in the voting machine is encrypted there is no
chance of hacking it or changing the number of votes being polled.

Every voting machine is being perfectly sealed and is kept in a secured locker while
shifting them to the election commission office so there is no chance of manipulating the votes
casted.

Applications:

This method of voting eradicates the problems arised due to the usage of traditional
voting process such as malpractices like proxy of votes, duplicating the ballot papers, destroying the
ballot boxes and human errors such as inaccuracy in counting the number of votes. This also
provides security to the information regarding number of votes polled that is saved in the memory.

Future scope:

Even though the electronic voting machine has many advantages it has certain limitations.
There is a chance of occurrence of malpractices faking the identity of a person and casting multiple
votes. There is a chance of destroying the electronic voting machine which can cause physical
damage to the electronic voting machine.

44
The malpractice of faking the identity of a person can be overcome by implementing
the biometric sensor, since the finger print of every person is unique. This biometric sensor must be
linked to the unique identification of the citizen’s i.e., aadhar which completely eradicates the
problem of falsifying the votes.

The security levels can be further increased by implementing the iris sensor which
detects the iris of the humans and links it to the aadhar which is unique. By matching the fingerprint
and the iris of the voter which is linked to the aadhar, the identification of the voter cannot be faked.
Thus there is no chance of duplicating the votes.

There is chance of manipulating the data regarding number of votes being polled. So
to eradicate this problem we can implement the servers wherein the data of votes polled will be
directly updated to the database of the server. In this process there is no chance of manipulating the
data.

45
REFERENCES

[1] The 8051 Micro controller and Embedded Systems -Muhammad Ali Mazidi, Janice Gillispie
Mazidi
[2] The 8051 Micro controller Architecture, Programming & Applications -Kenneth J.Ayala
[3] Micro processor Architecture, Programming & Applications -Ramesh S.Gaonkar
References:
1. www.nxp.com
2. www.engineersgarage.com

46
APPENDIX-1

Programming:

Coming to programming, we are using embedded C language for writing the program. Keil
compiler is software used where the machine language code is written and complied. After
compilation, the machine source code is converted into hex code which is to be dumped into the
microcontroller for further processing. Keil compiler also supports C language code. The
microvision IDE and debugger integrates complete device simulation, interfaces to many target
debug adapters, and provides various monitor debug solutions.

Code:

#include<reg51.h>

#define lcdport P2

sbit rs=P2^0;

sbit en=P2^1;

sbit sw=P3^6;

sbit swl=P1^2;

sbit sw2=P1^3;

sbit sw3=P1^4;

sbit sw4=P1^5;

sbit buzzer=P3^2;

sbit result=P3^7;

void delay(int itime)

int i,j;

47
for(i=0;i<itime;i++)

for(j=0;j<1275;j++);

void lcddata()

rs=1;

en=1;

delay(1);

en=0;

void lcdcmd(void)

rs=0;

en=1;

delay(1);

en=0;

void lcdprint(char *str)

while(*str)

lcddata(*str);

48
void lcd_init(void)

lcdcmd(0x02);

lcdcmd(0x28);

lcdcmd(0x0c);

void conversion(unsigned int temp)

unsigned int a,b,c,d;

a=temp/100;

b=temp%100;

c=b/10;

d=b%10;

//e=d/10;

//f=d%10;

lcddata(a | 0x30);

lcddata(c | 0x30);

lcddata(d | 0x30);

//lcddata(f | 0x30);

delay(10);

void main()

unsigned int total,count1,count2,count3,count4;

49
total=count1=count2=count3=count4=0;

buzzer=1;

lcd_init();

lcdcmd(1);

lcdprint(" ELECTRONIC ");

lcdcmd(0xc0);

lcdprint(" VOTING MACHINE ");

delay(300);

lcdcmd(0x01);

delay(50);

loop:

lcdcmd(0x01);

lcdprint(" Waiting for ");

lcdcmd(0xc0);

lcdprint(" polling officer");

delay(50);

while(sw!=0);

lcdcmd(0x01);

lcdprint("Press sw to vote");

delay(50);

buzzer=0;

delay(300);

buzzer=1;

while(1)

50
{

if(swl==0)

buzzer=0;

delay(100);

buzzer=1;

count1=count1+1;

conversion(count1);

lcdcmd(0x01);

lcdprint(" C1 gets vote ");

delay(500);

goto loop;

if(sw2==0)

buzzer=0;

delay(100);

buzzer=1;

count2=count2+1;

conversion(count2);

lcdcmd(0x01);

lcdprint(" C2 gets vote ");

delay(500);

goto loop;

51
}
if(sw3==0)
{
buzzer=0;
delay(100);

buzzer=1;

count3=count3+1;

conversion(count3);

lcdcmd(0x01);

lcdprint(" C3 gets vote ");

delay(500);
}
if(sw4==0)
{
buzzer=0;
delay(100);

buzzer=1;

count4=count4+1;

conversion(count4);

lcdcmd(0x01);

lcdprint(" C4 gets vote ");

delay(500);
}

if(result==0)
{

52
buzzer=0;

delay(100);

buzzer=1;

total=count1+count2+count3+count4;

lcdcmd(0x01);

lcdprint(" Total no. of ");

lcdcmd(0xc0);

lcdprint("votes polled:");

conversion(total);

delay(1000);

lcdcmd(0x01);

lcdprint(" C1 C2 C3 C4 ");

lcdcmd(0xc0);

conversion(count1);

lcdcmd(0xc4);

conversion(count2);

lcdcmd(0xc8);

conversion(count3);

lcdcmd(0xcc);

conversion(count4);

delay(1000);

53
54

You might also like