Sie sind auf Seite 1von 52

ELECTRONIC TOLL COLLECTION SYSTEM

BASED ON RFID (RADIO FREQUENCY IDENTIFICATION)


TECHNOLOGY

(A MAJOR PROJECT REPORT)

OF
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING

BY
Aditya Pandey (09104003)
Bikesh Chaudhary (09104012)
Ram Prakash Gupta (09104067)

UNDER THE SUPERVISION OF


Dr. B S Saini
Associate Professor

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


DR B R AMBEDKAR NATIONAL INSTITUTE OF TECHNOLOGY
JALANDHAR
Dr B R Ambedkar National Institute of Technology, Jalandhar

CERTIFICATE

We hereby certify that the work presented in this report entitled ‘Electronic Toll
Collection System Based on RFID Technology’ in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in
Electronics and Communication Engineering at Dr B R Ambedkar National
Institute of Technology, Jalandhar, is a record of our work carried out during
2012-2013 under the supervision of Dr B S Saini.

We have not submitted the matter embodied in this report to any other
University or Institute for the award of any other degree.

Aditya Pandey Bikesh Chaudhary Ram Prakash Gupta


(09104003) (09104012) (09104067)

This is to certify that the above statement made by the candidates is correct to
the best of my knowledge.

Signature of Supervisor:
Name of Supervisor: Dr B S Saini
Designation : Associate Professor
Date :

I
ACKNOWLEDGEMENT

Technical education equally comprises of practical and theoretical study. We


cannot achieve anything worthwhile in the field of technical education until and
unless theoretical education acquired in the classroom is effectively wedded to its
practical approach of the modern industry and other means of technical
application. And no academic endeavour can be single handedly accomplished.
This work is no exception.

We express our immense gratitude to our respected and learned guide Dr B S


Saini for his valuable help and guidance. We are indebted to sir for his
encouragement in helping us complete the project.

We are also thankful to Dr Arun Khosla, Head, Department of Electronics and


Communication Engineering, Dr B R Ambedkar National Institute of Technology,
Jalandhar and to our respected Director Dr S K Das, for permitting us to utilize all
the necessary facilities of the college.

We are also thankful to Dr R K Sunkaria and all the other staff members of our
department for their kind co-operation and suggestions for improvements in the
project.

We would like to express our deep appreciation towards our classmates for
providing us the necessary suggestions in our project and a cordial environment.

Aditya Pandey (09104003)

Bikesh Chaudhary (09104012)

Ram Prakash Gupta (09104067)

II
ABSTRACT

Our project is development of electronic toll collection (ETC) system using radio
frequency identification (RFID) technology. Research on ETC has been around
since 1992, during which RFID tags began to be widely used in vehicles to
automate toll processes. The proposed RFID system uses tags that are mounted
on the windshields of vehicles, through which information embedded on the tags
are read by RFID readers. The proposed system eliminates the need for motorists
and toll authorities to manually perform ticket payments and toll fee collections,
respectively. Data information are also easily exchanged between the motorists
and toll authorities, thereby enabling a more efficient toll collection by reducing
traffic and eliminating possible human errors.

III
LIST OF FIGURES

Figure No. Page No.

Figure 1.1 Model of Electronic Toll Plaza 1


Figure 2.1 Delhi Gurgaon Toll Plaza During Morning Rush Hour 5
Figure 2.2 Block Diagram of ETC System 7
Figure 3.1 RFID System 10
Figure 3.2 Block Diagram of RFID Tag 11
Figure 3.3 96-bit RFID Tag Protocol 11
Figure 3.4 Hardware of Em-18 Reader Module 12
Figure 3.5 Application Circuit for EM-18 Reader Module 13
Figure 3.6 Interfacing EM-18 Reader Module with Serial DB-9 Port 14
Figure 3.7 Inductive Coupling Between Tag and Reader 15
Figure 3.8 Propagation Coupling Between Tag and Reader 16
Figure 3.9 ARM Logo 17
Figure 3.10 LPC 2148 IC 18
Figure 3.11 Pin Diagram of LPC 2148 19
Figure 3.12 Architecture of LPC 2148 20
Figure 3.13 ARM 7 LPC 2148 Microcontroller Kit 22
Figure 3.14 Servo Motor with Motor Driver 24
Figure 3.15 Pulse Width Modulation for Servo Motor 25
Figure 3.16 Pulse Width Position of different types of Servo Motors 25
Figure 4.1 Flowchart of ETC System Algorithm 29

IV
INDEX
PAGE NO.

CERTIFICATE I

ACKNOWLEDGEMENT II

ABSTRACT III

LIST OF FIGURES IV

1. INTRODUCTION 1

1.1 ELECTRONIC TOLL COLLECTION (ETC) 1


1.2 DIAGRAM OF ETC 1
1.3 COMPONENTS OF ETC 2
1.4 ADVANTAGES OF ETC 2
1.5 ETC TECHNOLOGIES 3

2. PROJECT OVERVIEW 5

2.1PROBLEM DEFINITION 5
2.2 MOTIVATION 5
2.3 WHY RFID 6
2.4 FLOW CHART 7
2.5 TOOLS USED 8

3. HARDWARE 10

3.1 RFID 10
3.1.1 DIAGRAM OF RFID 10
3.1.2 RFID READER PROTOCOL 11
3.1.3 RFID MODULE 11
3.1.4 APPLICATION CIRCUIT 13
3.1.5 TYPES OF RFID TAGS 14
3.1.6 POWERING OF RFID TAG 15
3.1.7 OPERATING FREQUENCY 16

3.2 MICROCONTROLLER 17
3.2.1 ITRODUCTION TO ARM MICROCONTROLLER 17
3.2.2 LPC 2148 18
3.2.3 FEATURES OF LPC 2148 18
3.2.4 PIN DIAGRAM 19
3.2.5 ARCHITECTURE 20
3.2.6 BLUE BOARD LPC 2148 21

3.3 MOTORS 22
3.3.1 TYPES OF MOTOR 22
3.3.2 SERVO MOTOR 23
3.3.3 SERVO MOTOR WITH MOTOR DRIVER 24

4. CONCLUSION 26

5. FUTURE SCOPE OF APPLICATION 27

REFERENCES 28

APPENDIX I 29

APPENDIX II 30
ETC System Based on RFID Technology

CHAPTER 1 : INTRODUCTION

1.1 Electronic toll collection (ETC)


It is a technology enabling the electronic collection of toll payments. It has been
studied by researchers and applied in various highways, bridges, and tunnels
requiring such a process. This system is capable of determining if the car is
registered or not, and then informing the authorities of toll payment violations,
debits, and participating accounts .The most obvious advantage of this technology
is the opportunity to eliminate congestion in tollbooths, especially during festive
seasons when traffic tends to be heavier than normal. It is also a method by which
to curb complaints from motorists regarding the inconveniences involved in
manually making payments at the tollbooths. Other than this obvious advantage,
applying ETC could also benefit the toll operators.

It is purposed that each vehicle would be equipped with a transponder. “The


transponder‟s personalised signal would be picked up when the vehicle passed
through an intersection, and then relayed to a central computer which would
calculate the charge according to the intersection and the type of vehicle and add it
to the vehicle‟s bill.

1.2 DIAGRAM OF ETC

Figure 1.1 : Model of Electronic Toll Plaza

1
ETC System Based on RFID Technology

1.3 COMPONENTS OF ETC


1. Vehicle Identification

Automatic Vehicle Identification generally involves the use of


Transponders installed in the vehicle, which communicates with roadside
readers to identify the vehicle.

2. Vehicle Classification

Vehicle Classification is needed, as toll charges levied on a vehicle depend


not only on the toll route being used , but on the class of the vehicle –
Car/Jeep/Van, Truck, Bus, Multi Axle Vehicles etc.

3. Transaction Processing

Once the vehicle is identified, the toll charges need to be billed to the user
and the toll collected passed to the toll concessionaire. The ETC system has
to handle this financial transaction in a reliable and secure manner.

4. Violation Enforcement

This system needs to detect and manage cases of a vehicles passes through
an ETC lane without a valid Tag or insufficient funds in its account. Violator
detection and handling is essential for the success of an ETC system –
without policies and systems in place for this, an ETC system will simply
not work.

1.4 ADVANTAGES OF ELECTRONIC TOLL COLLECTION


For the Motorists:

1. Fewer or shorter queues at toll plazas by increasing toll booth service


turnaround rates;
2. Faster and more efficient service (no exchanging toll fees by hand);
3. The ability to make payments by keeping a balance on the card itself or by
loading a registered credit card;
4. The use of postpaid toll statements (no need to request for receipts).

2
ETC System Based on RFID Technology

For the Toll Operators:


1. Lowered toll collection costs;
2. Better audit control by centralized user account and
3. Expanded capacity without building more infrastructures.

For Government/Society:
1. Savings on fuel and reduction of emissions from idling and repeated stops
for vehicles.
2. Improves transparency of toll transactions.
3. Reduces revenue leakages.

Thus, the ETC system is a win-win situation for both the motorists and toll
operators, which is why it is now being extensively used throughout the world
ETC system commonly utilizes radio frequency identification (RFID) technology.

1.5 ETC TECHNOLOGIES


1. Dedicated Short Range Communications (DSRC)

Dedicated Short Range Communications is bidirectional communication between


an On Board Unit (OBU) and the Road Side Unit (RSE). This system works within
the 5.8 GHz band within 20-30 MHz.

5.8 Ghz Microwave (Passive)

In this case, the OBU does not have internal power source, like a battery. Instead, it
gets power from the reader. The Reader sends out electromagnetic waves to the
OBU and the antenna induces the energy to power the ICs.

5.8 Ghz (Active)

In this case, two way communications between OBUs and Road Side Units /
Infrastructure is possible. Active OBU has an internal power source, usually a
battery. The OBU use the power to work the IC and broadcasts a signal to the
reader continuously. It is normally used for long distance communication.

3
ETC System Based on RFID Technology

2. RFID (Radio Frequency Identification)

There are generally three types of RFID tags: active RFID tags, which contain a
battery and can transmit signals autonomously, passive RFID tags, which have no
battery and require an external source to provoke signal transmission, and battery
assisted passive(BAP) RFID tags, which require an external source to „wake up‟
but have significantly higher read range.

3. GNSS/CN (Global Navigational Satellite System/ Cellular Network System)

It is being used in Germany for commercial vehicle tolling. The location of the
vehicle is tracked using GPS receivers which transmit the information to the
control centre using GSM networks for calculation of toll.

This type of tolling eliminates the need of toll plaza infrastructure along highways.
However, enforcement of violated vehicle is a great challenge

4. Automatic Number Plate Recording (Vehicle Identification using Number


Plate)

In this system, images of the license plates of all vehicles are captured. These are
compared with the database of the license plate of the subscribers. This system
requires a robust system. They are less effective in foggy condition.

5. CALM (Communication Air-Interface, Long and Medium Range)

This technology supports multiple communication media including Cellular,


Infrared and Microwave. However, the ISO has till date, published the CALM
standard only for the infrared medium.

4
ETC System Based on RFID Technology

CHAPTER 2 : PROJECT OVERVIEW


2.1 PROBLEM DEFINITION
Design of RFID based Electronic Toll Collection (ETC) System.

 To facilitate Electronic payments process financial transactions without


human intervention at toll plazas.

 To allow such transactions to be performed while vehicles travel at near


highway cruising speed.

 To use RFID for automatic vehicle identification.

2.2 MOTIVATION

Figure 2.1 : Delhi- Gurgaon Toll Plaza during a Morning Rush Hour

 Highway expansion has led to a focus on toll collection.


Government of India has ambitious plan for India‟s highway network through
various phases of National Highways Development Project (NHDP), which are
being financed largely through user fees collected for the users of the improved
highways.
5
ETC System Based on RFID Technology

 An emerging priority is to implement an effective toll collection system.


Traditional tolling has come to be associated with delays at collection points and
congestion at toll plazas.

Example can be taken of Delhi-Gurgaon Toll Plaza, where few months ago they
had to stop toll collection for few days due to unmanageable congestion.

 Ambitious plan of Government of India to automate all the toll plazas.


We came to know about the ambitious plan of Govt. of India to automate all the
toll plazas throughout the country. Govt. of India formed a Committee, under
Nandan Nilekani, which would suggest the best available technology which could
be used for Electronic Toll Collection (ETC). The committee reviewed the various
ETC technologies, such as Dedicated Short Range Communication(DSRC), RFID-
Active and Passive, GPS based system, Automatic Number Plate Recording
(ANPR) etc., and it came to conclusion that Passive RFID (ISO 18000-6C) based
ETC is appropriate for India.

2.3 WHY RFID?


Passive RFID, besides satisfying functional requirements, is the cheapest solution
available. It is also a reliable, tested solution, despite being a relatively new
technology. It is extremely simple to use and administer, requiring no actions on
the part of the user (the sticker itself can be stuck on the vehicle by the auto vendor
or the manufacturer). It should be emphasized that the most persuasive reason in
favour of passive tags is the cost and low maintenance, it can cost 10% or less than
the cost of alternatives, and requires no battery replacement or any other action on
part of the user.

6
ETC System Based on RFID Technology

2.4 FLOW CHART

Signal
Processing • Gate Arm Motor
• Tag Control
• Microcontroller
• Reader • Traffic Lights Control
• Database (PC)
RFID Control

Figure 2.2 : BLOCK DIAGRAM OF ETC SYSTEM

7
ETC System Based on RFID Technology

2.5 TOOLS USED


1. Keil Software:

The Keil products from ARM include C/C++ compilers, debuggers, integrated
environments, RTOS, simulation models, and evaluation boards for ARM ,
Cortex-M, Cortex-R and LPC214x processor families. It supports every level of
software developer from the professional applications engineer to the student
just learning about embedded software development

2. Proteus Design Software:

Proteus is software for microprocessor simulation, schematic capture,


and printed circuit board (PCB) design. It is developed by Labcenter Electronics

System Component of Proteus

 ISIS Schematic Capture - a tool for entering designs.

 PROSPICE Mixed mode SPICE simulation - industry standard SPICE3F5


simulator combined with a digital simulator.

 ARES PCB Layout - PCB design system with automatic component placer,
rip-up and retry auto-router and interactive design rule checking.

 VSM - Virtual System Modelling lets co simulate embedded software for


popular micro-controllers alongside hardware design.

 System Benefits Integrated package with common user interface and fully
context sensitive help.

3. FLASH MAGIC

Flash Magic is a tool which used to program hex code in EEPROM of micro-
controller. It is a freeware tool. It only supports the micro-controller of Philips and
NXP. We can burn a hex code into those controllers which supports ISP (in
system programming) feature. If your device supports ISP then you can easily burn
a hex code into EEPROM of your device.

8
ETC System Based on RFID Technology

It supports several chips like ARM Cortex M0, M3, M4, ARM7 and 8051. It
uses Serial
or Ethernet protocol to program the flash of device.

4. HYPER TERMINAL

Hyper terminal is used for data communication via serial port com or TCP/IP
Winsock. HyperTerminal can be used to set up a dial-up connection to another
computer through the internal modem using Telnet or to access a bulletin board
service (BBS) in another computer. It can also be used to set up a connection for
data transfer between two computers (such as your desktop computer and a
portable computer) using the serial ports and for serial-port control of external
devices or systems such as scientific instruments, robots, or radio communications
stations. HyperTerminal can also be used as a troubleshooting tool when setting up
and using a modem. We can send commands through hyper terminal to make sure
that our modem is connected properly.

9
ETC System Based on RFID Technology

CHAPTER 3 : HARDWARE

3.1 RFID (RADIO FREQUENCY IDENTIFICATION)

RFID is a generic term used to identify technologies utilizing radio waves to


automatically identify people or objects. RFID technology was first introduced in
1948 when Harry Stockman wrote a paper exploring RFID technology entitled,
“Communication by Means of Reflected Power”. RFID technology has evolved
since then, and has been implemented in various applications, such as in
warehouse management, library system, attendance system, theft prevention, and
so on. In general, RFID is used for tracking, tracing, and identifying objects.

A complete RFID system consists of a transponder (tag), reader/writer, antenna,


and computer host. The transponder, better known as the tag, is a microchip
combined with an antenna system in a compact package. The microchip contains
memory and logic circuits to receive and send data back to the reader. These tags
are classified as either active or passive tags. Active tags have internal batteries
that allow a longer reading range, while passive tags are powered by the signal
from its reader and thus have shorter reading range. Tags could also be classified
based on the content and format of information. The classifications range from
Class 0 to Class 5. These classes have been determined by the Electronic Product
Code (EPC) Global Standard. In the table below, classes refer to a tag‟s basic
functionality (i.e., it either has a memory or an onboard power), while generation
refers to the tag specification‟s major release or version number.

3.1.1 DIAGRAM OF RFID SYSTEM

Figure 3.1 : RFID System

10
ETC System Based on RFID Technology

Figure 3.2 : Block Diagram of Passive RFID Tag

Figure 3.3 : 96-bit RFID Tag protocol

3.1.2 RFID READER PROTOCOL

96 bit EPC tags have been defined

• Allows for unique IDs for 268 million companies

• Each company can then have 16 million object classes

• Each object or SKU can have 68 billion serial numbers assigned to it

3.1.3 RFID Module


Features of EM-18 Reader Module:
 Reading Distance: 6-10 cm
 Dimension: 40mmx20mmx8mm (LxHxW)
 Frequency:125kHz

11
ETC System Based on RFID Technology

 Communications Parameter: 9600 bps,8,N,1


 Communication Interface: TTL Serial Interface, Wiegand Output
 Compatible Card codes:Manchester64-bit,modules64
 Current Rating: 35mA (Max)
 Operating Voltage: 4.6V - 5.4VDC
 Antenna : Integrated

Figure 3.4 : Hardware for EM-18 Reader Module

 EM-18 module is a 9 pin device which works on the protocol of ISO 18000-
6C which is best suitable for Indian context.
 We supply a highly rectified power voltage of 5V to the RFID to avoid any
kind of error in signal reading.

 After each and every read, the module notify with a buzzer beep and a LED
glow on a successful read.

12
ETC System Based on RFID Technology

 The communication of module, with arm7 controller kit and computer, is


done using RS-232 protocol. To follow that protocol for communication
max-232 IC is used on the EM-18 module board.

 RS-232 is a protocol used for serial communication which works on the


baud rate of 4800, 9600, 19200, 38400.

3.1.4 APPLICATION CIRCUIT FOR EM-18 READER MODULE

Figure 5 : Application Circuit for EM-18 Reader Module

13
ETC System Based on RFID Technology

Figure 3.6 : Interfacing EM-18 Reader module with Serial DB9 Port

3.1.5 Types of RFID Tags

Active Tags
 Battery powered
 Higher storage capacities (512 KB)
 Longer read range (300 feet)
 Typically can be re-written by RF Interrogators
 Cost around 50 to 250 dollars

Passive Tags
 Do not require power – Draws from Interrogator Field
 Lower storage capacities (few bits to 1 KB)
 Shorter read ranges (4 inches to 15 feet)
 Usually Write-Once-Read-Many/Read-Only tags
 Cost around 25 cents to few dollars

14
ETC System Based on RFID Technology

3.1.6 Powering of RFID Tag


In case of passive RFID device we have to power up the RFID tag from distant
position using the signal transmitted by RFID reader. This needs coupling between
the transmitter and reciever device and there are two method of powering up of a
passive RFID tag.

1. Inductive Coupling

In terms of operation, inductive coupling is the transfer of energy from one circuit
to another via the mutual inductance between the two circuits. For RFID inductive
coupling to be used, both the tag and the reader will have induction or "antenna"
coils. When the tag is placed close enough to the reader the field from the reader
coil will couple to the coil from the tag. A voltage will be induced in the tag that
will be rectified and used to power the tag circuitry

RFID inductive coupling is normally used on the lower RFID frequencies - often
LF, i.e. below 135 kHz or at 13.56 MHz. This type of powering of RFID tag is
used for short range RFID device.

Figure 3.7 : Inductive Coupling between Tag and Reader

15
ETC System Based on RFID Technology

2. Propagation Coupling:
This technique for powering of RFID tag is used for long range of RFID device.

Figure 3.8 : Propation Coupling between Tag and Reader

3.1.7 OPERATING FREQUENCIES:

RFID device work on different range of frequency from 125 KHz to 5.8 GHz.
Selection of operating range is decided on the basis of application and
requirement. For the purpose of Electronic toll collection system we need a
bandwidth of 868 MHz to 915 MHz which falls in the category of Ultra High
Frequency bandwidth. This BW is suitable for Indian context as this frequency is
highly power and cost efficient.

16
ETC System Based on RFID Technology

UHF Microwave
Frequency LF HF
868 - 915 2.45 GHz &
Ranges 125 KHz 13.56 MHz
MHz 5.8 GHz
Typical Max
Shortest Short Medium Longest
Read Range 1”-12” 2”-24” 1‟-10‟ 1‟-15‟
(Passive Tags)
Active tags with
Generally passive Active tags with
integral battery
Generally passive tags only, using integral battery or
Tag Power tags only, using inductive or
or passive tags
passive tags using
Source using capacitive
inductive coupling capacitive capacitive storage,
storage,
coupling E-field coupling
E-field coupling
Data Rate Slower Moderate Fast Faster
Ability to read
near Better Moderate Poor Worse
metal or wet
surfaces
Access Control &
Security
Identifying widgets Highway toll Tags
Library books supply chain
through Identification of
Laundry tracking
manufacturing private vehicle
Applications processes or in
identification Highway toll
fleets in/out of a
Access Control Tags
harsh environments yard or facility
Employee IDs
Ranch animal Asset tracking
identification
Employee IDs

3.2 Microcontroller
A microcontroller (sometimes abbreviated µC, uC or MCU) is a small
computer on a single integrated circuit containing a processor core, memory,
and programmable input/output peripherals.

3.2.1 Introduction to ARM

 ARM stands for Advanced RISC Machines

 An ARM controller is basically a 32bit controller designed and licensed by


ARM Holdings, a microprocessor design company headquartered in
England, founded in 1990 by Herman Hauser.

 It is one of the most used controller currently on the market.

Figure 3.9 : ARM Logo


17
ETC System Based on RFID Technology

3.2.2 LPC 2148


 The LPC2148 microcontrollers, manufactured by NXP (PHILIPS), are based
on a 32-bit ARM7TDMI-S CPU and combines with embedded high speed
flash memory of 512 KB.
 It has 128-bit wide memory interface and a unique accelerator architecture
which enable 32-bit execution at maximum clock rate. For critical code size
applications, the alternative 16-bit Thumb mode reduces code by more than
30% with minimal performance penalty.
 Due to its tiny size, low power consumption, blend of serial comm.
interfaces, various 32-bit timers, ADCs/DAC, PWM and 45 fast GPIO,
LPC2148 is ideal for applications such as:
o Access control, Point-Of-Sale.
o Comm. Gateways, protocol converters, soft modems, voice
recognition, low end imaging.
o Industrial Control, Medical Systems, etc.

3.2.3 Features of LPC 2148

 32-bit ARM7TDMI-SI microcontroller in tiny LQFP64 package Figure 3.10 : LPC2148 IC

 40 kB of SRAM 512 kB of flash program memory


 USB 2.0 Full Speed compliant Device controller.
 10-bit A/D converters, One 10-bit D/A converter.
 Two 32-bit Timers/External Event counters, PWM unit (6 o/p) and
watchdog.
 Multiple serial interfaced including 2 UARTs, 2 fast I2C-bus, SPI and
SSP.
 Vectored interrupt controller.
 45 of 5V tolerant fast GPIO pins.
 9 edge or level sensitive External Interrupt pins.
 60 MHz maximum CPU clock available from programmable on-chip
Phase Locked Loop (PLL).
 Power saving modes include Idle and Power-down.

18
ETC System Based on RFID Technology

 Processor wake-up from Power-down mode via external interrupt, USB,


Brown-Out Detect (BOD) or Real-Time Clock.
 Single power supply chip with Power-On Reset and BOD circuits.

3.2.4 PIN DIAGRAM OF LPC2148

Figure 3.11 : Pin Diagram of LPC 2148

19
ETC System Based on RFID Technology

3.2.5 Architecture of LPC 2148

Figure 3.12 : Architecture of LPC 2148

20
ETC System Based on RFID Technology

3.2.6 BLUE BOARD LPC 2148

BlueBoard-LPC214X is an evaluation board for LPC2148 ARM7TMDI based


microcontroller. The LPC2148 microcontroller has 512KB of internal flash and
32+8K RAM. Following are the salient features of the board.

 Dimensions: 114 X 127 mm2


 Two layer PCB (FR-4 material)
 Power:
 Power supply: DC 6.5V with power LED
 On-board linear regulators generate +3.3V/500mA and +5v/500mA from
power supply.
 USB connector (as alternate power source).
 Connectors:
 Extension headers for all microcontroller pins.
 RS232 connectors (2).
 VGA connector.
 PS/2 connector.
 JTAG connector.
 SD/MMC connector.
 USB B-type connector with Link-LED.
 All peripheral configurable via jumpers.
 Other Peripherals:
 256Kb I2C based EEPROM
 Audio power amplifier.
 2 line X 16 character LCD with back light control.
 Configurable for manual and automatic program download (ISP) via serial
port.
 8 controllable LEDs on SPI using 74HC595.

21
ETC System Based on RFID Technology

Figure 3.13 : ARM 7 LPC 2148 Microcontroller Kit

3.3 MOTORS:

An electric motor is an electric machine that converts electrical energy into


mechanical energy.
It is required for a physical barrier, such as a gate arm, to ensure that all vehicles
passing through the toll booth have paid a toll.

3.3.1 TYPES OF MOTOR


 There are various types of motors. Broadly we can categorize them into AC
and DC type motors.
 DC motors further have several types. The ones which are mostly used :
o Simple DC Motor
o Stepper Motor
o Servo Motor

22
ETC System Based on RFID Technology

3.3.2 SERVO MOTOR


A servo motor is a motor which forms part of a servomechanism. The servo motor
is paired with some type of encoder to provide position/speed feedback. This
feedback loop is used to provide precise control of the mechanical degree of
freedom driven by the motor. A servomechanism may or may not use a
servomotor. Servo motors have a range of 0°-180°.

Servos are controlled by sending them a pulse of variable width. The control wire
is used to send this pulse. The parameters for this pulse are that it has a minimum
pulse, a maximum pulse, and a repetition rate. Given the rotation constraints of the
servo, neutral is defined to be the position where the servo has exactly the same
amount of potential rotation in the clockwise direction as it does in the counter
clockwise direction. It is important to note that different servos will have different
constraints on their rotation but they all have a neutral position, and that position is
always around 1.5 milliseconds(ms).
To control the speed of the servo, the switches are open and close at different rates
in order to apply average voltages across the motor. The angle is determined by the
duration of a pulse that is applied to the control wire. This is called Pulse Width
Modulation. The servo expects to see a pulse every20ms. The length of the pulse
will determine how far the motor turns. For example, a 1.5ms pulse will make the
motor turn to the 90 degree position (neutral position).
When these servos are commanded to move, it will move to the position and hold
that position. If an external force pushes against the servo while the servo is
holding a position, the servo will resist from moving out of that position. The
maximum amount of force the servo can exert is the torque rating of the servo.
Servos will not hold their position forever though; the position pulse must be
repeated to instruct the servo to stay in position.

When a pulse is sent to a servo that is less than 1.5ms, the servo rotates to a
position and holds its output shaft by some number of degrees counter clockwise
from the neutral point. When the pulse is wider than 1.5ms the opposite occurs.
The minimal width and the maximum width of pulse that will command the servo
to turn to a valid position are functions of each servo. Different brands, and even
different servos of the same brand, will have different maximum and minimums.

23
ETC System Based on RFID Technology

Generally, the minimum pulse will be about 1ms wide and the maximum pulse will
be 2ms wide.

3.3.3 SERVO MOTOR WITH MOTOR DRIVER

Figure 3.14 : Servo Motor with Motor Driver

24
ETC System Based on RFID Technology

Figure 3.15 : Pulse Width Modulation of Servo Motor

Figure 3.16 : Pulse Width Position of Different types of Servo Motor

25
ETC System Based on RFID Technology

CONCLUSION

Passive RFID based is adequate for ETC in India. The advantages of this
technology in terms of cost and simplicity make it usable for the Indian
environment.

Within passive RFID there are multiple standards. To ensure that multiple
suppliers can provide the tags as well as readers, and that tags produced by one
producer can be read by all the readers, the standards have to be fixed. Passive
RFID based on EPC, Gen-2, ISO 18000-6C Standards for Electronic Toll
Collection on national Highways in India should be used.

The factors to be considered are:


 The system must be interoperable nationwide, and affordable.
 Technologies should be tried and tested.
 Systems should be easy to use.
 ETC should be scalable to other applications.
 Payments should be possible through credit cards and mobile phones etc.

Electronic toll collection can be a threat to location privacy. Many


implementations are implemented in a privacy-insensitive manner. Using E-
Cash and other modern cryptographic methods, it is possible to design systems that
do not know where individuals are, but are still able to enforce fares.

26
ETC System Based on RFID Technology

Future Scope and Application


India has about 42.36 lakh kilometers of road network, which is the second largest
in the world. The length of various categories of roads is as under:

National Highways: 70,934 km

State Highways: 1,54,522 km

Major district roads: 25,77,396 km

Rural roads: 14,33,577 km

According to the report given by National Highway Authority of India (NHAI)


National Highways carry 40% of road traffic. Due to this traffic congestion is very
high and to reduce it, Electronic Toll Collection must be implemented. And its
major concern is to reduce the traffic density, provides road safety and also
increases the Central Government‟s Economy. And National Highways Lane wise
distribution can be classified:

4-Lane - 22.3%

2-Lane - 52.3%

Single Lane - 25.4%

There is a possibility of maintaining ETC‟s on state highways as well as in busiest


hours in cities. This may leads to the reduction of congestion, pollution, traffic
violation at peak hours.

27
ETC System Based on RFID Technology

REFERENCES

 LPC2148 Datasheet (PDF) - NXP Semiconductors - ARM7-based


microcontrollers with full-speed USB 2.0
 ETC Report by Nandan Nilekani Committee.
 http://www.rfidjournal.com/
 http://www.wireless-technology-advisor.com/
 http://en.wikipedia.org/wiki/Electronic_toll_collection
 http://en.wikipedia.org/wiki/Rfid
 http://www.rhydolabz.com
 http://www.keil.com/
 http://www.nxp.com/
 http://www.arm.com/
 http://infocenter.arm.com/help/index.jsp
 http://www.microbuilder.eu/home.aspx
 http://www.embeddedlabs.in/
 http://www.edaboard.com/
 http://www.engineersgarage.com/forums/
 http:// forum.ngxtechnologies.com

28
ETC System Based on RFID Technology

Appendix I
ETC System Algorithm

Figure 4 : Flowchart of ETC System Algorithm

29
ETC System Based on RFID Technology

Appendix II
KEIL µVISION CODE

/*********************************************************************
*/
/* LPC214X.H: Header file for Philips LPC2141/42/44/46/48
*/
/*********************************************************************
**/

#ifndef __LPC214x_H
#define __LPC214x_H

/* Pin Connect Block */


#define PINSEL0 (*((volatile unsigned long *) 0xE002C000))
#define PINSEL1 (*((volatile unsigned long *) 0xE002C004))
#define PINSEL2 (*((volatile unsigned long *) 0xE002C014))

/* General Purpose Input/Output (GPIO) */


#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
#define IOPIN1 (*((volatile unsigned long *) 0xE0028010))
#define IOSET1 (*((volatile unsigned long *) 0xE0028014))
#define IODIR1 (*((volatile unsigned long *) 0xE0028018))
#define IOCLR1 (*((volatile unsigned long *) 0xE002801C))
#define IO0PIN (*((volatile unsigned long *) 0xE0028000))
#define IO0SET (*((volatile unsigned long *) 0xE0028004))
#define IO0DIR (*((volatile unsigned long *) 0xE0028008))
#define IO0CLR (*((volatile unsigned long *) 0xE002800C))
#define IO1PIN (*((volatile unsigned long *) 0xE0028010))
#define IO1SET (*((volatile unsigned long *) 0xE0028014))
#define IO1DIR (*((volatile unsigned long *) 0xE0028018))
#define IO1CLR (*((volatile unsigned long *) 0xE002801C))
#define FIO0DIR (*((volatile unsigned long *) 0x3FFFC000))
#define FIO0MASK (*((volatile unsigned long *) 0x3FFFC010))
#define FIO0PIN (*((volatile unsigned long *) 0x3FFFC014))
#define FIO0SET (*((volatile unsigned long *) 0x3FFFC018))
#define FIO0CLR (*((volatile unsigned long *) 0x3FFFC01C))
#define FIO1DIR (*((volatile unsigned long *) 0x3FFFC020))
#define FIO1MASK (*((volatile unsigned long *) 0x3FFFC030))
#define FIO1PIN (*((volatile unsigned long *) 0x3FFFC034))
#define FIO1SET (*((volatile unsigned long *) 0x3FFFC038))
#define FIO1CLR (*((volatile unsigned long *) 0x3FFFC03C))

/* VPB Divider */

30
ETC System Based on RFID Technology

#define VPBDIV (*((volatile unsigned char *) 0xE01FC100))

/* Reset */
#define RSID (*((volatile unsigned char *) 0xE01FC180))

/* Code Security / Debugging */


#define CSPR (*((volatile unsigned char *) 0xE01FC184))

/* System Control Miscellaneous */


#define SCS (*((volatile unsigned long *) 0xE01FC1A0))

/* Timer 0 */
#define T0IR (*((volatile unsigned long *) 0xE0004000))
#define T0TCR (*((volatile unsigned long *) 0xE0004004))
#define T0TC (*((volatile unsigned long *) 0xE0004008))
#define T0PR (*((volatile unsigned long *) 0xE000400C))
#define T0PC (*((volatile unsigned long *) 0xE0004010))
#define T0MCR (*((volatile unsigned long *) 0xE0004014))
#define T0MR0 (*((volatile unsigned long *) 0xE0004018))
#define T0MR1 (*((volatile unsigned long *) 0xE000401C))
#define T0MR2 (*((volatile unsigned long *) 0xE0004020))
#define T0MR3 (*((volatile unsigned long *) 0xE0004024))
#define T0CCR (*((volatile unsigned long *) 0xE0004028))
#define T0CR0 (*((volatile unsigned long *) 0xE000402C))
#define T0CR1 (*((volatile unsigned long *) 0xE0004030))
#define T0CR2 (*((volatile unsigned long *) 0xE0004034))
#define T0CR3 (*((volatile unsigned long *) 0xE0004038))
#define T0EMR (*((volatile unsigned long *) 0xE000403C))
#define T0CTCR (*((volatile unsigned long *) 0xE0004070))

/* Timer 1 */
#define T1IR (*((volatile unsigned long *) 0xE0008000))
#define T1TCR (*((volatile unsigned long *) 0xE0008004))
#define T1TC (*((volatile unsigned long *) 0xE0008008))
#define T1PR (*((volatile unsigned long *) 0xE000800C))
#define T1PC (*((volatile unsigned long *) 0xE0008010))
#define T1MCR (*((volatile unsigned long *) 0xE0008014))
#define T1MR0 (*((volatile unsigned long *) 0xE0008018))
#define T1MR1 (*((volatile unsigned long *) 0xE000801C))
#define T1MR2 (*((volatile unsigned long *) 0xE0008020))
#define T1MR3 (*((volatile unsigned long *) 0xE0008024))
#define T1CCR (*((volatile unsigned long *) 0xE0008028))
#define T1CR0 (*((volatile unsigned long *) 0xE000802C))
#define T1CR1 (*((volatile unsigned long *) 0xE0008030))
#define T1CR2 (*((volatile unsigned long *) 0xE0008034))
#define T1CR3 (*((volatile unsigned long *) 0xE0008038))
#define T1EMR (*((volatile unsigned long *) 0xE000803C))
#define T1CTCR (*((volatile unsigned long *) 0xE0008070))

/* Pulse Width Modulator (PWM) */


#define PWMIR (*((volatile unsigned long *) 0xE0014000))
#define PWMTCR (*((volatile unsigned long *) 0xE0014004))

31
ETC System Based on RFID Technology

#define PWMTC (*((volatile unsigned long *) 0xE0014008))


#define PWMPR (*((volatile unsigned long *) 0xE001400C))
#define PWMPC (*((volatile unsigned long *) 0xE0014010))
#define PWMMCR (*((volatile unsigned long *) 0xE0014014))
#define PWMMR0 (*((volatile unsigned long *) 0xE0014018))
#define PWMMR1 (*((volatile unsigned long *) 0xE001401C))
#define PWMMR2 (*((volatile unsigned long *) 0xE0014020))
#define PWMMR3 (*((volatile unsigned long *) 0xE0014024))
#define PWMMR4 (*((volatile unsigned long *) 0xE0014040))
#define PWMMR5 (*((volatile unsigned long *) 0xE0014044))
#define PWMMR6 (*((volatile unsigned long *) 0xE0014048))
#define PWMPCR (*((volatile unsigned long *) 0xE001404C))
#define PWMLER (*((volatile unsigned long *) 0xE0014050))

/* Universal Asynchronous Receiver Transmitter 0 (UART0) */


#define U0RBR (*((volatile unsigned char *) 0xE000C000))
#define U0THR (*((volatile unsigned char *) 0xE000C000))
#define U0IER (*((volatile unsigned long *) 0xE000C004))
#define U0IIR (*((volatile unsigned long *) 0xE000C008))
#define U0FCR (*((volatile unsigned char *) 0xE000C008))
#define U0LCR (*((volatile unsigned char *) 0xE000C00C))
#define U0MCR (*((volatile unsigned char *) 0xE000C010))
#define U0LSR (*((volatile unsigned char *) 0xE000C014))
#define U0MSR (*((volatile unsigned char *) 0xE000C018))
#define U0SCR (*((volatile unsigned char *) 0xE000C01C))
#define U0DLL (*((volatile unsigned char *) 0xE000C000))
#define U0DLM (*((volatile unsigned char *) 0xE000C004))
#define U0ACR (*((volatile unsigned long *) 0xE000C020))
#define U0FDR (*((volatile unsigned long *) 0xE000C028))
#define U0TER (*((volatile unsigned char *) 0xE000C030))

/* Universal Asynchronous Receiver Transmitter 1 (UART1) */


#define U1RBR (*((volatile unsigned char *) 0xE0010000))
#define U1THR (*((volatile unsigned char *) 0xE0010000))
#define U1IER (*((volatile unsigned long *) 0xE0010004))
#define U1IIR (*((volatile unsigned long *) 0xE0010008))
#define U1FCR (*((volatile unsigned char *) 0xE0010008))
#define U1LCR (*((volatile unsigned char *) 0xE001000C))
#define U1MCR (*((volatile unsigned char *) 0xE0010010))
#define U1LSR (*((volatile unsigned char *) 0xE0010014))
#define U1MSR (*((volatile unsigned char *) 0xE0010018))
#define U1SCR (*((volatile unsigned char *) 0xE001001C))
#define U1DLL (*((volatile unsigned char *) 0xE0010000))
#define U1DLM (*((volatile unsigned char *) 0xE0010004))
#define U1ACR (*((volatile unsigned long *) 0xE0010020))
#define U1FDR (*((volatile unsigned long *) 0xE0010028))
#define U1TER (*((volatile unsigned char *) 0xE0010030))

#endif // __LPC214x_H

32
ETC System Based on RFID Technology

/**********************************************************/
/* Name : main.c */
/******************************************************/

#include <stdio.h> /* prototype declarations for I/O functions */


#include <LPC214x.H> /* LPC21xx definitions */
#include <stdlib.h>
#include "Serial.h"
#include "lcd.h"
#include "db.c"

char received_ID[12]; //RFID Tag Number of 12 bytes

int main (void) { /* execution starts here */


int received_byte;
unsigned int count=0;
char buf[16] = {0};
PINSEL0 |= (1 << 7);
IO0DIR |= (1<<7);
uart0_init();
uart1_init(); // Initialize UART1
init_lcd();
delay(100000);
lcd_clear(); // clear display
lcd_putstring(0," ETC System ");
lcd_putstring(1,">");
uart0_puts ("\n\r UART0 Test by abcd \n");
timer_init(1); //Motor DOWN

while (1) { /* An embedded program does not stop */


count=0;
if(count==0)
{
do
{
received_byte=uart1_getkey();
received_ID[count]=(char)received_byte;
count++;
}while(count<12);
}

sprintf((char *)buf, "ID:%s ", received_ID);


lcd_putstring(1, (char *)buf);
uart0_puts(" \n \r Receved_Id= ");
uart0_puts (received_ID); // Transfer data to PC through Serial
sprintf((char *)buf, "%s ", received_ID);
db_compare((char *)buf);
}
}

/**********************************************************/

33
ETC System Based on RFID Technology

/* Name : PWM_motor.c */

/* Description : Generate PWM signal to operate servo Motor*/

/******************************************************/

#include <LPC214X.h>

#define PLOCK 0x0400


#define TIME 2000000
// ?????P0.31??
#define LED (1 << 7)

void timer0_MCR0(int count)


{
T0TC = 0; // set initial value of TC Timer Counter.
T0PR = 0; // set value of prescalar
T0MCR = 0x03; //Interrupt on MR0 and the TC will be reset
if MR0 matches it.
T0MR0 = count; // (0x2DC8A01)matched register 0 of timer0
T0TCR = 0x01; // timer enable
while(T0IR == 0x00); // wait for timer for overflow
T0IR = 0xff; // clear interrupts
T0TCR = 0x02; // timer reset
}

void timer1_MCR1(int count)


{
T1TC = 0; // set initial value of TC Timer Counter.
T1PR = 0; // set value of prescalar
T1MCR = 0x18; //Interrupt on MR1 and the TC will be reset
if MR1 matches it.
T1MR1 = count; // (0x2DC8A01)matched register 1 of timer1
T1TCR = 0x01; // timer enable
while(T1IR == 0x00); // wait for timer for overflow
T1IR = 0xff; // clear interrupts
T1TCR = 0x02; // timer reset
}

void timer_init (int x)


{
int m;
int a; //a=1 == count for 0.1ms
int i;
m=6000;
IO0DIR = 0xffffffff;
switch(x)
{
case 0: //Motor UP
a=8;
for(i=0;i<200;i++)
{

34
ETC System Based on RFID Technology

IO0SET = LED;
timer0_MCR0(m*a);
IO0CLR = LED;
timer0_MCR0((200-a)*m);
}

timer1_MCR1(m*10000);
break;
case 1: //Motor DOWN
a=17;
for(i=0;i<200;i++)
{
IO0SET = LED;
timer0_MCR0(m*a);
IO0CLR = LED;
timer0_MCR0((200-a)*m);
}

break;
}

/**********************************************************/
/* Name : db.c */

/* Description : Database of RFID tags. Verification of the tags and


controlling of motor accordingly is done here.*****/

/******************************************************/

#include<LPC214x.h>
#include "PWM_motor.c"
#include "lcd.h"
#include "Serial.h"

int M[3][3]={{1,3000,300},{2,200,200},{3,50,150}};

void database(int x)
{
char buf[16] = {0};
//buf[16] = {0};
//M[3][3]=

if(M[x][1]>=M[x][2])
{
M[x][1]=M[x][1]-M[x][2];
//motor_up();
timer_init(0);
sprintf((char *)buf, "BALANCE : %i ",
M[x][1]);

35
ETC System Based on RFID Technology

lcd_putstring(1, (char *)buf);


uart0_puts(" \n \r BALANCE= ");
uart0_puts ((char *)buf); // Transffer
data to PC through Serial
//display(M[x][2]);
timer_init(1);
}
else if((M[x][1]<M[x][2]))
{
//display('low balance');
lcd_putstring(1, " LOW BALANCE!!! ");
uart0_puts(" \n \r LOW BALANCE!!!");
}

void db_compare(char *buf)


{
int i,j,x;
char
M1[3][13]={{"0100162CBF84"},{"6D002DEC16BA"},{"6D002E8A32FB"}};
for(i=0;i<3;i++)
{
x=0;
for(j=0;j<12;j++)
{
if(M1[i][j]==buf[j])
x++;
}
if(x==12)
database(i);
}

/**********************************************************/
/* Name : Serial.h */
/******************************************************/
int uart0_getkey(void);
int uart1_getkey(void);
void uart1_init (void);
void uart0_init (void);
void uart1_putc (char);
void uart0_putc (char);
void uart1_puts (char *);
void uart0_puts (char *);

/**********************************************************/
/* Name : Serial.c */
/******************************************************/

36
ETC System Based on RFID Technology

#include <LPC21xx.H> /* LPC21xx definitions


*/
#include "Serial.h"

#define CR 0x0D

/* implementation of putchar (also used by printf function to output


data) */
int sendchar (int ch) { /* Write character to Serial
Port */

if (ch == '\n') {
while (!(U1LSR & 0x20));
U1THR = CR; /* output CR */
}
while (!(U1LSR & 0x20));
return (U1THR = ch);
}

int uart0_getkey (void) { /* Read character from


Serial Port */

while (!(U0LSR & 0x01));

return (U0RBR);
}

int uart1_getkey (void) { /* Read character from


Serial Port */

while (!(U1LSR & 0x01));

return (U1RBR);
}

void uart1_init()
{
/* initialize the serial interface */
PINSEL0 = (PINSEL0 & ~(3 << 16)) | (1 << 16);
PINSEL0 = (PINSEL0 & ~(3 << 18)) | (1 << 18);
//PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1
*/
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit
*/
U1DLM = 1;
U1DLL = 134; /* 9600 Baud Rate @ 15MHz VPB
Clock <97 @ 15MHz> <78 @ 12MHz> */
//U1ACR = 0x05;
U1LCR = 0x03; /* DLAB = 0
*/

37
ETC System Based on RFID Technology

}
/***************************************************************/
/****Function for send character 1 time via UART1****/
/***************************************************************/
void uart1_putc(char c)
{
while(!(U1LSR & 0x20)); // Wait until UART1 ready to send
character
U1THR = c; // Send character
}
/***************************************************************/
/*********Function for send string via UART1*******/
/***************************************************************/
void uart1_puts(char *p)
{
while(*p) // Point to character
{
uart1_putc(*p++); // Send character then point to next
character
}
}
/***************************************************************/
/**********Function for Initial UART0 ******/
/***************************************************************/

void uart0_init()
{
/* initialize the serial interface */
PINSEL0 = (PINSEL0 & ~(3 << 0)) | (1 << 0);
PINSEL0 = (PINSEL0 & ~(3 << 2)) | (1 << 2);
//PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0
*/
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit
*/
U0DLM = 1;
U0DLL = 134; /* 9600 Baud Rate @ 15MHz VPB
Clock */
U0LCR = 0x03; /* DLAB = 0
*/

}
/***************************************************************/
/*****Function for send character 1 time via UART0********/
/***************************************************************/
void uart0_putc(char c)
{
while(!(U0LSR & 0x20)); // Wait until UART0 ready to send
character
U0THR = c; // Send character
}
/***************************************************************/
/************** Function for send string via UART1******/

38
ETC System Based on RFID Technology

/***************************************************************/
void uart0_puts(char *p)
{
while(*p) // Point to character
{
uart0_putc(*p++); // Send character then point to next
character
}
}

/**********************************************************/
/* Name : lcd.h */
/******************************************************/

#ifndef _LCD_H
#define _LCD_H

#define MAX_CHAR_IN_ONE_LINE 16

enum ROW_NUMBERS
{
LINE1,
LINE2
};

void init_lcd(void);
void lcd_putstring(unsigned char line, char *string);
void lcd_clear(void);
void lcd_backlight_on(void);
int lcd_gotoxy(unsigned int x, unsigned int y);
void lcd_putchar(int c);

#endif

/**********************************************************/
/* Name : lcd.c */
/******************************************************/

#include <LPC214x.H> /* LPC214x definitions */


#include "lcd.h"

#define LCD_BACK_LIGHT_TIMEOUT 1000

#define LCD_BACKLIGHT (1 << 21)

#define LCD_BACK_LIGHT_DIR IO1DIR


#define LCD_BACK_LIGHT_SET IO1SET
#define LCD_BACK_LIGHT_CLR IO1CLR

#define LCD_DATA_DIR IO0DIR


#define LCD_DATA_SET IO0SET
#define LCD_DATA_CLR IO0CLR

39
ETC System Based on RFID Technology

#define LCD_CTRL_DIR IO1DIR


#define LCD_CTRL_SET IO1SET
#define LCD_CTRL_CLR IO1CLR

#define LCDRS (1 << 24)


#define LCDRW (1 << 23)
#define LCDEN (1 << 22)

#define LCD_D4 (1 << 10)


#define LCD_D5 (1 << 11)
#define LCD_D6 (1 << 12)
#define LCD_D7 (1 << 13)

#define LCD_DATA_MASK (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)


#define LCD_BUSY_FLAG LCD_D7

#define LCD_CONTROL_MASK 0x01C00000

/**
**********************************************************************
****

****
Function Name : delay()

**********************************************************************
*********
*/
void delay(int count)
{
int j=0,i=0;

for(j=0;j<count;j++)
{
/* At 60Mhz, the below loop introduces
delay of 10 us */
for(i=0;i<35;i++);
}
}

/**
**********************************************************************
**********************
Function Name : wait_lcd()

**********************************************************************
**********************
*/
void wait_lcd( void )
{
LCD_CTRL_CLR |= LCDRS;

40
ETC System Based on RFID Technology

LCD_CTRL_SET |= LCDRW |LCDEN;


while(IO1PIN & LCD_BUSY_FLAG); /* wait for busy flag to become
low */

LCD_CTRL_CLR |= LCDEN | LCDRW;


LCD_DATA_DIR |= LCD_DATA_MASK;

delay(100);
}
/**
**********************************************************************
**********************
Function Name : lcd_command_write()

**********************************************************************
**********************
*/
void lcd_command_write( unsigned char command )
{
unsigned char temp=0;
unsigned int temp1=0;

temp=command;
temp=(temp>>4)&0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;

LCD_CTRL_CLR = LCDRS;
LCD_CTRL_SET = LCDEN;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
delay(10000);
LCD_CTRL_CLR = LCDEN;

temp=command;
temp&=0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;
delay(100*2);

LCD_CTRL_CLR |= LCDRS;
LCD_CTRL_SET |= LCDEN;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
delay(10000);
LCD_CTRL_CLR |= LCDEN;
wait_lcd();
}
/**
**********************************************************************
**********************
Function Name : set_lcd_port_output()

41
ETC System Based on RFID Technology

**********************************************************************
**********************
*/
void set_lcd_port_output( void )
{
LCD_CTRL_DIR |= ( LCDEN | LCDRS | LCDRW );
LCD_CTRL_CLR |= ( LCDEN | LCDRS | LCDRW );
LCD_DATA_DIR |= LCD_DATA_MASK;
}
/* *
**********************************************************************
**********************
Function Name : lcd_clear()

**********************************************************************
**********************
*/
void lcd_clear( void)
{
lcd_command_write( 0x01 );
}
/**
**********************************************************************
**********************
Function Name : lcd_gotoxy()

**********************************************************************
**********************
*/
int lcd_gotoxy( unsigned int x, unsigned int y)
{
int retval = 0;

if( (x > 1) && (y > 15) )


{
retval = -1;
} else {
if( x == 0 )
{
lcd_command_write( 0x80 + y ); /* command - position
cursor at 0x00 (0x80 + 0x00 ) */
} else if( x==1 ){
lcd_command_write( 0xC0 + y ); /* command - position
cursor at 0x40 (0x80 + 0x00 ) */
}
}
return retval;
}

/**
**********************************************************************
**********************

42
ETC System Based on RFID Technology

Function Name : lcd_data_write()

**********************************************************************
**********************
*/
void lcd_data_write( unsigned char data )
{
unsigned char temp=0;
unsigned int temp1=0;

temp=data;
temp=(temp>>4)&0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;

LCD_CTRL_SET |= LCDEN|LCDRS;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
LCD_CTRL_CLR |= LCDEN;

temp=data;
temp&=0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;

LCD_CTRL_SET |= LCDEN|LCDRS;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
LCD_CTRL_CLR |= LCDEN;
wait_lcd();
}
/**
**********************************************************************
**********************
Function Name : lcd_putchar()

**********************************************************************
**********************
*/
void lcd_putchar( int c )
{
lcd_data_write( c );
}

/**
**********************************************************************
**********************
Function Name : lcd_putstring()

**********************************************************************
**********************
*/
void lcd_putstring( unsigned char line, char *string )
{

43
ETC System Based on RFID Technology

unsigned char len = MAX_CHAR_IN_ONE_LINE;

lcd_gotoxy( line, 0 );
while(*string != '\0' && len--)
{
lcd_putchar( *string );
string++;
}
}

/**
**********************************************************************
**********************
Function Name : lcd_backlight_on()

**********************************************************************
**********************
*/
void lcd_backlight_on()
{
LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT;
LCD_BACK_LIGHT_SET |= LCD_BACKLIGHT;
}

/**
**********************************************************************
**********************
Function Name : turn_off_lcd_back_light()

**********************************************************************
**********************
*/
void turn_off_lcd_back_light_cb(void)
{
LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT;
LCD_BACK_LIGHT_CLR |= LCD_BACKLIGHT;
}

/**
**********************************************************************
**********************
Function Name : init_lcd()

**********************************************************************
**********************
*/
void init_lcd( void )
{
set_lcd_port_output();
delay(100*100);
lcd_command_write(0x28); /* 4-bit interface, two line, 5X7
dots. */

44
ETC System Based on RFID Technology

lcd_clear() ; /* LCD clear


*/
lcd_command_write(0x02); /* cursor home
*/
lcd_command_write(0x06); /* cursor move direction
*/
lcd_command_write(0x0C) ; /* display on */
lcd_gotoxy(0, 0);
lcd_clear();
lcd_putstring(0,"ELECTRONIC TOLL");
lcd_putstring(1,"COLLECTION SYS.");
}

45

Das könnte Ihnen auch gefallen