SMS BASED VOTING MACHINE Project Report PDF
SMS BASED VOTING MACHINE Project Report PDF
SMS BASED VOTING MACHINE Project Report PDF
CHAPTER 1
INTRODUCTION
1.1
India is worlds largest democracy. Fundamental right to vote or simply voting in elections
forms the basis of Indian democracy. In India all earlier elections a voter used to cast his
vote by using ballot paper. 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. Cell phone based voting
machine 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. It reduces 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. The aim of our project is to design &
develop a mobile based voting machine.
This project focuses onto implement GSM (Global System for Mobile Communication) based
Voting System. This system is implemented using an embedded microcontroller. The embedded
microcontroller used here is AT89S52microcontroller. Actually, the aim of the project is to
implement an Automatic Voting system. GSM Based voting machine is fully controlled system.
There is no chance of any mistake. Primarily, the system functions with the help of different
technologies like the traditional cellular network such as Global System for Mobile
Communications (GSM) and other radio frequency medium. Today GSM fitted Banks, cars;
ambulances, fleets and police vehicles are common sights. The functional units of our projects
are GSM MODEM, LCD display, PC data base and AT89S52.
1.2
The aim of our project is to design & develop a mobile based voting machine. In this project
user can dial the specific number from any land line or mobile phone to cast his vote. Once
the user is connected to the voting machine he can enter his password & choice of vote. If
1
1.3
At present Electronic Voting Machines ("EVM") are being used in Indian General and State
Elections to implement electronic voting in part from 1999 elections and in total since 2004
elections. The EVMs reduce the time in both casting a vote and declaring the results
compared to the old paper ballot system. However, EVMs have been under a cloud of
suspicion over their alleged tamping arability and security problems during elections
(especially after the 2009 general elections). An EVM consists of two units:
Control Unit
Balloting Unit
The Control Unit is with the Polling Officer and the Balloting Unit is placed inside the
voting compartment
1.4
The current technology used in the project is SMS (Short Message Service) service based
on GSM (Global System for Mobile).GSM (Global System for Mobile communications) is
an open, digital cellular technology used for transmitting mobile voice and data services.
2
CHAPTER 2
CIRCUIT AND BLOCK DIAGRAM OF PROJECT
2.1 Block Diagram of Project
POWER
AT89S52
PC
SUPPLY
MICROCONTROLLER
DATABASE
GSM MODEM
(VB)
5V
EEPROM
MOBILE
LCD
2.1.3 Mobile
Here mobile is the user mobile whos SIM card number has been priory registered in
voting machine. Through mobile user will have to cast his\her vote in specific format using
Short Message Service (SMS).
2.1.4 PC Database
Computer (PC) is used as common interface between microcontroller and GSM module.
Software tool visual basic 6.0 is used to control, store and secondary display of votes. In
software part two forms are made one for administration access and another for voting
status display where all options are available for storage display and control.
the
same
circuit,
if
2.1.7 LCD
In this project 16*2 LCD is used. This LCD is interface with AT89S52 at port 2.It used to
display voting result with candidates A, B, C, D.
CHAPTER 3
COMPONENTS AND ITS DESCRIPTION
3.1 Component List
Basic components used in this project are:
Table 3.1 Component list
Sr.no
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
12.
13.
14.
15.
16.
17.
18.
19.
Component
Microcontroller
LCD display
LED
Resistor
Crystal oscillator
Capacitor
MAX 232
GSM module
SIM card
Copper clad
Voltage
regulator IC
Berge strip
Connecting wires
ZIF
Resistance array
Computer setup
DB-9 Connector
Switch
Specification
(AT89S52)
16*2 text
1K,10K
(11.0592Mhz)
(33pf,10mf(63V),)
SIM300
Any
7805
Male Female(16 pin)
40 pin
10k
9 slot
On/off
Quantity
1
1
2
8
1
2
2
1
1
2
1
2
As per need
requirement
1
1
1
2
1
Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes
of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmels high-density non-volatile memory technology and is
compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The onchip Flash allows the program memory to be reprogrammed in-system or by a conventional
non-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides a highlyflexible and cost-effective solution to many embedded control applications.
10
Features of 8052:
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
PIN DESCRIPTION:
VCC
Supply voltage.
GND
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. In addition, P1.0 and
P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the
11
Alternate Function
P 3.0
P 3.1
P 3.2
P 3.3
INT1(external interrupt 1)
P 3.4
P 3.5
P 3.6
P 3.7
12
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. 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. In the AT89C51, bit position IE.6 and IE.5 are unimplemented. User
software should not write 1s to these bit positions, since they may be used in future AT89
products. 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.3: Interrupts
(MSB)
EA
(LSB)
-
ET2
ES
ET1
EX1
ET0
EX0
14
15
3.2.3 GS M MODULE
The number of SMS messages that can be processed by a GSM modem per minute is very
low -- only about six to ten SMS messages per minute.
3.2.3.1 AT Commands
AT commands are instructions used to control a modem. AT is the abbreviation of
Attention.
commands are called AT commands. Many of the commands that are used to control
wired dial- up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and
ATO (Return to online data state), are also supported by GSM/GP RS modems and
mobile phones. Besides this common AT command set, GS M/GPRS modems and
mobile phones support an AT command set that is specific to the GSM technology, which
includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send
SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read
SMS messages).
Note that the starting "AT" is the prefix that informs the modem about the start of a
command line. It is not part of the AT command name. For example, D is the actual AT
command name in ATD and +CMGS is the actual AT command name in
AT+CMGS. However, some books and web sites use them interchangeably as the
name of an AT command.
Here are some of the tasks that can be done using AT commands with a GS M/GPRS
modem or mobile phone:
1. Get basic information about the mobile phone or GS M/GPRS modem. For
example, name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI
number (International Mobile Equipment Identity) (AT+CGSN) and software
version (AT+CGMR).
2. Get
(AT+CNUM)
subscriber.
For example
(International Mobile
Subscriber
MSISDN
Identity)
(AT+CIMI).
3. Get the current status of the mobile phone or GSM/GP RS modem. For
example,
mobile phone
activity status
(AT+CPAS),
mobile network
registration status (AT+CREG), radio signal strength (AT+CSQ), battery charge level
17
(AT+CMGS,
AT+CMSS),
read
(AT+CMGR,
AT+CMGL),
write
"+CMGL",
followed by a
next extended
AT
command "+CGMI":
AT+CMGL; +CGMI<CR>
19
An error will occur if both AT commands are prefixed with "AT", like this:
AT+CMGL; AT+C GMI<CR>
Syntax rule 3. A string is enclosed between double quotes.
Example: To read all SMS messages from message storage in SMS text mode (at this time
you do not need to know what SMS text mode is. More information will be provided later
in this SMS tutorial), you need to assign the string "ALL" to the extended AT
command +CMGL, like this:
AT+CMGL="ALL"<CR>
Syntax rule 4. Information responses and result codes (including both final result
codes and unsolicited result codes) always start and end with a carriage return
character and a linefeed character.
Example: After sending the command line "AT+CGMI<CR>to the mobile device, the
mobile device should return a response similar to this:
The first line is the information response of the AT command +CGMI and the second line
is the final result code. <C R> and <LF> represent a carriage return character and a line
feed character respectively. The final results c o d e "OK marks the end of the
response. It indicates no more data will be sent from the mobile device to the
computer / PC.
When a terminal program such as HyperTerminal of Microsoft Windows sees a
carriage return character, it moves the cursor to the beginning of the current line.
When it sees a linefeed character, it moves the cursor to the same position on the next line.
Hence,
the
command
line
"AT+CGMI<CR> "
that
you
entered
and
the
Final Result Codes of AT Commands: A final result code marks the end of an AT
command response. It is an indication that the GSM/GP RS modem or mobile phone has
finished the execution of a command line. Two frequently used final result codes are OK
and ERRO R. Only one final result code will be returned for each command line. Thus, you
will not see both OK and ERROR in the response of a command line.
The OK Final Result Code: The OK final result code indicates that a command
line has been executed successfully by the GSM/GP RS modem or mobile phone. It
always starts and ends with a carriage return character and a linefeed character.
Here is an example for illustration. Let's say you send the command line "AT+CMGL;
+CGMI<C R>to
your
GSM/GPRS
modem.
The
AT c o m m a n d "+CMGL" is
used to list SMS messages stored in the message storage area and the AT command
+CGMI" is used to get the manufacturer name of the GS M/GPRS modem. If
everything works properly without any errors, the command line, together with the
response returned, should be something similar to this:
AT+CMGL; +CGMI<CR>
<CR><LF>+CMGL: 1,"REC UNREAD","+85291234567",06/11/11, 00:30:29+32"<C
R><LF>Welcome
to
our
SMS
<CR><LF><CR><LF>OK<CR><LF>
As mentioned earlier, when a terminal program such as HyperTerminal of Microsoft
Windows sees a carriage return character, it moves the cursor to the beginning of the
current line. When it sees a linefeed character, it moves the cursor to the same
position on the next line. Hence, the command line you entered, together with the
response returned, will be displayed like this in a terminal program such as
HyperTerminal of Microsoft Windows:
AT+CMGL; +CGMI
21
Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the
+CMGS
Send message
+CMSS
+CMGW
+CMGD
Delete message
+CMGC
Send command
+CMMS
how to
Microsoft Windows to send an SMS text message. The lines in bold type are the
command lines that should be entered in HyperTerminal. The other lines are responses
returned from the GSM / GP RS modem or mobile phone.
23
AT OK AT+CMGF=1
OK
AT+CMGW="+7568501753"> A simple demo of SMS text messaging.
+CMGW:
OK
AT+CMSS=1
+CMSS:
OK
To send SMS messages from an application, you have to write the source code for
connecting to and sending AT commands to the mobile phone or GS M/GPRS
modem, just like what a terminal program does. You can write the source code in C,
C++, Java, Visual Basic, Delphi or other programming languages you like. However,
writing your own code has a few disadvantages:
1.
You have to learn how to compose the bits and bytes of an SMS message. For
example, to specify the character encoding (e.g. 7-bit encoding and 16-bit Unicode
encoding) of an SMS message, you need to know which bits in the message header
should be modified and what value should be assigned.
2.
In most cases, instead of writing your own code for interacting with the mobile phone or
GSM/GPRS modem via AT commands, a better solution is to use a high- level SMS
messaging
API
(Application
programming
interface)
S DK
(Software
development kit) / library. The AP I / SDK / library encapsulates the low- level details. So,
an SMS application developer does not need to know AT commands and the
composition of S MS messages in the bit-level. Some SMS messaging APIs / S DKs /
libraries support SMSC protocols in addition to AT commands. To move from a
24
Get access to the SMS center (SMSC) or SMS gateway of a wireless carrier.
Any SMS messages received will be forwarded to your computer / PC using a protocol
/ interface supported by the S MSC or SMS gateway.
3. Get access to the SMS gateway of an SMS service provider. Any SMS messages
received will be forwarded to your computer / PC using a protocol / interface supported
by the SMS gateway.
3.2.3.7 The 1st Way: Using a Computer to Receive SMS Messages through a Mobile Phone
or GSM/GP RS Modem
Receiving SMS messages through a mobile phone or GSM/GP RS modem has a major
advantage over the other two ways -- wireless carriers usually do not charge any fees for
receiving incoming SMS messages with their SIM cards. The disadvantage of receiving
SMS messages this way is that a mobile phone or GSM/GP RS modem cannot handle
25
Meaning
+CNMI
+CMGL
List messages
+CMGR
Read messages
+CNMA
Below shows a simple example that demonstrates how to use AT commands and the
HyperTerminal program of Microsoft Windows to read SMS text messages received by
a GSM / GP RS modem or mobile phone. The lines in bold type are the command lines
that should be entered in HyperTerminal. The other lines are responses returned from the
GSM / GP RS modem or mobile phone.
AT OK AT+CMGF=1
OK
AT+CMGL=" ALL"
+CMGL: 1,"REC
demo of SMS
text messaging.
OK
26
3.2.4 LCD
Ground
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Bit 4
12.
Bit 5
27
Bit 6
14.
Bit 7
15.
16.
Character LCDs can operate in 4-bit or 8-bit mode. In 4 bit mode, pins 7 through 10
are unused and the entire byte is sent to the screen using pins 11 through 14 by
sending 4-bits (nibble) at a time.
28
Description
The AT24C01A/02/04/08A/16A provides 1024/2048/4096/8192/16384 bits of serial
electrically erasable and programmable read-only memory (EEPROM) organized as
128/256/512/1024/2048 words of 8 bits each. The device is optimized for use in many
industrial and commercial applications where low-power and low-voltage operation are
essential. The AT24C01A/02/04/08A/16A is available in space-saving 8-lead PDIP, 8-lead
JEDEC
SOIC,
8-lead
Ultra-Thin
Mini-MAP
(MLP
2x3),
5-lead
SOT23
PIN Diagram
29
CHAPTER 4
DATABASE
In this project the database of voting is maintained though software tool Visual basics 6.0
In this software tool there is full duplex interfacing between microcontroller, PC and GSM
module.
was
derived
enables
the rapid
application
development
(RAD) of graphical user interface (GUI) applications, access to databases using Data
Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation
of ActiveX controls and objects. VBA is effectively the same language as Visual Basic but
VBA-code is tied to Microsoft Office and can only run within that environment.
The scripting language VBScript is a subset of Visual Basic.
A programmer can create an application using the components provided by the Visual Basic
program itself. Programs written in Visual Basic can also use the Windows API, but doing
so requires external function declarations. Though the program has received criticism for its
perceived faults, version 3 of Visual Basic was a runaway commercial success, and many
companies offered third party controls greatly extending its functionality.
The final release was version 6 in 1998. Microsoft's extended support ended in March 2008
and the designated successor was Visual Basic .NET (now known simply as Visual Basic).
and actions of those components, and writing additional lines of code for more
functionality. Since default attributes and actions are defined for the components, a simple
program can be created without the programmer having to write many lines of code.
Performance problems were experienced by earlier versions, but with faster computers and
native code compilation this has become less of an issue.
Although VB programs can be compiled into native code executables from version 5
onwards, they still require the presence of runtime libraries of approximately 1 MB in size.
Runtime libraries are included by default in Windows 2000and later, however for earlier
versions of Windows, i.e. 95/98/NT, runtime libraries must be distributed together with the
executable.
32
Statements tend to be terminated with keywords such as "End If", instead of using "{}"s
to group statements.
Multiple variable assignments are not possible. A = B = C does not imply that the
values of A, B and C are equal. The Boolean result of "Is B = C?" is stored in A. The
result stored in A would therefore be either false or true.
Boolean constant True has numeric value 1. This is because the Boolean data type is
stored as a 16-bit signed integer. In this construct 1 evaluates to 16 binary 1s (the
Boolean value True), and 0 as 16 0s (the Boolean value False). This is apparent when
performing a Not operation on a 16 bit signed integer value 0 which will return the
integer value 1, in other words True = Not False. This inherent functionality becomes
especially useful when performing logical operations on the individual bits of an integer
such as And, Or, Xor and Not. This definition of True is also consistent with BASIC
since the early 1970s Microsoft BASIC implementation and is also related to the
characteristics of CPU instructions at the time.
Logical and bitwise operators are unified. This is unlike some C-derived languages
(such as Perl), which have separate logical and bitwise operators. This again is a
traditional feature of BASIC.
Variable array base. Arrays are declared by specifying the upper and lower bounds in a
way similar to Pascal and FORTRAN. It is also possible to use the Option Base
statement to set the default lower bound. Use of the Option Base statement can lead to
confusion when reading Visual Basic code and is best avoided by always explicitly
specifying the lower bound of the array. This lower bound is not limited to 0 or 1,
because it can also be set by declaration. In this way, both the lower and upper bounds
are programmable. In more subscript-limited languages, the lower bound of the array is
not variable. This uncommon trait does exist in Visual Basic .NET but not in VBScript.
OPTION BASE was introduced by ANSI, with the standard for ANSI Minimal BASIC
in the late 1970s.
33
Relatively
strong
integration
with
the Windows
operating
system and
the Component Object Model. The native types for strings and arrays are the
dedicated COM types, BSTR and SAFEARRAY.
Banker's rounding as the default behaviour when converting real numbers to integers
with the Round function.[7] ? Round (2.5, 0) gives 2,? Round(3.5, 0) gives 4.
DefBool , DefVar,
DefObj,
12 Deftype statements in total offered by Visual Basic 6.0. The default type may be
overridden for a specific declaration by using a special suffix character on the
variable name (# for Double, for Single, & for Long, % for Integer, $ for String,
and @ for Currency) or using the key phrase as (type). VB can also be set in a mode
that only explicitly declared variables can be used with the command Option
Explicit.
With VB 6, you can create any program depending on your objective. For example,
if you are a college or university lecturer, you can create educational programs to
teach business, economics, engineering, computer science, accountancy, financial
management, information system and more to make teaching more effective and
interesting. If you are in business, you can also create business programs such as
inventory management system, point-of-sale system, payroll system, financial
program as well as accounting program to help manage your business and increase
productivity. For those of you who like games and working as games programmer,
you can create those programs as well. Indeed, there is no limit to what program
you can create! There are many such programs in this tutorial, so you must spend
more time on the tutorial in order to learn how to create those programs.
4.3.1 Form 1
4.3.2 Form 2
Form 2 is the main window of voting machine in software part for display, control and
storage of database.
35
36
37
CHAPTER 5
LAYOUT & PCB DESIGNING
5.1 Printed Circuit Board (PCB)
A printed circuit board, or PCB, is used to mechanically support and electrically
connect electronic
tracks
or
signal
traces etched from copper sheets laminated onto a non-conductive substrate. When the
board has only copper tracks and features, and no circuit elements such as capacitors,
resistors or active devices have been manufactured into the actual substrate of the board, it
is more correctly referred to as printed wiring board (PWB) or etched wiring board. Use of
the term PWB or printed wiring board although more accurate and distinct from what would
be known as a true printed circuit board, has generally fallen by the wayside for many
people as the distinction between circuit and wiring has become blurred. Today printed
wiring (circuit) boards are used in virtually all but the simplest commercially produced
electronic devices, and allow fully automated assembly processes that were not possible or
practical in earlier era tag type circuit assembly processes.
38
39
40
CHAPTER 6
SOFTWARE & HARDWARE TOOL
6.1 Software Tools:
6.1.1 Keil Uvision 4.0
Keil Software is used provide you with software development tools for 8051 based
microcontrollers. With the Keil tools, you can generate embedded applications for
virtually every 8051 derivative. The supported microcontrollers are listed in the - vision
41
CHAPTER 7
FLOW CHART AND ALGORITHMS
7.1 Flow Chart of Project
42
43
CHAPTER 8
ADVANTAGES & APPLICATIONS
8.1 Applications
a) The EVM system is a longtime-consuming process and very much prone to errors.
b) This situation continued till election scene was completely changed by electronic
voting machine.. Cell phone based voting machine is capable of saving considerable
printing stationery and transport of large volumes of electoral material.
c) SMS based voting system can be used in remote areas where manual voting system
is difficult to implement.
d) This system can be used in colleges, society and various other places for elections.
e) Fast track voting which could be used in small scale elections, like resident welfare
association, panchayat level election and other society level elections.
f) It could also be used to conduct opinion polls during annual shareholders meeting.
g) 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.
h) It is used in various TV serials as for public opinion.
8.2 Advantages
a) Democracy: All and only the authorized voters can vote, and each eligible voter can
vote no more than once. Voters can also choose not to vote.
b) Privacy: All votes remain secret while voting takes place and each individual vote
cannot be linked by any individual or authority to the voter who casts it.
c) Accuracy: The voting result accurately reflects voters Choices. In this case, no vote
can be altered, duplicated or eliminated without being detected.
d) Fairness: No partial result is available before the final result comes out.
44
CHAPTER 9
FUTURE SCOPE & LIMITATIONS
9.1 Future Scope
The system can be further modified to enhance its utility. The enhancements are:
a) Number of candidates could be increased.
b) It can be interfaced with printer to get the hard copy of the result almost instantly
from the machine itself.
c) It can also be interfaced with the personal computer and result can be stored in the
central server.
d) 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 can make results available at
any corner of the world in a matter of seconds.
9.2 Limitations
a) Number of candidates is less.
b) Major limitation is network problem.
c) Less storage of data.
d) Voting numbers are limited to three digits.
45
CHAPTER 10
CONCLUSION
We proposed a GSM mobile voting scheme, where the GSM authentication Infrastructure is
used to provide voter authentication and improve voter mobility. Authentication is always a
difficult requirement to fulfil for remote voting schemes, most of which apply a public-key
based signature scheme for voter authentication. In our scheme, by using the existing GSM
authentication infrastructure, the public-key overhead is largely reduced. Our scheme also
enhances the security and provides more mobility and convenience to voters. Where the
voters privacy is protected by applying a blind signature scheme. In this report, we
presented the basic structure and protocol of our GSM based mobile voting system.
46
REFERENCES / BIBLIOGRAPHY
Muhammad Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay.
Second edition, THE 8051 MICROCONTROLLER AND EMBEDDED
SYSTEM
K. J. Ayala. Third edition, The 8051 MICROCONTROLLER
Tutorial on microcontroller:
www.8051projects.net/microcontroller_tutorials/
Tutorial on LCD:
www.8051projects.net/lcd-interfacing/
WEBSITES
www.atmel.com
www.howstuffworks.com
www.alldatasheets.com
www.efyprojects.com
www.google.com
47
APPENDICES / ANNEXURE
REFRENCE
QUANTITY
RATE
PER
UNIT
AMOUNT
NUMBER
1.
MICROCONTROLLER AT89S52
55.00
55.00
2.
GSM MODULE
SIM 300
3000.0
3000.0
3.
MAX232
16PIN
20.00
40.00
4.
REGULATOR IC
LM7805
7.00
7.00
5.
LED
RED
2.00
4.00
GREEN
35.00
70.00
10F,16V
1.50
22pF
1.50
6.
COPPERCLADE PCB
7.
CAPACITOR
8.
CRYSTAL
OSSCILLATOR
11.0592MHZ
7.00
7.00
9.
IC BASE
40 PIN
4.00
4.00
10.
SOLDERING WIRE
15METER
10.00
150.00
11.
DB9 CONNECTOR
9 PIN
231.0
464.0
48
12.
RESISTERS
10K
1.00
1K
1.00
220
1.00
310K
1.00
4.00
13.
EEPROM
24C02
21.00
21.00
14.
TRANSISTOR
2N3904
8.00
8.00
15.
BATTERY
+9V
38.00
38.00
16.
TRANSFORMER
+12V
45.00
45.00
TOTAL:
3923/-
AMOUNT
1.
CARDBOARD SHEET
55.00
2.
FEVICOL
20.00
3.
SIM AIRTEL
60.0
4.
THERMOCOL SHEET
25.0
5.
40.00
Total
200/-
49
char msg[10],notice[96];
sfr lcddata=0x90; //p1 port
sbit rs=P3^7;
sbit rw=P3^6;
sbit en=P3^5;
sbit SDA=P2^1;
sbit SCL=P2^0;
//delay 1
for(j=0;j<1275;j++);
}
void delay2(unsigned int a)
// delay 2
{
unsigned int i,j;
for(i=0;i<a;i++)
for(j=0;j<1;j++);
}
// lcd commands
{
lcddata=d;
50
rw=0;
delay(2);
en=0;
}
void lcd(unsigned char word)
{
lcddata=word;
en=1;
rs=1;
rw=0;
delay(2);
en=0;
}
{
lcd(word[x]);
}
}
51
{
SDA = 1;delay(1);
SCL = 1;delay(1);
SDA = 0;delay(1);
SCL = 0;delay(1);
}
void I2c_stop()
{
}
void I2c_write(unsigned char a)
{
unsigned char i;
for(i=0;i<8;i++)
{
SDA = ((a & 0x80)? 1:0 );
a <<=1;
SCL = 1;
delay(1) ;
SCL = 0;
delay(1) ;
}
52
delay(1);
I2c_write(0xA0);delay(1);
I2c_write(add);
delay(1);
I2c_write(val);delay(1);
//writting in memory
I2c_stop();
}
unsigned char I2c_read()
{
unsigned char i,val;
val = 0x00;
//Reset in_data
for(i=0;i<8;i++)
{
val <<= 1;
SCL = 1;
delay2(1);
I2c_write(0xA0);
delay2(1);
I2c_write(add);
delay2(1);
I2c_start();
delay2(1);
I2c_write(0xA1);
delay2(1);
val = I2c_read();
delay2(1);
I2c_stop();
//writting in memory
return (val) ;
}
void main()
//main funtion
{
char x1,limit,num1,num,add,i,var,x;
//initializing of variable
char records='0';
command(0x38);
command(0x0C);
//initializing of lcd
SCON=0x50;
//initializing of timer
TMOD=0x20;
TH1=0xFD;
main1:
command(0x01);
command(0x80);
displaydata("Waiting 4 DATA");
main:
54
while(1)
{
while(RI==0);
msg[num]=SBUF;
num++;
//E command for saving data
if(msg[num-1]=='E')
goto proceed;
if(msg[num-1]=='B')
goto proceed2;
if(msg[num-1]=='N')
goto proceed3;
RI=0;
}
proceed3:
command(0x01);
command(0x80);
displaydata("NEW DATABASE");
NEW DATABASE//
write(0,'0');
goto main1;
proceed:
TR1=1;
RI=0;
55
x1=SBUF;
if(limit==1)
notice[num1]=x1;
if(x1=='#')
break;
num1++;
if(x1=='*')
{
limit=1;
num1=0;
}
RI=0;
}
//s command to save data
if(notice[0]=='S')
{
command(0x01);
command(0x80);
displaydata("SAVING DATABASE");
records=read(0);
records++;
write(0,records);
if(records=='1')
add=1;
if(records=='2')
56
add=17;
if(records=='4')
add=25;
if(records=='5')
add=33;
for(i=0;i<8;i++)
{
write(add+i,notice[i+1]);
}
command(0xc0);
displaydata("SAVED");
delay(200);
}
command(0x01);
command(0x80);
displaydata("A B C D ");
command(0xC0);
lcd(notice[1]);
lcd(notice[2]);
lcd(' ');
lcd(notice[3]);
lcd(notice[4]);
lcd(' ');
lcd(notice[5]);
57
lcd(notice[7]);
lcd(notice[8]);
delay(100);
//delay
goto main;
// go to main function
proceed2:
command(0x01);
command(0x80);
displaydata("READING DATA &");
command(0xc0);
displaydata("TRANSMITTING....");
var=read(0);
x=var-'0';
//incrementing votes
x=x*8;
for(i=0;i<x;i++)
{
TI=0;
SBUF=read(i+1);
while(TI==0);
}
TI=0;
SBUF='Z';
while(TI==0);
command(0x01);
command(0x80);
displaydata("SENT");
58
//form 1
//for password a
Form1.Hide
//hiding form1
Form2.Show
//showing form2
Else
MsgBox ("wrong user/pASSWORD")
//message box
End If
End Sub
Private Sub Command2_Click()
End
//exit
End Sub
Private Sub Form_Load()
Form1.Hide
Form2.Show
End Sub
A.4.1 FORM 2
Dim c1, c2, c3, c4, choice, start, num As Integer
Dim NONAME As Boolean
59
//open port 2
MSComm2.PortOpen = True
End If
MSComm2.Output = "AT+CMGD=1" & vbCrLf
Sleep (100)
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
//enable timmer 1
Timer2.Enabled = False
MSComm2.PortOpen = False
//stoping port 2
End Sub
Private Sub Command3_Click()
Command8.Enabled = False
//enabling command 8
Check1.Enabled = False
MSComm1.PortOpen = False
End Sub
Private Sub Command4_Click()
Command8.Enabled = True
Check1.Enabled = True
//candidate 1 variable
If c2 < 10 Then
m2 = "0"
//candidate 2 variable
Else
m2 = ""
End If
If c3 < 10 Then
m3 = "0"
//candidate 3 variable
Else
m3 = ""
End If
If c4 < 10 Then
m4 = "0"
//candidate 4 variable
Else
m4 = ""
End If
MSComm1.Output = "E*S" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 & "#"
MsgBox "Data Sent to Microcontroller"
Form2.Hide
Form1.Show
61
End Sub
Private Sub Command7_Click()
MSComm1.Output = "N"
End Sub
Private Sub Command9_Click()
'MSComm2.Output = "AT+CMGF=1" & vbCrLf
MSComm1.Output = "E*w" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 & "#"
MsgBox "Data Sent to Microcontroller"
End Sub
Private Sub Form_Load()
c1 = 0
c2 = 0
c3 = 0
c4 = 0
Command8.Enabled = False
Check1.Enabled = False
Timer1.Enabled = False
Timer2.Enabled = False
num = 0
NONAME = False
End Sub
Private Sub MSComm1_OnComm()
For i = 0 To a
Text8.Text = Text8.Text & "DAY" & (i + 1) & ": " & Mid$(Text7.Text, x, 2)
Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 2, 2)
Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 4, 2)
Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 6, 2) & vbCrLf
x=x+8
Next
Text7.Text = ""
End If
End Sub
c2 = c2 + 1
ElseIf choice = 3 Then
c3 = c3 + 1
ElseIf choice = 4 Then
c4 = c4 + 1
End If
65
Else
m1 = ""
End If
If c2 < 10 Then
m2 = "0"
66
End If
If c3 < 10 Then
m3 = "0"
Else
m3 = ""
End If
If c4 < 10 Then
m4 = "0"
Else
m4 = ""
End If
MSComm1.Output = "E*w" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 &
"#"
'MsgBox "Data Sent to Microcontroller"
'MsgBox "Data Sent to Microcontroller"
End If
Else
MSComm2.Output = "AT+CMGS=" & Chr(34) & Number1 & Chr(34) & vbCrLf
Sleep (200)
MSComm2.Output = "YOUR VOTING IS ALREADY DONE. VOTING ONCE IS ONLY
PERMITTED." & Chr(26)
End If
proceed:
Text6.Text = ""
67
//password verification
68