electronic toll collection sysem based on rfid

120
1. INTRODUCTION Radio-frequency Identification (RFID) is an automatic identification method, relying/storing and remotely retrieving data using called RFID tags (Transporters). An RFID tag is an object that can imbibe into a product, animal, or person for the purpose of identification using radio waves. Some tags can be read from several meters and also can be used beyond the line of sight of the reader. The model developed uses an active RFID technology and wireless communicator as it helps to improve data transfer between the tag and the host database over a long distance. The main objective of this module development is to implement an automated check in and checkout in Electronic Toll collection system. Electronic toll collection system (ETC) is one of the means that have been adopted by all developed countries to solve jam problem by parking charge and improve service quality. However the system can also be used in car alarms, warehouse inventory, security access control, personnel access & tracking without the need to swipe each item individually. 1

Upload: spiromarurthi

Post on 14-Oct-2014

929 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Electronic Toll Collection Sysem Based on Rfid

1. INTRODUCTION

Radio-frequency Identification (RFID) is an automatic identification method,

relying/storing and remotely retrieving data using called RFID tags (Transporters). An

RFID tag is an object that can imbibe into a product, animal, or person for the purpose of

identification using radio waves. Some tags can be read from several meters and also can

be used beyond the line of sight of the reader. The model developed uses an active RFID

technology and wireless communicator as it helps to improve data transfer between the tag

and the host database over a long distance.

The main objective of this module development is to implement an automated

check in and checkout in Electronic Toll collection system. Electronic toll collection

system (ETC) is one of the means that have been adopted by all developed countries to

solve jam problem by parking charge and improve service quality. However the system can

also be used in car alarms, warehouse inventory, security access control, personnel access

& tracking without the need to swipe each item individually.

1

Page 2: Electronic Toll Collection Sysem Based on Rfid

ABSTRACT:

Electronic Toll Collection (ETC), an adaptation of military "identification friend or

foe" technology, aims to eliminate the delay on toll roads by collecting tolls electronically. It is thus

a technological implementation of a road pricing concept. It determines whether the cars passing

are enrolled in the program, alerts enforcers for those that are not, and electronically debits the

accounts of registered car owners without requiring them to stop. The major advantage of ETC is

that users are able to drive through the toll plaza at highway speeds without having to slow down to

pay the toll. In some installations, ETC may also reduce congestion at the plazas by allowing more

vehicles per hour/per lane

2

Page 3: Electronic Toll Collection Sysem Based on Rfid

BLOCK DIAGRAM:

Block Diagram:

PIC

Micro

Controller

PIC

Micro

Controller

RFIDREADER

RFIDREADER

LCDLCD

Relay with ULN2003Relay with ULN2003

Gate ModelGate Model

Vehicle with RFID Tag

Power SupplyPower Supply

Recharge Keys

Recharge Keys

3

Page 4: Electronic Toll Collection Sysem Based on Rfid

BLOCK DIAGRAM DESCRIPTION

The purpose of the project is to provide a fast and safe environment for toll

collection and to automatically control the vehicle movements at the toll stations by

providing individual identities to each user with the help of RFID technology. This project is

going to deal with the Toll gate collection and payment calculations, in order to make the

Toll gate collection unmanned. Transaction processing deals with maintaining customer accounts,

posting toll transactions and customer payments to the accounts, and handling customer inquiries.

whenever the vehicle comes the driver will access his cards and only the authorized person can enter

and pass out if the card is valid and also if enough amount is present in the card. The card will be

placed in front of the reader and the card is checked for validation then the concerned amount will be

reduced and then the gate will be opened and the vehicle will be allowed.

4

Page 5: Electronic Toll Collection Sysem Based on Rfid

CIRCUIT DIAGRAM

5

Page 6: Electronic Toll Collection Sysem Based on Rfid

CIRCUIT DIAGRAM DESCRIPTION

Presently toll collection system is mainly depend on the men. that means it is

depending on human effort so in this proposal to reduce human effort and the security is

improved and avoiding jam at toll center.

This system working like shown figure, here we are using AT89S52 microcontroller

it is interfaced with lcd, steeper motor, RFID. Here microcontroller is totally 40 pins .here

display purpose microcontroller is interred faced with LCD.

In LCD 8 pins are a data pin that is 7 to 14 are connected to port0 of microcontroller.

These 8 pins are data pins. These are used to send information to lcd or read contents what

data in register that display on the LCD.

Pin 4 in lcd to port 3.5 pin of micro controller pin 4 LCD is called register select pin.

This is used to select the internal register of LCD, this pin made low then the instruction

command code reregister is selected. if this pin is made high then the data register is selected.

Pin 5is connected to pin 3.6 in micro controller. Pin5 of LCD is called read/write pin.

If this pin is made high then the user is allowed to read information from it. If this pin is

made low then the user is allowed to write the information to it.

Pin 6 is connected to port3.7 pin of micro controller. This is used by the LCD to latch

information presented to its data pins.

In the system is another important section is there that is UART serial

communication. microcontroller interfaced with MAX232.this is inner facing micro

controller is inter faced with MAX 232 because it is modifying version of RS232.we need

line driver to convert the RS232 signals to TTL voltage levels that will be acceptable to

micro controller .in micro controller is inter facing pins TXD,RXD pins. One example of

such a convert is MAX 232 from maximum crop. The MAX232 converts from rs232 voltage

level to TTL levels, and vice versa. One advantage of MAX232 chip is that is uses a 5v

power supply, we need dual power supplies that are common in many older system.

MAX232 requires 4 capacitors ranging from 1 to 22 micro farad.

6

Page 7: Electronic Toll Collection Sysem Based on Rfid

After MAX 232 inter faced is communicated with serial communication process that

with help of modem it can link with RFID reader .in this system is main module is RFID.

System having tags given that’s having small micro chip that’s working when it face before

of the reader. RFID reads information of tag detects and display on the controller side. If any

invalid tag that time display.RFID is mainly reads data from tag and send information

controller it is main part of etc.

In the system another module is mechanical part is there that steeper motor is inter

facing with micro controller with help of ULN 2003. Here 16 pin chip. Pin 3 and pins 4 are

linked with micro controller. ULN chip pin 12 to pin 16 are out put pins that are link with

steeper motor.remainig are connected with resistors.

7

Page 8: Electronic Toll Collection Sysem Based on Rfid

HARDWARE REQUIREMENTS:

POWER SUPPLY

RFID TAG

LCD,

PIC 16F877A MICROCONTROLLER.

SOFTWARE REQUIREMENTS:

CCS OR MPLAB

EMBEDDED ‘C’

8

Page 9: Electronic Toll Collection Sysem Based on Rfid

HARDWARE REQUIREMENTS:

Processor : intel Core

RAM :

Hard Disk :

Input Device :

Output Device :

SOFTWARE REQIREMENTS:

Operating Systems :

Front End :

Language :

9

Page 10: Electronic Toll Collection Sysem Based on Rfid

OBJECTIVES OF THE STUDY

The main objective of this project is to ELECTRONIC TOLL COLLECTION

SYSTEM to ease the collecting toll and reduce traffic and improve service. The

RFID card will be given to the user which contains the digital code, which have to the

corresponding details stored in the centralized database system which can be accessed

in the relevant office as and when required.

Radio-frequency Identification (RFID) is an automatic identification method,

relying/storing and remotely retrieving data using called RFID tags (Transporters). An

RFID tag is an object that can imbibe into a product, animal, or person for the purpose of

identification using radio waves. Some tags can be read from several meters and also can

be used beyond the line of sight of the reader. The model developed uses an active RFID

technology and wireless communicator as it helps to improve data transfer between the tag

and the host database over a long distance.

The main objective of this module development is to implement an automated

check in and checkout in Electronic Toll collection system. Electronic toll collection

system (ETC) is one of the means that have been adopted by all developed countries to

solve jam problem by parking charge and improve service quality. However the system can

also be used in car alarms, warehouse inventory, security access control, personnel access

& tracking without the need to swipe each item individually.

10

Page 11: Electronic Toll Collection Sysem Based on Rfid

RFID

As an evolutionary automatic identification technology, RFID was considered a

niche technology a few years ago. As the costs associated with RFID hardware have

decreased, and standards defined for managing data, RFID has gone main stream. It has the

potential of powering business systems such that they become the competitive backbone of

organizations. Radio-frequency identification (RFID) is an automatic identification

method, relying on storing and remotely retrieving data using devices called RFID tags or

transponders.

An RFID tag is an object that can be applied to or incorporated into a product,

animal, or person for the purpose of identification using radio waves. Some tags can be

read from several meters away and beyond the line of sight of the reader.

Most RFID tags contain at least two parts. One is an integrated circuit for

storing and processing information, modulating and demodulating a (RF) signal and

can also be used for other specialized functions. The second is an antenna for receiving

and transmitting the signal. A technology called chip less RFID allows for discrete

identification of tags without an integrated circuit, thereby allowing tags to be printed

directly onto assets at lower cost than traditional tags.

Today, a significant thrust in RFID use is in enterprise supply chain

management, improving the efficiency of inventory tracking and management.

However, a threat is looming that the current growth and adoption in enterprise supply

chain market will not be sustainable.

A fair cost-sharing mechanism, rational motives and justified returns from

RFID technology investments are the key ingredients to achieve long-term and

sustainable RFID technology adoption.

EMBEDDEDSYSTEMS

Embedded System is a combination of hardware and software used to achieve a

single specific task. An embedded system is a microcontroller-based, software driven,

11

Page 12: Electronic Toll Collection Sysem Based on Rfid

reliable, real-time control system, autonomous, or human or network interactive, operating

on diverse physical variables and in diverse environments and sold into a competitive and

cost conscious market.

An embedded system is not a computer system that is used primarily for

processing, not a software system on PC or UNIX, not a traditional business or scientific

application. High-end embedded & lower end embedded systems. High-end embedded

system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital

Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit

Controllers used with an minimal operating systems and hardware layout designed for the

specific purpose. Examples Small controllers and devices in our everyday life like Washing

Machine, Microwave Ovens, where they are embedded in.

Fig 1.1“V Diagram”

In this place we need to discuss the role of simulation software, real-time systems

and data acquisition in dynamic test applications. Traditional testing is referred to as

“static” testing where functionality of components is tested by providing known inputs and

12

Page 13: Electronic Toll Collection Sysem Based on Rfid

measuring outputs. Today there is more pressure to get products to market faster and

reducedesigncycletimes.

This has led to a need for “dynamic” testing where components are tested while in

use with the entire system – either real or simulated. Because of cost and safety concerns,

simulating the rest of the the system with real-time hardware is preferred to testing

components in the actual real system.

The diagram shown on this slide is the “V Diagram” that is often used to describe

the development cycle. Originally developed to encapsulate the design process of software

applications, many different versions of this diagram can be found to describe different

product design cycles. Here we have shown one example of such a diagram representing

the design cycle of embedded control applications common to automotive, aerospace and

defense applications.

In this diagram the general progression in time of the development stages is shown

from left to right. Note however that this is often an iterative process and the actual

development will not proceed linearly through these steps. The goal of rapid development

is to make this cycle as efficient as possible by minimizing the iterations required for a

design. If the x-axis of the diagram is thought of as time, the goal is to narrow the “V” as

much as possible and thereby reduce development time

The y-axis of this diagram can be thought of as the level at which the system

components are considered. Early on in the development, the requirements of the overall

system must be considered.

As the system is divided into sub-systems and components, the process becomes

very low-level down to the point of loading code onto individual processors. Afterwards

components are integrated and tested together until such time that the entire system can

enter final production testing. Therefore the top of the diagram represents the high-level

system view and the bottom of the diagram represents a very low-level view.

Characteristics of Embedded System:

13

Page 14: Electronic Toll Collection Sysem Based on Rfid

• An embedded system is any computer system hidden inside a product other than a

computer

• There will encounter a number of difficulties when writing embedded system

software in addition to those we encounter when we write applications

1. Throughput – Our system may need to handle a lot of data in a

short period of time.

2. Response–Our system may need to react to events quickly

3. Testability–Setting up equipment to test embedded software can

be difficult

4. Debugability–Without a screen or a keyboard, finding out what

the software is doing wrong (other than not working) is a

troublesome problem

5. Reliability – embedded systems must be able to handle any

situation without human intervention

6. Memory space – Memory is limited on embedded systems, and

you must make the software and the data fit into whatever

memory exists

7. Program installation – you will need special tools to get your

software into embedded systems

8. Power consumption – Portable systems must run on battery

power, and the software in these systems must conserve power

9. Processor hogs – computing that requires large amounts of CPU

time can complicate the response problem

10. Cost – Reducing the cost of the hardware is a concern in many

embedded system projects; software often operates on hardware

that is barely adequate for the job.

14

Page 15: Electronic Toll Collection Sysem Based on Rfid

• Embedded systems have a microprocessor/ microcontroller and a memory. Some

have a serial port or a network connection. They usually do not have keyboards,

screens or disk drives.

Applications

1. Military and aerospace embedded software applications

2. Communicat ion Appl ica t ions

3. Industrial automation and process control software.

Power supply

The Entire Project needs power for its operation. However, from the study of this

project it comes to know that we supposed to design 5v and 12v dc power supply. So by

utilizing the following power supply components, required power has been gained.

(230/12v (1A and 500mA) – Step down transformers, Bridge rectifier to converter ac to dc,

booster capacitor and +5v (7805) and +12v (7812) regulator to maintain constant 5v & 12

supply for the controller circuit and RFID Reader).

15

Page 16: Electronic Toll Collection Sysem Based on Rfid

RFID Reader Details

The DLP-RFID1 is a low-cost, USB-powered module for reading from and writing

to ISO 15693, ISO 18000-3, and Tag-it™ intelligent RFID transponder tags. It has the

ability to both read and write up to 256 bytes of data in addition to reading the unique

identifier (UID/SID). All of the DLP-RFID1’s electronics and antenna reside within the

compact unit, and all operational power is taken from the host PC via the USB interface.

The range of the internal antenna is up to 4 inches depending upon the size of the tag being

read.

RFID stands for Radio Frequency Identification. It is an electronic technology

whereby digital data encoded in an RFID Tag (or transponder) is retrieved utilizing a

reader. In contrast to bar code technology, RFID systems do not require line-of-sight access

to the tag in order to retrieve the tag’s data, and they are well suited to harsh environments.

An RFID tag consists of an integrated circuit attached to an antenna. In the case of

the tags used with the DLP-RFID1, the antenna is in the form of conductive ink “printed”

on a material that allows for connection to the integrated circuit. This type of passive

(battery-free) tag is commonly referred to as an “inlay”.

The RFID reader (or “interrogator”) is typically a microcontroller-based radio

transceiver that powers the tag with a time-varying electromagnetic radio frequency (RF)

field. When the RF field passes through the tag’s antenna, AC voltage is generated in the

antenna and rectified to supply power to the tag. Once powered, the tag can receive

commands from the reader. The information stored in the tag can then be read by the reader

and sent back to the host PC for processing.

The data in the tag consists of a hard-coded, permanent serial number (or UID) and

user memory that can be written to, read from and locked if desired. Once locked, user data

can still be read but not changed.

LCD MODULE

A liquid crystal is a material (normally organic for LCDs) that will flow like a liquid

but whose molecular structure has some properties normally associated with solids. The

16

Page 17: Electronic Toll Collection Sysem Based on Rfid

Liquid Crystal Display (LCD) is a low power device. The power requirement is typically in

the order of microwatts for the LCD. However, an LCD requires an external or internal light

source. It is limited to a temperature range of about 0C to 60C and lifetime is an area of

concern, because LCDs can chemically degrade

There are two major types of LCDs which are:

1. Dynamic-scattering LCDs

2. Field-effect LCDs

Field-effect LCDs are normally used in such applications where source of energy is

a prime factor (e.g., watches, portable instrumentation etc.).They absorb considerably less

power than the light-scattering type. However, the cost for field-effect units is typically

higher, and their hoight is limited to 2 inches. On the other hand, light-scattering units are

available up to 8 inches in height. Field-effect LCD is used in the project for displaying the

appropriate information.

The turn-on and turn-off time is an important consideration in all displays. The

response time of LCDs is in the range of 100 to 300ms.The lifetime of LCDs is steadily

increasing beyond 10,000+hours limit. Since the color generated by LCD units is dependent

on the source of illumination, there is a wide range of color choice.

STEPPER MOTORS

These motors are also called stepping motors or step motors. This name is used

because this motor rotates trough a fixed angular step in response to each input current pulse

received by its controller. In the recent years, there has been wide demand of stepping motors

because of the explosive growth of the computer industry. This popularity is due to the fact

that they can be directly controlled by computers, microprocessors and programmable

controllers.

17

Page 18: Electronic Toll Collection Sysem Based on Rfid

As we know industrial motors are used to convert electric into mechanical energy

but they cannot be used for precision positioning of an object. These stepper motors are

ideally suited for situations where precise positioning is required.

When a command pulse is received each time the output shaft rotates in a series

of discrete angular intervals. When number of pulses supplied are definite then shaft of the

stepper motor turns through definite known angle. This makes stepper motor suited for open

loop position control because no feedback need to be taken from the shaft.

Such motors develop some torques ranging from 1Mn-m. In a tiny wristwatch motor of 3mm

diameter, up to 40N-M in a motor of 15cm diameter suitable for machine tool applications.

Power output ranges from 1Wto a max of 2500W. The only moving party in a stepper motor

is its rotor, which has no windings, commutator or brushes. This feature makes it quite robust

and reliable.

Step Angle The angle through which motor shaft rotates for each command is

called the step angle. Smaller the stepper angle, greater the no. of steps for revolution and

higher the resolution or accuracy of positioning obtained. The step angle can be as small as

0.72 degrees as large as 90 degrees. But most common step sizes are 1.8, 2.5, 7.5 and 15.

Resolution is given by the number of steps needed to complete one revolution of

the rotor shaft. Higher the resolution greater the extraordinary ability to operate at very high

stepping rates up to (20,000 steps 1 second)Operation at high speeds is called slewing.

Stepping motors come in two varieties, permanent magnet and variable

reluctance (there are also hybrid motors, which are indistinguishable from permanent magnet

motors from the controller's point of view). Lacking a label on the motor, you can generally

tell the two apart by feel when no power is applied. Permanent magnet motors tend to "cog"

as you twist the rotor with your fingers, while variable reluctance motors almost spin freely

(although they may cog slightly because of residual magnetization in the rotor). You can also

distinguish between the two varieties with an ohmmeter. Variable reluctance motors usually

have three (sometimes four) windings, with a common return, while permanent magnet

motors usually have two independent windings, with or without center taps. Center-tapped

windings are used in unipolar permanent magnet motors.

18

Page 19: Electronic Toll Collection Sysem Based on Rfid

Working System of ETC

FIG 3.1 system of ETC

Electron toll collection system working like shown in figure. In the system is mainly

depending on microcontroller and RFID. Vehicle owner contain tag when ever vehicle

19

Page 20: Electronic Toll Collection Sysem Based on Rfid

coming into toll center .in toll center RFID reader is road side I center. Here we used low

frequency RFID so that frequency is 125 KHz, when vehicle man his tag before on reader it

immediately working the tag information and content of data and every thing is display on

controller side. Tag have correct information that time we can pay money and alternately

gate is working and gate opened or closed with in time . time is depending on code.

Tag if any defaults we can reset the system. and tag is invalid that time toll center

having some toll center personalities and enquiry the every thing and any defaults thy can

take immediately action.In the system everything on control of toll center.

20

Page 21: Electronic Toll Collection Sysem Based on Rfid

4. HARDWARE REQUIREMENTS

MICROCONTROLLER PIC16F877A

INTRODUCTION

The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256 bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.

HIGH-PERFORMANCE RISC CPU

Lead-free; RoHS-compliant

Operating speed: 20 MHz, 200 ns instruction cycle

Operating voltage: 4.0-5.5V

Industrial temperature range (-40° to +85°C)

15 Interrupt Sources

35 single-word instructions

All single-cycle instructions except for program branches (two-cycle)

SPECIAL MICROCONTROLLER FEATURES

Flash Memory: 14.3 Kbytes (8192 words)

Data SRAM: 368 bytes

Data EEPROM: 256 bytes

Self-reprogrammable under software control

In-Circuit Serial Programming via two pins (5V)

Watchdog Timer with on-chip RC oscillator

Programmable code protection

Power-saving Sleep mode

Selectable oscillator options

In-Circuit Debug via two pins

21

Page 22: Electronic Toll Collection Sysem Based on Rfid

PERIPHERAL FEATURES

33 I/O pins; 5 I/O ports

Timer0: 8-bit timer/counter with 8-bit prescaler

Timer1: 16-bit timer/counter with prescaler

Can be incremented during Sleep via external crystal/clock

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

Two Capture, Compare, PWM modules

16-bit Capture input; max resolution 12.5 ns

16-bit Compare; max resolution 200 ns

10-bit PWM

Synchronous Serial Port with two modes:

SPI Master

I2C Master and Slave

USART/SCI with 9-bit address detection

Parallel Slave Port (PSP)

8 bits wide with external RD, WR and CS controls

Brown-out detection circuitry for Brown-Out Reset

Analog Features

10-bit, 8-channel A/D Converter

Brown-Out Reset

ANALOG COMPARATOR MODULE

2 analog comparators

Programmable on-chip voltage reference module

Programmable input multiplexing from device inputs and internal VREF

Comparator outputs are externally accessible

Program memory (FLASH) is used for storing a written program. Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development. 

EEPROM - data memory that needs to be saved when there is no supply.It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power

22

Page 23: Electronic Toll Collection Sysem Based on Rfid

supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance. 

RAM - Data memory used by a program during its execution.

In RAM are stored all inter-results or temporary data during run-time.

PORTS are physical connections between the microcontroller and the outside world. PIC16F877A has five I/O Ports and 33 pins in all 5 ports. 

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time which is very useful with some devices. 

CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program.

 

  Fig.3.1 Architectures of the System.

CISC, RISC

It has already been said that PIC16F877A has a RISC architecture. This term is often found in computer literature, and it needs to be explained here in more detail. Harvard architecture is a newer concept than von-Neumann's. It rose out of the need to speed up the work of a microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a greater flow of data is possible through the central processing unit, and of course, a greater speed of work. Separating a program from data memory makes it further possible for instructions not to have to be 8-bit words. PIC16F877A uses 14 bits for instructions which allows for all instructions to be one word

23

Page 24: Electronic Toll Collection Sysem Based on Rfid

instructions. It is also typical for Harvard architecture to have fewer instructions than von-Neumann's, and to have instructions usually executed in one cycle. 

Microcontrollers with Harvard architecture are also called "RISC microcontrollers". RISC stands for Reduced Instruction Set Computer. Microcontrollers with von-Neumann's architecture are called 'CISC microcontrollers'. Title CISC stands for Complex Instruction Set Computer.

Since PIC16F877A is a RISC microcontroller, that means that it has a reduced set of instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these instructions are executed in one cycle except for jump and branch instructions. According to what its maker says, PIC16F877A usually reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its class.

APPLICATIONS

PIC16F877A perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F877A applicable even in areas where microcontrollers had not previously been considered (example: timer functions, interface replacement in larger systems, coprocessor applications, etc.).

System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assembly-line production, to store calibration data available only after final testing, or it can be used to improve programs on finished products.

CLOCK / INSTRUCTION CYCLE

Clock is microcontroller's main starter, and is obtained from an external component called an "oscillator". If we want to compare a microcontroller with a time clock, our "clock" would then be a ticking sound we hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock can run. Execution of instruction starts by calling an instruction that is next in string. Instruction is called from program memory on every Q1 and is written in instruction register on Q4. Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On the following diagram we can see the relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC) holds information about the address of the next instruction.

24

Page 25: Electronic Toll Collection Sysem Based on Rfid

Fig 3.2 Clock/Instruction Cycle

PIPELINING

Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are connected in such a way that in order to make a call, one instruction cycle is needed, and one more is needed for decoding and execution. However, due to pipelining, each instruction is effectively executed in one cycle. If instruction causes a change on program counter, and PC doesn't point to the following but to some other address (which can be the case with jumps or with calling subprograms), two cycles are needed for executing an instruction. This is so because instruction must be processed again, but this time from the right address. Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4 clocks.

  Fig 3.3 Instruction Pipeline Flow

TCY0 reads in instruction MOVLW 55h (it doesn't matter to us what instruction was executed, because there is no rectangle pictured on the bottom).TCY1 executes instruction MOVLW 55h and reads in MOVWF PORTB.TCY2 executes MOVWF PORTB and reads in CALL SUB_1.TCY3 executes a call of a subprogram CALL SUB_1, and reads in instruction BSF PORTA,

25

Page 26: Electronic Toll Collection Sysem Based on Rfid

BIT3. As this instruction is not the one we need, or is not the first instruction of a subprogram SUB_1 whose execution is next in order, instruction must be read in again. This is a good example of an instruction needing more than one cycle. TCY4 instruction cycle is totally used up for reading in the first instruction from a subprogram at address SUB_1.TCY5 executes the first instruction from a subprogram SUB_1 and reads in the next one.

PIN DESCRIPTION

PIC16F877A has a total of 40 pins. It is most frequently found in a DIP40 type of case but can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to go through when mounting aren't necessary in soldering this type of a component.

Fig.3.4 Pin Diagram of PIC16F877A

Pins on PIC16F877A microcontroller have the following meaning:

There are 40 pins on PIC16F877A. Most of them can be used as an IO pin. Others are already for specific functions. These are the pin functions.1. MCLR – to reset the PIC2. RA0 – port A pin 03. RA1 – port A pin 14. RA2 – port A pin 25. RA3 – port A pin 3

26

Page 27: Electronic Toll Collection Sysem Based on Rfid

6. RA4 – port A pin 47. RA5 – port A pin 58. RE0 – port E pin 09. RE1 -  port E pin 110. RE2 – port E pin 211. VDD – power supply12. VSS – ground13. OSC1 – connect to oscillator14. OSC2 – connect to oscillator15. RC0 – port C pin 016. RC1 – port C pin 017. RC2 – port C pin 018. RC3 – port C pin 019. RD0 - port D pin 020. RD1 - port D pin 121. RD2 - port D pin 222. RD3 - port D pin 323. RC4 - port C pin 424. RC5 - port C pin 525. RC6 - port C pin 626. RC7 - port C pin 727. RD4 - port D pin 428. RD5 - port D pin 529. RD6 - port D pin 630. RD7 - port D pin 731. VSS - ground32. VDD – power supply33. RB0 - port B pin 034. RB1 - port B pin 135. RB2 - port B pin 236. RB3 - port B pin 337. RB4 - port B pin 438. RB5 - port B pin 539. RB6 - port B pin 640. RB7 - port B pin 7

By utilizing all of this pin so many application can be done such as:1. LCD – connect to Port B pin.2. LED – connect to any pin declared as output.3. Relay and Motor - connect to any pin declared as output.4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and SDA) 5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.6. GSM modem dial up modem – connect to RC6 and RC7 – the serial communication interface using RS232 protocol.

27

Page 28: Electronic Toll Collection Sysem Based on Rfid

For more detail function for each specific pin please refer to the device datasheet from Microchip. 

CLOCK GENERATOR – OSCILLATOR

Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions.

TYPES OF OSCILLATORS

PIC16F877A can work with four different configurations of an oscillator. Since configurations with crystal oscillator and resistor-capacitor (RC) are the ones that are used most frequently, these are the only ones we will mention here. Microcontroller type with a crystal oscillator has in its designation XT, and a microcontroller with resistor-capacitor pair has a designation RC. This is important because you need to mention the type of oscillator when buying a microcontroller. 

XT OSCILLATOR

Crystal oscillator is kept in metal housing with two pins where you have written down the frequency at which crystal oscillates. One ceramic capacitor of 30pF whose other end is connected to the ground needs to be connected with each pin.

Oscillator and capacitors can be packed in joint case with three pins. Such element is called ceramic resonator and is represented in charts like the one below. Center pins of the element is the ground, while end pins are connected with OSC1 and OSC2 pins on the microcontroller. When designing a device, the rule is to place an oscillator nearer a microcontroller, so as to avoid any interference on lines on which microcontroller is receiving a clock.RC Oscillator.

In applications where great time precision is not necessary, RC oscillator offers additional savings during purchase. Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature. It should be mentioned here that resonant frequency is also influenced by normal variations in process parameters, by tolerance of external R and C components, etc.

Above diagram shows how RC oscillator is connected with PIC16F877A. With value of resistor R being below 2.2k, oscillator can become unstable, or it can even stop the oscillation. With very high value of R (ex.1M) oscillator becomes very sensitive to noise and humidity. It is recommended that value of resistor R should be between 3 and 100k. Even though oscillator will work without an external capacitor (C=0pF), capacitor above 20pF should still be used for noise and stability. No matter which oscillator is being used, in order to get a clock that microcontroller works upon, a clock of the oscillator must be divided by 4. Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits.

28

Page 29: Electronic Toll Collection Sysem Based on Rfid

Fig 3.5 Clock and Instruction Cycles

Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period and amplitude, but after some period of time it becomes stabilized.

To prevent such inaccurate clock from influencing microcontroller's performance, we need to keep the microcontroller in reset state during stabilization of oscillator's clock. Diagram above shows a typical shape of a signal which microcontroller gets from the quartz oscillator.

RESET

Reset is used for putting the microcontroller into a 'known' condition. That practically means that microcontroller can behave rather inaccurately under certain undesirable conditions. In order to continue its proper functioning it has to be reset, meaning all registers would be placed in a starting position. Reset is not only used when microcontroller doesn't behave the way we want it to, but can also be used when trying out a device as an interrupt in program execution, or to get a microcontroller ready when loading a program.

In order to prevent from bringing a logical zero to MCLR pin accidentally (line above it means that reset is activated by a logical zero), MCLR has to be connected via resistor to the positive supply pole. Resistor should be between 5 and 10K. This kind of resistor, whose function is to keep a certain line on a logical one as a preventive, is called a pull up.

Microcontroller PIC16F877A knows several sources of resets:

a) Reset during power on, POR (Power-On Reset)b) Reset during regular work by bringing logical zero to MCLR microcontroller's pin.c) Reset during SLEEP regimed) Reset at watchdog timer (WDT) overflowe) Reset during at WDT overflow during SLEEP work regime.

The most important reset sources are a) and b). The first one occurs each time a power supply is brought to the microcontroller and serves to bring all registers to a starting position initial state. The second one is a product of purposeful bringing in of a logical zero to MCLR pin during normal operation of the microcontroller. This second one is often used in program development. 

During a reset, RAM memory locations are not being reset. They are unknown during a power up and are not changed at any reset. Unlike these, SFR registers are reset to a starting position

29

Page 30: Electronic Toll Collection Sysem Based on Rfid

initial state. One of the most important effects of a reset is setting a program counter (PC) to zero (0000h) , which enables the program to start executing from the first written instruction. 

Reset at supply voltage drop below the permissible (Brown-out Reset) Impulse for resetting during voltage voltage-up is generated by microcontroller itself when it detects an increase in supply Vdd (in a range from 1.2V to 1.8V). That impulse lasts 72ms which is enough time for an oscillator to get stabilized. These 72ms are provided by an internal PWRT timer which has its own RC oscillator. Microcontroller is in a reset mode as long as PWRT is active. However, as device is working, problem arises when supply doesn't drop to zero but falls below the limit that guarantees microcontroller's proper functioning. This is a likely case in practice, especially in industrial environment where disturbances and instability of supply are an everyday occurrence. To solve this problem we need to make sure that microcontroller is in a reset state each time supply falls below the approved limit. 

Fig.3.6 Voltage Drop Below the Proper Level

If, according to electrical specification, internal reset circuit of a microcontroller can not satisfy the needs, special electronic components can be used which are capable of generating the desired reset signal. Beside this function, they can also function in watching over supply voltage. If voltage drops below specified level, a logical zero would appear on MCLR pin which holds the microcontroller in reset state until voltage is not within limits that guarantee accurate performance.

CENTRAL PROCESSING UNIT

Central processing unit (CPU) is the brain of a microcontroller. This part is responsible for finding and fetching the right instruction which needs to be executed, for decoding that instruction, and finally for its execution. Central processing unit connects all parts of the microcontroller into one whole. Surely, its most important function is to decode program instructions.

When programmer writes a program, instructions have a clear form like MOVLW 0x20. However, in order for a microcontroller to understand that, this 'letter' form of an instruction must be translated into a series of zeros and ones which is called an 'opcode'. This transition from a letter to

30

Page 31: Electronic Toll Collection Sysem Based on Rfid

binary form is done by translators such as assembler translator (also known as an assembler). Instruction thus fetched from program memory must be decoded by a central processing unit. We can then select from the table of all the instructions a set of actions which execute a assigned task defined by instruction. As instructions may within themselves contain assignments which require different transfers of data from one memory into another, from memory onto ports, or some other calculations, CPU must be connected with all parts of the microcontroller. This is made possible through a data bus and an address bus.

Arithmetic logic unit is responsible for performing operations of adding, subtracting, moving (left or right within a register) and logic operations. Moving data inside a register is also known as 'shifting'. PIC16F877A contains an 8-bit arithmetic logic unit and 8-bit work registers.

Fig 3.7 STATUS Register format

In instructions with two operands, ordinarily one operand is in work register (W register), and the other is one of the registers or a constant. By operand we mean the contents on which some operation is being done, and a register is any one of the GPR or SFR registers. GPR is an abbreviation for 'General Purposes Registers', and SFR for 'Special Function Registers'. In instructions with one operand, an operand is either W register or one of the registers. As an addition in doing operations in arithmetic and logic, ALU controls status bits (bits found in STATUS register). Execution of some instructions affects status bits, which depends on the result itself. Depending on which instruction is being executed, ALU can affect values of Carry (C), Digit Carry (DC), and Zero (Z) bits in STATUS register.

PORTS

Term "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a register inside a microcontroller which is connected by wires to the pins of a microcontroller. Microcontroller uses them in order to monitor or control other components or devices. Due to functionality, some pins have twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an external input for free-run counter. Selection of one of these two pin functions is done in one of the configuration registers. An illustration of this is the fifth bit T0CS in OPTION register. By selecting one of the functions the other one is disabled.

31

Page 32: Electronic Toll Collection Sysem Based on Rfid

All port pins can be designated as input or output, according to the needs of a device that's

being developed. In order to define a pin as input or output pin, the right combination of

zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register

contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output

pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B has

TRISB. Pin direction can be changed during the course of work which is particularly fitting

for one-line communication where data flow constantly changes direction. PORTA and

PORTB state registers are located in bank 0, while TRISA and TRISB pin direction

registers are located in bank 1.

MEMORY ORGANIZATION

PIC16F877A has two separate memory blocks, one for data and the other for program.

EEPROM memory with GPR and SFR registers in RAM memory make up the data block,

while FLASH memory makes up the program block. 

PROGRAM MEMORY

Program memory has been carried out in FLASH technology which makes it possible to

program a microcontroller many times before it's installed into a device, and even after its

installment if eventual changes in program or process parameters should occur. The size of

program memory is 1024 locations with 14 bits width where locations zero and four are

reserved for reset and interrupt vector.

DATA MEMORY

Data memory consists of EEPROM and RAM memories. EEPROM memory consists of

256 eight bit locations whose contents is not lost during loosing of power supply.

EEPROM is not  directly addressable, but is accessed indirectly through EEADR and

EEDATA registers. As EEPROM memory usually serves for storing important parameters

(for example, of a given temperature in temperature regulators) , there is a strict procedure

for writing in EEPROM which must be followed in order to avoid accidental writing. RAM

memory for data occupies space on a memory map from location 0x0C to 0x4F which

32

Page 33: Electronic Toll Collection Sysem Based on Rfid

comes to 68 locations. Locations of RAM memory are also called GPR registers which is

an abbreviation for General Purpose Registers. GPR registers can be accessed regardless

of which bank is selected at the moment. 

MEMORY BANKS

Beside this 'length' division to SFR and GPR registers, memory map is also divided in

'width' (see preceding map) to two areas called 'banks'. Selecting one of the banks is done

via RP0 bit in STATUS register.

EXAMPLE:

  bcf STATUS, RP0

Instruction BCF clears bit RP0 (RP0=0) in STATUS register and thus sets up bank 0.

bsf STATUS, RP0

Instruction BSF sets the bit RP0 (RP0=1) in STATUS register and thus sets up bank1.

It is useful to consider what would happen if the wrong bank was selected. Let's assume

that we have selected bank 0 at the beginning of the program, and that we now want to

write to certain register located in bank 1, say TRISB. Although we specified the name of

the register TRISB, data will be actually stored to a bank 0 register at the appropriate

address, which is PORTB in our example.

BANK0 macro

      Bcf STATUS, RP0   ;Select memory bank 0

      endm

BANK1 macro

      Bsf STATUS, RP0   ;Select memory bank 1

      endm

Bank selection can be also made via directive banksel after which name of the register

to be accessed is specified. In this manner, there is no need to memorize which register is

in which bank.

PROGRAM COUNTER

33

Page 34: Electronic Toll Collection Sysem Based on Rfid

Program counter (PC) is a 13-bit register that contains the address of the instruction being

executed. It is physically carried out as a combination of a 5-bit register PCLATH for the

five higher bits of the address, and the 8-bit register PCL for the lower 8 bits of the address.

By its incrementing or change (i.e. in case of jumps) microcontroller executes program

instructions step-by-step.

STACK

PIC16F877A has a 13-bit stack with 8 levels, or in other words, a group of 8 memory

locations, 13 bits wide, with special purpose. Its basic role is to keep the value of program

counter after a jump from the main program to an address of a subprogram . In order for a

program to know how to go back to the point where it started from, it has to return the

value of a program counter from a stack. When moving from a program to a subprogram,

program counter is being pushed onto a stack (example of this is CALL instruction). When

executing instructions such as RETURN, RETLW or RETFIE which were executed at the

end of a subprogram, program counter was taken from a stack so that program could

continue where was stopped before it was interrupted. These operations of placing on and

taking off from a program counter stack are called PUSH and POP, and are named

according to similar instructions on some bigger microcontrollers.

IN SYSTEM PROGRAMMING

In order to program a program memory, microcontroller must be set to special working

mode by bringing up MCLR pin to 13.5V, and supply voltage Vdd has to be stabilized

between 4.5V to 5.5V. Program memory can be programmed serially using two 'data/clock'

pins which must previously be separated from device lines, so that errors wouldn't come up

during programming.

34

Page 35: Electronic Toll Collection Sysem Based on Rfid

Fig 3.8 Direct addressing format

INDIRECT ADDRESSING

Indirect unlike direct addressing does not take an address from an instruction but

derives it from IRP bit of STATUS and FSR registers. Addressed location is accessed via

INDF register which in fact holds the address indicated by a FSR. In other words, any

instruction which uses INDF as its register in reality accesses data indicated by a FSR

register. Let's say, for instance, that one general purpose register (GPR) at address 0Fh

contains a value of 20. By writing a value of 0Fh in FSR register we will get a register

indicator at address 0Fh, and by reading from INDF register, we will get a value of 20,

which means that we have read from the first register its value without accessing it directly

(but via FSR and INDF). It appears that this type of addressing does not have any

advantages over direct addressing, but certain needs do exist during programming which

can be solved smoothly only through indirect addressing.

35

Page 36: Electronic Toll Collection Sysem Based on Rfid

Indirect addressing is very convenient for manipulating data arrays located in GPR

registers. In this case, it is necessary to initialize FSR register with a starting address of the

array, and the rest of the data can be accessed by incrementing the FSR register.

 

Fig 3.9 Indirect addressing format

Such examples include sending a set of data via serial communication, working with

buffers and indicators (which will be discussed further in a chapter with examples), or

erasing a part of RAM memory (16 locations) as in the following instance.

Reading data from INDF register when the contents of FSR register is equal to zero returns

the value of zero, and writing to it results in NOP operation (no operation).

INTERRUPTS

Interrupts are a mechanism of a microcontroller which enables it to respond to some

events at the moment they occur, regardless of what microcontroller is doing at the time.

This is a very important part, because it provides connection between a microcontroller and

environment which surrounds it. Generally, each interrupt changes the program flow,

interrupts it and after executing an interrupt subprogram (interrupt routine) it continues

from that same point on.

36

Page 37: Electronic Toll Collection Sysem Based on Rfid

Control register of an interrupt is called INTCON and can be accessed regardless of

the bank selected. Its role is to allow or disallowed interrupts, and in case they are not

allowed, it registers single interrupt requests through its own bits.

INTCON REGISTER

Fig 3.10 INTCON register Format

Bit 7 GIE (Global Interrupt Enable bit) Bit which enables or disables all interrupts.

1 = all interrupts are enabled

0 = all interrupts are disabled

Bit 6 EEIE (EEPROM Write Complete Interrupt Enable bit) Bit which enables an interrupt

at the end of a writing routine to EEPROM

1 = interrupt enabled

0 = interrupt disabled

If EEIE and EEIF (which is in EECON1 register) are set simultaneously , an interrupt will

occur.

bit 5 T0IE (TMR0 Overflow Interrupt Enable bit) Bit which enables interrupts during

counter TMR0 overflow.

1 = interrupt enabled

0 = interrupt disabled

If T0IE and T0IF are set simultaneously, interrupt will occur.

bit 4 INTE (INT External Interrupt Enable bit) Bit which enables external interrupt from

pin RB0/INT.

1 = external interrupt enabled

37

Page 38: Electronic Toll Collection Sysem Based on Rfid

0 = external interrupt disabled

If INTE and INTF are set simultaneously, an interrupt will occur.

bit 3 RBIE (RB port change Interrupt Enable bit) Enables interrupts to occur at the change

of status of pins 4, 5, 6, and 7 of port B. 

1 = enables interrupts at the change of status

0 =interrupts disabled at the change of status

If RBIE and RBIF are simultaneously set, an interrupt will occur.

bit 2 T0IF (TMR0 Overflow Interrupt Flag bit) Overflow of counter TMR0.

1 = counter changed its status from FFh to 00h

0 = overflow did not occur

Bit must be cleared in program in order for an interrupt to be detected.

bit 1 INTF (INT External Interrupt Flag bit) External interrupt occurred.

1 = interrupt occurred

0 = interrupt did not occur

If a rising or falling edge was detected on pin RB0/INT, (which is defined with bit

INTEDG in OPTION register), bit INTF is set.

bit 0 RBIF (RB Port Change Interrupt Flag bit) Bit which informs about changes on pins

4, 5, 6 and 7 of port B.

1 = at least one pin has changed its status

0 = no change occurred on any of the pins

Bit has to be cleared in an interrupt subroutine to be able to detect further interrupts.

 

PIC16F877A has four interrupt sources:

1. Termination of writing data to EEPROM

2. TMR0 interrupt caused by timer overflow.

3. Interrupt during alteration on RB4, RB5, RB6 and RB7 pins of port B.

4. External interrupt from RB0/INT pin of microcontroller

Generally speaking, each interrupt source has two bits joined to it. One enables

interrupts, and the other detects when interrupts occur. There is one common bit called GIE

38

Page 39: Electronic Toll Collection Sysem Based on Rfid

which can be used to disallow or enable all interrupts simultaneously. This bit is very

useful when writing a program because it allows for all interrupts to be disabled for a

period of time, so that execution of some important part of a program would not be

interrupted. When instruction which resets GIE bit was executed (GIE=0, all interrupts

disallowed), any interrupt that remained unsolved should be ignored.

Interrupts which remained unsolved and were ignored, are processed when GIE bit

(GIE=1, all interrupts allowed) would be cleared. When interrupt was answered, GIE bit

was cleared so that any additional interrupts would be disabled, return address was pushed

onto stack and address 0004h was written in program counter - only after this does replying

to an interrupt begin! After interrupt is processed, bit whose setting caused an interrupt

must be cleared, or interrupt routine would  automatically be processed over again during a

return to the main program.

KEEPING THE CONTENTS OF IMPORTANT REGISTERS

Only return value of program counter is stored on a stack during an interrupt (by

return value of program counter we mean the address of the instruction which was to be

executed, but wasn't because interrupt occurred). Keeping only the value of program

counter is often not enough. Some registers which are already in use in the main program

can also be in use in interrupt routine. If they were not retained, main program would

during a return from an interrupt routine get completely different values in those registers,

which would cause an error in the program. One example for such a case is contents of the

work register W. If we suppose that main program was using work register W for some of

its operations, and if it had stored in it some value that's important for the following

instruction, then an interrupt which occurs before that instruction would change the value

of work register W which would directly be influenced the main program.

Procedure of recording important registers before going to an interrupt routine is

called PUSH, while the procedure which brings recorded values back, is called POP.

PUSH and POP are instructions with some other microcontrollers (Intel), but are so widely

accepted that a whole operation is named after them. PIC16F877A does not have

instructions like PUSH and POP, and they have to be programmed.

39

Page 40: Electronic Toll Collection Sysem Based on Rfid

Fig 3.11 Common error: saving the value wasn't done before entering the interrupt routine

Due to simplicity and frequent usage, these parts of the program can be made as macros.

The concept of a Macro is explained in "Program assembly language". In the following

example, contents of W and STATUS registers are stored in W_TEMP and

STATUS_TEMP variables prior to interrupt routine. At the beginning of PUSH routine we

need to check presently selected bank because W_TEMP and STATUS_TEMP are found

in bank 0. For exchange of data between these registers, SWAPF instruction is used instead

of MOVF because it does not affect the STATUS register bits.

Example is an assembler program for following steps:

1. Testing the current bank

2. Storing register regardless of the current bank

3. Storing STATUS register in bank 0.

4. Executing interrupt routine for interrupt processing (ISR)

5. Restores STATUS register

40

Page 41: Electronic Toll Collection Sysem Based on Rfid

6. Restores W register

If there are some more variables or registers that need to be stored, then they need to

be kept after storing STATUS register (step 3), and brought back before STATUS register

is restored (step 5). The same example can be carried out using macros, thus getting a more

legible program. Macros that are already defined can be used for writing new macros.

Macros BANK1 and BANK0 which are explained in "Memory organization" chapter are

used with macros 'push' and 'pop'.

FREE-RUN TIMER TMR0

Timers are usually the most complicated parts of a microcontroller, so it is necessary to set

aside more time for understanding them thoroughly. Through their application it is possible

to establish relations between a real dimension such as "time" and a variable which

represents status of a timer within a microcontroller. Physically, timer is a register whose

value is continually increasing to 255, and then it starts all over again: 0, 1, 2, 3,

4...255....0,1, 2, 3......etc.

This incrementing is done in the background of everything a microcontroller does. It is

up to programmer to think up a way how he will take advantage of this characteristic for

his needs. One of the ways is increasing some variable on each timer overflow. If we know

how much time a timer needs to make one complete round, then multiplying the value of a

variable by that time will yield the total amount of elapsed time. 

EEPROM DATA MEMORY

PIC16F877A has 256 bytes of EEPROM memory locations on addresses from 00h to 63h

that can be written to or read from. The most important characteristic of this memory is

that it does not lose its contents with the loss of power supply. Data can be retained in

EEPROM without power supply for up to 40 years (as manufacturer of PIC16F877A

microcontroller states), and up to 1 million cycles of writing can be executed. 

41

Page 42: Electronic Toll Collection Sysem Based on Rfid

In practice, EEPROM memory is used for storing important data or process

parameters. One such parameter is a given temperature, assigned when setting up a

temperature regulator to some process. If that data wasn't retained, it would be necessary to

adjust a given temperature after each loss of supply. Since this is very impractical (and

even dangerous), manufacturers of microcontrollers have began installing one smaller type

of EEPROM memory.

MODULE 2

4.2 RFID MODULE

Radio-frequency identification (RFID) is an automatic identification method,

relying on storing and remotely retrieving data using devices called RFID tags or

42

Page 43: Electronic Toll Collection Sysem Based on Rfid

transponders. The technology requires some extent of cooperation of an RFID reader and

an RFID tag.

An RFID tag is an object that can be 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.

Most RFID tags contain at least two parts. One is an integrated circuit for storing

and processing information, modulating and demodulating a radio-frequency (RF) signal,

and other specialized functions. The second is an antenna for receiving and transmitting the

signal.

There are generally two types of RFID tags:

Active RFID tags, which contain a battery, and

Passive RFID tags, which have no battery.

Future Chip less RFID allows for discrete identification of tags without an integrated

circuit, thereby allowing tags to be printed directly onto assets at a lower cost than

traditional tags.

VARIETIES OF RFID TAGS

RFID tags come in three general varieties passive, active, or semi-passive (also

known as battery-assisted or semi-active) and beacon types. Passive tags require no internal

power source, thus being pure passive devices (they are only active when a reader is nearby

to power them by wireless illumination), whereas semi-passive and active tags require a

power source, usually a small battery. Beacon tags transmit autonomously with a certain

blink pattern and do not respond to interrogation.

Passive

43

Page 44: Electronic Toll Collection Sysem Based on Rfid

Passive RFID tags have no internal power supply. The minute electrical current

induced in the antenna by the incoming radio frequency signal provides just enough power

for the CMOS integrated circuit in the tag to power up and transmit a response. Most

passive tags signal by backscattering the carrier wave from the reader. This means that the

antenna has to be designed both to collect power from the incoming signal and also to

transmit the outbound backscatter signal. The response of a passive RFID tag is not

necessarily just an ID number; the tag chip can contain non-volatile data, possibly writable

EEPROM for storing data.

Active

Unlike passive RFID tags, active RFID tags have their own internal power source,

which is used to power the integrated circuits and to broadcast the response signal to the

reader. Communications from active tags to readers is typically much more reliable (i.e.

fewer errors) than those from passive tags due to the ability for active tags to conduct a

"session" with a reader.

Active tags, due to their onboard power supply, also may transmit at higher power

levels than passive tags, allowing them to be more robust in "RF challenged" environments

with humidity and spray or with RF-dampening targets (including humans and cattle,

which contain mostly water), reflective targets from metal (shipping containers, vehicles),

or at longer distances. In turn, active tags can be larger (due to battery size) and more

expensive to manufacture (due to price of the battery). However, the potential shelf life of

an active tag can be many years.

Many active tags today have operational ranges of hundreds of meters, and a battery

life from several months to 10 years. Active tags may include larger memories than passive

tags, and may include the ability to store additional information received from the reader.

Special active RFID tags may include specialized sensors. For example, a

temperature sensor can be used to record the temperature profile during the transportation

and storage of perishable goods. Other sensor types used include humidity, shock/vibration,

light, nuclear radiation, pressure and concentrations of gases such as ethylene.

44

Page 45: Electronic Toll Collection Sysem Based on Rfid

Increasingly, active tags on the market today are internationally standardized

according to the ISO 18000-7 air interface standard, which operates at the 433 MHz

frequency. In addition, active tags that are sold in the form of an electronic seal are

standardized according to the ISO 18185 standard.

Beacon tags

Beacon tags blink the coded identity signal at a regular pattern. This may be a

constant blink rate or a blink rate with stochastic shift or some triggered blinking. Not to

activate the responder function in a tag first prevents from limiting the speed capabilities

and improves the availability of the identification information under noisy conditions.

Therefore the beacon concept appliers to very robust processes: The regular availability of

the coded signal reduces latency and allows for low power levels, as with active tags.

However, the permanent talk of many tags may pollute the frequency channel and therefore

prevent from operating in denser populations. The design of the blinking scheme must take

the battery life cycle into account. Currently (2008) none of the offered products follows

any known line of international standardization. However, all blinking must obey the

national wireless communications regulations concerning power level and channel

occupation.

Antenna Types

The antenna used for an RFID tag is affected by the intended application and the

frequency of operation. Low-frequency is 30–300 kHz. LFID or Low FID passive tags are

normally inductively coupled, and because the voltage induced is proportional to

frequency, many coil turns are needed to produce enough voltage to operate an integrated

circuit. Compact Low FID tags, like glass-encapsulated tags used in animal and human

identification, use a multilayer coil (3 layers of 100–150 turns each) wrapped around a

ferrite core.

High frequency is 3-30 MHz At 13.56 MHz, a HFID or High FID tag, using a

planar spiral with 5–7 turns over a credit-card-sized form factor can be used to provide

ranges of tens of centimeters. These coils are less costly to produce than LF coils, since

45

Page 46: Electronic Toll Collection Sysem Based on Rfid

they can be made using lithographic techniques rather than by wire winding, but two metal

layers and an insulator layer are needed to allow for the crossover connection from the

outermost layer to the inside of the spiral where the integrated circuit and resonance

capacitor are located.

Ultrahigh-frequency or UHF is 300 MHz-3 GHz. UHFID and microwave passive

tags are usually radiatively-coupled to the reader antenna and can employ conventional

dipole-like antennas. Only one metal layer is required, reducing cost of manufacturing.

Dipole antennas, however, are a poor match to the high and slightly capacitive input

impedance of a typical integrated circuit. Folded dipoles, or short loops acting as inductive

matching structures, are often employed to improve power delivery to the IC. Half-wave

dipoles (16 cm at 900 MHz) are too big for many applications; for example, tags embedded

in labels must be less than 10 cm (4 inches) in extent. To reduce the length of the antenna,

antennas can be bent or meandered, and capacitive tip-loading or bowtie-like broadband

structures are also used. Compact antennas usually have gain less than that of a dipole that

is, less than 2 dB and can be regarded as isotropic in the plane perpendicular to their axis.

Dipoles couple to radiation polarized along their axes, so the visibility of a tag with

a simple dipole-like antenna is orientation-dependent. Tags with two orthogonal or nearly-

orthogonal antennas, often known as dual-dipole tags, are much less dependent on

orientation and polarization of the reader antenna, but are larger and more expensive than

single-dipole tags.

Patch antennas are used to provide service in close proximity to metal surfaces, but

a structure with good bandwidth is 3–6 mm thick, and the need to provide a ground layer

and ground connection increases cost relative to simpler single-layer structures.

HFID and UHFID tag antennas are usually fabricated from copper or aluminum.

Conductive inks have seen some use in tag antennas but have encountered problems with

IC adhesion and environmental stability.

Tag attachment

46

Page 47: Electronic Toll Collection Sysem Based on Rfid

There are three different kinds of RFID tags based on their attachment with

identified objects, i.e. attachable, implantable and insertion tags [10]. In addition to these

conventional RFID tags, Eastman Kodak Company has filed two patent applications for

monitoring ingestion of medicine based on a digestible RFID tag.

RFID Backscatter

To communicate, tags respond to queries generating signals that must not create

interference with the readers, as arriving signals can be very weak and must be

differentiated. Besides backscattering, load modulation techniques can be used to

manipulate the reader's field. Typically, backscatter is used in the far field, whereas load

modulation applies in the near field, within a few wavelengths from the reader.

4.3 POWER SUPPLY UNIT

The input to the circuit is applied from the regulated power supply. The a.c. input

i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a

rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a

pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c

components present even after rectification. Now, this voltage is given to a voltage regulator

to obtain a pure constant dc voltage.

47

Page 48: Electronic Toll Collection Sysem Based on Rfid

Fig 4.3 power supply

Power supply unit consists of following units

i) Step down transformer

ii) Rectifier unit

iii) Input filter

iv).Regulator unit

v) Output filter

STEPDOWN TRANSFORMER

The Step down Transformer is used to step down the main supply voltage from

230V AC to lower value. This 230 AC voltage cannot be used directly, thus it is stepped

down. The Transformer consists of primary and secondary coils. To reduce or step down

the voltage, the transformer is designed to contain less number of turns in its secondary

core. The output from the secondary coil is also AC waveform. Thus the conversion from

AC to DC is essential. This conversion is achieved by using the Rectifier Circuit/Unit.

48

Page 49: Electronic Toll Collection Sysem Based on Rfid

Step down transformers can step down incoming voltage, which enables you to have

the correct voltage input for your electrical needs.  For example, if our equipment has been

specified for input voltage of 12 volts, and the main power supply is 230 volts, we will

need a step down transformer, which decreases the incoming electrical voltage to be

compatible with your 12 volt equipment.

RECTIFIER UNIT

The Rectifier circuit is used to convert the AC voltage into its corresponding DC

voltage. The most important and simple device used in Rectifier circuit is the diode. The

simple function of the diode is to conduct when forward biased and not to conduct in

reverse bias. Now we are using three types of rectifiers. They are

1. Half-wave rectifier

2. Full-wave rectifier

3. Bridge rectifier

Half-Wave Rectifier:

In half wave rectification, either the positive or negative half of the AC wave is

passed, while the other half is blocked. Because only one half of the input waveform

reaches the output, it is very inefficient if used for power transfer. Half-wave rectification

can be achieved with a single diode in a one phase supply, or with three diodes in a three-

phase supply

Bridge Rectifier

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-

wave rectification. This is a widely used configuration, both with individual diodes wired

as shown and with single component bridges where the diode bridge is wired internally.

A diode bridge or bridge rectifier is an arrangement of four diodes in a bridge

configuration that provides the same polarity of output voltage for either polarity of input

voltage. When used in its most common application, for conversion of alternating current

49

Page 50: Electronic Toll Collection Sysem Based on Rfid

(AC) input into direct current (DC) output, it is known as a bridge rectifier. A bridge

rectifier provides full-wave rectification from a two-wire AC input, resulting in lower cost

and weight as compared to a center-tapped transformer design.

The Forward Bias is achieved by connecting the diode’s positive with positive of

the battery and negative with battery’s negative. The efficient circuit used is the Full wave

Bridge rectifier circuit. The output voltage of the rectifier is in rippled form, the ripples

from the obtained DC voltage are removed using other circuits available. The circuit used

for removing the ripples is called Filter circuit.

INPUT FILTER

Capacitors are used as filter. The ripples from the DC voltage are removed and

pure DC voltage is obtained. And also these capacitors are used to reduce the harmonics of

the input voltage. The primary action performed by capacitor is charging and discharging.

It charges in positive half cycle of the AC voltage and it will discharge in negative half

cycle. So it allows only AC voltage and does not allow the DC voltage. This filter is fixed

before the regulator. Thus the output is free from ripples.

REGULATOR UNIT

Regulator regulates the output voltage to be always constant. The output voltage

is maintained irrespective of the fluctuations in the input AC voltage. As and then the AC

voltage changes, the DC voltage also changes. Thus to avoid this Regulators are used. Also

when the internal resistance of the power supply is greater than 30 ohms, the output gets

affected. Thus this can be successfully reduced here. The regulators are mainly classified

for low voltage and for high voltage. Further they can also be classified as

i) Positive regulator

1. input pin

2. ground pin

3. output pin

It regulates the positive voltage.

50

Page 51: Electronic Toll Collection Sysem Based on Rfid

ii) Negative regulator

1. ground pin

2. input pin

3. output pin

It regulates the negative voltage.

FIXED REGULATORS

Fig 4.4 An assortment of 78xx series ICs

"Fixed" three-terminal linear regulators are commonly available to generate fixed

voltages of plus 3 V, and plus or minus 5 V, 9 V, 12 V, or 15 V when the load is less than

about 7 amperes.

7805 VOLTAGE REGULATOR

The 7805 provides circuit designers with an easy way to regulate DC voltages to 5v.

Encapsulated in a single chip/package (IC), the 7805 is a positive voltage DC regulator that

has only 3 terminals. They are: Input voltage, Ground, Output Voltage.

General Features:

Output Current up to 1A

Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V

Thermal Overload Protection

Short Circuit Protection

Output Transistor Safe Operating Area Protection

51

Page 52: Electronic Toll Collection Sysem Based on Rfid

Output Filter

The Filter circuit is often fixed after the Regulator circuit. Capacitor is most often

used as filter. The principle of the capacitor is to charge and discharge. It charges during

the positive half cycle of the AC voltage and discharges during the negative half cycle. So

it allows only AC voltage and does not allow the DC voltage. This filter is fixed after the

Regulator circuit to filter any of the possibly found ripples in the output received finally.

Here we used 0.1µF capacitor. The output at this stage is 5V and is given to the

Microcontroller. The output voltage overshoots when the load is removed or a short clears.

When the load is removing from a switching mode power supply with a LC low-pass

output filter, the only thing the control loop can do is stop the switching action so no more

energy is taken from the source. The energy that is stored in the output filter inductor is

dumped into the output capacitor causing a voltage overshoot.

The magnitude of the overshoot is the vector sum of two orthogonal voltages, the

output voltage before the load is removed and the current through the inductor times the

characteristic impedance of the output filter, Zo = (L/C)^1/2. This can be derived from

conservation of energy considerations.

The two energies are equal when the load is removed, since the load is no longer

taking energy from the system. Equating the two energies, substituting zero current for the

final inductor current, then the solution for the final voltage Vf is:

This is the orthogonal vector sum of the output voltage and the load current times

the characteristic impedance and is illustrated in Figure .The problem becomes worse if the

current in the inductor is established by a short circuit on the output and the short circuit

clears. In this case, the initial voltage is zero (short circuit) and the overshoot is I*Zo,

where I can be very large, resulting in a ruinous overshoot.

4.4 UART

52

Page 53: Electronic Toll Collection Sysem Based on Rfid

SERIAL COMMUNICATION

A serial port sends and receives data one bit at a time over one wire. While it takes

eight times as long as to transfer each byte of data this way, only a few wires are required.

In fact, two-way (full duplex) communications is possible with only three separate wires-

one to send, one to receive, and a common signal ground wire.

Bi-directional communications

Communicating by wires

The Parity Bit

Cable lengths

MAX-232C

DCE And DTE devices

Synchronous and Asynchronous Communications

Bi-directional Communications

The serial port on your PC is a full-duplex device meaning that it can send and

receive data at the same time. In order to be able to do this, it uses separate lines for

transmitting and receiving data. Some types of serial devices support only one-way

communications and therefore use only two-wires in the cable – the transmit line and the

signal ground.

Communicating by bits

Once the start bit has been sent, the transmitter sends the actual data bits. There may

either be 5,6,7, or 8 data bits, depending on the number you have selected. Both receiver

and the transmitter must agree on the number of data bits, as well as the baud rate. Almost

all devices transmit data using either 7 or 8 data bits. Notice that when only 7 data bits are

employed, you cannot send ASCII values greater than 127. Likewise, using 5 bits limits the

highest possible value to 31. After the data has been transmitted, a stop bit is sent. A stop

bit has a value of 1- or a mark state- and it can be detected correctly even if the previous

data bit also had a value of 1. This is accomplished by the stop bit’s duration.

The Parity Bit

53

Page 54: Electronic Toll Collection Sysem Based on Rfid

Besides the synchronization provided by the use of start and stop bits, an additional

bit called a parity bit may optionally be transmitted along with the data. A parity bit affords

a small amount of error checking, to help detect data corruption that might occur during

transmission.

Cable Lengths

The MAX-232 standard imposes a cable length limit of 50 feet. You can usually

ignore this “standard”, since a cable can be as long as 10000 feet at baud rates up to 19200

if you use a high quality, well shielded cable. The external environment has a large effect

on lengths for unshielded cables.

MAX232 (Voltage Converter)

Since the RS232 is not compatible with today microprocessors and micro

controller, we need line driver to convert the RS232 signals to TTL voltage levels that will

be acceptable to the 8051’s TXD and RXD pins. One example of such a converter is MAX

232 from maxim corp. The MAX 232 converts from RS232 voltage levels to TTL voltage

levels, and vice versa. One advantage of MAX232 chip is that it uses a +5V power source,

which is the same as the source voltage for the at89s52 micro controller. In other words,

with a single +5v power supply we can power both the PIC and MAX 232, with no need of

for the dual power supplies that are common in many older systems. The MAX 232

requires four capacitors ranging from 1 to 22 microfarad. The most widely used value for

this capacitor is 22microfarad.

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator

to supply TIA/EIA-232-Fvoltage levels from a single 5-V supply. Each receiver converts

TIA/EIA-232-F inputs to 5-V TTL/CMOS levels. These receivers have a typical threshold

of 1.3 V, a typical hysterias is of 0.5 V, and can accept ±30-V inputs. Each driver converts

TTL/CMOS input levels into TIA/EIA-232-F levels.

PIN DIAGRAM OF MAX232

54

Page 55: Electronic Toll Collection Sysem Based on Rfid

Fig 4.5 max232 pin diagram

DCE and DTE devices

Two terms you should be familiar with are DTE and DCE. DTE stands for Data

Terminal Equipment, and DCE stands for Data Communication Equipment. These terms

are used to indicate the pin-out for the connectors on a device and the direction of the

signals on the pins. Your computer is a DTE device, while most other devices are usually

DCE devices. If you have trouble keeping the two straight then replace the term “DTE

device” with your PC and the term DCE device with “remote Device” in the following

discussion. The RS-232 standard states that DTE devices use a 25-pin male connector, and

DCE devices use a 25-pin female connector. You can therefore connect a DTE device to a

DCE using a straight pin-for-pin connection. However, to connect two like devices, you

must instead use a null modem cable. Null modem cables cross the transmit and receive

lines in the cable.

The DTE device puts this line in a mark condition to tell the remote device that it

is ready and able to receive data. If the DTE device is not able to receive data (typically

because its receive buffer is almost full), it will put this line in the space condition as a

signal to the DCE to stop sending data. When the DTE device is ready to receive more data

it will place this line back in the mark condition. The complement of the RTS wire is CTS,

which stands for Clear to Send. The DCE device puts this line in a mark condition to tell

55

Page 56: Electronic Toll Collection Sysem Based on Rfid

the DTE device that it is ready to receive the data. Likewise, if the DCE device is unable to

receive data, it will place this line in the space condition. Together, these two lines make up

what is called RTS/CTS or “hardware” flow control. The software wedge supports this type

of flow control as well as Xon/Xoff or “software” flow control. Software flow control uses

special control characters transmitted from one device to another to tell the other device to

stop or start sending data. With software flow control the RTS and CTS lines are not used.

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 simplify confirm that a device is

connected and turned on. The software wedge sets DTR to the mark state when the serial

port is opened and leaves it in that state until the port is closed. The DTR and DSR lines

were originally designed to provide an alternate method of hardware handshaking. It would

be pointless to use both RTS/CTS and DTR/DSR for flow control signals at the same time.

Because of this DTR and DSR are rarely used for flow control.

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

the 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, because additional bits to mark the beginning and end of each data

byte are not required. The serial ports on IBM style PCs are asynchronous devices and

therefore only support asynchronous serial communications. Asynchronous means no

“synchronization”, and thus does not require sending and receiving idle characters.

However, the beginning and end of each byte of data must be identified by start and stop

bits. The start bit indicates when the data byte is about to begin and the stop bit signals

when it ends.

4.5 LCD DISPLAY

56

Page 57: Electronic Toll Collection Sysem Based on Rfid

Liquid crystal display (LCD) has material which combines the properties of both

liquid and crystals. They have a temperature range within which the molecules are almost

as mobile as they would be in a liquid, but are grouped together in an order form similar to

a crystal.

LCD DISPLAY

Fig 4.6 lcd module

More microcontroller devices are using 'smart LCD' displays to output visual

information. The following discussion covers the connection of a Hitachi LCD display to a

PIC microcontroller. LCD displays designed around Hitachi's LCD HD44780 module, are

inexpensive, easy to use, and it is even possible to produce a readout using the 8 x 80 pixels

of the display. Hitachi LCD displays have a standard ASCII set of characters plus Japanese,

Greek and mathematical symbols.

HARDWARE DIAGRAM

57

Page 58: Electronic Toll Collection Sysem Based on Rfid

Fig 4.7 lcd pin configuration

For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-

bit data bus it only requires the supply lines plus seven extra lines. When the LCD display

is not enabled, data lines are tri-state which means they are in a state of high impedance (as

though they are disconnected) and this means they do not interfere with the operation of the

microcontroller when the display is not being addressed. The LCD also requires 3 "control"

lines from the microcontroller.

When the LCD is initialized, it is ready to continue receiving data or instructions. If

it receives a character, it will write it on the display and move the cursor one space to the

right. The Cursor marks the next location where a character will be written. When we want

to write a string of characters, first we need to set up the starting address, and then send one

character at a time.

58

Page 59: Electronic Toll Collection Sysem Based on Rfid

Pins description

Table 4.3 pins for lcd

Logic status on control lines

RS (Command / Data):

This bit is to specify weather received byte is command or data. So that LCD can recognize the operation to be performed based on the bit status.

RS = 0 => Command

RS = 1 => Data

RW (Read / Write)

RW bit is to specify weather controller wants READ from LCD or WRITE to LCD. The READ operation here is just ACK bit to know weather LCD is free or not.

RW = 0 => Write

RW = 1 => Read

EN (Enable LCD)

EN bit is to ENABLE or DISABLE the LCD. When ever controller wants to write some thing into LCD or READ acknowledgment from LCD it needs to enable the LCD.

59

Page 60: Electronic Toll Collection Sysem Based on Rfid

EN = 0 => High Impedance

EN = 1 => Low Impedance

ACK (LCD Ready)

ACK bit is to acknowledge the MCU that LCD is free so that it can send new command or data to be stored in its internal Ram locations.

ACK = 1 => Not ACK

ACK = 0 => ACK

Reading data from the LCD is done in the same way, but control line R/W has to

be high. When we send a high to the LCD, it will reset and wait for instructions. Typical

instructions sent to LCD display after a reset are: turning on a display, turning on a cursor

and writing characters from left to right.  Characters that can be shown on the display are

stored in data display (DD) RAM. The size of DDRAM is 80 bytes.

Before we access DD RAM after defining a special character, the program must set

the DD RAM address. Writing and reading data from any LCD memory is done from the

last address which was set up using set-address instruction. Once the address of DD RAM

is set, a new written character will be displayed at the appropriate place on the screen. Until

now we discussed the operation of writing and reading to an LCD as if it were an ordinary

memory. But this is not so. The LCD controller needs 40 to 120 microseconds (uS) for

writing and reading. Other operations can take up to 5 mS. During that time, the

microcontroller can not access the LCD, so a program needs to know when the LCD is

busy. We can solve this in two ways.One way is to check the BUSY bit found on data line

D7. This is not the best method because LCD's can get stuck, and program will then stay

forever in a loop checking the BUSY bit. The other way is to introduce a delay in the

program. The delay has to be long enough for the LCD to finish the operation in process.

At the beginning we mentioned that we needed 11 I/O lines to communicate with an

LCD. However, we can communicate with an LCD through a 4-bit data bus. Thus we can

reduce the total number of communication lines to seven.

60

Page 61: Electronic Toll Collection Sysem Based on Rfid

4.6 Stepper Motor

A stepper motor is an electromechanical evince which converts electrical pulses

into discrete mechanical movements. The shaft or spindle of a stepper motor rotates

indiscrete step increments when electrical command pulses are applied to it in the proper

sequence. The motors rotation has several direct relationships to these applied input pulses.

The sequence of the applied pulses is directly related to the direction of motor shafts

rotation. The speed of the motor shafts rotation is directly related to the frequency of the

input pulses and the length of rotation is directly related to the number of input pulses

applied.

Stepper motors operate differently from DC brush motors, which rotate when

voltage applied to their terminals. Stepper motors, on the other hand, effectively have

multiple "toothed" electromagnets arranged around a central gear-shaped piece of iron. The

electromagnets are energized by an external control circuit, such as a microcontroller. To

make the motor shaft turn, first one electromagnet is given power, which makes the gear's

teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth are thus

aligned to the first electromagnet, they are slightly offset from the next electromagnet. So

when the next electromagnet is turned on and the first is turned off, the gear rotates slightly

to align with the next one, and from there the process is repeated. Each of those slight

rotations is called a "step," with an integer number of steps making a full rotation. In that

way, the motor can be turned by a precise angle.

Stepper motors nameplates typically give only the winding current and occasionally

the voltage and winding resistance. The rated voltage will produce the rated winding current

at DC: but this is mostly a meaningless rating, as all modern drivers are current limiting and

the drive voltages greatly exceed the motor rated voltage.

A stepper's low speed torque will vary directly with current. How quickly the torque

falls off at faster speeds depends on the winding inductance and the drive circuitry it is

attached to, especially the driving voltage.

Steppers should be sized according to published torque curve, which is specified by the

manufacturer at particular drive voltages and/or using their own drive circuitry. It is not

61

Page 62: Electronic Toll Collection Sysem Based on Rfid

guaranteed that you will achieve the same performance given different drive circuitry, so the

pair should be chosen with great care.

Stepper Motor Controller by ULN2003

Fig 4.8 stepper motor interfacing chip

There are three main types of stepper motors

1. Permanent Magnet Stepper (can be subdivided in to 'tin-can' and 'hybrid', tin-can

being a cheaper product, and hybrid with higher quality bearings, smaller step

angle, higher power density)

2. Hybrid Synchronous Stepper

3. Variable Reluctance Stepper

Stepper Motor Advantages

1. The rotation angle of the motor is proportional to the input pulse.

2. The motor has full torque at standstill (if the windings are energized)

3. Precise positioning and repeatability of movement since good stepper motors

have an accuracy of3 – 5% of a step and this error isnon cumulative from one step to the

next.

4. Excellent response to starting/stopping/reversing.

62

Page 63: Electronic Toll Collection Sysem Based on Rfid

5. Very reliable since there are no contact brushes in the motor. Therefore the life of

the motor is simply dependant on the life of the bearing.

6. The motors response to digital input pulses provides open-loop control, making

the motor simpler and less costly to control.

7. It is possible to achieve very low speed synchronous rotation with a load that is

directly coupled to the shaft.

8. A wide range of rotational speeds can be realized as the speed is proportional to

the frequency of the input pulses.

Applications

Computer-controlled stepper motors are one of the most versatile forms of

positioning systems. They are typically digitally controlled as part of an open loop system,

and are simpler and more rugged than closed loop servo systems.

Industrial applications are in high speed pick and place equipment and multi-axis

machine CNC machines often directly driving lead screws or ballscrews. In the field of

lasers and optics they are frequently used in precision positioning equipment such as linear

actuators, linear stages, rotation stages, goniometers, and mirror mounts. Other uses are in

packaging machinery, and positioning of valve pilot stages for fluid control systems.

Commercially, stepper motors are used in floppy disk drives, flatbed scanners,

computer printers, plotters, slot machines, and many more devices.Some people looking

for generators for homemade Wind Turbines found success in using stepper motors for

generating power

63

Page 64: Electronic Toll Collection Sysem Based on Rfid

5. SOFT WARE REQUIREMENTS

Keil an ARM Company makes C compilers, macro assemblers, real-time

kernels, debuggers, simulators, integrated environments, evaluation boards, and emulators

for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families.

The Keil 8051 Development Tools are designed to solve the complex problems

facing embedded software developers

Keil development tools for the 8051 Microcontroller Architecture support

every level of software developer from the professional applications engineer to the student

just learning about embedded software development.

When starting a new project, simply select the microcontroller you use from the

Device Database and the µVision IDE sets all compiler, assembler, linker, and memory

options for you.

Numerous example programs are included to help you get started with the most

popular embedded 8051 devices.

The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN,

UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of

your 8051 device. Simulation helps you understand hardware configurations and avoids

time wasted on setup problems. Additionally, with simulation, you can write and test

applications before target hardware is available

EMBEDDED ‘C’:

Ex: Hitec – c, Keil – c

HI-TECH Software makes industrial-strength software development tools and C

compilers that help software developers write compact, efficient embedded processor code.

For over two decades HI-TECH Software has delivered the industry's most reliable

embedded software development tools and compilers for writing efficient and compact

64

Page 65: Electronic Toll Collection Sysem Based on Rfid

code to run on the most popular embedded processors. Used by tens of thousands of

customers including General Motors, Whirlpool, Qualcomm, John Deere and many others,

HI-TECH's reliable development tools and C compilers, combined with world-class

support have helped serious embedded software programmers to create hundreds of

breakthrough new solutions. Which ever embedded processor family you are targeting with

your software, whether it is the ARM, PICC or 8051 series, HI-TECH tools and C

compilers can help you write better code and bring it to market faster. HI-TECH PICC is a

high-performance C compiler for the Microchip PIC micro 10/12/14/16/17 series of

microcontrollers. HI-TECH PICC is an industrial-strength ANSI C compiler - not a subset

implementation like some other PIC compilers. The PICC compiler implements full

ISO/ANSI C, with the exception of recursion. All data types are supported including 24

and 32 bit IEEE standard floating point. HI-TECH PICC makes full use of specific

features and using an intelligent optimizer, can generate high-quality code easily rivaling

hand-written assembler. Automatic handling of page and bank selection frees the

programmer from the trivial details of assembler code.

EMBEDDED “C” COMPILER

ANSI C - full featured and portable.

Reliable - mature, field-proven technology.

Multiple C optimization levels .

An optimizing assembler.

Full linker, with overlaying of local variables to minimize RAM usage.

Comprehensive C library with all source code provided.

Includes support for 24-bit and 32-bit IEEE floating point and 32-bit

long data types.

Mixed C and assembler programming.

Unlimited number of source files.

Listings showing generated assembler.

Compatible - integrates into the MPLAB IDE, MPLAB ICD .

65

Page 66: Electronic Toll Collection Sysem Based on Rfid

Runs on multiple platforms: Windows, Linux, UNIX, Mac OS X,

Solaris.

EMBEDDED SYSTEM TOOLS

ASSEMBLER

An assembler is a computer program for translating assembly language —

essentially, a mnemonic representation of machine language — into object code. A cross

assembler (see cross compiler) produces code for one type of processor, but runs on

another. The computational step where an assembler is run is known as assembly time.

Translating assembly instruction mnemonics into opcodes, assemblers provide the ability to

use symbolic names for memory locations (saving tedious calculations and manually

updating addresses when a program is slightly modified), and macro facilities for

performing textual substitution typically used to encode common short sequences of

instructions to run inline instead of in a subroutine. Assemblers are far simpler to write than

compilers for high-level languages.

ASSEMBLY LANGUAGE HAS SEVERAL BENEFITS

Speed: Assembly language programs are generally the fastest programs around.

Space: Assembly language programs are often the smallest.

Capability: You can do things in assembly which are difficult or impossible in

High level languages.

Knowledge: Your knowledge of assembly language will help you write better

programs, even when using High level languages. An example of an assembler we use in

our project is RAD 51.

SIMULATOR

Simulator is a machine that simulates an environment for the purpose of training or

research. We use a UMPS simulator for this purpose in our project.

66

Page 67: Electronic Toll Collection Sysem Based on Rfid

UMPS

Universal microprocessor program simulator simulates a microcontroller with its

external environment. UMPS is able to simulate external components connected to the

microcontroller. Then, debug step is dramatically reduced. UMPS is not dedicated to only

one microcontroller family, it can simulate all kind of microcontrollers. The main

limitation is to have less than 64K-Bytes of RAM and ROM space and the good

microcontroller library. UMPS provide all the facilities other low-cost simulator does not

have. It offers the user to see the "real effect" of a program and a way to change the

microcontroller family without changing IDE. UMPS provide a low-cost solution to the

problems. UMPS is really the best solution to your evaluation.

UMPS KEY FEATURES

The speed, UMPS can run as fast as 1/5 the real microcontroller speed. No need

to wait 2 days to see the result of a LCD routine access. All the microcontroller parts are

simulated, interrupts, communication protocol, parallel handshake, timer and so on. UMPS

have an integrated assembler/disassembler and debugger. It is able to accept an external

assembler or compiler. It has a text editor which is not limited to 64K-bytes and shows

keyword with color. It can also communicate with an external compiler to integrate all the

debug facilities you need. UMPS is universal, it can easily be extended to other

microcontroller with a library. Ask us for toolkit development. External resource

simulation is not limited. It can be extended to your proper needs by writing your own

DLL. UMPS allows you to evaluate at the lowest cost the possibility to build a

microcontroller project without any cable. - UMPS include a complete documentation on

each microcontroller which describe special registers and each instruction.

USER INTERFACES

User interfaces for embedded systems vary widely, and thus deserve some special

comment. User interface is the ultimate aim for an embedded module as to the user to

check the output with complete convenience. One standard interface, widely used in

embedded systems, uses two buttons (the absolute minimum) to control a menu system

67

Page 68: Electronic Toll Collection Sysem Based on Rfid

(just to be clear, one button should be "next menu entry" the other button should be "select

this menu entry").

Another basic trick is to minimize and simplify the type of output. Designs

sometimes use a status light for each interface plug, or failure condition, to tell what failed.

A cheap variation is to have two light bars with a printed matrix of errors that they select-

the user can glue on the labels for the language that he speaks. For example, most small

computer printers use lights labeled with stick-on labels that can be printed in any

language. In some markets, these are delivered with several sets of labels, so customers can

pick the most comfortable language.

In many organizations, one person approves the user interface. Often this is a

customer, the major distributor or someone directly responsible for selling the system.

PLATFORM

There are many different CPU architectures used in embedded designs such as

ARM, MIPS, Coldfire/68k, PowerPC, X86, PIC, 8051, Atmel AVR, H8, SH, V850, FR-V,

M32R etc.

This in contrast to the desktop computer market, which as of this writing (2003) is

limited to just a few competing architectures, mainly the Intel/AMD x86, and the

Apple/Motorola/IBM PowerPC, used in the Apple Macintosh. With the growing

acceptance of Java in this field, there is a tendency to even further eliminate the

dependency on specific CPU/hardware (and OS) requirements.

Standard PC/104 is a typical base for small, low-volume embedded and ruggedized

system design. These often use DOS, Linux or an embedded real-time operating system

such as QNX or Inferno.

A common configuration for very-high-volume embedded systems is the system on

a chip, an application-specific integrated circuit, for which the CPU was purchased as

intellectual property to add to the IC's design. A related common scheme is to use a field-

programmable gate array, and program it with all the logic, including the CPU. Most

modern FPGAs are designed for this purpose.

68

Page 69: Electronic Toll Collection Sysem Based on Rfid

TOOLS

Like typical computer programmers, embedded system designers use compilers,

assemblers, and debuggers to develop embedded system software. However, they also use a

few tools that are unfamiliar to most programmers.

Software companies that specialize in the embedded market Ported from the GNU

software development tools. Sometimes, development tools for a personal computer can be

used if the embedded processor is a close relative to a common PC processor. Embedded

system designers also use a few software tools rarely used by typical computer

programmers.

One common tool is an "in-circuit emulator" (ICE) or, in more modern designs, an

embedded debugger. This debugging tool is the fundamental trick used to develop

embedded code. It replaces or plugs into the microprocessor, and provides facilities to

quickly load and debug experimental code in the system. A small pod usually provides the

special electronics to plug into the system. Often a personal computer with special software

attaches to the pod to provide the debugging interface.

Another common tool is a utility program (often home-grown) to add a checksum

or CRC to a program, so it can check its program data before executing it.

An embedded programmer that develops software for digital signal processing often

has a math workbench such as MathCad or Mathematical to simulate the mathematics.

Less common are utility programs to turn data files into code, so one can include

any kind of data in a program. A few projects use Synchronous programming languages for

extra reliability or digital signal processing.

DEBUGGING

Debugging is usually performed with an in-circuit emulator, or some type of

debugger that can interrupt the microcontroller's internal microcode. The microcode

interrupt lets the debugger operate in hardware in which only the CPU works. The CPU-

based debugger can be used to test and debug the electronics of the computer from the

viewpoint of the CPU. This feature was pioneered on the PDP-11.

69

Page 70: Electronic Toll Collection Sysem Based on Rfid

As the complexity of embedded systems grows, higher level tools and operating

systems are migrating into machinery where it makes sense. For example, cell phones,

personal digital assistants and other consumer computers often need significant software

that is purchased or provided by a person other than the manufacturer of the electronics. In

these systems, an open programming environment such as Linux, OSGi or Embedded Java

is required so that the third-party software provider can sell to a large market.

OPERATING SYSTEM

Embedded systems often have no operating system, or a specialized embedded

operating system (often a real-time operating system), or the programmer is assigned to

port one of these to the new system.

BUILT- IN SELF- TEST

Most embedded systems have some degree or amount of built-in self-test.

There are several basic types.

1. Testing the computer.

2. Test of peripherals.

3. Tests of power.

4. Communication tests.

5. Cabling tests.

6. Rigging tests.

7. Consumables test.

8. Operational test.

9. Safety test.

70

Page 71: Electronic Toll Collection Sysem Based on Rfid

START UP

All embedded systems have start-up code. Usually it disables interrupts, sets up the

electronics, tests the computer (RAM, CPU and software), and then starts the application

code. Many embedded systems recover from short-term power failures by restarting

(without recent self-tests). Restart times under a tenth of a second are common.

Many designers have found a few LEDs useful to indicate errors (they help

troubleshooting). A common scheme is to have the electronics turn on all of the LED(s) at

reset (thereby proving that power is applied and the LEDs themselves work), whereupon

the software changes the LED pattern as the Power-On Self Test executes. After that, the

software may blink the LED(s) or set up light patterns during normal operation to indicate

program execution progress or errors. This serves to reassure most technicians/engineers

and some users. An interesting exception is that on electric power meters and other items

on the street, blinking lights are known to attract attention and vandalism.

71

Page 72: Electronic Toll Collection Sysem Based on Rfid

6. CODE

#INCLUDE<PIC1.H>

#INCLUDE<STRING.H>

VOID DELAY_1MS(VOID);

VOID DELAY_30MS(VOID);

VOID DELAY(UNSIGNED INT);

VOID MSDELAY(UNSIGNED CHAR);

VOID LCD_CMD(UNSIGNED CHAR);

VOID LCD_POS(UNSIGNED CHAR);//SETHE LCDADDRESS

VOID LCD_CHAR(UNSIGNED CHAR); //CONVERTTHEINTEGER VALUE TO

WRITING FORMAT

VOID LCD_PRINT(UNSIGNED CHAR *);

VOID LCD_INIT(VOID); //WRITE THE STRING TO LCD

VOID LCD_CLEAR(VOID);

VOID UART_INIT(VOID);

SBIT RS=P2^7;//RESET

SBIT RW=P2^6;//READ/WRITE

SBIT EN=P2^5;//ENABLE

SFRLCD=0X80; //DATA0-DATA7 TO P0

VOID MAIN()

{

UNSIGNED CHAR K,RF[13],I;

72

Page 73: Electronic Toll Collection Sysem Based on Rfid

LCD_INIT();

LCD_PRINT("LCD IS READY");

DELAY(500);

LCD_CLEAR();

UART_INIT();

LCD_PRINT("UART IS READY");

DELAY(500);

LCD_CLEAR();

LCD_CMD(0X81);

LCD_PRINT("UNMANNED TOLL TAX COLLECTION");

LCD_CMD(0XC2);

LCD_PRINT("GATE SYSTEM");

DELAY(500);

P1=0X00;

WHILE(1)

{ LCD_CLEAR();

LCD_CMD(0X82);

LCD_PRINT("PLACE THE TAG");

LCD_CMD(0XC2);

LCD_PRINT("BEFORE READER");

DELAY(500);

FOR(K=0;K<12;K++)

{ WHILE(!RI);

RF[K] = SBUF;

73

Page 74: Electronic Toll Collection Sysem Based on Rfid

RI=0;}

RF[12]='\0';

LCD_CLEAR();

LCD_PRINT(RF);

DELAY(1000);

IF(!STRCMP(RF,"26006FCA6FEC"))

{

//LCD_CLEAR();

//LCD_PRINT(RF);

DELAY(1000);

//SM RIGHT

FOR(I=0;I<100;I++)

{P1=0X11;

DELAY(5);

P1=0X22;

DELAY(5);

P1=0X44;

DELAY(5);

P1=0X88;

DELAY(5);}

LCD_CLEAR();

LCD_PRINT("GATE CLOSED");

FOR(I=0;I<10;I++)

DELAY(500);

74

Page 75: Electronic Toll Collection Sysem Based on Rfid

FOR(I=0;I<100;I++)

{

P1=0X88;

DELAY(5);

P1=0X44;

DELAY(5);

P1=0X22;

DELAY(5);

P1=0X11;

DELAY(5);

}

LCD_CLEAR();

LCD_PRINT("GATE OPENED");

DELAY(2000);

}

ELSE

{

DELAY(500);

LCD_CLEAR();

LCD_PRINT("INVALID CARD");

DELAY(500);

DELAY(500);

}

}

75

Page 76: Electronic Toll Collection Sysem Based on Rfid

}

VOID UART_INIT(VOID)

{

SCON=0X50;//MODE 1..8 BIT DATA,..1 STOP BIT,..1 START BIT

TMOD=0X20;//TIMER 1....MODE 2...8 BIT AUTO RELOAD

TL1 = 0XFD;

TH1=0XFD;//BAUD RATE 9600

TR1 = 1;

}

VOID LCD_INIT()

{

DELAY(1);//ONLY FOR AVOIDING WARNING

DELAY_30MS()

LCD_CMD(0X38);

DELAY_30MS();

LCD_CMD(0X01);

DELAY_30MS();

LCD_CMD(0X0C);

DELAY_30MS();

LCD_CMD(0X06);

DELAY_30MS();

LCD_CMD(0X80);

DELAY_30MS();

}

//===============================================

VOID LCD_CLEAR(VOID)

{

76

Page 77: Electronic Toll Collection Sysem Based on Rfid

LCD_CMD(0X01);

LCD_CMD(0X80); }

//THIS IS THE FUNCTION FOR SETTING THE STARTING ADDRESS OF DATA DISPLAY

VOID LCD_ POS(UNSIGNED CHAR POS)

{ UNSIGNED CHAR I;

LCD=POS;

RS=0;

RW=0;

EN=1;

FOR(I=0;I<50;I++);

EN=0;

FOR(I=0;I<50;I++);

}

//===============================================

VOID LCD_CHAR(UNSIGNED CHAR DAT) //DISPLAY_DATA

{ UNSIGNED CHAR I;

LCD=DAT;

RS=1;

RW=0;

EN=1;

FOR (I=0;I<50;I++);

EN=0;

FOR (I=0;I<50;I++);

}

77

Page 78: Electronic Toll Collection Sysem Based on Rfid

7. ADVANTAGES

The entire project idea is to develop with help of RFID.

1. Easily collecting toll.

2. Avoiding traffic at toll center.

3. In the system total information of vehicles.

4. We can recognize un register vehicles.

8. CONCLUSION

78

Page 79: Electronic Toll Collection Sysem Based on Rfid

In order to implement contemporary system of “ELECTRONIC TOLL COLLECTION

SYSTEM BASED ON RFID” the Embedded systems plat form has utilized. For this purpose, a

new RFID technology based on micro-controller was implemented and tested in this study.

The verification system presented has the following advantages: The verification system

consists of data base about the user of RFID multipurpose card.

The state of art of microcontroller AT89S52 used as a mediator in between PC and

RFID; it act as user interface whenever user shows RFID card it will read out by MCU

using RFID card reader then it transfer those thing to PC interfacing/ front end software.

The RFID security system is major role of this project. A kind of radio frequency chip was

adopted to design electronic toll collection system of expressway.

Structural and process designs were made, in addition, a new RFID authentication

and authorization protocol model was used to guarantee system security.

9. FUTURE SCOPE

79

Page 80: Electronic Toll Collection Sysem Based on Rfid

In this project we are using RFID module. This project is good and easy process

of collecting toll from vehicles. Compare to normal manually system is better and in this

we can further to implementing to every vehicle owner having the one tag that tag is

contain total information of vehicle.

Tag is near kept on RFID reader it’s detect the tag and it display on the control

system. in tag in future we can add all details of car .so it’s helpful to car security when the

vehicle is thief ted.

In future vehicle toll collection easy without jam at centers and it will be good to

government authority.

BIBLIOGRAPHY

80

Page 81: Electronic Toll Collection Sysem Based on Rfid

www.rfid.com/reader/tag

www.at89s52.com/pdf/

www.microchips.com

www.uln2003apg.com/stepermotor

www.max232n.com/texas

www.mikroelektronika.co.yu/english/product/books/PICbook/0_Uvod.

BOOKS

Customizing and programming microcontroller-Myke Predcko-TMH publication-

2000

Complete guide to microcontroller -e-book

C programming for embedded systems- Kirk Zurell

Teach yourself electronics and electricity- Stan Giblisco

Embedded Microcomputer system- onathan w.Valvano PHI publication2000

microcontroller inter facing- Douglas v.hall TMH publication-2000

81

Page 82: Electronic Toll Collection Sysem Based on Rfid

82

Page 83: Electronic Toll Collection Sysem Based on Rfid

83

Page 84: Electronic Toll Collection Sysem Based on Rfid

84