Upload
gaus-patel
View
12
Download
0
Tags:
Embed Size (px)
DESCRIPTION
FINGUR+GSM BASED LOCKER SYSTEM
Citation preview
Student’s name: Vaibhav
INTRODUCTION
INTRODUCTION OF PROJECT:
User home security is the prime concern for every user as it provides opportunities for them to work
freely without worrying about the home security This project provides security system for the user
house . For this it take help of GSM Technology, each use will have a unique ID code for his door, which
he will needs to show while opening the door the security system will generate a unique encrypted code
for user access and will SMS it to user with the help of GSM module attached, use will need to enter this
code in order to open the door, otherwise the door will be locked and the access s denied by the system.
.
Block Diagram and Description:
Block Diagram
MICROCONTROLLER
LCD DISPLAY
GSMMODULE
POWER SUPPLY
FINGURPRINT
MODEM
DOOR MOTOR
GSMNETWORK
USERCELLPHONE
MOTORDRIVER
RS-232
RS-232
KEYPAD
Description:
Mobile Phone
In this project we have used one cell phones for user on which he will receive a SMS with
unique password.he cell phone will use GSM Network for communication
Microcontroller
This is the most important segment of the project, i.e. the microcontroller 8051 The controller is
responsible for detection and polling of the peripherals status. It is responsible for making. It is
responsible for prioritizing all the devices attached to it. We have used the PHILLIPS 89V51
microcontroller. The a low-power, high-performance CMOS 4-bit microcontroller with 8K
bytes of in-system programmable Flash memory. It has got 32 I/O lines, Watchdog timer, two
data pointers, two 16-bit timer/counters, six-vector two-level interrupt architecture, a full duplex
serial port, on-chip oscillator, and a clock circuitry.
GSM Modem
GSM module is used to establish communication between a computer and aGSM-GPRS system.
Global System for Mobile communication (GSM) is an architecture used for mobile
communication in most of the countries. Global Packet Radio Service (GPRS) is an extension of
GSM that enables higher data transmission rate. GSM module consists of a GSM modem
assembled together with power supply circuit and communication interfaces (like RS-232, USB,
etc) for computer. The MODEM is the soul of such modules.
LCD
We have used 16*2 LCD in order to display the user information.
Door Motor and:
We have used a DC motor for door i
Circuit diagram & Description
Specification of Components used:
. ARM LPC 2148
It is the heart of the entire system and used for data analysis and storage. It will capture the all the answers feed by users and will do the comparison with standard answers enter by system operator. ARM7 is a generation of ARM processor designs. This generation introduced the Thumb 16-bit instruction set providing improved code density compared to previous designs. The most widely used ARM7 designs implement the ARMv4T architecture, but some implement ARMv3 or ARMv5TEJ. All these designs use a Von Neumann architecture, thus the few versions comprising a cache do not separate data and instruction caches.
The NXP (founded by Philips) LPC2148 is an ARM7TDMI-S based high-performance 32-bit RISC Microcontroller with Thumb extensions 512KB on-chip Flash ROM with In-System Programming (ISP) and In-Application Programming (IAP), 32KB RAM, Vectored Interrupt Controller, Two 10bit ADCs with 14 channels, USB 2.0 Full Speed Device Controller, Two UARTs, one with full modem interface. Two I2C serial interfaces, Two SPI serial interfaces Two 32-bit timers, Watchdog Timer, PWM unit, Real Time Clock with optional battery backup, Brown out detect circuit General purpose I/O pins. CPU clock up to 60 MHz, On-chip crystal oscillator and On-chip PLL.
Features and benefits
2.1 Key features
* 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
* 8 kB to 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash memory.
128-bit wide interface/accelerator enables high-speed 60 MHz operation.
* In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot
loader software. Single flash sector or full chip erase in 400 ms and programming of
256 B in 1 ms.
* EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip RealMonitor software and high-speed tracing of instruction execution.
* USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM.
In addition, the LPC2146/48 provides 8 kB of on-chip RAM accessible to USB by DMA.
* One or two (LPC2141/42 vs. LPC2144/46/48) 10-bit ADCs provide a total of 6/14
analog inputs, with conversion times as low as 2.44 s per channel.
* Single 10-bit DAC provides variable analog output (LPC2142/44/46/48 only).
* Two 32-bit timers/external event counters (with four capture and four compare
channels each), PWM unit (six outputs) and watchdog.
* Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input
An Introduction to the ARM 7 Architecture
The principle feature of the ARM 7 microcontroller is that it is a register based load-and-store architecture with a number of operating modes. While the ARM7 is a 32 bit microcontroller, it is also capable of running a 16-bit instruction set, known as “THUMB”. This helps it achieve a greater code density and enhanced power saving. While all of the register-to-register data processing instructions are single-cycle, other instructions such as data transfer instructions, are multi-cycle. To increase the performance of these instructions, the ARM 7 has a three-stage pipeline. Due to the inherent simplicity of the design and low gate count, ARM 7 is the industry leader in low-power processing on a watts per
MIP basis. Finally, to assist the developer, the ARM core has a built-in JTAG debug port and on-chip “embedded ICE” that allows programs to be downloaded and fully debugged in-system.
In order to keep the ARM 7 both simple and cost-effective, the code and data regions are accessed via a single data bus. Thus while the ARM 7 is capable of single-cycle execution of all data processing instructions, data transfer instructions may take several cycles since they will require at least two accesses onto the bus (one for the instruction one for the data). In order to improve performance, a three stage pipeline is used that allows multiple instructions to be processed simultaneously.
The pipeline has three stages; FETCH, DECODE and EXECUTE. The hardware of each stage is designed to be independent so up to three instructions can be processed simultaneously. The pipeline is most effective in speeding up sequential code. However a branch instruction will cause the pipeline to be flushed marring its performance. As we shall see later the ARM 7 designers had some clever ideas to solve this problem.
ARM-3-StagePipeline
ARM7 Programming Model
The programmer’s model of the ARM 7 consists of 15 user registers, as shown in Fig. 3, with R15 being used as the Program Counter (PC). Since the ARM 7 is a load-and-store architecture, an user program must load data from memory into the CPU registers, process this data and then store the result back
into memory. Unlike other processors no memory to memory instructions are available.
Fig 2 Load And Store Architecture
As stated above R15 is the Program Counter. R13 and R14 also have special functions; R13 is used as the stack pointer, though this has only been defined as a programming convention. Unusually the ARM instruction set does not have PUSH and POP instructions so stack handling is done via a set of instructions that allow loading and storing of multiple registers in a single operation. Thus it is possible to PUSH or POP the entire register set onto the stack in a single instruction. R14 has special significance and is called the “link register”. When a call is made to a procedure, the return address is automatically placed into R14, rather than onto a stack, as might be expected. A return can then be implemented by moving the contents of R14 into R15, the PC. For multiple calling trees, the contents of R14 (the link register) must be placed onto the stack.
.
Fig 3 User Mode Register Model
In addition to the 16 CPU registers, there is a current program status register (CPSR). This contains a set of condition code flags in the upper four bits that record the result of a previous instruction, as shown in Fig 4. In addition to the condition code flags, the CPSR contains a number of user-configurable bits that can be used to change the processor mode, enter Thumb processing and enable/disable interrupts.
Current Program Status Register and Flags
Exception and Interrupt Modes
The ARM 7 architecture has a total of six different operating modes, as shown below. These modes are protected or exception modes which have associated interrupt sources and their own register sets.
User: This mode is used to run the application code. Once in user mode the CPSR cannot be written to and modes can only be changed when an exception is generated.
FIQ: (Fast Interrupt reQuest) This supports high speed interrupt handling. Generally it is used for a single critical interrupt source in a system
IRQ: (Interrupt ReQuest) This supports all other interrupt sources in a system
Supervisor: A “protected” mode for running system level code to access hardware or run OS calls. The ARM 7 enters this mode after reset.
Abort: If an instruction or data is fetched from an invalid memory region, an abort exception will be generated
Undefined Instruction: If a FETCHED opcode is not an ARM instruction, an undefined instruction exception will be generated.
The User registers R0-R7 are common to all operating modes. However FIQ mode has its own R8 –R14 that replace the user registers when FIQ is entered. Similarly, each of the other modes have their own R13 and R14 so that each operating mode has its own unique Stack pointer and Link register. The CPSR is also common to all modes. However in each of the exception modes, an additional register - the saved program status register (SPSR), is added. When the processor changes the current value of the CPSR stored in the SPSR, this can be restored on exiting the exception-mode.
Fig 5 Full Register Set For ARM 7
Entry to the Exception modes is through the interrupt vector table. Exceptions in the ARM processor can be split into three distinct types.
(i) Exceptions caused by executing an instruction, these include software interrupts, undefined instruction exceptions and memory abort exceptions
(ii) Exceptions caused as a side effect of an instruction such as a abort caused by trying to fetch data from an invalid memory region.
(iii) Exceptions unrelated to instruction execution, this includes reset, FIQ and IRQ interrupts.
13
Power Supply
There are many types of power supply. Most are designed to convert high voltage AC mains electricity to a
suitable DC voltage supply for electronics circuits and other devices. A power supply can by broken down into
a series of blocks, each of which performs a particular function.
A 5V regulated supply
.
Each of the blocks is described in more detail below:
Transformer - steps down high voltage AC mains to low voltage AC.
Rectifier - converts AC to DC, but the DC output is varying.
Smoothing – smoothens the DC from varying greatly to a small ripple.
Regulator - eliminates ripple by setting DC output to a fixed voltage.
14
Transformer
Transformer circuit symbol
Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work
only with AC and this is one of the reasons why mains electricity is AC.
Step-up transformers increase voltage, step-down transformers reduce voltage. Most power supplies use a step-
down transformer to reduce the dangerously high mains voltage (230V in UK) to a safer low voltage.
The input coil is called the primary and the output coil is called the secondary. There is no electrical connection
between the two coils, instead they are linked by an alternating magnetic field created in the soft-iron core of
the transformer. The two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is
stepped down current is stepped up.
The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-
down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage
mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.
Bridge rectifier
A bridge rectifier can be made using four individual diodes, but it is also available in special packages
containing the four diodes required. It is called a full-wave rectifier because it uses all the AC wave (both
positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses 0.7V when
conducting and there are always two diodes conducting, as shown in the diagram below. Bridge rectifiers are
rated by the maximum current they can pass and the maximum reverse voltage they can withstand (this must be
15
at least three times the supply RMS voltage so the rectifier can withstand the peak voltages). Please see the
Diodes page for more details, including pictures of bridge rectifier
Root Mean Square (RMS) Values
The value of an AC voltage is continually changing from zero up to the positive peak, through zero to the
negative peak and back to zero again. Clearly for most of the time it is less than the peak voltage, so this is not a
good measure of its real effect.
Instead we use the root mean square voltage (VRMS) which is 0.7 of the peak voltage (Vpeak):
VRMS = 0.7 × Vpeak and Vpeak = 1.4 × VRMS
These equations also apply to current.
They are only true for sine waves (the most common type of AC) because the 0.7 and 1.4 are different values
for other shapes.
The RMS value is the effective value of a varying voltage or current. It is the equivalent steady DC (constant)
value which gives the same effect.
16
Bridge rectifier
Alternate pairs of diodes conduct, changing over
the connections so the alternating directions of
AC are converted to the one direction of DC.
Smoothing
Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to act as a
reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The diagram
shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid line). The capacitor charges
quickly near the peak of the varying DC, and then discharges as it supplies current to the output.
17
Note that smoothing significantly increases the average DC voltage to almost the peak value (1.4 × RMS value).
For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the bridge rectifier),
with smoothing this increases to almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small ripple
voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the equation below
gives the required value for the smoothing capacitor. A larger capacitor will give less ripple. The capacitor
value must be doubled when smoothing half-wave DC.
Electrolytic Capacitors
Examples: Circuit symbol:
Electrolytic capacitors are polarised and they must be connected the correct way round, at least one of their
leads will be marked + or -. They are not damaged by heat when soldering.
There are two designs of electrolytic capacitors; axial where the leads are attached to each end (220µF in
picture) and radial where both leads are at the same end (10µF in picture). Radial capacitors tend to be a little
smaller and they stand upright on the circuit board.
18
It is easy to find the value of electrolytic capacitors because they are clearly printed with their capacitance and
voltage rating. The voltage rating can be quite low (6V for example) and it should always be checked when
selecting an electrolytic capacitor. If the project parts list does not specify a voltage, choose a capacitor with a
rating which is greater than the project's power supply voltage. 25V is a sensible minimum for most battery
circuits.
Voltage regulator
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They are
also rated by the maximum current they can pass. Negative voltage regulators are available, mainly for use in
dual supplies. Most regulators include some automatic protection from excessive current ('overload protection')
and overheating ('thermal protection').
Many of the fixed voltage regulator ICs has 3 leads and look like power transistors, such as the 7805 +5V 1A
regulator shown on the right. They include a hole for attaching a heat sink if necessary.
19
GSM MODEM
GSM/GPRS MODEM is a class of wireless MODEM devices that are designed for communication of a computer with the GSM and GPRS network. It requires a SIM (Subscriber Identity Module) card just like mobile phones to activate communication with the network. Also they have IMEI (International Mobile Equipment Identity) number similar to mobile phones for their identification. A GSM/GPRS MODEM can perform the following operations:
1. Receive, send or delete SMS messages in a SIM.
2. Read, add, search phonebook entries of the SIM.
3. Make, Receive, or reject a voice call.
The MODEM needs AT commands, for interacting with processor or controller, which are communicated through serial communication. These commands are sent by the controller/processor. The MODEM sends back a result after it receives a command. Different AT commands supported by the MODEM can be sent by the processor/controller/computer to interact with the GSM and GPRS cellular network.
GSM/GPRS Module
A GSM/GPRS module assembles a GSM/GPRS modem with standard communication interfaces like RS-232 (Serial Port), USB etc., so that it can be easily interfaced with a computer or a microprocessor / microcontroller based system. The power supply circuit is also built in the module that can be activated by using a suitable adaptor.
20
GSM
• Developed by Group Spéciale Mobile (founded 1982) which was an initiative of CEPT ( Conference of European Post and Telecommunication )
• Aim : to replace the incompatible analog system
21
• Presently the responsibility of GSM standardization resides with special mobile group under ETSI ( European telecommunication Standards Institute )
• Under ETSI, GSM is named as “ Global System for Mobile communication “
• Today many providers all over the world use GSM (more than 135
countries in Asia, Africa, Europe, Australia, America)
• More than 1300 million subscribers in world and 45 million subscriber in India.
AT Commands
AT commands are used to control MODEMs. AT is the abbreviation for Attention. These commands come from Hayes
commands that were used by the Hayes smart modems. The Hayes commands started with AT to indicate the attention
from the MODEM. The dial up and wireless MODEMs (devices that involve machine to machine communication) need
AT commands to interact with a computer. These include the Hayes command set as a subset, along with other
extended AT commands.
AT commands with a GSM/GPRS MODEM or mobile phone can be used to access following information and services:
1. Information and configuration pertaining to mobile device or MODEM and SIM card.
2 SMS services.
3. MMS services.
4. Fax services.
5. Data and Voice link over mobile network.
The Hayes subset commands are called the basic commands and the commands specific to a GSM network are called
extended AT commands.22
Types of AT Commands:
There are four types of AT commands:
AT commands' syntax
Case Sensitivity -
The AT commands are generally used in uppercase letters. However some MODEMs and mobile phones allow both uppercase and small case letters.
Single Command -
The AT commands include a prefix AT which indicates the beginning of the command to MODEM; and a carriage return which indicates the end of the command.
23
However string ‘AT’ itself is not the part of the command. For example in ATD, D is the command name not ATD.
The extended AT commands have a ‘+’ in the command name.
For example: AT+CGMI<Carriage return>
Command Line -
Multiple AT commands can be sent to MODEM in a single command line. The commands in a line are separated by a semi-colon (;).
For example: AT+CGMI; +CBS<Carriage return>
24
SMS Text mode :
Command Description
AT+CSMS Select message service
AT+CPMS Preferred message storage
AT+CMGF Message format
AT+CSCA Service centre address
AT+CSMP Set text mode parameters
AT+CSDH Show text mode parameters
AT+CSCB Select cell broadcast message types
AT+CSAS Save settings
AT+CRES Restore settings
AT+CNMI New message indications to TE
AT+CMGL List messages
AT+CMGR Read message
AT+CMGS Send message
AT+CMSS Send message from storage
AT+CMGW Write message to memory
AT+CMGD Delete message
25
3. Initial setup AT commands
We are ready now to start working with AT commands to setup and check the status of the GSM modem.
AT Returns a "OK" to confirm that modem is working
AT+CPIN="xxxx" To enter the PIN for your SIM ( if enabled )
AT+CREG? A "0,1" reply confirms your modem is connected to GSM network
AT+CSQ Indicates the signal strength, 31.99 is maximum.
4. Sending SMS using AT commands
We suggest try sending a few SMS using the Control Tool above to make sure your GSM modem can send
SMS before proceeding. Let's look at the AT commands involved ..
AT+CMGF=1 To format SMS as a TEXT message
AT+CSCA="+xxxxx" Set your SMS center's number. Check with your provider.
To send a SMS, the AT command to use is AT+CMGS ..
AT+CMGS="+yyyyy" <Enter>
> Your SMS text message here <Ctrl-Z>
The "+yyyyy" is your receipent's mobile numbe
26
5. Receiving SMS using AT commands
The GSM modem can be configured to response in different ways when it receives a SMS.
a) Immediate - when a SMS is received, the SMS's details are immediately sent to the host computer (DTE) via
the +CMT command
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,2,0,0,0 Set how the modem will response when a SMS is received
When a new SMS is received by the GSM modem, the computer (DTE) will receive the following ..
+CMT : "+61xxxxxxxx" , , "04/08/30,23:20:00+40"
This the text SMS message sent to the modem
Your computer (DTE) will have to continuously monitor the COM serial port, read and parse the message.
b) Notification - when a SMS is recieved, the host computer ( DTE ) will be notified of the new message. The computer
will then have to read the message from the indicated memory location and clear the memory location.
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,1,0,0,0 Set how the modem will response when a SMS is received
When a new SMS is received by the GSM modem, the DTE will receive the following ..
+CMTI: "SM",3 Notification sent to the computer. Location 3 in SIM memory
27
AT+CMGR=3 <Enter> AT command to send read the received SMS from modem
The modem will then send to the computer details of the received SMS from the specified memory location ( eg. 3 ) ..
+CMGR: "REC READ","+61xxxxxx",,"04/08/28,22:26:29+40"
This is the new SMS received by the GSM modem
After reading and parsing the new SMS message, the computer (DTE) should send a AT command to clear the memory
location in the GSM modem ..
AT+CMGD=3 <Enter> To clear the SMS receive memory location in the GSM mod
RS- 232 Protocol
One of the 8051s many powerful features is its integrated UART, otherwise known as a serial port. The fact that
the 8051 has an integrated serial port means that you may very easily read and write values to the serial port. If
it were not for the integrated serial port, writing a byte to a serial line would be a rather tedious process requring
turning on and off one of the I/O lines in rapid succession to properly "clock out" each individual bit, including
start bits, stop bits, and parity bits.
However, we do not have to do this. Instead, we simply need to configure the serial ports operation mode and
baud rate. Once configured, all we have to do is write to an SFR to write a value to the serial port or read the
same SFR to read a value from the serial port. The 8051 will automatically let us know when it has finished
sending the character we wrote and will also let us know whenever it has received a byte so that we can process
it. We do not have to worry about transmission at the bit level--which saves us quite a bit of coding and
processing time.
Setting the Serial Port Mode
28
The first thing we must do when using the 8051s integrated serial port is, obviously, configure it. This lets us
tell the 8051 how many data bits we want, the baud rate we will be using, and how the baud rate will be
determined.
First, lets present the "Serial Control" (SCON) SFR and define what each bit of the SFR represents:
Bit Name Bit Addres Explanation of Function
7 SM0 9Fh Serial port mode bit 0
6 SM1 9Eh Serial port mode bit 1.
5 SM2 9Dh Mutliprocessor Communications Enable (explained later)
4 REN 9Ch Receiver Enable. This bit must be set in order to receive characters.
3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and 3.
2 RB8 9Ah Receive bit 8. The 9th bit received in mode 2 and 3.
1 TI 99h Transmit Flag. Set when a byte has been completely transmitted.
0 RI 98h Receive Flag. Set when a byte has been completely received.
Additionally, it is necessary to define the function of SM0 and SM1 by an additional table:
SM0 SM1 Serial Mode Explanation Baud Rate
0 0 0 8-bit Shift Register Oscillator / 12
0 1 1 8-bit UART Set by Timer 1 (*)
1 0 2 9-bit UART Oscillator / 64 (*)
1 1 3 9-bit UART Set by Timer 1 (*)
(*) Note: The baud rate indicated in this table is doubled if PCON.7 (SMOD) is set.
The SCON SFR allows us to configure the Serial Port. Thus, well go through each bit and review its function.
The first four bits (bits 4 through 7) are configuration bits.
Bits SM0 and SM1 let us set the serial mode to a value between 0 and 3, inclusive. The four modes are defined
in the chart immediately above. As you can see, selecting the Serial Mode selects the mode of operation
29
(8-bit/9-bit, UART or Shift Register) and also determines how the baud rate will be calculated. In modes 0 and
2 the baud rate is fixed based on the oscillators frequency. In modes 1 and 3 the baud rate is variable based on
how often Timer 1 overflows. Well talk more about the various Serial Modes in a moment.
The next bit, SM2, is a flag for "Multiprocessor communication." Generally, whenever a byte has been received
the 8051 will set the "RI" (Receive Interrupt) flag. This lets the program know that a byte has been received and
that it needs to be processed. However, when SM2 is set the "RI" flag will only be triggered if the 9th bit
received was a "1". That is to say, if SM2 is set and a byte is received whose 9th bit is clear, the RI flag will
never be set. This can be useful in certain advanced serial applications. For now it is safe to say that you will
almost always want to clear this bit so that the flag is set upon reception of any character.
The next bit, REN, is "Receiver Enable." This bit is very straightforward: If you want to receive data via the
serial port, set this bit. You will almost always want to set this bit.
The last four bits (bits 0 through 3) are operational bits. They are used when actually sending and receiving
data--they are not used to configure the serial port.
The TB8 bit is used in modes 2 and 3. In modes 2 and 3, a total of nine data bits are transmitted. The first 8 data
bits are the 8 bits of the main value, and the ninth bit is taken from TB8. If TB8 is set and a value is written to
the serial port, the datas bits will be written to the serial line followed by a "set" ninth bit. If TB8 is clear the
ninth bit will be "clear."
The RB8 also operates in modes 2 and 3 and functions essentially the same way as TB8, but on the reception
side. When a byte is received in modes 2 or 3, a total of nine bits are received. In this case, the first eight bits
received are the data of the serial byte received and the value of the ninth bit received will be placed in RB8.
TI means "Transmit Interrupt." When a program writes a value to the serial port, a certain amount of time will
pass before the individual bits of the byte are "clocked out" the serial port. If the program were to write another
byte to the serial port before the first byte was completely output, the data being sent would be garbled. Thus,
the 8051 lets the program know that it has "clocked out" the last byte by setting the TI bit. When the TI bit is
set, the program may assume that the serial port is "free" and ready to send the next byte.
30
Finally, the RI bit means "Receive Interrupt." It funcions similarly to the "TI" bit, but it indicates that a byte has
been received. That is to say, whenever the 8051 has received a complete byte it will trigger the RI bit to let the
program know that it needs to read the value quickly, before another byte is read.
Setting the Serial Port Baud Rate
Once the Serial Port Mode has been configured, as explained above, the program must configure the serial ports
baud rate. This only applies to Serial Port modes 1 and 3. The Baud Rate is determined based on the oscillators
frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillator frequency divided by 12. This
means if youre crystal is 11.059Mhz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is
always the oscillator frequency divided by 64, so a 11.059Mhz crystal speed will yield a baud rate of 172,797.
In modes 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1
overflows, the higher the baud rate. There are many ways one can cause timer 1 to overflow at a rate that
determines a baud rate, but the most common method is to put timer 1 in 8-bit auto-reload mode (timer mode 2)
and set a reload value (TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.
To determine the value that must be placed in TH1 to generate a given baud rate, we may use the following
equation (assuming PCON.7 is clear).
TH1 = 256 - ((Crystal / 384) / Baud)
If PCON.7 is set then the baud rate is effectively doubled, thus the equation becomes:
TH1 = 256 - ((Crystal / 192) / Baud)
For example, if we have an 11.059Mhz crystal and we want to configure the serial port to 19,200 baud we try
plugging it in the first equation:
TH1 = 256 - ((Crystal / 384) / Baud)
TH1 = 256 - ((11059000 / 384) / 19200 )
TH1 = 256 - ((28,799) / 19200)
TH1 = 256 - 1.5 = 254.5
As you can see, to obtain 19,200 baud on a 11.059Mhz crystal wed have to set TH1 to 254.5. If we set it to 254
we will have achieved 14,400 baud and if we set it to 255 we will have achieved 28,800 baud. Thus were
stuck...
31
But not quite... to achieve 19,200 baud we simply need to set PCON.7 (SMOD). When we do this we double the
baud rate and utilize the second equation mentioned above. Thus we have:
TH1 = 256 - ((Crystal / 192) / Baud)
TH1 = 256 - ((11059000 / 192) / 19200)
TH1 = 256 - ((57699) / 19200)
TH1 = 256 - 3 = 253
Here we are able to calculate a nice, even TH1 value. Therefore, to obtain 19,200 baud with an 11.059MHz
crystal we must:
1. Configure Serial Port mode 1 or 3.
2. Configure Timer 1 to timer mode 2 (8-bit auto-reload).
3. Set TH1 to 253 to reflect the correct frequency for 19,200 baud.
4. Set PCON.7 (SMOD) to double the baud rate.
Writing to the Serial Port
Once the Serial Port has been propertly configured as explained above, the serial port is ready to be used to send
data and receive data. If you thought that configuring the serial port was simple, using the serial port will be a
breeze.
To write a byte to the serial port one must simply write the value to the SBUF (99h) SFR. For example, if you
wanted to send the letter "A" to the serial port, it could be accomplished as easily as:
MOV SBUF,#A
Upon execution of the above instruction the 8051 will begin transmitting the character via the serial port.
Obviously transmission is not instantaneous--it takes a measureable amount of time to transmit. And since the
8051 does not have a serial output buffer we need to be sure that a character is completely transmitted before we
try to transmit the next character.
The 8051 lets us know when it is done transmitting a character by setting the TI bit in SCON. When this bit is
set we know that the last character has been transmitted and that we may send the next character, if any.
Consider the following code segment:
32
CLR TI ;Be sure the bit is initially clear
MOV SBUF,#A ;Send the letter A to the serial port
JNB TI,$ ;Pause until the TI bit is set.
The above three instructions will successfully transmit a character and wait for the TI bit to be set before
continuing. The last instruction says "Jump if the TI bit is not set to $"--$, in most assemblers, means "the same
address of the current instruction." Thus the 8051 will pause on the JNB instruction until the TI bit is set by the
8051 upon successful transmission of the character.
Reading the Serial Port
Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to
read the value stored in the SBUF(99h) SFR after the 8051 has automatically set the RI flag in SCON.
For example, if your program wants to wait for a character to be received and subsequently read it into the
Accumulator, the following code segment may be used:
JNB RI,$ ;Wait for the 8051 to set the RI flag
MOV A,SBUF ;Read the character from the serial port
The first line of the above code segment waits for the 8051 to set the RI flag; again, the 8051 sets the RI flag
automatically when it receives a character via the serial port. So as long as the bit is not set the program repeats
the "JNB" instruction continuously.
Once the RI bit is set upon character reception the above condition automatically fails and program flow falls
through to the "MOV" instruction which reads the value.
33
Block Diagram Description
Fingerprint module R305
Fingerprint processing includes two parts: fingerprint enrollment and fingerprint matching (the matching can
be 1:1 or 1: N). When enrolling, user needs to enter the finger two times. The system will process the two time
finger images, generate a template of the finger based on processing results and store the template. When
matching, user enters the finger through optical sensor and system will generate a template of the finger and
compare it with templates of the finger library. For 1:1 matching, system will compare the live finger with
specific template designated in the Module; for 1: N matching, or searching, system will search the whole
finger library for the matching finger. In both circumstances, system will return the matching result, success or
failure
34
Features
Basic Power: 8-12v AC/DC
Interface: RS232.
Matching Mode: 1:1 and 1:N
Baud rate: 9600 – 115200. Default: 57600.
Storage Capacity: 256.
Average Search Time: <1sec
Image Acquire Time: <0.5sec
LCD
(Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is
very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven
35
segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no
limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed
in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data.
The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to
do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data
register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the
LCD
Pin Diagram:
in Description:
Pin No Function Name
36
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
4 Selects command register when low; and data register when high Register Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7
8-bit data pins
DB0
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
ELAYS:Relays are used throughout the automobile. Relays which come in assorted sizes, ratings, and applications, are used as
remote control switches. A typical vehicle can have 20 relays or more.
37
RELAY APPLICATIONS:
Relays are remote control electrical switches that are controlled by another switch, such as a horn switch or a
computer as in a power train control module. Relays allow a small current flow circuit to control a higher
current circuit. Several designs of relays are in use today, 3-pin, 4-pin, 5-pin, and 6-pin, single switch or dual
switches.
38
RELAY OPERATION
All relays operate using the same basic principle. Our example will use a commonly used 4 - pin relay. Relays
have two circuits: A control circuit (shown in GREEN) and a load circuit (shown in RED). The control circuit
has a small control coil while the load circuit has a switch. The coil controls the operation of the switch.
RELAY ENERGIZED (ON)
Current flowing through the control circuit coil (pins 1 and 3) creates a small magnetic field which causes the
switch to close, pins 2 and 4. The switch, which is part of the load circuit, is used to control an electrical circuit
that may connect to it. Current now flows through pins 2 and 4 shown in RED, when the relay is energized.
RELAY DE-ENERGIZED (OFF)
When current stops flowing through the control circuit, pins 1 and 3, the relay becomes de-energized. Without
the magnetic field, the switch opens and current is prevented from flowing through pins 2 and 4. The relay is
now OFF.39
RELAY OPERATION :
When no voltage is applied to pin 1, there is no current flow through the coil. No current means no magnetic
field is developed, and the switch is open. When voltage is supplied to pin 1, current flow though the coil
creates the magnetic field needed to close the switch allowing continuity between pins 2 and 4.
40
DC Motor
Geared DC motors can be defined as an extension of DC motor which already had its Insight details
demystified here. A geared DC Motor has a gear assembly attached to the motor. The speed of motor is
counted in terms of rotations of the shaft per minute and is termed as RPM .The gear assembly helps in
increasing the torque and reducing the speed. Using the correct combination of gears in a gear motor, its
speed can be reduced to any desirable figure. This concept where gears reduce the speed of the vehicle but
increase its torque is known as gear reduction. This Insight will explore all the minor and major details that
make the gear head and hence the working of geared DC motor.
External Structure
At the first sight, the external structure of a DC geared motor looks as a straight expansion over the simple DC
ones.
41
The lateral view of the motor shows the outer protrudes of the gear head. A nut is placed near the shaft which
helps in mounting the motor to the other parts of the assembly.
42
Also, an internally threaded hole is there on the shaft to allow attachments or extensions such as wheel to be
attached to the motor
43
Working of project:
Project Description
In this projectwe are concentrating on Fingerprint scanning. This module can operate in 2 modes they are Master mode and User mode. We will be using Master mode to register the fingerprints which will be stored in the ROM present on the scanner with a unique id.
When this module is interfaced to the microcontroller, we will be using it in user mode. In this mode we will be verifying the scanned images with the stored images. When coming to our application the images of the persons who are authorized to enter into the locker room will be stored in the module with a unique id. To prove that the persons are authorized to enter that area they need to scan their images.
This scanner is interfaced to 8051 microcontroller. By using this controller we will be controlling the scanning process. After the scanning has been completed. Immediately the locker will be opened. After the security system will generate a unique encrypted code for user access and will SMS it to user with the help of GSM module attached, this code is purely generated on complex software algorithm. User will need to enter this code in order to open the door, if the code matches the encrypted code system will open the door, otherwise the door will be locked and the access s denied by the system.
44
Flowchart:
45
START
USER SHOW HIS FINGUR READER SYSTEM
SYSTEM SEARCHES DATA FOR USER VALIDATION
IS USER VALID?
GENERATE PASSWORD FOR USER
STOP
SEND PASSWORD TO USER VIA SMS
OPEN THE DOOR
ISCODE VALID?
Advantages
46
1. High level of security is obtained by the use of GSM Technology
2. Security is ensured even if th unauthorized user tries to open the door with the valid user id, as the encrypted code
will only be sent to valid user cell phone
3. Low cost, easy to use
4. System can be easily modify for new users
Applications
1. Home security system
2.Peronal door security system
3.Jwellary stores
47
BILL OF MATERIAL:
Sr. No. Description Quantity Price 1 P89V51RD2 1 1802 Transformer 18 V, 0.5A 1 1203 Heat sink 1 124 LM7805 1 85 Diode 1N4007 4 86 Capacitor 1000 µf 1 77 Disc Capacitor 10 58 IC Base 40 Pin 1 189 Relimate Base 10 40
10 Relimate Connector 10 8811 Pull Up Resistance 10 K 4 812 PCB 3 70013 Reset Switch 5 514 IC Base 8 Pin 3 1615 IC Base 16 Pin 2 1216 12 V Relay 2 2017 230 v relay 1 3518 GSM Modem 1 200019 Resistance 20 1020 LM 35 Temp sensor 1 4521 LDR 1 2222 FINGUR PRINT MODEM R305 1 220023 transistor Bc 547 5 1824 transistor Bc 557 5 1825 Heat Sink 1 826 LCD 1 15027 DC Motor 1 5028 LED 5 529 Keypad 1 100
TOTAL AMOUNT 6000
48
Bibliography:
REFERENCE BOOKS:-
The 8051 microcontroller :- Kenneth Ayala
The 8051 microcontroller and Embedded systems :- Muhammad Ali Mazidi
WEB-SITES:-
www.datasheetarchieve.com
www.maxim-ic.com
www.alldatasheet.com/
www.nxp.com/-Philips
49