DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
RRS COLLEGE OF ENGINEERING AND TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad)
Muthangi (V), Patancheru (M), Medak (Dist.)
RRS COLLEGE OF ENGINEERING AND TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad) Muthangi (V), Patancheru (M), Medak (Dist.)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
This is to certify that the mini-project work entitled “ELECTRONIC VOTING SYSTEM” is a bonafide work carried out by M.SUNIL KUMAR bearing Roll No: 08M51A0464 and N.DILIP KUMAR bearing Roll No: 08M51A0475 in partial fulfillment of the requirements for the degree of BACHELOR OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING by the Jawaharlal Nehru Technological University, Hyderabad during the academic year2010.
The results embodied in this report have not been submitted to any other University or Institution for the award of any degree or diploma.
HEAD OF THE DEPARTMENT
We sincerely thank the management of our college RRS COLLEGE OF ENGINEERING AND TECHNOLOGY for providing required facilities during our project work. We derive our great pleasure in expressing our sincere gratitude to our principal DR.M.PRABHAKAR for his timely suggestions, which helped us to complete the project work successfully. It is the very auspicious moment we would like to express our gratitude to Sri.S.PRABHAKARA RAO, Head of the Department, ECE for his consistent encouragement during the progress of this project. His valuable comments during this period have been valuable and worth for a lifetime. Our grateful thanks to Sri. SRINIVASA RAO, Project Trainer and others at MTS TECHNOLOGIES for giving this opportunity to do our dissertation in this organization and also their kind co-operation throughout our work. We also are thankful to both teaching and Non-Teaching staff of E.C.E department for their kind co-operation and all sorts of help bringing out this project successfully.
We hereby declare that the project entitled “ELECTRONIC VOTING SYSTEM WITH POLLING OFFICER CONTROL” is the work done by us in campus at RRS COLLEGE OF ENGINEERING AND TECHNOLOGY, Muthangi in collaboration with MTS TECHNOLOGIES during the academic year 2011 and is submitted as Mini Project in partial fulfillment of the requirements for the award of degree of BACHELOR OF TECHNOLOGY in ELECTRONICS AND COMMUNICATION ENGINEERING from JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD.
M.SUNIL KUMAR (08M51A0464)
N.DILIP KUMAR (08M51A0475)
India is world’s largest democracy. It is perceived to be charismatic one as it accommodates cultural, regional, economical, social disparities and still is able to stand on its own. Fundamental right to vote or simply voting in elections forms the basis of Indian democracy. In India all earlier elections be it state elections or centre elections a voter used to cast his/her vote to 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. EVM is capable of saving considerable printing stationery and transport of large volumes of electoral material. It is easy to transport, store, and maintain. It completely rules out the chance of invalid votes. Its use results in reduction of polling time, resulting in fewer problems in electoral preparations, law and order, candidates' expenditure, etc. and easy and accurate counting without any mischief at the counting centre. It is also eco friendly. This LCD based electronic voting machine is designed for three candidates. The input part consists of a set of four switches. The switches and 16x2 LCD are interfaced to microcontroller AT89C51 for various operations and displays This project is based on assembly language programming. The software language used in this project is Embedded ‘C’ and simulated using software Keil µVision3.
Chapter 1: Introduction
CHAPTER 1: INTRODUCTION
DEMOCRACY AND VOTING Democracy has come to be accepted as the most preferred form of political system all over the world. However, the success of a democratic structure is to be judged by the successes that can be solely attributed to this system. There are various challenges before democracy. These are foundational challenges, challenge of expansion and deepening of democracy. All of these are dependent on how the democracy is perceived by people who form the government, participate in formation of government and are benefited by it. As we all know that India is world’s largest democracy. It is perceived to be charismatic one as it accommodates cultural, regional, economical, social disparities and still is able to stand on its own. India follows a federal form of government. It means that governance power is not residing with one authority, but is distributed at various levels. In India power is distributed between states and central authority. What forms the basis of such vast and complex system of governance? One needs not to be an Einstein to guess the answer. It is fundamental right to vote or simply voting in elections. Indian constitution provide every adult above the age of 18 years irrespective of his/her religion, region, caste, creed, color, economic status, education and sex the essential right to vote and elect her/his candidate to represent her/him. Hence voting can be termed as backbone of not just democracy in India but all around the world. Voting can be done in various ways. In early Roman Empire voting used to be done by raising hands in favor or against. In board rooms voting is done in similar way, some write their vote down, some choose to speak, some choose to cast vote using latest technology. 1.2 VOTING TECHNIQUES
In India all earlier elections be it state elections or centre elections a voter used to cast his/her vote to 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 method wanted voters to be skilled voters to know how to put a stamp, and methodical folding of ballot paper. Millions of paper would be printed and heavy ballot boxes would be loaded and unloaded to and from ballot office to polling station. All this 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. The marking system of voting was introduced in 1962 to make it possible for a substantial number of illiterate voters to indicate easily their preferences in choosing their representatives. Over the years, there was a pronounced increase in the volume of work: crores of ballot papers had to be printed and lakhs of ballot boxes had to be prepared, transported, and kept in storage; and a great amount of time was taken up by the conduct of elections. To overcome these difficulties, the Election Commission of India (ECI) thought of electronic gadgets. The Electronics Corporation of India Ltd. (ECIL), Hyderabad, and Bharat Electronics Ltd. (BEL), Bangalore, developed the electronic voting machine in 1981.
1.3 Project Overview:
An embedded system is a combination of software and hardware to perform a dedicated task. Some of the main devices used in embedded products are Microprocessors and Microcontrollers. Microprocessors are commonly referred to as general purpose processors as they simply accept the inputs, process it and give the output. In contrast, a microcontroller not only accepts the data as inputs but also manipulates it, interfaces the data with various devices, controls the data and thus finally gives the result. The Project Electronic Voting System based is an exclusive project that can be used by the government instead of normal ballot paper system. By using this system the saving of considerable printing stationery and transport of large volumes of electoral material, easy transportation, storage, and maintenance, no invalid votes, reduction in polling time, resulting in fewer problems in electoral preparations, law and order, candidates' expenditure, etc. and easy and accurate counting without any mischief at the counting centre, Eco friendly.
The entire process is very easy to understand: ➢ Like in earlier system, your name is called and you are asked to sign or put your thumb impression in a register. ➢ After your identification is done by Election Officer, an ink mark is put on your finger, same as earlier. ➢ Then the Election Officer gives you a slip that bears the Voter register number where you signed or put your thumb impression. ➢ You hand over this slip to the presiding officer who confirms the serial number and permits you to vote by pressing the button of the Control Unit of EVM. ➢ You are not given any ballot thereafter, and are sent to the EV Machine placed behind a card board in a corner. The machine is placed in such a way that your polled vote will be a secret.
➢ On the EVM, you press the switch placed in front of your favorite candidate and
➢ As soon as the button is pressed, the LED indicator lights off and a buzzer sound
comes from the machine. This signifies that your vote has been casted rightly. Now you can come out. After the hour fixed for the close of the poll and the last voter has recorded his vote, the EVM is closed so that no further recording of votes in the machine is possible.
1.4 Thesis Overview:
The thesis explains the implementation of “ELECTRONIC VOTING SYSTEM”. The organization of the thesis is explained here with: Chapter 1 provides introduction to the overall thesis and the overview of the project. In this project a brief introduction of electronic voting system and how the electronic voting system evolved from its predecessor the normal ballot system. Chapter 2 presents the topic embedded systems. It explains what is embedded systems, need for embedded systems, and explanation of it along with its applications. Chapter 3 presents the hardware description. It deals with the block diagram of the project and explains the purpose of each block. In the same chapter the design aspect of independent modules are considered. Chapter 4 presents the software description. It explains softwares used in the project i.e. Keil Microvision (Embedded C) ,Proload and Cadence Orcad softwares.
Chapter 5 presents the project description .It deals with schematic diagram of the project and explains interfacing of each block with AT89C51 microcontroller. Chapter 6 Presents the results, conclusion and future scope of the project.
CHAPTER 2: EMBEDDED SYSTEMS
2.1 Description of embedded systems:
An embedded system is a computer system designed to perform one or a few dedicated functions often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a generalpurpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many devices in common use today. Embedded systems are controlled by one or more main processing cores that are typically either microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated to handle a particular task, which may require very powerful processors. For example, air traffic control systems may usefully be viewed as embedded, even though they involve mainframe computers and dedicated regional and national networks between airports and radar sites. (Each radar probably includes one or more embedded systems of its own.) Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not a strictly definable term, as most systems have some element of extensibility or programmability. For example, handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them, but they allow different applications to be loaded and peripherals to be connected. Moreover, even systems which don't expose programmability as
a primary feature generally need to support software updates. On a continuum from "general purpose" to "embedded", large application systems will have subcomponents at most points even if the system as a whole is "designed to perform one or a few dedicated functions", and is thus appropriate to call "embedded". Embedded systems programming is not like normal PC programming. In many ways, programming for an embedded system is like programming PC 15 years ago. The hardware for the system is usually chosen to make the device as cheap as possible. Spending an extra dollar a unit in order to make things easier to program can cost millions. Hiring a programmer for an extra month is cheap in comparison. This means the programmer must make do with slow processors and low memory, while at the same time battling a need for efficiency not seen in most PC applications. Below is a list of issues specific to the embedded field.
Embedded development makes up a small fraction of total programming. There's also a large number of embedded architectures, unlike the PC world where 1 instruction set rules, and the UNIX world where there's only 3 or 4 major ones. This means that the tools are more expensive. It also means that they're lower featured, and less developed. On a major embedded project, at some point you will almost always find a compiler bug of some sort. Debugging tools are another issue. Since you can't always run general programs on your embedded processor, you can't always run a debugger on it. This makes fixing your program difficult. Special hardware such as JTAG ports can overcome this issue in part. However, if you stop on a breakpoint when your system is controlling real world hardware (such as a motor), permanent equipment damage can occur. As a result, people doing embedded programming quickly become masters at using serial IO channels and error message style debugging.
To save costs, embedded systems frequently have the cheapest processors that can do the job. This means your programs need to be written as efficiently as possible. When dealing with large data sets, issues like memory cache misses that never matter in PC programming can hurt you. Luckily, this won't happen too often- use reasonably efficient algorithms to start, and optimize only when necessary. Of course, normal profilers won't work well, due to the same reason debuggers don't work well. So more intuition and an understanding of your software and hardware architecture is necessary to optimize effectively. Memory is also an issue. For the same cost savings reasons, embedded systems usually have the least memory they can get away with. That means their algorithms must be memory efficient (unlike in PC programs, you will frequently sacrifice processor time for memory, rather than the reverse). It also means you can't afford to leak memory. Embedded applications generally use deterministic memory techniques and avoid the default "new" and "malloc" functions, so that leaks can be found and eliminated more easily. Other resources programmers expect may not even exist. For example, most embedded processors do not have hardware FPUs (Floating-Point Processing Unit). These resources either need to be emulated in software, or avoided altogether.
2.1.3 Real time issues:
Embedded systems frequently control hardware, and must be able to respond to them in real time. Failure to do so could cause inaccuracy in measurements, or even damage hardware such as motors. This is made even more difficult by the lack of resources available. Almost all embedded systems need to be able to prioritize some tasks over others, and to be able to put off/skip low priority tasks such as UI in favor of high priority tasks like hardware control.
2.2 Need for embedded systems:
The uses of embedded systems are virtually limitless, because every day new products are introduced to the market that utilizes embedded computers in novel ways. In recent years, hardware such as microprocessors, microcontrollers, and FPGA chips have become much cheaper. So when implementing a new form of control, it's wiser to just buy the generic chip and write your own custom software for it. Producing a custom-made chip to
handle a particular task or set of tasks costs far more time and money. Many embedded computers even come with extensive libraries, so that "writing your own software" becomes a very trivial task indeed. From an implementation viewpoint, there is a major difference between a computer and an embedded system. Embedded systems are often required to provide Real-Time response. The main elements that make embedded systems unique are its reliability and ease in debugging.
Embedded debugging may be performed at different levels, depending on the facilities available. From simplest to most sophisticated they can be roughly grouped into the following areas: • • Interactive resident debugging, using the simple shell provided by the embedded operating system (e.g. Forth and Basic) External debugging using logging or serial port output to trace operation using either a monitor in flash or using a debug server like the Remedy Debugger which even works for heterogeneous multicore systems. • An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via a JTAG or Nexus interface. This allows the operation of the microprocessor to be controlled externally, but is typically restricted to specific debugging capabilities in the processor. • • • An in-circuit emulator replaces the microprocessor with a simulated equivalent, providing full control over all aspects of the microprocessor. A complete emulator provides a simulation of all aspects of the hardware, allowing all of it to be controlled and modified and allowing debugging on a normal PC. Unless restricted to external debugging, the programmer can typically load and run software through the tools, view the code running in the processor, and start or stop its operation. The view of the code may be as assembly code or source-code. Because an embedded system is often composed of a wide variety of elements, the debugging strategy may vary. For instance, debugging a software (and microprocessor) centric embedded system is different from debugging an embedded system where most of the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing number of embedded systems today use more than one single processor core. A common
problem with multi-core development is the proper synchronization of software execution. In such a case, the embedded system design may wish to check the data traffic on the busses between the processor cores, which requires very low-level debugging, at signal/bus level, with a logic analyzer, for instance.
Embedded systems often reside in machines that are expected to run continuously for years without errors and in some cases recover by themselves if an error occurs. Therefore the software is usually developed and tested more carefully than that for personal computers, and unreliable mechanical moving parts such as disk drives, switches or buttons are avoided. Specific reliability issues may include: • The system cannot safely be shut down for repair, or it is too inaccessible to repair. Examples include space systems, undersea cables, navigational beacons, bore-hole systems, and automobiles. • The system must be kept running for safety reasons. "Limp modes" are less tolerable. Often backups are selected by an operator. Examples include aircraft navigation, reactor control systems, safety-critical chemical factory controls, train signals, engines on single-engine aircraft. • The system will lose large amounts of money when shut down: Telephone switches, factory controls, bridge and elevator controls, funds transfer and market making, automated sales and service. • A variety of techniques are used, sometimes in combination, to recover from errors— both software bugs such as memory leaks, and also soft errors in the hardware: • • • • • Watchdog timer that resets the computer unless the software periodically notifies the watchdog Subsystems with redundant spares that can be switched over to software "limp modes" that provide partial function Designing with a Trusted Computing Base (TCB) architecture ensures a highly secure & reliable system environment An Embedded Hypervisor is able to provide secure encapsulation for any subsystem component, so that a compromised software component cannot interfere with other subsystems, or privileged-level system software. This encapsulation keeps faults from
propagating from one subsystem to another, improving reliability. This may also allow a subsystem to be automatically shut down and restarted on fault detection. • Immunity Aware Programming
2.3 Applications of embedded systems:
Embedded systems span all aspects of modern life and there are many examples of their use.
2.3.1 Telecommunication systems: It employs numerous embedded systems from telephone switches for the
network to mobile phones at the end-user. Computer networking uses dedicated routers and network bridges to route data.
2.3.2 Consumer electronics:
It includes personal digital assistants (PDAs), embedded systems which include microwave oven, remote control, VCD players, DVD players, digital camera, mp3 players, videogame consoles, GPS receivers and printer’s etc….
2.3.3 Household appliances:
Home appliances as microwave ovens, washing machines and dishwashers, are including embedded systems to provide flexibility, efficiency and features. Advanced HVAC systems use networked thermostats to more accurately and efficiently control temperature that can change by time of day and season.
2.3.4 Office/home automation system:
It uses wired- and wireless-networking that can be used to control lights, climate, security, audio/visual, surveillance, etc., all of which use embedded devices for sensing and controlling.
2.3.5 Transport systems:
From flight to automobiles increasingly use embedded systems. New airplanes contain advanced avionics such as inertial guidance systems and GPS receivers that also have considerable safety requirements. Various electric motors — brushless DC motors, induction motors and DC motors — are using electric/electronic motor controllers. Automobiles, electric vehicles, and hybrid vehicles are increasingly using embedded
systems to maximize efficiency and reduce pollution. Other automotive safety systems include anti-lock braking system (ABS), Electronic Stability Control (ESC/ESP), traction control (TCS) and automatic four-wheel drive.
CHAPTER 3: HARDWARE DESCRIPTION
In this chapter the block diagram of the project and design aspect of independent modules are described. The block diagram is as shown below in fig 3.1:
Regulated power supply
Party ‘X’ switch
Party ‘Y’ switch
Polling officer switch
Party ‘Z’ switch
Fig 3.1: Block diagram of real time clock based automatic street light controlling system with LDR based backup control system
The main blocks of this project are:
Microcontroller (AT89C51) Regulated power supply (RPS) Liquid crystal display (LCD)
The detailed explanation of each and every block mentioned above is as follows:
3.2 Microcontroller: 3.2.1 Introduction to microcontrollers:
Microcontrollers these days are silent workers in many apparatus, ranging from the washing machine to the video recorder. Nearly all of these controllers are mask programmed and therefore are of very little use for applications that require the programs to be changed during the course of execution. Even if the programs could be altered, the information necessary to do so an instruction set, an assembler language and description for the basic hardware is either very difficult to obtain or are in adequate when it came to the issue of accessibility.
3.2.2 Advantage of microcontrollers:
• If a system is developed with a microprocessor, the designer has to go for external memory such as RAM, ROM or EPROM and peripherals and hence the size of the PCB will be large enough to hold all the required peripherals. • But the microcontroller has got all these peripheral facilities on a single chip so development of a similar system with a microcontroller reduces PCB size and cost of the design. • One of the major difference between a microcontroller and a microprocessor is that a controller often deals with bits, not bytes as in the real world application, for example switch contacts can only be open or close, indicators should be lit or dark and motors can be either turned on or off and so forth.
The Microcontroller has two 8-bit timers/ counters built within it, which makes it more suitable to this application since we need to produce some accurate timer delays. It is even more advantageous that the timers also act as interrupt.
3.2.3 INTRODUCTION TO AT89C51:
The 8051 family of microcontrollers is based on architecture which is highly optimized for embedded control systems. It is used in a wide variety of applications from military equipment to automobiles to the keyboard on PC. The basic architecture consists of the following features: One 8051 processor cycle consists of twelve oscillator periods. Each of the twelve oscillator periods is used for a special function by the 8051 core such as op code fetches and samples of the interrupt daisy chain for pending interrupts. The time required for any 8051 instruction can be computed by dividing the clock frequency by 12, inverting that result and multiplying it by the number of processor cycles required by the instruction in question. Therefore, if you have a system which is using an 11.059MHz clock, you can compute the number of instructions per second .inverting this will provide the amount of time taken by each instruction cycle. Features of a microcontroller are given as follows: • • • • • • • An eight bit ALU. 32 discrete I/O pins (4 groups of 8) which can be individually accessed. Two 16 bit timer /counters. Full duplex UART. 6 interrupt sources with 2 priority levels. 28 bytes of on board RAM. Separate 64K byte address spaces for DATA and CODE memory.
3.2.4 MEMORY ORGANIZATION:
The 8051 architecture provides the user with three physically distinct memory spaces which can be seen in figure 3.1.Each memory space consists of contiguous addresses from 0 to maximum size, in bytes, of the memory space .Address overlaps are resolved by utilizing these instructions which refer specifically to a given address space. The three memory spaces function as described below.
3.2.5 THE CODE SPACE:
The first memory space is the CODE segment in which the executable program resides. This segment can be up to 64K (since it is addressed by 16 address lines). The processor treats this segment as read only and will generate signals appropriate to access a memory device such as an EPROM. However, this does not mean that the CODE segment must be implemented using an EPROM. Many embedded systems these days are using EEPROM which allows the memory to be overwritten either by the 8051 itself or by an external device. This makes upgrade to the product easy to do since new software can be downloaded into the EEPROM rather than having to disassemble it and install a new EPROM.
FIG-3.1 Memory organization
3.2.6 THE DATA SPACE:
The second memory space is the 128 bytes of internal RAM on the 8051, or the first 128 bytes of internal RAM on the 8052. This segment is typically referred to as the DATA segment. The RAM locations in this segment are accessed in one or two cycles depending on the instruction. This access time is much quicker than access to the XDATA segment because memory is directly rather than via a memory pointer such as DPTR which must first be initialized. Therefore, frequently used variables and temporary scratch variables are usually assigned to the DATA segment. Variables stored in the DATA segment can also be accessed indirectly via R0 or R1.The register being used as the memory pointer must contain the address of the byte to be retrieved or altered. These instructions can take one or two processor cycles depending on the source/destination data byte.
3.2.7 PROCESSOR STATUS:
Processor status is kept in a bit addressable SFR called PSW(Processor Status Word).This register contains the carry bit, an auxiliary bit which is used with BCD operations, the Accumulator parity flag and overflow flag, two general purpose flags, and two bits which select the register bank to use as the default. As mentioned before, the register bank selection bits make a two bit number from 0 to 3 which indicate the bank to be used. Bank 0 begins at the base of the DATA segment (address 00H), bank 1 begins at 08H, bank 2 begins at address 10H and bank 3 at address 18H.Any of these memory locations are always available for direct and indirect memory accesses via their addresses regardless of the register bank selection.
3.2.8 POWER CONTROL:
The CHMOS versions of the 8051 feature two power saving modes that can be activated by software: idle mode and power down mode. These modes are accessed via the PCON (Power Control). The idle mode is activated by setting the IDLE bit high. The idle mode causes all program execution to stop. Internal RAM contents are preserved and the oscillator continues to run but is blocked from the CPU. The timers and the UART continue to function as normal. Idle mode is terminated by the activation of any interrupt. Upon completion of the interrupt service routine, execution will continue from the instruction following the instruction which set the IDLE bit.
3.2.9 INTERRUPTS OF 8051:
The basic 8051 supports six interrupt sources: two external interrupts, two timer/counter interrupts, and a serial byte in/out interrupt. These interrupt sources force the processor to vector to one of five locations in the lowest part of the CODE address space (serial input and serial output interrupts share the same vector ). The interrupt service routine must either reside there or be branched from there.
3.2.10 ON-BOARD TIMER/COUNTERS:
The standard 8051 has two timer/counters (other 8051 family members have varying amounts), each of which case they count processor cycles or can be used to count falling edges on the signal applied to their respective I/O pin (either T0 or T1). When used as a counter, the input signal must have a frequency equal to or lower than the instruction cycle frequency divided by 2 i.e: the oscillator frequency /24, since the incoming signal is sampled every instruction cycle, and the counter is incremented only when a 1 to 0 transition is detected which will require two samples . If desired, the timer/counters can force a software interrupt when they overflow. The TCON (Timer Control ) SFR is used to start or stop the timers as well as hold the overflow flags of the timers. The timer/counters are started or stopped by changing the timer run bits (TR0 and TR1) in the TCON.
• • • • • • • • • • • • • • • •
Endurance:1000 write/erase cycles 4.0 V to 5.5V operating range Fully static operation:0 to 33 MHz Three-level program memory lock 128x x 8 bit Internal RAM 32 programmable I/O lines Two 16-bit timer/counters Six interrupt sources Full duplex UART serial channel Low-power idle and power-down modes Interrupt Recovery from Power-down mode Watchdog Timer Dual Data Pointer Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and Page Mode)
The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System Programmable Flash memory. The device is manufactured using Atmel highdensity 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 insystem or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications.
The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two timer/counters, a fivearchitecture, a full oscillator, and clock AT89C51 is designed operation down to zero software selectable Idle Mode stops the RAM, timer/counters, system to continue down mode saves the the oscillator, disabling until the next external data pointers, two 16-bit vector two-level interrupt duplex serial port, on-chip circuitry. In addition, the with static logic for frequency and supports two power saving modes. The CPU while allowing the serial port, and interrupt functioning. The PowerRAM contents but freezes all other chip functions interrupt or hardware reset
FIG- 3.2 Pin Description of 89C51
3.2.13 PIN DESCRIPTION:
Supply voltage (all packages except 42-PDIP). GND: Ground (all packages except 42-PDIP; for 42-PDIP GND connects only the logic core and the embedded program memory). VDD: Supply voltage for the 42-PDIP which connects only the logic core and the embedded program memory.
PWR/GND: Ground for the 42-PDIP which connects only the I/O Pad Drivers. PWR/GND and GND are weakly connected through the common silicon substrate, but not through any metal link. The application board must connect both GND and PWRGND to the board ground. PORT 0: Port 0 is an 8-bit open drain bi-directional 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. External pull-ups are required during program verification. PORT 1: Port 1 is an 8-bit bi-directional 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. Port 1 also receives the low-order address bytes during Flash programming and verification. PORT2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. 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 use 16-bit 25
addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. PORT 3: Port 3 is an 8-bit bi-directional 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 AT89S51, as shown in the following table. Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 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 DIS-RTO 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. 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 26 Alternate Functions RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe)
skipped dur-ing 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 AT89S51 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 exter-nal 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 amplifier.
Table 3.1 Port 3 Alternate Function
Fig 3.5: Block diagram Of Microcontroller
Machine cycle for the 8051:
The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family, these clock cycles are referred to as machine cycles. The length of the machine cycle depends on the frequency of the crystal oscillator. The crystal oscillator, along with on-chip circuitry, provides the clock source for the 8051 CPU. The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is used to make the 8051 based system compatible with the serial port of the IBM PC. In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal frequency and its inverse is taken. The assembly language program is written and this program has to be dumped into the microcontroller for the hardware kit to function according to the software. The program dumped in the microcontroller is stored in the Flash memory in the microcontroller. Before that, this Flash memory has to be programmed and is discussed in the next section.
3.2.10 Programming the Flash:
The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The lowvoltage programming mode provides a convenient way to program the AT89C51 inside the user’s system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers. The AT89C51 is shipped with either the highvoltage or low-voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table.
Table 3.2: Programming the Flash
The AT89C51 code memory array is programmed byte-byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode. Programming Algorithm: Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table. To program the AT89C51, the following steps should be considered: 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The bytewrite cycle is self-timed and typically takes no more than 1.5 ms. 6. Repeat steps 1 through 5, changing the address and data for the entire array or until the Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy: end of the object file is reached.
The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY. Chip Erase: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip erase operation must be executed before the code memory can be reprogrammed. Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates 89C51 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming Programming Interface: Every code byte in the Flash array can be written and the entire array
can be erased by using the appropriate combination of control signals. The write operation
cycle is self timed and once initiated, will automatically time itself to completion. All major programming vendors offer worldwide support for the Atmel microcontroller series.
Fig 3.3 Flash Programming Modes
3.3 Block Diagram of Regulated power supply:
The circuit block diagram and block diagram of regulated power supply is shown below in fig 3.3 and fig 3.4 respectively:
Fig 3.3: Basic circuit diagram of Regulated Power Suppl
230V AC 50Hz
Step down Transformer
Fig 3.4: Block diagram of Regulated power supply The basic circuit diagram and block diagram of a regulated power supply (DC O/P) with LED connected as load is shown above. The components mainly used in above figure are: • • • • • • • 230V AC MAINS TRANSFORMER BRIDGE RECTIFIER(DB107) CAPACITOR VOLTAGE REGULATOR(IC 7805) RESISTOR LED(LIGHT EMITTING DIODE)
The detailed explanation of each and every component mentioned above is as follows:
3.3.1 230V AC Mains:
Mains is general purpose alternating current (AC) electric power supply. Electric power is referred to by several names including household power, household electricity, power line, domestic power, wall power, line power, AC power, city power, street power, and grid power, etc.. In India the main power supply used for household purpose is of 230V the frequency is 50Hz.The tolerance range in India is between 216V to 253V. To maintain the voltage at the customer's service within the acceptable range, electrical distribution utilities use regulating equipment at electrical substations or along
the distribution line. At a substation, the step- down transformer will have an automatic on-load tap changer, allowing the ratio between transmission voltage and distribution voltage to be adjusted in steps. For long (several kilometers) rural distribution circuits, automatic voltage regulators may be mounted on poles of the distribution line.
Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level. Here step down transformer is used to decrease 230V to 12V.
3.3.3 Bridge Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. In this project we use W06M IC as bridge rectifier. Fig 3.7 shows the bridge rectifier W06M, which is a 4-pin IC
Fig 3.5: W06M bridge rectifier IC
Features of W06M IC: ➢ Surges overload ratings to 40 amperes peak.
High temperature soldering guaranteed: 260°C/10 seconds/0.375inch (9.5mm) lead lengths at 5lbs., (2.3kg) tension.
The process of converting a pulsating direct current to a pure direct current using filters is called as filtration. Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage. The construction and picture of electrolytic capacitor is shown in fig 3.6 and fig 3.7 respectively:
Fig 3.6:Construction of a Capacitor
Fig 3.7:Picture Electrolytic Capaticor The Capacitor or sometimes referred to as a Condenser is a passive device, and one which stores energy in the form of an electrostatic field which produces a potential (Static Voltage) across its plates. In its basic form a capacitor consists of two parallel conductive plates that are not connected but are electrically separated either by air or by an insulating material called the Dielectric. When a voltage is applied to these plates, a current flows charging up the plates with electrons giving one plate a positive charge and the other plate an equal and opposite negative charge. This flow of electrons to the plates is known as the Charging Current and continues to flow until the voltage across the plates (and hence the capacitor) is equal to the applied voltage Vcc. At this point the capacitor is said to be fully charged and this is illustrated below. In this project electrolytic capacitors are used.
3.3.5 Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V is required. In order to obtain this voltage levels LM 7805 voltage regulator is to be used. The first number 78 represents positive supply and the numbers 05 represent the required output voltage levels. The symbol of LM 7805 Voltage Regulator is as shown in fig 3.8.It consists of three terminals input, ground and output.
Fig 3.8: Symbol of Voltage Regulator
Resistors can be made to control the flow of current, to workas Voltage dividers, to dissipate power and it can shape electrical waves when used in combination of other components. Basic unit is ohms. Ohm's law: The behavior of an ideal resistor is dictated by the relationship specified in Ohm's law: V = IR Where, V= voltage drop across resistor R= resistance of resistor I= current flowing through resistor. Ohm's law states that the voltage (V) across a resistor is proportional to the current (I) through it where the constant of proportionality is the resistance (R). Power Dissipation: The power dissipated by a resistor (or the equivalent resistance of a resistor network) is calculated using the following:
The picture of resistor and colour bands in resistor is shown in fig 3.9 and fig 3.10 respectively. Resistor component consists of four bands. Band 1 represents 1’st digit, band 2 represents 2’nd digit, band 3 represents number of zeros i.e. multiplier and band 4 represents tolerance.
Fig 3.9: Picture of Resistor
Fig 3.10: Color Bands in Resistor The detailed values of all four bands for each colour are shown in table no.3.1:
Color 1st band 2nd band 3rd band (multiplier) 4th band (tolerance) Temp. Coefficient
Black Brown Red Orange Yellow Green Blue Violet Gray White Gold Silver None
3.5 Light Emitting Diode (LED):
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices, and are increasingly used for lighting. Introduced as a practical electronic component in 1962, early LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet and infrared wavelengths, with very high brightness.
Fig 3.11: Structure inside a LED
Fig 3.12: Parts of a LED
The fig 3.11 and fig 3.12 shows structure inside an LED and parts of LED respectively. The structure of the LED light is completely different than that of the light bulb. Amazingly, the LED has a simple and strong structure. The light-emitting semiconductor material is what determines the LED's color. The LED is based on the semiconductor diode. When a diode is forward biased (switched on), electrons are able to recombine with holes within the device, releasing energy in the form of photons. This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. An LED is usually small in area (less than 1 mm2), and integrated optical components are used to shape its radiation pattern and assist in reflection. LEDs present many advantages over incandescent light sources including lower energy consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater durability and reliability. However, they are relatively expensive and require more precise current and heat management than traditional light sources. Current LED products for general lighting are more expensive to buy than fluorescent lamp sources of comparable output. They also enjoy use in applications as diverse as replacements for traditional light sources in automotive lighting (particularly indicators) and in traffic signals. The compact size of LEDs has allowed new text and video displays and sensors to be developed, while their high switching rates are useful in advanced communications technology.LED has two terminals anode and cathode .Longer terminal is anode and shorter terminal is cathode as shown in fig 3.13.
Fig 3.13: Electrical Symbol & Polarities of LED
Advantages of LEDs:
LED lights have a variety of advantages over other light sources: • • • • • • • • High-levels of brightness and intensity High-efficiency Low-voltage and current requirements Low radiated heat High reliability (resistant to shock and vibration) No UV Rays Long source life Can be easily controlled and programmed
Application of LEDs:
Application’s of LEDs fall into three major categories: • • • Visual signal application where the light goes more or less directly from the LED to the human eye, to convey a message or meaning. Illumination where LED light is reflected from object to give visual response of these objects. Generate light for measuring and interacting with processes that do not involve the human visual system.
3.6 Liquid crystal display:
3.6.1 Description: LCD is a type of display used in digital watches and many portable computers. LCD displays utilize to sheets of polarizing material with a liquid crystal solution between them. An electric current passed through the liquid causes the crystals to align so that light cannot pass through them. LCD technology has advanced very rapidly since its initial inception over a decade ago for use in lap top computers. Technical achievements has resulted in brighter displace, higher resolutions, reduce response times and cheaper manufacturing process. The liquid crystals can be manipulated through an applied electric voltage so that light is allowed to pass or is blocked. By carefully controlling where and what wavelength (color) of light is allowed to pass, the LCD monitor is able to display images. A backlight provides LCD monitor’s brightness. Over the years many improvements have been made to LCD to help enhance resolution, image, sharpness and response times.One of the latest such advancement is applied to glass during acts as switch allowing control of light at the pixel level, greatly improving LCD’s ability to display small-sized fonts and image clearly. Other advances have allowed LCD’s to greatly reduce liquid crystal cell response times. Response time is basically the amount of time it takes for a pixel to “change colors”, in reality response time is the amount of time it takes a liquid crystal cell to go from being active to inactive. Serial LCD display is a very functional and low-cost LCD that can be easily controlled by a PIC microcontroller. The LCD display consists of two lines by 16 characters and provides basic text wrapping so that the text looks right on the display. The LCD display is compatible with the microcontroller’s supplies and signal levels. In addition, this Intelligent Serial LCD also provides with full control over all of its advanced LCD features, allowing you to move the cursor anywhere on the display with a single instruction and turn the display on and off in any configuration. The LCD display requires only a 5 V power supply and the connection related to transferring data to the LCD via the 8-bit data bus. Many useful text formatting functions are built into the operation of the LCD. With this display and the PIC microcontroller, users can design a professional-looking text user interface on any
microcontroller application, supply an easy-to-use debugging interface that does not require a PC, and provide real-time sensor data output on autonomous robotic applications. These LCD Modules are very common these days, and are quite simple to work with, as all the logic required to run them is on board. The general picture of LCD is as shown in 3.17, which is of 2*16 serial LCD i.e. 2 rows and 16 columns. In one row 16 characters can be displayed, as 2 rows are present, hence total 32 characters can be displayed in entire LCD screen.
Fig 3.17: Picture of LCD 3.6.2 Schematic diagram: Fig 3.18 shows the schematic diagram of 2*16 serial LCD i.e. 2 line (rows), 16 character (columns).It consists of 8 data lines D0-D7, remaining 6 pins are read/write, ground (GND) ,power supply (Vcc),enable (E),register select (RS) and intensity (VO) as shown below:
Fig 3.18: Schematic diagram of LCD
3.6.3 Circuit description: Above is the quite simple schematic. The LCD panel's Enable and Register Select is connected to the Control Port. The Control Port is an open collector / open drain output. While most Parallel Ports have internal pull-up resistors, there are a few which don't. Therefore by incorporating the two 10K external pull up resistors, the circuit is more portable for a wider range of computers, some of which may have no internal pull up resistors. We make no effort to place the Data bus into reverse direction. Therefore we hard wire the R/W line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a result we cannot read back the LCD's internal Busy Flag which tells us if the LCD has accepted and finished processing the last instruction. This problem is overcome by inserting known delays into our program. The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy here. As with all the examples, I've left the power supply out. You can use a bench
power supply set to 5v or use a onboard +5 regulator. Remember a few de-coupling capacitors, especially if you have trouble with the circuit working properly. The 2 line x 16 character LCD modules are available from a wide range of manufacturers and should all be compatible with the HD44780. The one I used to test this circuit was a Powertip PC-1602F and an old Philips LTN211F-10 which was extracted from a Poker Machine! The diagram to the right, shows the pin numbers for these devices. When viewed from the front, the left pin is pin 14 and the right pin is pin 1. Fig 3.19 shows the display pattern of LCD.
Fig 3.19: Display pattern of LCD
3.6.4 Pin description of LCD: The pin diagram of 2*16 LCD is as shown in fig 3.20:
Fig 3.20: Pin diagram of LCD
The description of each pin of LCD display is as follows: Vcc, Vss and Vee: While Vcc and Vss provide +5V and ground respectively, Vee is used for controlling LCD contrast. Register Select (RS): 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. Read/Write (R/W): R/W input allows the user to write information to the LCD or read information from it. R/W = 1 for reading. R/W= 0 for writing. Enable (EN): The LCD to latch information presented to its data pins uses the enable pin. 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, DO – 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 numbers 0-9 to these pins while making RS=1. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to home position or blink the instruction command codes.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 is busy taking care of internal operations and will not accept any information.
Module size: 80.0mm(L) x 36.0mm(W) x 18.0mm(T) Display size: 56.2mm(L) x 11.5mm(W) Character size: 2.95 x 5.55mm Allows any device to display to the LCD with only 1 pin using the standard 8-bit bus User can extend display up to 20 feet Automatic character wrap at the end of each line Calendar and time tracking and automatic display on screen Correct handling of carriage return <CR> character Correct handling of backspace character Hard reset function that powers down and brings up the LCD display Commands to clear any display line without clearing the whole screen No contrast adjustment required Able to display byte value as decimal numbers on the screen Able to display byte value as numbers with zero in front if number is less than 10 Able to display byte value as a Hexadecimal number on the screen.
Fig 3.21 Buzzer A Buzzer or Beeper is a signaling device, usually electronic, typically used in automobiles, household appliances such as microwave ovens, or game shows.
It most commonly consists of a number of switches or sensors connected to a control unit that determines if and which button was pushed or a preset time has lapsed, and usually illuminates a light on the appropriate button or control panel, and sounds a warning in the form of a continuous or intermittent buzzing or beeping sound. Initially this device was based on an electromechanical system which was identical to an electric bell without the metal gong (which makes the ringing noise). Often these units were anchored to a wall or ceiling and used the ceiling or wall as a sounding board. Another implementation with some AC-connected devices was to implement a circuit to make the AC current into a noise loud enough to drive a loudspeaker and hook this circuit up to an 8-ohm speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder which makes a high-pitched tone. Usually these were hooked up to "driver" circuits which varied the pitch of the sound or pulsed the sound on and off. In game shows it is also known as a "lockout system" because when one person signals ("buzzes in"), all others are locked out from signalling. Several game shows have large buzzer buttons which are identified as "plungers". The buzzer is also used to signal wrong answers and when time expires on many game shows, such as Wheel of Fortune, Family Feud and The Price is Right. The word "buzzer" comes from the rasping noise that buzzers made when they were electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 cycles. Other sounds commonly used to indicate that a button has been pressed are a ring or a beep.
Fig 3.22 Switch
A Push Switch or Push to make switch, allows electricity to flow between its two contacts when held in. When the button is released, the circuit is broken. So it is called a non- latching switch. Other forms are push to break which does the opposite. i.e., when the button is not pressed, electricity can flow, but when it is pressed the circuit is broken.
CHAPTER 4: SOFTWARE DESCRIPTION
This project is implemented using following softwares: • • KEIL COMPILER PROLOAD
4.1 KEIL COMPILER
Keil compiler is a software used where the machine language code is written and compiled. 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. It’s important that you know C language for microcontroller which is commonly known as Embedded C. As we are going to use Keil C51 Compiler, hence we also call it Keil C. Keil C is not much different from a normal C program. If you know assembly, writing a C program is not a crisis. In Keil, we will have a main function, in which all your application specific work will be defined. In case of embedded C, you do not have any operating system running in there. So you have to make sure that your program or main file should never exit. This can be done with the help of simple while (1) or for (;;) loop as they are going to run infinitely. We have to add header file for controller you are using, otherwise you will not be able to access registers related to peripherals. #include <REG51.h> //header file for 89C51 To create a project, write and test the previous example source code, follow the following steps:
1. Open Keil and start a new project
Figure 4.1: Picture of KEIL microvision
2. You will be prompted to choose a name for your new project, Create a separate folder where all the files of your project will be stored, choose a name and click save. The following window will appear where you will be asked to select a device for Target 'Target 1'
Figure 4.2: Snapshot of selecting the AT89C51
3. From the list at the left, seek for the brand name ATMEL, then under ATMEL, select AT89S51. You will notice that a brief description of the device appears on the right. Leave the two upper check boxes unchecked and click OK. The AT89S52 will be called your 'Target device', which is the final destination of your source code. You will be asked whether to 'copy standard 8051 startup code' click No. 4. Click File, New, and something similar to the following window should appear. The box named 'Text1' is where your code should be written later.
Figure 4.3 Snapshot of New Project
5. Now you have to click 'File, Save as' and choose a file name for your source code ending with the letter '.c'. You can name as 'code.c' for example and click save. Then you have to add
this file to your project work space at the left as shown in the following
Figure 4.4 Snapshot of adding files to group
6.After right-clicking on 'source group 1', click on 'Add files to group...', then you will be prompted to browse the file to add to 'source group 1', choose the file that you just saved, eventually 'code.c' and add it to the source group. You will notice that the file is added to the project tree at the left. 7. In some versions of this software you have to turn ON manually the option to generate HEX files. make sure it is turned ON, by right-clicking on target 1, Options for target 'target 1', then under the 'output' tab, by checking the box 'generate HEX file'. This step is very important as the HEX file is the compiled output of your project that is going to be transferred to the microcontroller. 8. You can then start to write the source code in the window titled 'code.c' then before testing your source code; you have to compile your source code, and correct eventual syntax errors.
In KEIL IDE, this step is called 'rebuild all targets' and has this icon:
Figure 4.5 Snapshot showing debug icon
9. If after rebuilding the targets, the 'output window' shows that there is 0 errors, then you are ready to test the performance of your code. In keil, like in most development environment, this step is called Debugging, and has this icon: appear, like the run icon circled in the following figure: . After clicking on the debug
icon, you will notice that some part of the user interface will change; some new icons will
Figure 4.6 Snapshot showing Simulation icon
3.2 PROLOAD Proload is a software which accepts only hex files. Once the machine code is converted into hex code, that hex code has to be dumped into the microcontroller and this is done by the Proload. Proload is a programmer which itself contains a microcontroller in it other than the one which is to be programmed. This microcontroller has a program in it written in such a
way that it accepts the hex file from the keil compiler and dumps this hex file into the microcontroller which is to be programmed. As the proload programmer kit requires power supply to be operated, this power supply is given from the power supply circuit designed above. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply, a source is required. Thus this is accomplished from the power supply board with an output of 12volts.
5. PROJECT DESCRIPTION
In this chapter, schematic diagram and interfacing of AT89C51 microcontroller with each module is considered. Fig 5.1 shows schematic diagram of Intelligent Electronic Voting Machine.
2 B U Z Z E R
Liquid Crystal D isplay (LCD )
U 3 3 3 3 3 3 3 3 9 8P 7P 6P 5P 4P 3P 2P P 1 2 3 4 5 6 7 8 1 1 P P P P P P P P 9 8X X 1 9 4 0 E R V 1 2 A C A S T C T 8 9 C 5 1 2 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 . . . . . . . . . . . . . . . . 0 P/ 1 P/ 2P / 3P / 4P / 5P / 6P / 7P / 0P 1P 2P 3P 4 P 5 P 6P 7 P P A2 A2 2A 2A 2A 2A 2A 2A 2 D. 20 D. 21 . D 22 . D 32 . D 42 . D 52 . D 62 . D7 1 02/ A 13/ A /24 A /35 A /46 A /57 A /68 A /7 A 8 9
1 0 3 . 0 1 / 1R X D 3 . 11 /2 T X D 3 . 2 1 / 3I N T 0 3 . 3 1 / 4I N T 1 3 . 14 5/ T 0 3 . 15 6/ T 1 3 . 61 /7 W R 3 . 7 / R D A S 3 0 L 2 E9 E N P o t e n t i o m e t e r
P a r ty Z
1 k o h m L R E S I S
r t y E D T O
P o l l i n g O ffi c e r S w i tc h
R e s u l t S w i tc h
Figure 5.2 Schematic diagram of Electronic Voting Machine
The detailed explanation of each module interfacing with microcontroller is as follows:
5.1 SWITCH interfacing with AT89C51:
In the project we use three switches for representing three different parties; we also have a polling officer switch and a result switch. When the candidates wants to cast the vote he has to get himself authenticated by the polling officer, after the authentication the polling officer gives permission to the candidate to cast his vote by pressing the polling officer switch, then the person can cast his vote by pressing the switch which is beside the respective party symbol, without the permission of the polling officer even the vote is cast it does get registered, thus we can eradicate any malpractice.
U 3 3 3 3 3 3 3 3 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 P P P P P P P P P P P P P P P P 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 . . . . . . . . . . . . . . . . 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 / / / / / / / / A P A P AP AP AP AP AP AP 2 1 D 2 0. 0 /2 A 2 8 D 2 1. 1 /2 A 3 9 D2 . 2 2 / A2 41 0 D2 . 3 3 / A2 51 1 D2 . 4 4 / A2 61 2 D2 . 5 5 / A2 71 3 D2 . 6 6 / A2 81 4 D2 . 7 7 / A 1 5
r t y
r t y
1 0 P 3 . 0 / R 1 1X D P 3 . 1 / T1 X2 D P 3 . 2 / I 1N 3 T 0 P 3 . 3 / I 1N 4 T 1 P 3 . 4 /1 T 5 0 P 3 . 5 /1 T 6 1 P 3 . 6 / W 7 R 1 P 3 . 7 / R D 3 0 L A1 L E / P R 9O 2 L 2 P S E N P P G
1 9 1 8 X T A X T A P a r t y Z 3 1 E 9 R A
A / V S T T 8 9 C
Figure5.3 SWITCH interfacing with AT89C51
Initially when the candidate enters the booth the leds in the EVM will be glowing when he presses the switch the gets turned off then gets in when he releases the switch thus indicating that the vote has been registered, the background phenomenon is that the switch when not switched on receives certain amount of current from Vcc when it is pressed it gets reset to zero and when released gets back to normal state. We also have a result switch which is used to display the result after the voting procedure is over,by using this switch the result is obtained correctly and in a very short span of time, thus reducing the human efforts and improving the accuracy.
5.3 LCD interfacing with AT89C51:
AT89C51 microcontroller is used here to display message on the LCD module. the LCD module used in this project is a 2*16 LCD. It can display 16 characters in each of 2 rows and 32 characters at a time. The LCD interfacing with microcontroller is done using a 8-bit data bus. As for the order of data transfer, the four high order bits (for 8-bit operation, DB4 to DB7) are transferred before the four low order bits (for 8-bit operation, DB0 to DB3). Any character on LCD is displayed by sending its respective ASCII code. Hence to display 1 on LCD microcontroller has to send 31h as data. Fig 5.4 shows LCD interfacing with PIC16F72 microcontroller. When RS pin =0 instruction register is selected and information on data bus is taken as commands. The IR stores instruction codes, such as display clear and cursor shift, and address information for display data RAM (DDRAM) and character generator RAM (CGRAM).. When RS pin=1 data register is selected and information on data bus is taken as ASCII value of respective character to be displayed on LCD. The DR temporarily stores
data to be written into DDRAM or CGRAM and temporarily stores data to be read from
DDRAM or CGRAM. When address information is written into the IR, data is written and then stored into the DR from DDRAM or CGRAM by an internal operation.
Liq u id C ryst a l D isp la y (LC D
U 3 3 3 3 3 3 3 3 1 2 3 4 5 6 7 8 1 1 3 4 9 8P 7P 6P 5P 4P 3P 2P P P P P P P P P P 9 8X X 9 E R 0 V 1 1 2 A S C A T C T 8 9 C 5 1 2 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 . . . . . . . . . . . . . . . . 0P 1P P2 P3 P4 P5 P6 P7 P0 P1 P2 P3 4P 5P P6 7P P / 2A / 2A /2 A /2 A /2 A /2 A /2 A /2 A 2 . 2D0 . 2D1 22D 23D 24D 25D 26D 7D 1 2 /0 A 3 /1 A 4 / 2A 5 / 3A 6 / 4A 7 / 5A 8 / 6A / 7A 0 1/ R 2/ T /3 I N /4 I N 5 / T 6 / T 7/ W / R X 0 1 D P o t e n t i o m e t e r T T R 8 9
Figure5.4 LCD interfacing with AT89C51 RW pin is used to either read from LCD (RW=1) or write to LCD (RW=0). When a High to Low pulse is applied on the Enable pin the information present on the data bus is latched into the LCD register.
5.4 LED interfacing with AT89C51:
LED stands for Light Emitting Diode. Microcontroller port pins cannot drive these LEDs as these require high currents to switch on. Thus the positive terminal of LED is directly connected to Vcc, power supply and the negative terminal is connected to port pin through a current limiting resistor. This current limiting resistor is connected to protect the port pins from sudden flow of high currents from the power supply. Fig 5.5 shows the LED interfacing the microcontroller. LED and switches can be connected to any one of the four port pins.
U P a L E r t y D X 3 3 3 3 3 3 3 3 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 P P P P P P P P P P P P P P P P
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 . . . . . . . . . . . . . . . . 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 / / / / / / / / A P A P AP AP AP AP AP AP 2 1 D 2 0. 0 /2 A 2 8 D 2 1. 1 /2 A 3 9 D2 . 2 2 / A2 41 0 D2 . 3 3 / A2 51 1 D2 . 4 4 / A2 61 2 D2 . 5 5 / A2 71 3 D2 . 6 6 / A2 81 4 D2 . 7 7 / A 1 5
P a L E
r t y D
1 0 P 3 . 0 / R 1 1X D P 3 . 1 / T1 X2 D P 3 . 2 / I 1N 3 T 0 P 3 . 3 / I 1N 4 T 1 P 3 . 4 /1 T 5 0 P 3 . 5 /1 T 6 1 P 3 . 6 / W 7 R 1 P 3 . 7 / R D 3 0 L A1 L E / P R 9 O 2 L 2 P S E N P P G
1 9 1 8 X T A X T A P a L E r t y D Z 3 1 E 9 R A
A / V S T T 8 9 C
Figure5.5 LED interfacing withAT89C51
Thus in order to glow the LED, first there should be a current flow through the LED. In order to have a current flow, a voltage difference should exist between the LED terminals. To ensure the voltage difference between the terminals and as the positive terminal of LED is connected to power supply Vcc, the negative terminal has to be connected to ground. Thus this ground value is provided by the microcontroller port pin. With this, the port pin P1.0 is initialized to zero and thus now a voltage difference is established between the LED terminals and accordingly, current flows and therefore the LED glow.
CHAPTER 6: RESULTS
1. The EVM consists of three party switches and a polling officer switch and in collaboration
with microcontroller. 2. The Microcontroller is accepting vote signal and is responding accordingly. 3. In voting mode, BU communicates with microcontroller in order to exchange various signals. 4.In case of low ‘vote signal’ the Microcontroller is not at all responding to push to button switch which is an interfacing medium between the voter and the Microcontroller. 5. An interfacing between the voter and the Microcontroller is running successfully with the help of vote cast LED panel. 6. Feedback system of the control unit is running successfully with the help of LED system. In total, the complete system (including all the hardware components and software routines) is working as per the initial specifications and requirements of our project. Because of the creative nature of the design, some features can further be fine-tuned and can become more user friendly. So certain aspects of the system can be modified as operational experience is gained with it. As the users work with the system, they develop various new ideas for the development and enhancement of the project.
APPLICATIONS & ADVANTAGES
• • • • • Fast track voting which could be used in small scale elections, like resident welfare association, “panchayat” level election and other society level elections. It could also be used to conduct opinion polls during annual share holders meeting. It could also be used to conduct general assembly elections where number of candidates are less than or equal to eight in the current situation. It could be used at places where there is no electricity as the thing is operational with the help of a simple 5 volt battery. It could well become a fine example of using environment friendly resources as there is no need for having lakhs of ballot papers as was used in older system of voting
It involves very less time for a voter to actually cast its vote unlike conventional method where it becomes very cumbersome to handle ballot papers. It is more fast and reliable.
• • • • Number of candidates could be increased by using other microcontroller or an 8255 IC. It could be interfaced with printer to get the hard copy of the result almost instantly from the machine itself. It could also be interfaced with the personal computer and result could be stored in the central server and its backup could be taken on the other backend servers. Again, once the result is on the server it could be relayed on the network to various offices of the election conducting authority. Thus our project could make the result available any corner of the world in a matter of seconds
In days of using nonpolluting and environment friendly resources of energy, it could pose a very good example.
REFRENCES AND BIBLOGRAPHY
1. Muhammad Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay. Second edition, “THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM” 2. K. J. Ayala. Third edition, “The 8051 MICROCONTROLLER” 3.Millman & Halkias. “INTEGRATED ELECTRONICS”. 4. www.wikipedia.com 5. www.8051microcontrollerprojects.com 6.www.datasheet4u.com 7.www.rickey’sworld.com
The present project is implemented on KEIL µvision software. In order to operate street lights, Proload tool has been used to burn the program onto the microcontroller.Coding of the project is given below: