harish doc
TRANSCRIPT
1. INTRODUCTION
As the time moves the life style of the persons has completely changed and there is no
time for the people for micro management of every issue personally. So, this is the right time to
provide some space to the technology into our lives for monitoring the issues which requires our
personal presence for the things to happen. One among those issues which require our personal
presence is attendance system. Paper based attendance system is not efficient and easy when
dealing with large number of people. So our project aims in providing a very reliable and very
user friendly solution to overcome this kind of problem.
As we know the advancements in the Radio Frequency and GSM technologies and
making use of those existing technologies we can design a device which is capable of identifying
the arrival of student and forward an SMS to the corresponding parent. The basic idea of the
system is to employ a unique RFID tag to each student. As soon as the student enters the college/
class entrance, the RF reader reads the identity number of the tag and informs the same to a
micro controller and compares it with the identity number in the database and if any match is
found then it sends message to the parent of the corresponding student.
To design the entire system we require a microcontroller which acts as a medium of
communication between the RF reader and the GSM modem. The major advantage of this
system is the presence of the GSM modem enables the device to communicate with the target
(parent) no matter where ever he/she was present on the globe.
1
2. POWER SUPPLY
The power supply unit is used to provide a constant 5V of DC supply from a 230V of AC
supply. These 5V DC will acts as power to different standard circuits. It mainly uses 2 devices
1. Bridge wave rectifier
2. Voltage regulator
Figure 2.1: Block Diagram of Power Supply
2.1 Bridge Wave Rectifier:
A rectifier is an electrical device that converts alternating current (AC) to direct current
(DC), a process known as rectification. The term rectifier describes a diode that is being used to
convert AC to DC. A bridge-wave rectifier converts the whole of the input waveform to one of
constant polarity (positive or negative) at its output. Bridge-wave rectifier converts both
polarities of the input waveform to DC (direct current), and is more efficient. However, in a
circuit with a center tapped transformer (9-0-9) is used.
Figure 2.2: Bridge Wave Rectifier
2
In this only two diodes are activated at a time i.e. D1 and D3 activate for positive cycle
and D2 and D4 activates for negative half cycle. D2 and D4 convert negative cycle to positive
cycle as it as negative supply and negative cycle as positive cycle at its output.
2.2 Voltage Regulator:
This is most common voltage regulator that is still used in embedded designs.
LM7805 voltage regulator is a linear regulator. With proper heat sink these LM78xx types can
handle even more than 1A current. This will connect at the output of rectifier to get constant Dc
supply instead of ripple voltages. It mainly consists of 3 pins
1. Input voltage
2. Output voltage
3. Ground
Figure 2.3: Voltage Regulator
The capacitor C2 is used to get thee ripple voltage as input to regulator instead of full
positive cycles. For some devices we require 12V/9V/4V Dc supply at that time we go for
7812/7809/7804 regulator instead of 7805 regulator
Figure 2.4: Circuit Diagram of Power Supply
3
3. EMBEDDED SYSTEMS
3.1 Introduction To Embedded System:
A general-purpose definition of embedded systems is that they are devices used to
control, monitor or assist the operation of equipment, machinery or plant. “Embedded” reflects
the fact that they are an integral part of the system. All embedded systems include computers or
microprocessors. Some of these computers are however very simple systems as compared with a
personal computer.
The simplest devices consist of a single microprocessor (often called a “chip”), which
may itself be packaged with other chips in a hybrid systems or Application Specific Integrated
Circuit (ASIC). Its input comes from a detector or sensor and its output goes to a switch or an
activator which (for example) may start or stop the operation of a machine or, operating a value,
may control the flow of fuel to an engine.
Figure 3.1: Block Diagram of Embedded Systems
4
3.2 Processors:
Processors are the ones which performs some specific task or operation. These are
divided in to several types like:
1. Digital Signal Processors.
2. Application Specific Integrated Circuits.
3. Micro Processors.
4. Micro Controllers.
3.2.1 Digital Signal Processors:
This is a one which performs scientific and mathematical Calculations. The output of this
type of processors will be in floating point values. Hence, we can get accurate values as outputs.
Best example of a Digital Signal Processors will be Weather Forecasting.
3.2.2 Applications specific Integrated Circuits:
As the name itself specifies, this is integrated circuit designed for a specific application.
IC designed for one specific application cannot be used in other applications. Best Example for
ASIC will be Cell phone card.
3.2.3 Microprocessors:
These are the ones which perform arithmetic and logical operations.
Figure 3.2: Block Diagram of Microprocessor
5
Arithmetic and logical unit performs arithmetical and logical calculations. Control unit
controls all the peripheral devices connected to the microprocessors. Memory is a one which is
used to store some data or information. Best Example for a microprocessor will be our Personal
Computer.
3.2.4 Micro Controllers:
These are the ones which are similar to that of a microprocessor which performs
arithmetic and logical calculations. These have additional advantage to that it is having
additional inbuilt features like:
1. Electrically Erasable Programmable Read Only Memory (EEPROM)
2. Universal Synchronous Asynchronous Receiver and Transmitter (USART).
3. Analog to Digital Converter (ADC).
4. Digital to Analog Converter (DAC).
5. Oscillators.
6. Timers.
7. Many others.
The output of a microcontroller is always in integer format only. It cannot provide accurate
values or floating point values.
Figure 3.3: Block Diagram of Microcontroller
6
3.3 Applications of Embedded System:
(a) Manufacturing and process control:
Manufacturing plants.
Water and sewage systems.
Power stations.
Power grid systems.
Oil refineries and related storage facilities.
Bottling plants.
Automated factories.
Simulators.
Test equipment for control system development, maintenance and testing.
(b) Construction industry:
Surveying and location Equipment.
Construction Plant.
(c) Transport:
Aero planes
Trains and Buses.
Marine craft (known cases include: radar mapping; ballast monitoring; cargo loading;
ship main control system)
Automobiles
Fuel services.
Air Traffic Control Systems.
Signaling system.
Radar Systems.
Traffic Lights.
Ticketing systems and Machines.
Car Parking and other meters.
(d) Buildings and premises:
7
Electrically supply- supply, measurement, control, protection.
Backing lighting and generators.
Fire control systems.
Heating and ventilating systems.
Lifts Elevators, escalators.
Security Systems.
Security Cameras.
Door locks.
(e) Domestic service:
Catering.
Cleaning.
(f) Communications:
Telephone.
Cable systems.
Telephone switches.
Satellites.
(g) Office systems and mobile management:
Telephone systems
Faxes and Copier.
Time recording systems.
Mobile telephones
Still and Video Cameras.
(h) Banking, Finance and Commercial:
Automated teller systems.
Credit card Systems.
Point of scale systems including scanner / cash systems.
8
4. OVER VIEW OF THE PROJECT
4.1 Block Diagram Of The Project:
Figure 4.1: Block Diagram Of The Project
9
4.2 Circuit Diagram Of The Project:
Figure 4.2 Circuit Diagram of the Project
The basic circuit diagram of the project as shown in the Fig4.2 describes the necessary
connections that are to be made while designing the hardware module of the project.
There are different hardware modules in this project. They are:
1. 8051 Microcontroller (AT89C51)
2. 16X2 LCD DISPLAY
3. Real Time Clock
4. Serial communication
5. RFID MODEM
6. GSM MODEM
7. LED and Switches
10
ALU
ACCUMULATOR
REGISTERS
STACK POINTER
TIMER/COUNTER
INTERNALROM
PROGRAM COUNTER
I/O PORTS
I/O PORTS
INTERNALCIRCUITS
CLOCK CIRCUIT
INTERNAL RAM
5. MICROCONTROLLERS
A microcontroller is an integrated chip with minimum required devices. The microcontroller
includes a CPU: ALU, PC,SP and registers, RAM, ROM, I/O ports, and timers like a standard computer,
but because they are designed to execute only a single specific task to control a single system, they are
much smaller and simplified so that they can include all the functions required on a single chip.
Most microcontrollers will also combine other devices such as:
A Timer module to allow the microcontroller to perform tasks for certain time periods.
A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC
or another microcontroller.
An ADC to allow the microcontroller to accept analogue input data for processing.
Figure 5.1: Functional Block Diagram of Microcontroller.
11
5.1 MICROCONTROLLER Vs MICROPROCESSOR:
1. A microcontroller is meant to be more self-contained and independent, and functions
as a tiny, dedicated computer than microprocessor.
2. The microcontroller may function as a computer with addition of external digital parts;
the microprocessor must have many additional parts to be operational.
3. Most microprocessors have many operational codes (op codes) for moving data from
external memory to the CPU; microcontrollers may have one or two.
4. Microcontrollers are designed by using CMOS (complementary metal oxide
semiconductor) technology, an efficient fabrication technique that uses less power and is
more immune to power spikes than other techniques.
5.2 Advantages Of Microcontrollers:
Their powerful, cleverly chosen electronics is able to control a variety of processes and
devices (industrial automatics, voltage, temperature, engines, etc) independently or by means of
I/O instruments such as switches, buttons, sensors, LCD screens, relays etc.
5.3 Types Of 8051 Microcontroller:
The 8051 has the widest range of variants of any embedded controller on the market.
The smallest device is the Atmel 89c1051, a 20 Pin FLASH variant with 2 timers, UART, 20mA.
The fastest parts are from Dallas, with performance close to 10 MIPS! The most powerful chip
is the Intel Technologies 80C517A, with 32 Bit ALU, 2 UARTS, 2K RAM, PLCC84 package,
8x 16 Bit PWMs, and other features.
Among the MAJOR manufacturers are:
AMD - Enhanced 8051 parts (no longer producing 80x51 parts)
Atmel - FLASH and semi-custom parts
Dallas - Fast variant. Also battery backed
12
Intel - 8051 through 80C51GB / 80C51Sl. They invented the 8051
ISSI - IS80C51/31 runs up to 40MHz
OKI - 80C154, mask parts
Philips - 87C748 thru 89c588, mostly old legacy 8051 parts from signetics.
5.4 Architectural Block Diagram:
Figure 5.2: Architectural Block Diagram of 8051
13
5.5 ATMEL AT89C51:
The smallest current device is the ATMEL 89c51, a 40 Pin FLASH variant with 2 timers,
UART, 500mA. ATMEL was the first with standard FLASH, and with more program cycles
than other custom FLASH. These parts compete with OTP and MASK product on price, but
eliminate inventory problems and the hidden costs of OTP development.
5.5.1 Why we go for AT89C51?
The AT89C51 is a low power, high performance CMOS 8-bit microcontroller with
4Kbytes of Flash programmable and erasable read only memory (PEROM). This device is
compatible with the industry standard 8051 instruction set and pin out. The on-chip Flash allows
the program memory to be quickly reprogrammed using a nonvolatile memory programmer such
as the PG302 (with the ADT87 adapter). By combining an industry standard 8-bit CPU with
Flash on a monolithic chip, the 8951 is a powerful microcomputer which provides a highly
flexible and cost effective solution to many embedded control applications.
5.6 Features of AT89C51:
1. It is an 8-bit microcontroller.
2. It has a flash memory of 4KB for storing the program.
3. It has RAM of 128 bytes.
4. It has 32 I/O ports.
-Port 0 (pin 39 to pin 32).
-Port 1 (pin 1 to pin 8).
-Port 2 (pin 21 to pin 28).
-Port 3 (pin 10 to pin 17).
5. It has four register banks.
6. It has two 16-bit timers. Timer 0 and Timer 1
14
7. It has full duplex asynchronous serial port.
8. It can support up to 64KB of external memory with the help of PC and DPTR.
9. It has 16-bit address bus.
10. Six interrupts with two priority levels
-2 general purpose interrupts (INT0, INT1).
-4 preprogrammed interrupt (Timer0, Timer1, Serial interrupt, Reset interrupt).
11. Wide range of frequency of operation (0 to 24 MHz).
12. It will operate on 5V dc supply.
13. It can support maximum of 500mA of current.
5.7 Pin Out Diagram:
Figure 5.3: Pin out Diagram of 8051.
15
1–8: Port 1: Each of these pins can be used as either input or output. Also, pins 1 and 2
(P1.0 and P1.1) have special functions associated with Timer 2.
9: Reset Signal: High logical state on this input halts the MCU and clears all the
registers. Bringing this pin back to logical state zero starts the program anew as if the
power had just been turned on. In another words, positive voltage impulse on this pin
resets the MCU. Depending on the device's purpose and environs, this pin is usually
connected to the push-button, reset-upon-start circuit or a brown out reset circuit.
Figure 5.4: Reset Circuit
10-17: Port 3: As with Port 1, each of these pins can be used as universal input or output.
However, each pin of Port 3 has an alternative function:
Pin 10: RXD - Serial input for asynchronous communication or serial output for
synchronous communication.
Pin 11: TXD - Serial output for asynchronous communication or clock output for
synchronous communication
Pin 12: INT0 - Input for interrupt 0
Pin 13: INT1 - Input for interrupt 1
Pin 14: T0 - Clock input of counter 0
Pin 15: T1 - Clock input of counter 1
Pin 16: WR - Signal for writing to external (add-on) RAM memory
16
Pin 17: RD - Signal for reading from external RAM memory
18-19: X2 and X1: Input and output of internal oscillator. Quartz crystal controlling the
frequency commonly connects to these pins. Capacitances within the oscillator
mechanism (see the image) are not critical and are normally about 30pF. New MCUs
work at frequencies from 0Hz to 50MHz+.
Figure 5.5: Clock Circuit.
20: GND: Ground
21- 28: Port 2: If external memory is not present, pins of Port 2 act as universal
input/output. If external memory is present, then these pins serve as the location of the
higher address byte, i.e. addresses A8 – A15
29: PSEN: MCU activates this bit (brings to low state) upon each reading of byte
(instruction) from program memory. If external ROM is used for storing the program,
PSEN is directly connected to its control pins.
30: ALE: Before each reading of the external memory, MCU sends the lower byte of the
address register (addresses A0 – A7) to port P0 and activates the output ALE. External
register (74HCT373 or 74HCT375 circuits are common), memorizes the state of port P0
upon receiving a signal from ALE pin, and uses it as part of the address for memory chip
31: EA: Bringing this pin to the logical state zero designates the ports P2 and P3 for
transferring addresses regardless of the presence of the internal memory. This means that
even if there is a program loaded in the MCU it will not be executed.
32-39: Port 0: Similar to Port 2, pins of Port 0 can be used as universal input/output, if
external memory is not used. If external memory is used, P0 behaves as address output
17
(A0 – A7) when ALE pin is at high logical level, or as data output (Data Bus) when ALE
pin is at low logical level.
40: VCC: Power +5V
5.8 Memory In 8051 Microcontroller:
The 8051 has three very general types of memory. The memory types are illustrated in
the following figure: On-Chip Memory, External Code Memory, and External RAM.
Figure 5.6: Memory Block Diagram.
On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on
the microcontroller itself. External Code Memory is code (or program) memory that resides off-
chip. This is often in the form of an external EPROM. External RAM is RAM memory that
resides off-chip. This is often in the form of standard static RAM or flash RAM.
ROM memory:
In this MCU contain 4 kilobytes of the flash memory on the chip. It is of EEPROM. We
can use 12v to program MCU. This option is cost-effective only for large series. The main
purpose of ROM is to store the programs to be executed.
18
RAM memory:
RAM is used for storing temporary data and auxiliary results generated during the
runtime. Apart from that, RAM comprises a number of registers: hardware counters and timers,
I/O ports, buffer for serial connection, etc. With older versions, RAM spanned 256 locations,
while new models feature additional 128 registers. First 256 memory locations form the basis of
RAM (addresses 0 – FFH) of every 8051 MCU. Locations that are available to the user span
addresses from 0 to 7Fh, i.e. first 128 registers, and this part of RAM is split into several blocks
as can be seen in the following figure.
Figure 5.7: Ram Memory
The main purpose of RAM is to provide synchronization between ROM and CPU so as to
increase the speed of microcontroller.
Bit Memory:
The 8051, being a communications-oriented microcontroller, gives the user the ability to
access a number of bit variables. These variables may be either 1 or 0. There are 128 bit
variables available to the user, numbered 00h through 7Fh.
Special Function Register (SFR) Memory:
Special Function Registers (SFRs) are areas of memory that control specific functionality
of the 8051 processor. It may appear that SFR is part of Internal Memory. However, when using
19
this method of memory access (it is called direct address), any instruction that has an address of
00h through 7Fh refers to an Internal RAM memory address; any instruction with an address of
80h through FFh refers to an SFR control register.
5.9 Register Banks:
General Purpose registers:
The 8051 uses 8 "R" registers which are used in many of its instructions. These "R"
registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7). These registers
are generally used to assist in manipulating values and moving data from one memory location to
another.
SFR Registers (Special Function Registers):
SFR registers can be seen as a sort of control panel for managing and monitoring the
microcontroller.
Figure 5.8: Special Function Registers.
20
5.10 Timers:
The 8051 comes equipped with two timers, both of which may be controlled, set, read,
and configured individually. The 8051 timers have three general functions:
1) Keeping time and/or calculating the amount of time between events,
2) Counting the events themselves, or
3) Generating baud rates for the serial port.
Timer SFRs:
The 8051 has two timers which each function essentially the same way. One timer is
TIMER0 and the other is TIMER1. The two timers share two SFRs (TMOD and TCON) which
control the timers, and each timer also has two SFRs dedicated solely to itself (TH0/TL0 and
TH1/TL1).
5.10.1 The TMOD SFR (Timer Mode):
The TMOD SFR is used to control the mode of operation of both timers. Each bit of the
SFR gives the microcontroller specific information concerning how to run a timer. The high four
bits (bits 4 through 7) relate to Timer 1 whereas the low four bits (bits 0 through 3) perform the
exact same functions, but for timer 0.
The individual bits of TMOD have the following functions:
Bit Name Explanation of Function Timer
7 GATE1
When this bit is set the timer will only run when INT1
(P3.3) is high. When this bit is clear the timer will run
regardless of the state of INT1.
1
6 C/T1 When this bit is set the timer will count events on T1
(P3.5). When this bit is clear the timer will be
1
21
incremented every machine cycle.
5 T1M1 Timer mode bit (see below) 1
4 T1M0 Timer mode bit (see below) 1
3 GATE0
When this bit is set the timer will only run when INT0
(P3.2) is high. When this bit is clear the timer will run
regardless of the state of INT0.
0
2 C/T0
When this bit is set the timer will count events on T0
(P3.4). When this bit is clear the timer will be
incremented every machine cycle.
0
1 T0M1 Timer mode bit (see below) 0
0 T0M0 Timer mode bit (see below) 0
The Four bits (two for each timer) are used to specify a mode of operation. modes of
operation are:
TxM1 TxM0 Timer Mode Description of Mode
0 0 0 13-bit Timer.
0 1 1 16-bit Timer
1 0 2 8-bit auto-reload
1 1 3 Split timer mode
.
22
5.10.2 The TCON SFR:
There is one more SFR that controls the two timers and provides valuable information
about them. The TCON SFR has the following structure:
Bit NameBit
AddressExplanation of Function Timer
7 TF1 8FhTimer 1 Overflow. This bit is set by the microcontroller
when Timer 1 overflows.1
6 TR1 8EhTimer 1 Run. When this bit is set Timer 1 is turned on.
When this bit is clear Timer 1 is off. 1
5 TF0 8DhTimer 0 Overflow. This bit is set by the microcontroller
when Timer 0 overflows.0
4 TR0 8ChTimer 0 Run. When this bit is set Timer 0 is turned on.
When this bit is clear Timer 0 is off. 0
Only four bits of SFR are used for timers, the remaining four are used for interrupts.
23
6. LIQUID CRYSTAL DISPLAY UNIT (LCD)
6.1 Introduction:
Liquid Crystal Displays are created by sandwiching a thin (10-12 micro mm) layer of a
liquid crystal fluid between two glass plates. A transparent, electrically conductive film or back
plane is put up on the rear glass sheet. The transparent sections of the conductive film in the
shape of the desired characters are coated on the front glass plate. When a voltage is applied
between a segment and the back plane, an electric field is created in the region under the
segment. This electric field changes the transmission of light through the region under the
segment film.
6.2 Liquid Crystal Display Description:
In this project, JHD 162A Liquid Crystal Display (16x2), which is shown below, is
interfaced with the CPU.
Figure 6.1 JHD 162A Liquid Crystal Display
The features of JHD 162A LCD is as follows: -
16 Characters x 2 Lines 5x7DotswithCursor
Built-in controller
+5v Power Supply
24
Pin
numberSymbol Level I/O Function
1 Vss - - Power supply (GND)
2 Vcc - - Power supply (+5V)
3 Vee - - Contrast adjust
4 RS 0/1 I0= Instruction input
1 = Data input
5 R/W 0/1 I0 = Write to LCD module
1 = Read from LCD module
6 E 1, 1->0 I Enable signal
7 DB0 0/1 I/O Data bus line 0 (LSB)
8 DB1 0/1 I/O Data bus line 1
9 DB2 0/1 I/O Data bus line 2
10 DB3 0/1 I/O Data bus line 3
11 DB4 0/1 I/O Data bus line 4
12 DB5 0/1 I/O Data bus line 5
13 DB6 0/1 I/O Data bus line 6
14 DB7 0/1 I/O Data bus line 7 (MSB)
Pin assignment for <= 80 character displays
The pin description of the JHD 162A LCD without backlight is as shown in Table. If the
LCD is having Backlight, then it will have two more pins with pin numbers 15 & 16 connected
to VCC and GND respectively.
25
4-bit mode is best used when the speed required in an application and at least 10 I/O pins
are available. 4-bit mode requires minimum 6 bits. To wire a Microcontroller to an LCD 4-bit
mode, just the top 4-bits (DB4-7) are written as shown in the Figure below:
Figure 6.2: Data Transfer Using a 4-Bit Interface
6.3 Getting The LCD To Display Text:
After successfully initializing the LCD and turning the display ON, one can begin to
display messages on the LCD by sending the correct instructions to it. Getting the LCD to
display text is a two-step process. First, the LCD's cursor must be moved to the LCD address
where the character is to be displayed. This is done with the "DDRAM Address Set" command.
Second, the actual character must be written to the cursor in order to store it in the DDRAM at
the cursor's location. This is performed with the "CGRAM/DDRAM Data Write" command.
6.4 Interfacing of LCD with 89C52 Microcontroller:
In this project, the JHD 162A LCD is interfaced with the 89s52 Microcontroller. Port1
pins of 89s52 are used to read and write the data from LCD by interfacing P0.0 - P0.7 lines to
26
D0-D7 lines of LCD. Similarly Port3 pins (P3.2-P3.4) are connected to control pins of LCD i.e.
E, R/W and RS pins respectively.
6.5 16x2 Alphanumeric LCD Module Features:
Intelligent, with built-in Hitachi HD44780 compatible LCD controller and RAM
providing simple interfacing
61 x 15.8 mm viewing area
5 x 7 dot matrix format for 2.96 x 5.56 mm characters, plus cursor line
Can display 224 different symbols
Low power consumption (1 mA typical)
6.6 ADVANTAGES OF GRAPHIC LCDS
Download high quality fonts of any size, style or language easily and quickly
Create graphics using primitives such as bitmaps, pixels, lines, rectangles and bar
graphs. Software Control
Backlight & Contrast is adjustable in most models
4 different brightness settings
Line wrap and Auto screen scroll
7. REAL TIME CLOCK (RTC)
7.1 FEATURES OF DS1307:
27
Real time clock counts seconds, minutes, hours, date of month, day of week and year
with leap year compensation valid up to 2100
56 byte nonvolatile RAM for general data storage
2-wrire interface (I2C)
Automatic power fail detect
Consumes less than 500 nA for battery back-up at 25'C
7.2 Connecting RTC (DS1307) with AT89S52:
The DS1307 Serial Real Time Clock is a low–power, full BCD clock/calendar plus 56
bytes of nonvolatile SRAM.
Address and data are transferred serially via the 2–wire bi–directional bus.
The clock/calendar provides seconds, minutes, hours, day, date, month, and year
information.
The end of the month date is automatically adjusted for months with less than 31 days,
including corrections for leap year.
The clock operates in either the 24–hour or 12–hour format with AM/PM indicator.
The DS1307 has a built–in power sense circuit which detects power failures and
automatically switches to the battery supply.
7.3 Circuit diagram of RTC:
Figure 7.1: Pin out diagram of DS1307
28
Figure 7.2: Circuit diagram of RTC
7.4 Two Wire Timing Interface:
Start data transfer: A change in the state of the data line from high to low, while the clock
line is high, defines a START condition. Stop data transfer: A change in the state of the data line
from low to high, while the clock line is high, defines the STOP condition.
Data valid: The state of the data line represents valid data when, after a START
condition, the data line is stable for the duration of the high period of the clock signal. The data
on the line must be changed during the low period of the clock signal. There is one clock pulse
per bit of data. Each data transfer is initiated with a START condition and terminated with a
STOP condition. The number of data bytes transferred between the START and the STOP
conditions is not limited, and is determined by the master device. The information is transferred
byte–wise and each receiver acknowledges with a ninth bit.
29
8. SERIAL COMMUNICATION
8.1Introduction:
All IBM PC and compatible computers are typically equipped with two serial ports and
one parallel port. Although these two types of ports are used for communicating with external
devices, they work in different ways.
8.2 Synchronous and Asynchronous Communications:
There are two basic types of serial communications, synchronous and asynchronous.
With synchronous communications, the two devices initially synchronize themselves to each
other, and then continually send characters to stay in sync. Even when data is not really being
sent, a constant flow of bits allows each device to know where the other is at any given time.
That is, each character that is sent is either actual data or an idle character. Synchronous
communications allows faster data transfer rates than asynchronous methods.
9 Pin Connector on a DTE device (PC connection)
Male RS232
DB9
Pin Number Direction of signal:
1 Carrier Detect (CD) (from DCE) Incoming signal from a modem
2 Received Data (RD) Incoming Data from a DCE
3 Transmitted Data (TD) Outgoing Data to a DCE
4 Data Terminal Ready (DTR) Outgoing handshaking signal
5 Signal Ground Common reference voltage
6 Data Set Ready (DSR) Incoming handshaking signal
7 Request To Send (RTS) Outgoing flow control signal
8 Clear To Send (CTS) Incoming flow control signal
9 Ring Indicator (RI) (from DCE) Incoming signal from a modem
30
The TD (transmit data) wire is the one through which data from a DTE device is transmitted to a
DCE device. The TD line is kept in a mark condition by the DTE device when it is idle. DTR stands for
Data Terminal Ready. Its intended function is very similar to the RTS line. DSR (Data Set Ready) is the
companion to DTR in the same way that CTS is to RTS. Some serial devices use DTR and DSR as
signals to simply confirm that a device is connected and is turned on.
8.3 Driver For Serial Communication:
Serial RS-232 communication works with voltages (-15V ... -3V for high) and +3V ...
+15V for lo]) which are not compatible with normal computer logic voltages. On the other hand,
microcontroller operates between 0V ... +5V. Therefore, to receive serial data from an RS-232
interface the voltage has to be reduced.
RS-232 µC Logic
-----------------------------------------------
-15V ... -3V <-> 0V <-> low
+3V ... +15V <-> 5V <-> high
RS 232:
RS-232 stands for Recommend Standard number 232 . The full RS-232C standard
specifies a 25-pin "D" connector of which 22 pins are used. Most of these pins are not needed for
normal PC communications, and indeed, most new PCs are equipped with male D type
connectors having only 9 pins.
RS-232 Level Converters:
Almost all digital devices required either TTL or CMOS logic levels. Therefore the first step to
connecting a device to the RS-232 port is to transform the RS-232 levels back into 0 and 5 Volts,
this is done by RS-232 Level Converters.
31
8.4 MAX-232:
It includes a Charge Pump, which generates +10V and -10V from a single 5v supply.
This I.C. also includes two receivers and two transmitters in the same package. This is handy in
many cases when you only want to use the Transmit and Receive data Lines. You don't need to
use two chips, one for the receive line and one for the transmit.
Figure8.1: Pin Diagram of MAX232
Figure 8.2: Typical MAX-232 Circuit
32
9 RADIO FREQUENCY IDENTIFICATION (RFID)
9.1 Introduction:
RFID is the use of an object (typically referred to as an RFID tag) applied to or
incorporated into a product, animal, or person for the purpose of identification and tracking using
radio waves. Some tags can be read from several meters away and beyond the line of sight of the
reader.
RFIDs are easy to conceal or incorporate in other items. For example, in 2009 researchers
at Bristol University successfully glued RFID micro transponders to live ants in order to study
their behavior. This trend towards increasingly miniaturized RFIDs is likely to continue as
technology advances. However, the ability to read at distance is limited by the inverse-square
law.
RFID is becoming increasingly prevalent as the price of the technology decreases.
Governments use RFID applications for traffic management, while automotive companies use
various RFID tracking solutions for product management. Many of these solutions may work
together in the future, though privacy regulations prevent many initiatives from moving forward
at the same pace that technology allows.
9.2 Components of RFID System:
An RFID system consists of RFID tags, a means of reading or interrogating the tags
and a means of communicating the data to a host computer or information management system.
The system will also include a facility for entering or programming data into tags, if it is not
done at the source by the manufacturer. There may also be present antennas for communication
between the tag and the reader.
A typical RFID system is made up of three components:
1. Tags,
2. Readers
3. Host computer system.
33
9.2.1 RFID Tags:
An RFID tag is a tiny radio device that is also referred to as a transponder, smart tag, smart
label or radio barcode. The word transponder is derived from the words transmitter and
responder. The tag responds to a transmitted or communicated request for the data it carries. The
tag comprises a simple silicon microchip (typically less than half a millimeter in size) attached to
a small flat aerial and mounted on a substrate.
The transponder memory may comprise of read-only (ROM), random access (RAM), and
non-volatile programmable memory for data storage depending on the type and sophistication of
the device. The ROM-based memory is used to accommodate security data and the transponder
operating system instructions. The RAM-based memory is used for temporary data storage
during transponder interrogation and response.
TYPES OF RFID TAGS
On the basis of the presence of battery, tags can be classified into
Active tags
Passive tags.
9.2.2 Readers:
The reader, sometimes called an interrogator or scanner, sends and receives RF
data to and from the tag via antennae. A reader may have multiple antennae that are responsible
for sending and receiving radio waves.
The readers can be fixed or mobile, can read information stored on the tags and write
information to them. This can be achieved without direct line of sight and in environments where
traditional data collection could not operate. A major advantage is that information can be
written to the tag multiple times so storing a history that travels with the article.
34
Once the signal from a transponder has been correctly received and decoded, algorithms
can be applied to decide whether the signal is a repeat transmission and may then instruct the
transponder to stop transmitting. This is known as Command Response Protocol and is used to
circumvent the problem of reading multiple tags in a short span of time.
9.3 RFID Tag Data Format:
Figure 9.1 RFID Tag Data Format
Printed barcode labels generally conform to the Universal Product Code standard (UPC)
of product identification. RFID tags used to identify products in the supply chain serve the same
purpose, so it’s often expeditious to explain RFID tags simply as ʺelectronic barcodes.ʺ Both
RFID tags and barcode labels digitally convey information about objects. Currently, ʺClass 1+ʺ
RFID tags are available with a digital memory of 96 bits, each bit being either logic 1 or a logic
0. Because alphanumeric characters (i.e., A‐to‐Z and 0‐9) each require 8 bits of memory, it’s
possible to store 12 characters in an RFID tag (which isn’t saying much). On the other hand
those 96 bits represent a possible 79,228,162,514,264,300,000,000,000,000 (that’s over 79.2
trillion) unique numerical identities. Or you could split the 96 bits into fields that each represents
some characteristic of the object, creating a sort of family tree of objects.
35
9.4 Frequency Range of RFID:
There are several versions of RFID that operate at different radio frequencies. The choice
of frequency is dependent on the business requirements and read environment – it is not a
technology where ‘one size fits all’ applications.
Three primary frequency bands are being used for RFID:
Low Frequency (125/134KHz) – Most commonly used for access control, animal
tracking and asset tracking.
High -Frequency (13.56 MHz) – Used where medium data rate and read ranges up to
about 1.5 meters are acceptable. This frequency also has the advantage of not being
susceptible to interference from the presence of water or metals.
Ultra High-Frequency (850 MHz to 950 MHz) – offer the longest read ranges of up to
approximately 3 meters and high reading speeds.
9.5 Principle of Working:
In the RFID system, the reader sends out a radio frequency wave to the tag and the tag
broadcasts back its stored data to the reader. The system has two antennas, one for the tag and
the other on the reader. The data collected from the tag can either be sent directly to a host
computer through standard interfaces or it can be stored in a portable reader and later updated to
the computer for data processing. The automatic reading and direct use of tag data is called
‘automatic data capture’.
When the tag which is battery free, is to be read, the reader sends out a power pulse to the
antenna lasting for about 50ms.The magnetic field generated is collected by the antenna in the
transponder that is tuned to the same frequency. This received energy is rectified and stored on a
capacitor within the transponder.
When the power pulse has finished, the transponder immediately transmits back its data,
using the energy stored within its capacitor as its power source. The data is picked up by the
receiving antenna and decoded by the reader unit.
36
Once all the data has been transmitted, the storage capacitor is discharged resetting the
transponder to make it ready for the next read cycle. The period between transmission pulses is
called sync time and lasts between 20ms and 50ms depending on the system set up.
Figure 9.2 Working Of RFID System
The scanning antennas can be permanently affixed to a surface; handheld antennas are
also available. They can take whatever shape you need; for example, you could build them into a
door frame to accept data from persons or objects passing through. When an RFID tag passes
through the field of the scanning antenna, it detects the activation signal from the antenna. That
"wakes up" the RFID chip, and it transmits the information on its microchip to be picked up by
the scanning antenna.
9.6 Advantages:
37
RFID technology permits no line of sight reading.
Robustness and reliability under difficult environmental conditions.
These tags can be read through water, snow, concrete, bricks, plastics, wood, and most
non-metallic materials
Available in a wide variety of physical forms, shapes, sizes and protective housings.
RFID tags can be read at very high speeds.
The tag need not be on the surface of the object (and is therefore not subject to wear).
The read time is typically less than 100 milliseconds
Large numbers of tags can be read at once rather than item by item.
9.7 Applications:
Principle areas of applications of RFID include:
1. Transportation
2. Manufacturing and processing.
3. Security.
Texas Instruments Radio Frequency Identification (TI-RFid) Systems has introduced its
new RFID tag for textile rental and dry cleaning applications. TI-RFid tags provide more
accurate identification and greater accountability as well as improved handling through each
stage of cleaning and processing to final customer delivery.
RFID system allows booksellers to gain such information as the range of books a shopper
has browsed, the number of times a particular title was picked up, and even the length of time
spent flipping through pages. The shelves can scan the contents of the shelves and, via computer,
alert store employees when supplies are running low or when theft is detected.
38
10 GLOBAL SYSTEM FOR MOBILE
COMMUNICATIONS (GSM)
10.1 History Of GSM
The proposed system had to meet certain criteria:
Good subjective speech quality
Low terminal and service cost
Support for international roaming
Ability to support handheld terminals
Support for range of new services and facilities
Spectral efficiency
ISDN compatibility
And interaction with the integrated service digital network (ISDN) which offers the
capability to extend the single-subscriber –line system with the various to a multiservice
system. The first commercial GSM system, called D2, was implemented in Germany in
1982.This valuable channel of communication can equip us with a powerful tool for
controlling desired device or process parameter from distant location, through
electromagnetic waves. With a little effort logic can be setup to even receive a feedback on
the status of the device or the process being controlled.
10.2 Architecture Of The GSM Network:
A GSM network is composed of several functional entities, whose functions and
interfaces are specified. Figure 1.1 shows the layout of a generic GSM network. The GSM
network can be divided into three broad parts. The Mobile Station is carried by the subscriber.
The Base Station Subsystem controls the radio link with the Mobile Station. The Mobile Station
and the Base Station Subsystem communicate across the Um interface, also known as the air
39
interface or radio link. The Base Station Subsystem communicates with the Mobile services
Switching Center across the A interface.
Figure 10.1 General Architecture of a GSM Network
10.2.1 Mobile Station:
The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card
called the Subscriber Identity Module (SIM). The SIM provides personal mobility, so that the
user can have access to subscribed services irrespective of a specific terminal. By inserting the
SIM card into another GSM terminal, the user is able to receive calls at that terminal, make calls
from that terminal, and receive other subscribed services.
10.2.2 Base Station Subsystem:
The Base Station Subsystem is composed of two parts, the Base Transceiver Station
(BTS) and the Base Station Controller (BSC). These communicate across the standardized Abis
interface, allowing (as in the rest of the system) operation between components made by
different suppliers.
10.2.3 Network Subsystem:
The central component of the Network Subsystem is the Mobile services Switching
Center (MSC). It acts like a normal switching node of the PSTN or ISDN, and additionally
40
provides all the functionality needed to handle a mobile subscriber, such as registration,
authentication, location updating, handovers, and call routing to a roaming subscriber.
10.3 GSM Modem:
GSM Modem Product, from Sparr Electronics limited (SEL), provides full functional
capability to Serial devices to send SMS and Data over GSM Network. The product has SIM
Card holder to which activated SIM card is inserted for normal use. The power to this unit can be
given from UPS to provide uninterrupted operation.
10.4 Application Areas:
Mobile Transport vehicles.
LAN based SMS servers
Alarm notification of critical events including Servers
Network Monitoring and SMS reporting
Data Transfer applications from remote locations
Monitor and control of Serial services through GSM Network
Integration to custom software for Warehouse, Stock, Production.
AMR- Automatic Meter Reading and many more…
10.5 Pin Outs And Details:
Figure10.2: Pin out and Details
41
Serial Port D-Type 9 pin connector which is male on the back of the GSM modem, thus you will
require a female connector on your device. Below is a table of pin connections for the 9 pin D-
Type connector.
Pin
No.
Abbreviation Full Name
Pin 3 TD Transmit Data
Pin 2 RD Receive Data
Pin 7 RTS Request To Send
Pin 8 CTS Clear To Send
Pin 6 DSR Data Set Ready
Pin 5 SG Signal Ground
Pin 1 CD Carrier Detect
Pin 4 DTR Data Terminal Ready
Pin 9 RI Ring Indicator
10.6 Short Message Commands:
10.6.1 Parameters Definition:
<da> Destination Address, coded like GSM 03.40 TP-DA
<dcs> Data Coding Scheme, coded like in document [5].
<dt> Discharge Time in string format :
42
“yy/MM/dd,hh :mm :sszz”(Year [00-99], Month [01-12], Day [01-31], Hour,
Minute, Second and Time Zone [quarters of an hour] )
<fo> First Octet, coded like SMS-SUBMIT first octet in document [4], default value is
17 for SMS-SUBMIT
<Index> Place of storage in memory.
<length> Text mode (+CMGF=1): number of characters PDU mode (+CMGF=0): length of
the TP data unit in octets
<mem1> Memory used to list, read and delete messages (+CMGL, +CMGR and +CMGD).
<mem2> Memory used to write and send messages (+CMGW, +CMSS).
<mid> CBM Message Identifier.
<mr> Message Reference.
<oa> Originator Address.
<pid> Protocol Identifier.
<pdu> For SMS : GSM 04.11 SC address followed by GSM 03.40 TPDU in hexadecimal
format, coded as specified in doc [4] For CBS : GSM 03.41
<ra> Recipient Address.
<sca> Service Center Address
<scts> Service Center Time Stamp in string format :
“yy/MM/dd,hh :mm :ss zz”
(Year/Month/Day, Hour: Min: Seconds Time Zone)
<sn> CBM Serial Number
43
<st> Status of a SMS-STATUS-REPORT
<stat> Status of message in memory.
<tooa> Type-of-Address of <oa>.
<tora> Type-of-Address of <ra>.
<tosca> Type-of-Address of <sca>.
<total1> Number of message locations in <mem1>.
<total2> Number of messages locations in <mem2.
<used1> Total number of messages locations in <mem1>.
<used2> Total number of messages locations in <mem2.
<vp> Validity Period of the short message, default value is 167
10.7 READ MESSAGE +CMGR:
Command syntax: AT+CMGR=<index>
Response syntax for text mode:
+CMGR :< stat>, <oa>,[<alpha>,] <scts> [,<tooa>,<fo>,
<pid>,<dcs>,<sca>,<tosca>,<length>] <CR><LF> <data> (for SMS MS MS-DELIVER only)
+CMGR : <stat>,<da>,[<alpha>,] [,<toda>,<fo>,<pid>,<dcs>, [<vp>], <sca>,
<tosca>,<length>]<CR><LF> <data> (for SMS-SUBMIT only)
+CMGR : <stat>,<fo>,<mr>,[<ra>],[<tora>],<scts>,<dt>,<st> (for SMS SMS- STATUS-
REPORT only)
Response syntax for PDU mode:
44
+CMGR: <stat>, [<alpha>] ,<length> <CR><LF> <pdu>
A message read with status “REC UNREAD” will be updated in memory with the status “REC
READ”.
Note :
the <stat> parameter for SMS Status Reports is always “READ”.
10.8 SEND MESSAGE +CMGS:
Command syntax in text mode:
AT+CMGS= <da> [ ,<toda> ] <CR>
text is entered <ctrl-Z / ESC >
Command syntax in PDU mode :
AT+CMGS= <length> <CR>
PDU is entered <ctrl-Z / ESC >
The message reference, <mr>, which is returned to the application is allocated by the product. This
number begins with 0 and is incremented by one for each outgoing message (successful and failure
cases); it is cyclic on one byte (0 follows 255).
Note:
this number is not a storage number – outgoing messages are not stored.
45
11 LED AND SWITCHES
11.1 LED
A light-emitting diode (LED) is an electronic light source. LEDs are based on the
semiconductor diode. When the diode is forward biased, electrons are able to recombine with
holes and energy is released in the form of light. This effect is called electroluminescence and
the color of the light is determined by the energy gap of the semiconductor. The LED is usually
small in area with integrated optical components to shape its radiation pattern and assist in
reflection. Applications of LEDs are diverse. They are used as low-energy and also for
replacements for traditional light sources in well-established applications such as indicators and
automotive lighting. 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 communications
technology.
Figure 11.1: Led
Led’s are connect to the ports of microcontroller by using transistors and resisters.
Transistor is used to decrease power dissipation and Led’s are glow from external supply instead
of microcontroller.
46
11.2 SWITCH
In this project Switch is used for editing of time and calendar
Figure 11.2: Switches
In electronics, a switch is an electronic electronics, a switch is an electrical
component that can break an electrical circuit, interrupting the current or diverting it from
one conductor to another. The most familiar form of switch is a manually operated
electromechanical device with one or more sets of electrical contacts. Each set of contacts
can be in one of two states: either 'closed' meaning the contacts are touching and electricity
can flow between them, or 'open', meaning the contacts are separated and non conducting. In
this at the time of switch pressed (supply applied) the voltage across resister 8.2Kohms is
VCC as capacitor is short circuit. And these switches are connected to LEDs by using
microcontroller program. When we release the switch the capacitor get charges to VCC.
Figure 11.3: Internal Circuit Of A Manual Switch
47
12 SOFTWARE DESCRIPTIONS AND CODING
12.1 Introduction:
The software coding required to perform the control operations of AT89s52 micro
controller developed was coded with the help of Keil Cx51 Complier package. Keil Cx51
Complier compiles the program written and checks for errors in the program. Then, the compiler
generates a filename.hex file that can be burnt in EPROM of 89S52 Microcontroller. Finally the
error free compiled filename.hex file was burnt into the CPU memory with the help of Keil
Programmer.
12.2 Software Used: Embedded C or Assembly Language.
12.3 Tools Used: Keil uv2 IDE.
12.3.1 Introduction To KeilCx51 Complier:
The Cx51 Complier package may be used on all 8051 family processors and is executable
under the Windows 32-bit command line prompt. The C programming language is a general-
purpose programming language that provides code efficiency, elements of structured
programming and a rich set of operators. C is not a big language and is not designed for a
particular area of application. Some code of the C programming language and standard libraries
are altered or enhanced as the peculiarities of an embedded processor.
48
Figure 12.1 Development tools in Keil Software
12.3.2 Compiling with the Cx51 Compiler:
The directives below allow compiling of the Cx51 compiler. Control directives can be
divided into three groups: Source controls, Object controls and Listing controls. Source controls
define macros on the command line and determine the name of the file to be complied. Listing
controls govern various aspects of the listing file (*.LST), in particular its format and specific
content.
12.3.3 Running Cx51 from the Command Prompt:
To invoke the C51 or Cx51 compiler, enter C51 or Cx51 at the command prompt. On the
command line, the name of the C source file to be compiled as well as other necessary control
directives required to compile the source file must be included. The format for the Cx51
command line is:
C51 sourcefile_directives..._
Cx51 sourcefile_directives.... _
OR
C51 @commandfile
Cx51 @commandfile
Where:
Source file is the name of the source program you want to compile.
Directives are the directives we want to use to control the function of the command.
Commandfile is the name of a command input file that may contain source file and directives. A
commandfile is used, when the Cx51 invocation line gets complex and exceeds the limits of the
windows command prompt.
The Cx51 complier displays the following information upon successful compilation:
49
C51 COMPLIER V6.10
C51 COMPILATION COMPLETE 0 WARNING (S), 0 ERROR (S)
0 ERROR LEVEL
After the compilation, the number of errors and warnings detected is the output to the screen.
The Cx51 complier then sets the ERRORLEVEL to indicate the status of compilation. As shown
below:
ERRORLEVEL MEANING
0 No errors or warnings
1 Warnings only
2 Errors and possible warnings
3 Fatal errors
12.3.4 Cx51 Output Files:
The Cx51 complier generates a number of output files during compilation. By default
each of these output files shares the same filename as the source file. However, each has a
different file extension. The following lists the files and gives a brief description of each: File
filename.LST: -
Files with this extension are listing files that contain the formatted source text along with any
errors detected by the compiler. Listing files may optionally contain the symbols used and the
assembly code generated.
filename.OBJ: -
50
Files with this extension are object modules that contain reloadable object code. The Lx51
Linker/Locator may link object modules to an absolute object module.
Filename. I: -
Files with this extension contain the source text as expanded by the preprocessor. All macros are
expanded and all comments are deleted in this listing.
filename.SRC: -
Files with this extension are assembly source files generated from your C source code. These
files can be assembled with the A51 assembler.
12.3.5 Debugging:
When micro-Vision2 IDH and the micro-Vision2 Debugger is being used, complete
debug information is obtained when Options for Target - Output - Debug information is
obtained. For command line tools the following rules apply. By default, the C51 complier uses
the Intel Object Format (OFM2) for object files and generates complete symbol information. All
Intel compatible emulators may be used for program debugging. The DEBG directive embeds
debugging information in the object file. In addition, the OBJECTEXTEND directive embeds
additional variable type information in the object file that allows type specific display of
variables and structures when using certain emulators. The Cx51 complier uses the OFM2 object
file format. The Cx51 complier also uses the OFM2 format when the directive OFM2 is active.
The OFM2 format requires the extended Lx51 linker/locator and cannot be used with the BL51
linker/locator.
12.3.6 Complier Limits:
The Cx51 complier embodies some known limitations that are listed below. For the most part,
there are no limits with respect to components of the C language. If there is enough address space, several
thousand symbols could be defined. A maximum of 19 levels of indirection (access modifiers) to any
standard data type are supported. This includes array descriptors, indirection operators and function
descriptors. Instruction blocks ({...}) may be nested up to 15 levels deep. Macros may be nested up to 8
levels deep. A maximum of 32 parameters may be passed into a macro or function call. The maximum
51
length of a line or a macro definition is 2000 characters. Even after a macro expansion the result may not
exceed 2000 characters.
13. SOURCE CODE
#include<reg52.h>
#include<string.h>
#define LCD P0
sbit clk=P2^1;
sbit dat=P2^0;
sbit SEL = P3^4;
sbit INC = P3^5;
sbit DEC = P3^6;
sbit EXIT = P3^7;
int i=0;
bit flag = 0;
bit t_flag=0;
bit receive=0;
char k;
unsigned char buff[10];
unsigned char
hour0,hour1,minute0,minute1,date0,date1,mon0,mon1,year0,year1='0'
;
void send_byte(unsigned char);
52
unsigned char receive_byte(unsigned char);
void write_i2c(unsigned char,unsigned char,unsigned char);
unsigned char read_i2c(unsigned char,unsigned char);
void edit_hrs(unsigned char ,unsigned char,unsigned char);
void edit_week(unsigned char ,unsigned char,unsigned char);
void init_lcd(void);
void cmd_lcd(unsigned char);
void data_lcd(unsigned char);
void display_lcd(unsigned char *);
void delay_ms(int);
void serial_send(unsigned char);
void SEND_STR(unsigned char *);
void send_data(void);
void time(void);
void edit_time(void);
char code *month[] =
{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV
","DEC"};
unsigned char day[] = {31,28,31,30,31,30,31,31,30,31,30,31};
char code *week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
unsigned char key_code;
53
char code *menu[] = {" EDIT TIME "};
void ext_int0(void) interrupt 0
{
if(SEL == 0)
key_code = 0x80;
else if(INC == 0)
key_code = 0x40;
else if(DEC == 0)
key_code = 0x20;
else if(EXIT == 0)
key_code = 0x10;
while((P3 & 0xF0) != 0xF0);
}
void serial_int(void)interrupt 4
{
if(RI)
{
receive=1;
RI = 0;
54
if(k<12)buff[k++]=SBUF;
}
else
{
t_flag=1;
TI=0;
}
}
void main()
{
int i,sita,cm,suresh=0;
init_lcd();
display_lcd(" RFID BASED ");
cmd_lcd(0xC0);
display_lcd("ATTANDACE SYSTEM ");
delay_ms(100);
cmd_lcd(0x01);
SCON = 0x50;
TMOD = 0x20;
TH1 = -3;
TR1 = 1;
55
write_i2c(0xD0,0x00,0x00);
key_code = 0x00;
i = 0;
while(1)
{
flag=0;
lable: time();
if(receive==1)
{
cmd_lcd(0x01);
for(i=0;i<12;i++);
cmd_lcd(0x01);
k=0;
buff[i]='\0';
if(strcmp(buff,"1C00A5A1E7FF"))
{
strcpy(buff,"D.VYSALI ");
cmd_lcd(0x01);
cm=cm+1;
if(cm%2==1)
56
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("917382374997");
serial_send('"');
SEND_STR("\r\n");
SEND_STR("D.VYSALI ID:08NT1A0411...IN");
serial_send(hour0);
serial_send(hour1);
serial_send(':');
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
serial_send(date1);
serial_send('/');
serial_send(mon0);
57
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
}
else
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("917382374997");
serial_send('"');
SEND_STR("\r\n");
SEND_STR("D.VYSALI ID:08NT1A0411...OUT");
serial_send(hour0);
58
serial_send(hour1);
serial_send(':');
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
serial_send(date1);
serial_send('/');
serial_send(mon0);
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
cmd_lcd(0x01);
}
}
else if(strcmp(buff,"41007641C0B6"))
{
59
strcpy(buff,"P.TEJA KUMAR");
sita=sita+1;
if(sita%2==1)
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("919573477552");
serial_send('"');
SEND_STR("\r\n");
SEND_STR("P.TEJA KUMAR ID:08NT1A0438 ..IN");
serial_send(hour0);
serial_send(hour1);
serial_send(':');
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
60
serial_send(date1);
serial_send('/');
serial_send(mon0);
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
cmd_lcd(0x01);
}
else
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("919573477552");
61
serial_send('"');
SEND_STR("\r\n");
SEND_STR("P.TEJA KUMAR ID:08NT1A0438 ..OUT");
serial_send(hour0);
serial_send(hour1);
serial_send(':');
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
serial_send(date1);
serial_send('/');
serial_send(mon0);
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
cmd_lcd(0x01);
62
} }
else if(strcmp(buff,"1C00A5A68E91"))
{
strcpy(buff,"K.NAVEEN KUMAR");
sita=sita+1;
if(sita%2==1)
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("919490009788");
serial_send('"');
SEND_STR("\r\n");
SEND_STR("K.NAVEEN KUMAR ID:09NT5A0403 ..IN");
serial_send(hour0);
serial_send(hour1);
serial_send(':');
63
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
serial_send(date1);
serial_send('/');
serial_send(mon0);
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
cmd_lcd(0x01);
}
else
{
cmd_lcd(0xc0);
display_lcd(buff);
cmd_lcd(0x80);
64
display_lcd("SENDING SMS........");
SEND_STR("AT+CMGS=");
serial_send('"');
SEND_STR("919490009788");
serial_send('"');
SEND_STR("\r\n");
SEND_STR("K.NAVEEN KUMAR ID:09NT5A0403 ..OUT");
serial_send(hour0);
serial_send(hour1);
serial_send(':');
serial_send(minute0);
serial_send(minute1);
SEND_STR(" ");
serial_send(date0);
serial_send(date1);
serial_send('/');
serial_send(mon0);
serial_send(mon1);
serial_send('/');
serial_send(year0);
serial_send(year1);
65
SEND_STR("\r\n");
serial_send(0x1A);
delay_ms(500);
cmd_lcd(0x01);
}
}
receive=0;
}
if(key_code == 0x80)
{
do{
cmd_lcd(0x01);
display_lcd(menu[i]);
break;
}while(key_code = 0x80);
if(key_code==0x10)
goto lable;
if(i == 0)
{
66
edit_time();
}
}
i = 1;
}
}
void init_lcd(void)
{
cmd_lcd(0x38);
cmd_lcd(0x0C);
cmd_lcd(0x06);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char var)
{
LCD = ((var & 0xF0) | 0x08);
LCD = 0;
LCD = ((var << 4) | 0x08);
LCD = 0;
67
delay_ms(2);
}
void data_lcd(unsigned char var)
{
LCD = ((var & 0xF0) | 0x0a);
LCD = 0;
LCD = ((var << 4) | 0x0a);
LCD = 0;
delay_ms(2);
}
void display_lcd(char *str)
{
while(*str)
data_lcd(*str++);
}
void delay_ms(int cnt)
{
int i;
while(cnt--)
for(i=0;i<500;i++);
68
}
void time(void)
{
//unsigned char base_addr = 0x20;
cmd_lcd(0x80);
data_lcd((read_i2c(0xD0,0x02)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x02) % 0x10) + 0x30);
hour0=(read_i2c(0xD0,0x02)/0x10)+0x30 ;
hour1=(read_i2c(0xD0,0x02)%0x10)+0x30 ;
data_lcd(':');
data_lcd((read_i2c(0xD0,0x01)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x01) % 0x10) + 0x30);
minute0=((read_i2c(0xD0,0x01)/0x10) + 0x30);
minute1=((read_i2c(0xD0,0x01)%0x10) + 0x30);
data_lcd(':');
data_lcd((read_i2c(0xD0,0x00)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x00) % 0x10) + 0x30);
display_lcd(" ");
display_lcd(week[read_i2c(0xD0,0x03)]);
data_lcd(' ');
data_lcd(' ');
69
data_lcd(' ');
cmd_lcd(0XC0);
data_lcd((read_i2c(0xD0,0x04)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x04) % 0x10) + 0x30);
date0=((read_i2c(0xD0,0x04)/0x10) + 0x30);
date1=((read_i2c(0xD0,0x04)%0x10) + 0x30);
data_lcd('/');
data_lcd((read_i2c(0xD0,0x05)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x05) % 0x10) + 0x30);
mon0=((read_i2c(0xD0,0x05)/0x10) + 0x30);
mon1=((read_i2c(0xD0,0x05)%0x10) + 0x30);
data_lcd('/');
data_lcd((read_i2c(0xD0,0x06)/0x10) + 0x30);
data_lcd((read_i2c(0xD0,0x06) % 0x10) + 0x30);
year0=((read_i2c(0xD0,0x06)/0x10) + 0x30);
year1=((read_i2c(0xD0,0x06)%0x10) + 0x30);
data_lcd(' ');
data_lcd(' ');
data_lcd(' ');
data_lcd(' ');
data_lcd(' ');
70
data_lcd(' ');
data_lcd(' ');
data_lcd(' ');
data_lcd(' ');
}
void edit_time(void)
{
unsigned char var;
flag=1;
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT HRS : ");
edit_hrs(0,23,02);
}
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT MINS");
edit_hrs(0,59,01);
}
71
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT WEEK");
edit_hrs(0,6,3);
}
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT YEAR");
edit_hrs(0,99,6);
}
var = read_i2c(0xD0,0x06);
if((var % 4) == 0)
day[1] = 29;
else
day[1] = 28;
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT MONTH");
72
edit_hrs(1,12,5);
}
if(flag==1)
{
cmd_lcd(0x01);
display_lcd("EDIT DAY");
edit_hrs(1,day[i],4);
}
key_code = 0x00;
write_i2c(0xD0,0x00,0x00);
cmd_lcd(0x01);
}
void edit_hrs(unsigned char MIN,unsigned char MAX,unsigned char
addr)
{
int temp,val;
val = read_i2c(0xD0,addr);
temp = val;
if(key_code == 0x40)
73
{
temp++;
if(temp > MAX)
temp = MIN;
}
else if(key_code == 0x20)
{
temp--;
if(temp < MIN)
temp = MAX;
}
}
void SEND_STR(unsigned char *s)
{
while(*s)
serial_send(*s++);
}
void serial_send(unsigned char buf)
{
t_flag= 0;
SBUF = buf;
74
while(t_flag == 0);
}
14 FINAL OUTPUTS
In Ideal state, i.e. when no RFID tag is placed on the reader, the present date, time and calendar
is displayed on the LCD screen.
Figure 14.1: Idle Display Of LCD
When Tag of D.Vysali Is placed,
Figure 14.2: LCD when student1 Enters
75
When Tag of P Teja Kumar is placed,
Figure 14.3: LCD when student2 Enters
When Tag of K Naveen Kumar is placed,
Figure 14.4: LCD when student3 Enters
76
15. CONCLUSION AND FUTURE SCOPE
15.1 CONCLUSION:
The project “RFID AND GSM BASED STUDENT ATTENDANCE SYSTEM” has
been successfully designed and tested.
It has been developed by integrating features of all the hardware components used.
Presence of every module has been reasoned out and placed carefully thus contributing to the
best working of the unit. Thus the data to be sent is encoded within the transmitted signal so
that a well designed receiver can separate the data from the signal upon reception of this
signal. The decoded data can then be used to perform specified tasks.
Secondly, using highly advanced IC’s and with the help of growing technology the
project has been successfully implemented.
This is a very useful technique over present conventional attendance systems. By using
Microcontroller, we controlled the system according to zones .It is mainly useful in attendance
system dealing with large number of people.
77
Finally by using these systems human work has been reduced and also errors in
attendance system are also avoided.
15.1.1 Advantages:
It can also used in industries, colleges, police people, fire stations, hospitals.
We can control the home appliances by sending a SMS to programmed home automation kit
with coded instructions by the authenticated programmer simultaneously we will get a
feedback and the status of the device. Since we have an option of Roaming Service provided
by the GSM service providers hence we can get SMS at any place on the earth.
We can Switch ON/OFF the devices by sending a SMS from any place in the world.
It is cheaper when compared to the other type of automation system.
It is more effective when compared to the other type of automation system
15.1.2 Disadvantages:
It requires a continuous electrical power supply for its proper working
We have to continuously recharge the GSM SIMCARD.
Maintenance cost is high i.e. service charges are more per SMS.
If the SIM gets damaged we need to reprogram with other number for security purposes
because the cost depends on the service provider.
15.2 Future Scope:
In our project we used GSM module to intimate the parents about the arrival of the
student to college/student. It doesn’t allow the wrong attendance or errors.
By adding GSM we can enhance the services provided by the system. As GSM is used
worldwide, coverage area for this application is vast.
An implementation of this system in large scale we can reduce the human work as well as
time. Cost of the system can be reduced over the mass production of the unit.
78
17 BIBLIOGRAPHIES
1. Design with PIC Microcontrollers-John B.Peatman, Pearson Education, 2005.
2. An Embedded System Primer-David E.Simon, Pearson Ed., 2005.
3. Wireless communications Principles & Practice-Theodore, S.Rappaport, PHI, 2ndEdn.
2002.
4. Mobile Cellular Telecommunocations-W.C.Y.Lee, MC Graw Hill, 2nd Edn, 1989.
REFERENCES
1. www.electronicstutorials.com
2. www.aimglobal.com
3. www.kernel.org
4. onlamp.com
79