You are on page 1of 50

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

CHAPTER 1

INTRODUCTION
In this modern era, all commercial as well as industrial tasks are done at a more accurate and less time consuming rate. Everything is done at a much easier level which is the aim of todays fast developing technology. Be it commercial or an industrial one, we expect maximum accuracy. Under these circumstances, the routine task of manually switching and monitoring seems very monotonous and time consuming. It is even more disturbing when one realizes that the track switching unnecessarily leads to so many accidents. Keeping this in mind, we have come up with a project which can completely stop collision of trains. Rail transport is the most commonly used mode of long distance transportation in India. Rail operations throughout the country are run by the State-owned Company, Indian Railways. The rail network traverses through the length and breadth of the country, covering a total length of 63,140 km (39,200 miles). RFID tags are mounted on the locomotive which continuously transmits a specific code assigned to each TAG. The RFID receivers are placed at regular intervals on the locomotive track. When the locomotive moves over the receiver, it detects the precise TAG code. This detected code is transmitted to the control room at the base stations using radio communication. The information received at the control room is continuously monitored by a computer. The computer detects any collision occurring chance (i.e. if two locomotives are on the same track commencing in opposite directions, any fault in the track. . . . . . .). It warns the locomotive operator about the danger. The warnings can be of two types:
1. 2.

The track controlling circuit is directed to change one of the locomotives track. The locomotive is directed to stop with the assistance of track traffic light or by some

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

other means.

CHAPTER 2

RFID (Radio Frequency Identifier)


Radio-frequency identification (RFID) is an automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders. Using 2.45GHz Radio Frequency Identification, RFID automatically identifies and positions all kind of rolling stock with high precision, at high speed and in the most demanding environments. In 1946 Leon Theremin invented an espionage tool for the Soviet which retransmitted incident radio waves with audio information. Sound waves vibrated a diaphragm which slightly altered the shape of the resonator, which modulated the reflected radio frequency. Even though this device was a passive covert listening device, not an identification tag, it has been attributed as the first known device and a predecessor to RFID technology. The technology used in RFID has been around since the early 1920s according to one source.

Block diagram

RFID Receiver

RFID Transmitter

To Microcontroller

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

2.45GHz

Fig2.1: RFID Module

2.1 RFID TRANSMITTER


All RFID transmitters have a unique eight-digit identification number, and a 32-bit check sum, which ensures the high reliability of the system. ID-tags are available as read-only or read/ write. As RFID tag is an object that can be attached to or incorporated into a product, animal, or person for the purpose of identification using radio waves. Chip-based RFID tags contain silicon chips and antennas. Passive tags require no internal power source, whereas active tags require a power source. Indian Railways can use a specialized classification code for identifying its locomotives. The code can even be of three to 10 letters, followed by a digit identifying the model (either assigned chronologically or encoding the power rating of the locomotive). The three (or four) letters are, from left to right, the gauge of tracks on which the locomotive operates, the type of power source or fuel for the locomotive, and the kind of operation the locomotive can be used for.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

2.2 RFID READER


RFID reader modules are also called as interrogator. They convert radio waves returned from the RFID tag into a form that can be passed on to controllers, which can make use of it. RFID tags and readers have to be tuned to the same frequency in order to communicate. RFID Systems use many different frequencies, but the most common and widely used and supported is 125 kHz.

2.2.1 RFID Reader Module:

Fig2.2: RFID Reader Module

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

PIN NO Pin no. 4 Pin no. 6

SIGNAL Data high (JP4) TxD

DESCRIPTION It will give data high signal Transmit data (TTL level) o/p from module to serial interface

Pin no.8

RxD

Receive data (TTL level) i/p to module from serial interface

Pin no. 12 Pin no. 13 Pin no. 14

Buzzer (active low) LED (active low) Data low (JP4)

Buzzer will buzz for 280ms when tag is detected LED will glow for 280ms when tag is detected It will give data low signal Loop antenna should be connected

Pin no. 27&28 Antenna i/p (JP5)

Table2.1: RFID reader module pin description

2.2.2 TECHNICAL DATA:


Frequency Read range Power supply Current consumption max. Operating temp Serial interface format : 125 kHz : up to 8 cm : 5V DC : 60 mA : -200 to +650 : 9600 baud, no parity, 8 data bits, 1 stop bit.

2.3 Types of RFID Tags:


RFID cards are also known as proximity, proxy or contactless cards and come in 3 general varieties: passive, semi passive(also known as semi active), or active.

2.3.1 Passive Tags


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

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

integrated circuit in the tag to power up and transmit a response. Most passive tags signal by backscattering the carrier signal from the reader. This means that the antenna has to be designed to both 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 EEPROM for storing data. Unlike passive RFID tags, active RFID tags have their own internal power source which is used to power any Integrated Circuits that generate the outgoing signal.

2.3.2 Active tags


Active RFID tags have their own internal power source which is used to power any Integrated circuits that generate the outgoing signal. Active tags are typically much more reliable (e.g. fewer errors) the passive tags due to the ability for active tags to conduct a session with the reader. Active tags, due to their onboard power supply, also transmit at higher power levels than passive tags, allowing them to be more to be more effective in RF challenged environments like water (including humans/cattle, which are mostly water), metal (shipping containers, vehicles), or at longer distances. Many active tags have practical ranges of hundreds of meters, and a battery life of up to 10 years. Active RFID tags include sensors such as temperature logging which have been used in concrete maturity monitoring or to monitor temperature perishable goods. Other sensors that have been married with active RFID include humidity, shock/vibration, light, radiation, temperature, and atmospherics like ethylene. Active tags typically have much longer range (approximately 100m/300 feet) and larger memories than passive tags, as well as the ability to store additional information sent by the transceiver.

2.4 THE WORKING OF RFID

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Fig2.3: Working Of RFID

RFID is so called Radio Frequency Identification system which consists of two main parts: transmitter and receiver. The labels, access cards and even passports in some countries they have RFID transponders integrated. These transponders are called tags. The user can store RFID card/tag details in the module memory. When the user shows the card, the ID is read and compared with the stored card memory. When there is a match the unit activates a relay provided on the baseboard. This relay when connected to the Door Closure mechanism can open for a certain period for the person to enter after which it closes the door once again. If the RFID card shown does not match with the stored database, then the door remains closed. Facility has been provided to add and delete the card numbers using a Master Card. Beep and LED are provided for Audio and Visual indication of various conditions.

2.4.1 ADDING AND DELETING CARDS (TAGS): After making master card you can add or delete cards from the memory. To add or to delete cards first show master card, you will get single short BEEP and LED flashes at faster

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

rate. Then show new cards to be added in the memory. For every addition you will get a single short Beep. For deletion you will get two short Beeps. Show the Master Card once again to complete the Addition or Deletion Process. If the memory is full while adding cards it will give long BEEP and comes out. LED starts blinking at normal rate to show power ON status.

2.4.2 TECHNICAL DETAILS 1. Card memory: Up to 40 Cards (For Consecutive Numbers) or up to 25 Cards (For Random Numbers) Up to 150 Cards (For Consecutive Numbers) or up to 100 Cards (For Random Numbers) 2. Relay ON timing: 4 Seconds 3. Maximum Time between Read to Activations of Relay: 350 milliseconds520 milliseconds. 4. Input Voltage: 8V to 12V DC. 5. Frequency of Operation: 125 kHz 6. Read Range: up to 8 cm 7. Serial Interface Format: 9600 bps, No Parity, 8 Data bits, 1 Stop bit

2.5 Applications:
Access control Time and attendance Vending machines Industrial and other applications where Reading and comparing of the same is required for permission to access.

2.6 Advantages:

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Tag detection not requiring human intervention reduces employment costs and eliminates human errors from data collection. As no line-of-sight is required, tag placement is less constrained. RFID tags have a longer read range than, e.g., barcodes. Tags can have read/write memory capability, while barcodes do not. An RFID tag can store large amounts of data additionally to a unique identifier. Unique item identification is easier to implement with RFID than with barcodes. Tags are less sensitive to adverse conditions (dust, chemicals, physical damage etc.). Many tags can be read simultaneously. RFID tags can be combined with sensors. Automatic reading at several places reduces time lags and inaccuracies in an inventory. Tags can locally store additional information; such as distributed data storage may increase fault tolerance of the entire system. Reduces inventory control and provisioning costs.

CHAPTER 3

AT 89C51 MICROCONTROLLER
The AT89C51 microcontroller used here is a low power, high performance CMOS 8-bit microcontroller with 4KB of Flash memory. The device is manufacturing using Atmels high density nonvolatile memory technology and is compatible with the industry standard MCS51 instruction set and pin outs. The on-chip flash allows the program memory to be reprogrammed. By combining a versatile 8-bit CPU with flash on a monolithic chip, the AT89C51 is a powerful microcontroller that provides a highly flexible and cost effective solution to many embedded control applications.

Fig3.1: Pin diagram of AT89C51 Microcontroller

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

3.1 FEATURES

8-bit CPU optimized for control applications Extensive Boolean processing capabilities 64K program memory address space 64K data memory address space 4K bytes of on-chip program memory 128 bytes of on-chip data RAM 32 bi-directional and individually addressable I/O lines Two 16-bit timers Full duplex UART 6-source/5 vector interrupt structure with two priority levels On-chip clock oscillator Easy interface to all microprocessors/microcontrollers Operates ratio metrically or with 5V DC or analog span adjusted voltage reference No zero or full-scale adjust required 8-channel multiplexer with address logic 0V to 5V input range with single 5V power supply Outputs meet TTL voltage level specifications Standard hermetic or molded 28-pin DIP package Resolution of 8 bits Total Unadjusted Error 1 /2 LSB and 1 LSB Low power up to 15mW Conversion Time of 100s

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

3.2 89C51 ARCHITECTURE

Fig3.2: Architecture of AT89C51 Microcontroller

PORT0
Port0 is an 8-bit open drain bi-directional I/O port. As an output port each pin can sink 8 TTL inputs. When 1s are written to port0 pins, the pins can be used as high-impedance inputs. Port0 may also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull-ups. Port0 also receives hex code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Each bit of this SFR P0 corresponds to one of the pins on the microcontroller. For example, bit 0 of Port0 is pin P0.0, bit 7 is pin P0.7. Writing a value 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level.

PORT1
Port1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port1 output buffers can sink/source four TTL inputs. When 1s are written to Port1 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port1 also receives the low order

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

address bytes during Flash programming and verification. Each bit of this SFR P1 corresponds to one of the pins on the microcontroller. For example, bit 0 of Port1 is pin P1.0, bit 7 is pin P1.7. Writing a value 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level.

PORT2
Port2 is an 8-bit bidirectional I/O port with internal pull-ups. The port2 output buffers can sink/source four TTL inputs. When 1s are written to Port2 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port2 pins that are externally being pulled low will source current because of the internal pull-ups. Port2 emits the high-order address byte during fetches from external program memory and during access to external data memory that uses 16-bit addresses (MOVX @DPTR). In this application it uses strong internal pull-ups. Each bit of this SFR P2 corresponds to one of the pins on the microcontroller. For example, bit 0 of Port2 is pin P2.0, bit 7 is pin P2.7. Writing a value 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level. While the 89C51 has four I/O port (P0, P1, P2 and P3), if our hardware uses external RAM or external code memory (i.e., our program is stored in an external ROM or EPROM chip or if we are using external RAM chips) we may not use P0 or P2. This is because the 89C51 uses ports P0 and P2 to address the external memory. Thus if we are using external RAM or code memory we may only use ports P1 and P3 for your own use.

PORT3
Port3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port3 output buffers can sink/source four TTL inputs. When 1s are written to Port3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port3 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port3 also serves the functions of various special features of the AT89C51 as listed below:

P3.0 RXD (serial input port)

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

P3.1 TXD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe)

Each bit of this SFR P3 corresponds to one of the pins on the microcontroller. For example, bit 0 of Port3 is pin P3.0, bit 7 corresponds to pin P3.7. Writing a value 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level.

3.3 Types of Memory


On-chip memory refers to any memory (Code, RAM) that physically exists on the microcontroller itself. External code memory is program memory that resides off the chip. This is often in the form of standard static RAM or flash RAM.

3.3.1 Code Memory


This memory refers to Read Only Memory that holds the actual 89C51 program. It is limited to 64K size. Code memory may be found on-chip, either burned into the microcontroller as EEPROM. Code may also be stored completely off-chip in an external ROM or more commonly, an external EEPROM. Flash ROM is also another popular method of storing a program. Various combinations of these memory types may also be used--that to say, it is possible to have 4K of code memory on-chip and 64K of code memory off-chip in an EEPROM. When the program is stored on-chip the 64K maximum is often reduced to 4K, 8K, or 16K. This varies depending on the version of the chip that is being used. Each version offers specific capabilities and one of the distinguishing factors from chip to chip is how ROM/EEPROM space

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

the chip has.

3.3.2 On-Chip RAM Memory


The 89C51 has on-chip RAM memory of two types:

Internal RAM Special Function Register (SFR) memory.

The 128 bytes of internal RAM are subdivided as shown on the memory map. The first 8 bytes (00h 07h) are register bank 0. By manipulating certain SFRs, a program may choose to use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in addresses 08h through 1Fh. Bit memory also resides in from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack. This fact severely limits the 89C51s stack since, as illustrated in the memory map, the area reserved for the stack is only 80 bytes--and usually it is less since these 80 bytes have to be shared between the stack and user variables.

a) Register Banks
The 89C51 microcontroller uses registers in many of its instructions. These R registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6 and R7). These registers are generally used to assist in manipulating values and moving data from one memory location to another. For example, to add the value of R4 to the Accumulator, we would execute the following instruction: ADD A, R4 Thus if the Accumulator (A) contained the value 6 and R4 contained the value 3, the Accumulator would contain the value 9 after this instruction was executed. However, as the memory map shows, the R register R4 is really part of Internal RAM.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Specially, R4 is address 04h. ADD A, 04h This instruction adds the value found in Internal RAM address 04h to the value of the Accumulator, leaving the result in the Accumulator. Since R4 is really Internal RAM 04h, the above instruction effectively accomplished the same thing.

b) Bit Memory
The 89C51 gives the user the ability to access a number of bit variables. These variables may be either 0 or 1. There are 128 bit variables available to the user, numbered 00h through 7Fh. The user may make use of these variables with commands such as SETB and CLR. For example, to set bit number 24 (hex) to 1 we would execute the instruction: SETB 24h

c) Special Function Register (SFR) Memory


Special Function Registers (SFRs) are areas of memory that control specific functionality of the 89C51 processor. For example, four SFRs permit access to the 89C51s 32 I/O lines. Another SFR allows a program to read or write to the 89C51s serial port. Other SFRs allow the user to set the serial baud rate, control and access timers and configure the 89C51s interrupt system. When programming, SFRs have the illusion of being Internal Memory. For example, if you want to write the value 1 to Internal RAM location 50 hex, we would execute the instruction: MOV 50h, #01h SFRs are accessed as if they were normal Internal RAM. The only difference is that Internal RAM is from address 00h through 7Fh whereas SFR registers exist in the address range of 80h through FFh. Each SFR has an address (80h through FFh) and a name.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

3.4 Serial communication


The 89c51 has an integrated UART for serial communication. The operation mode and the baud rate should be selected for serial communication. Once configured, all we have to do is to write to an SFR to write a value to the serial port or read the same SFR to read a value from the serial port. The 89c51 will automatically let us know when it has finished sending the character we wrote and will also let us know whenever it has received a byte so that we can process it.

3.4.1 Setting the Serial Port Mode


The SCON SFR allows us to configure the serial port. The first four bits (bits 4 through 7) are configuration bits. Bits SM0 and SM1 let us set the serial mode a value between 0 and 3, inclusive. As we can see, selecting the serial mode selects the mode of operation (8-bit/9-bit, UART or shift register) and also determine how the baud rate will be calculated. In modes 0 and 2 the Baud rate is fixed based on the oscillator frequency. In mode 1 and mode 3 the baud rate is variable based on how timer 1 overflows.

SM0

SM1

SM2

REN

TB8

RB8

TI

RI

Serial Port Control Register (SCON) The next bit, SM2, Is a flag for Multiprocessor communication. Generally whenever a byte has been received the 89c51 will set the RI (receive interrupt) flag. This let the program know that a byte has been received and that it needs to be processed. However, when SM2 is set the RI flag will only be triggered if the 9th bit received is 1. That is to say, if SM2 is set and a byte is received whose 9th bit is clear, the RI flag will never set. This can be useful in certain advanced serial applications. For now it is safe to say that we will almost always want to clear this bit so that the flag is set upon reception of any character. The next bit, REN is Receiver Enable. If we want to receive data via the serial port, set this bit. The last four bits (bits 0

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

through 3) are operational bits. They are used when actually sending and receiving data--they are not used to configure the serial port. The TB8 bit is used in modes 2 and 3. In modes 2 and 3, a total of nine data bits are transmitted. The first 8 data bits are the 8 bits of the main value, and the ninth bit is taken from TB8. If TB8 is set and value is written to the serial port, the data bits will be written to the serial line followed by a set ninth bit. If TB8 is clear the ninth bit will be clear. The RB8 also operates in modes 2 and 3 and functions essentially the same way as TB8, but on the reception side. When a byte is received in modes 2 and 3, a total of nine bits are received. In this case, the first eight bits received are the data of the serial byte received and the value of the ninth bit received will be placed in RB8. TI means Transmit Interrupt. When a program writes a value to the serial port, a certain amount of time will pass before the individual bits of the byte are clocked out the serial port. If the program were to write another byte to the serial port before the first byte was completely output, the data being sent would be garbled. Thus, the 89C51 lets the program know that it has clocked out the last byte by setting the TI bit. When the TI bit is set, the program may assume that the serial port is free and ready to send the next byte. Finally, the RI bit means Receive Interrupt. It functions similarly to the TI bit, but it indicates that a byte has been received. That is to say, whenever the 89C51 has received a complete byte it will trigger the RI bit to let the program know that it needs to read the value quickly, before another byte is read.

3.4.2 Setting the Serial Port Baud Rate


Once the Serial Port Mode has been configured, as explained above, the program must configure the serial ports baud rate. This only applies to Serial Port Modes 1 and 3. The Baud Rate is determined based on the oscillator frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillator frequency divided by 12. This means if the crystal frequency is 11.059MHz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is always the oscillator frequency divided by 64, so a 11.0592MHz crystal speed will yield a baud rate of

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

172,797.

3.4.3 Reading the Serial Port


Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to read the value stored in the SBUF (99h) SFR after the 89C51 has automatically set the RI flag in SCON. For example, if our program wants to wait for a character to be received and subsequently read it into the Accumulator, the following code segment may be used: JNB RI, $ MOV A, SBUF ; Wait for the 89C51 to set the RI flag ; Read the character from the serial port

The first line of the above code segment waits for the 89C51 to set the RI flag; again, the 89C51sets the RI flag automatically when it receives a character via the serial port. So as long as the bit is not set the program repeats the JNB instruction continuously. Once the RI bit is set upon character reception the above condition automatically fails and program flow falls through to the MOV instruction that reads the value.

3.5 Interrupts
Interrupts are events that cause program flow to deviate from sequential execution. They provide a mechanism to suspend normal program flow, execute a subroutine and resume program flow. The subroutine is called an interrupt handler. The event may be one of the timers overflowing, receiving a character via the serial port, transmitting a character via the serial port, or one of two external events. The 89C51 may be configured so that when any of these events occur the main program is temporarily suspended and control passed to a special section of code related to the event that occurred. Once complete, the control would be returned to the original program. The ability to interrupt normal program execution when certain events occur makes it much easier and much more efficient to handle certain conditions. If it were not for interrupts we would have to manually check in our main program whether the timers had over flown, whether we had received another character via the serial port, or if some external

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

event had occurred. Besides making the main program ugly and hard to read, such a situation would make our program inefficient since wed be burning precious instruction cycles checking for events that usually dont happen. Luckily, this isnt necessary. Interrupts let us forget about checking for the condition. The microcontroller itself will check for the condition automatically and when the condition is met will jump to a subroutine (called an interrupt handler), execute the code, then return. Instead of a normal RET instruction we have a RETI instruction. The RETI instruction does the same thing as a RET instruction, but tells the 89C51 that an interrupt routine has finished. You must always end your interrupt handlers with RETI. Obviously we need to be able to distinguish between various interrupts and executing different code depending on what interrupt was triggered. This is accomplished by jumping to a fixed address when a given interrupt occurs.

Source

Interrupt Vector Address (Hex)

IE0 TF0 IE1 TF1 RI+TI TF2+EXF2

03 0B 13 1B 23 2B Table3.1: Interrupt Vectors

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

3.5.1 Setting up Interrupts


At power up, all interrupts are disabled. This means that even if, for example, the TF0 bit is set, the 89C51 will not execute the interrupt. The program must specifically tell the 89C51 that it wishes to enable interrupts and specifically which interrupts it wishes to enable. The program may enable and disable interrupts by modifying the IE SFR (A8h):

EI

--

ET2

ES

ET1

EX1

ET0

EX0

Interrupt Enable (IE) Register

3.5.2 Interrupt Priorities


By using interrupt priorities we may assign higher priority to certain interrupt conditions. Foe example, we may have enabled Timer 1 interrupt, which is automatically called every time Timer 1 overflows. Additionally, we may have enabled the serial port. Interrupt which is called every time a character is received via the serial port. However, we may consider that receiving a character is much more important than the timer interrupt. In this case, if Timer 1 interrupt is already executing we may wish that the serial interrupt itself interrupts the Timer 1 interrupt. When the serial interrupt is complete, control passes back to Timer 1 Interrupt and finally back to the main program. We may accomplish this by assigning a high priority to the Serial Interrupt and a low priority to the Timer 1 Interrupt. Interrupt priorities

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

are controlled by the IP SFR (B8h).

--

--

PT2

PS

PT1

PX1

PT0

PX0

Interrupt Priority (IP) Register


A high priority interrupt cannot be interrupted. A high-priority interrupt may interrupt a low-priority interrupt. A low priority interrupt may occur if no other interrupt is already executing. If two interrupts occur at the same time, the interrupt with higher priority will execute first. If both interrupts are of the same priority the interrupt that is serviced first by polling sequence will be executed first.

CHAPTER 4

DESCRIPTION OF THE SYSTEM

Alternate Track

RS232 Interface RFID Reader

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Traffic Light Controller

Track Monitoring Circuit

COMPUTER or MICRO-CONTROLLER

Track Controlling Circuit Power Supply

FM Transmitter Amplifier

Fig4.1: Block Diagram of the System

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

As shown in the block diagram, this unit mainly consists of the following blocks: 1. Microcontroller 2. Track Monitoring Circuit 3. Track Controlling Circuit 4. Power Supply 5. RFID Tag & Reader 6. RS232 Interface 7. FM Transmitter

4.1 INTERFACING
RFID Tag: The RFID tags have a unique eight-digit code number, which are mounted on the
train. Tags continuously transmit code in RF frequency.

RFID Reader: The code transmitted by the tag is received by RFID reader modules which are
placed on the track. They convert radio waves received from the RFID tags in to a form that can be passed on to micro controllers.

Max-232: This module is primary when RS-232 is interfaced with microcontroller. It converts
TTL logic to RS-232 logic or vice versa.

RS-232: RS-232 is used for serial communication to connect RFID reader to microcontroller. Track controlling circuit: DC motor is used to change the track. Relay circuit is used to
change the polarities of the batteries connected to DC motor.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

IR sensors: IR sensors are used to locate and find the presence of train. IR sensors are used
near railway crossing.

4.2 DESCRIPTION:
Here the RFID reader will read the details of the incoming train. And if it is the authorized train then it will let the train go to the station. , if not it will not let the train go . Instead.. it will lead the train through the other track by changing the track of the train and it will also inform the station nearer of this. By keeping The RFID reader in different predetermined places .we can provide more security for trains. We can avoid the collision of two trains which will be using the same track. Each train will have a RFID tag which contains information about the train. When the train passes the RFID reader which is placed near the station, it reads the information near the RFID tag of the train. This RFID tag will pass on that information to the computer on the station which will refer to the stable present near the information sent by the RFID reader. And the train will be the correct one then it will be let in to enter the station . if not it will change the track of the train with the help of the track switching circuit, so that the train will be not allowed inside the station. There by avoiding any chance of collision with another train standing on the same track as the train this is coming from the other end. Our project is designed using 89C51 microcontroller to avoid railway accidents happening at unattended railway gates. The project utilizes the powerful IR transmitters and two receivers:; one pair of transmitters and receivers is fixed at upside(from where the train comes) at a level higher than a human being in exact alignment and similarly the other pair is fixed at down side of the train direction. Sensor activation time is adjusted by calculating the time taken at a certain speed to cross at least one compartment of standard minimum size of the Indian railway . We have considered 5 seconds for this project . Sensors are fixed at 1 km on both sides of the gate. We call the sensor along the train direction as foreside sensor and the other as aft side sensor. When foreside receiver gets activated , the gate motor is turned on in one direction and the gate is closed and stays closed until the train crosses the gate and reaches

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

aft side sensors .when upside receiver gets activated motor turns in opposite direction and gate opens and motor stops. Buzzer will immediately sound at the fore side receiver activation and gate will close after 5 seconds, so giving time to drivers to clear gate area in order to avoid trapping between the gates and stop sound after the train has crossed. The same principle is applied for track switching. Consider a situation where in an express train and a local train is traveling in opposite directions on the same track; the express train is allowed to travel on the same track and the local train to switch on the other track. Two sensors are placed at the either side of the junction where the track switches. If the train approaching the other side, and another sensor placed along that direction get activated and will send a interrupt service routine switches the track. Indicator light have been provided to avoid collisions. Here the switching operation is performed using a stepper motor. Assuming that with a certain delay, and train passes the track and is switched back to its original position, allowing the first train to pass without any interruption. This concept of track switching can applied at 1km distance from the stations.

4.3 COMMUNICATION CIRCUIT:


4.3.1 FREQUENCY MODULATION (FM)
FM is used extensively in communications systems. FM is used in radio broadcasting, for the transmission of the sound signal in standard (NTSC) TV, for private land-mobile radio systems, for direct-satellite broadcasting, and for cordless and cellular telephone systems. The simplest and most common form of FM which we are using operates as a switch. It is used in our project to switch ON-OFF the train using the transmitter and receiver. As the signal from the train is received, microcontroller sends signal to change the track and also to stop the train. The signal to stop the train is transmitted by FM transmitter and the signal is received by FM receiver.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

CHAPTER 5

HARDWARE DESCRIPTION
5.1 Power Supply Unit:
The power supply unit is the heart of any circuit or system. So here for project purpose, we implement a DC power supply derived from AC. A DC power supply which maintains the output voltage constant irrespective of AC mains fluctuations or load variations is known as regulated DC power supply offers excellent line and load regulation and output voltages of +5V and +12V at output currents up to one amps.
Regulator Filter Rectifier Transformer

I/P Fig5.1: Power Supply Unit

O/P (5V or 12V)

Power Supply Circuit

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Fig5.2: Power Supply Circuit

The various parts of the power supply unit are as explained.

5.1.1 Step Down Transformer:


The Transformer rating is 230V AC at primary and 12-0-12V, 1 Amperes that is more than enough to drive any electronic circuit or varying load. The 12V AC appearing across the secondary is the RMS value of the waveform and the peak value would be 12 * 1.414 = 16.8 volts. This value limits our choice of rectified diode as IN 4007, which is having PIV rating more than 16 volts.

5.1.2 Rectifier stage:


The two diodes D1 and D2 are connected across the secondary winding of the transformer as a full wave rectifier. During the positive half-cycle of secondary voltage, the end A of a secondary winding becomes positive and end B negative. Therefore diode D2 conducts while D1 does not. Note that current across the center tap terminal is in the same direction for both half cycles of input AC voltage. Therefore pulsating DC is obtained at the point C with respect to ground.

5.1.3 Filter stage:

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Here the capacitor C1 is used for filtering purpose and connector across the rectifier output. It filters AC component present in the rectifier DC and gives steady DC Voltage. As a rectifier voltage increases, it charges the capacitor and also supplies current in the load. When capacitor is charged to the peek value of the rectifier voltage, rectifier voltage starts to decrease. As the next voltage peek immediately recharges the capacitor, the discharge period is of very small duration. Due to this continuous charge-discharge-recharge cycle very little ripple is observed in the filtered output. Moreover, output voltage is higher as it remains substantially near the peak value of the rectifier output voltage. This phenomenon is also explained in other form as: the stunt capacitor offers low reactance path AC components of current and open circuit to DC component. During positive half-cycle the capacitor stores the energy in the form of electro-static field. During the negative half-cycle the filter capacitor releases the stored energy to the load.

5.1.4 Voltage Regulation Stage:


Across the point D and ground there is rectified and filtered DC. In the present circuit, LM7812 a three terminal voltage regulator IC is used to get +12V and LM7805 voltage regulator IC is used to get +5V regulated DC output. In the three terminals, pin1 is input i.e. rectified and filtered DC is connected to the pin. Pin2 is common pin and is grounded. Pin3 gives the stabilized DC output to the load. A stabilized DC output is obtained of +5V and +12V respectively.

5.1.5 3-Terminal 1A Positive Voltage Regulator Features


Output current up to 1A Output voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V Thermal overload protection Short circuit protection

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Output transistor safe operating area protection

Description
The LM7805 series of three terminal positive regulators are available in the TO-220/DPAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shutdown and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed regulators, these devices can be used with external components to obtain adjustable voltages and currents.

5.2 MAX232:
This module is primary of interest for people building their own electronics with an RS232 interface. Off-the-shelf computers with RS-232 interfaces already contain the necessary electronics, and there is no need to add the circuitry as described here. Serial RS-232 communication works with voltages (-15V to -3V for high) and (+3V to +15V for low) which are not compatible with normal computer logic voltages. On the other hand, classic TTL computer logic operates between 0V to +15V. So the maximum RS-232 signal levels are far too high for computer logic electronics and the negative RS-232 voltage for high cant be grokked at all by computer logic. Therefore to receive serial data from an RS-232 interface the voltage has to be reduced and the low and high voltage level inverted. In the other direction (sending data from some logic over RS-232) the low logic voltage has to be bumped up and a negative voltage has to be generated. RS-232 TTL Logic

------------------------------------------------15V -3V <-> +2V +5V <-> high +3V +15V<-> 0V +0.8V <-> low

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

The MAX232 from Maxim was the first IC which in one package contains the necessary drivers (two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became popular because it just needs one voltage (+5V) and generates the necessary RS-232 voltage levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry. Circuitry designers no longer need to design and build a power supply with three voltages (e.g. -12V, +5V and +12V), but could just provide one +5V power supply, e.g. with the help of a simple 78x05 voltage converter. The MAX232 (A) has two receivers (converts from RS-232 to TTL voltage levels) and two drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS232 signals can be converted in each direction.

MAX232 to RS-232 DB9 Connection as a DCE MAX232 Pin No. 7 8 9 10 11 12 13 14 15 T2out R2in R2out T2in T1in R1out R1in T1out GND CTS RTS RTS CTS TX RX TX RX GND RS-232 RS-232 TTL TTL TTL TTL RS-232 RS-232 0 7 8 n/a n/a n/a n/a 3 2 5 MAX232 Pin Name Signal Voltage DB9 Pin

Table5.1: MAX232 to RS-232 DB9 Connection as a DCE

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

5.3 RS-232:
RS-232 is the mostly widely used interfacing standard. This standard is used in PCs and numerous types of equipments. However since the standard was set long before the advent of the TTL logic family. Its input and output levels are not TTL compatible. In RS-232, a1 is represented by -3 to -25 volts while a 0 bit is represented by +3 to +25 volts, making -3 to +3 undefined. For this reason, to connect any RS-232 to a microcontroller system we must use voltage converter such as MAX232 to convert the TTL logic levels to the RS-232 voltage level and vice-versa.

5.3.1 Features

Supply Voltage range: Supply Current: Transmitter o/p voltage swing: Data Rate: 5mA 7.8V

4.5 to 5.5V

220Kbps

Fig5.3: RS-232 Pin configuration

Pin 1 2 3 4

Description Data Carrier Detect (DCD) Received Data (RxD) Transmitted Data (TxD) Data Terminal Ready (DTR)

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

5 6 7 8 9

Signal Ground (GND) Data Set Ready (DSR) Request To Send (RTS) Clear To Send (CTS) Ring Indicator (RI) Table5.2: RS-232 pin description

5.4 555 Timer:

Fig5.4: IC 555 Timer No 1 2 3 4 Name GND TR Q R Ground, low level A short pulse high low on the trigger starts the timer Purpose

During the timing interval, the output stays at +VCC A timing interval can be interrupted by applying a reset pulse to low (0V)

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

5 6 7 8

CV THR DIS V+, VCC

Control Voltage allows access to the internal voltage divider (2/3 VCC) The threshold at which the interval ends (it ends if U.thr > 2/3 VCC) Connected to a capacitor whose discharge time will influence the timing interval The positive supply voltage which must be between 5V and 15V, high level Table5.3: IC 555 Timer pin description

The 555 is an integrated circuit (chip) implementing a variety of timer and multi-vibrator applications. The 555 timer has three operating modes:

Monostable Mode: In this mode, the 555 timer functions as a one-shot. Applications include timers, missing pulse detection, bounce free switches, touch switches, frequency divider, capacitance measurement, pulse width modulation etc.

Astable Free Running Mode: The 555 timer can operate as an oscillator. Uses include LED and lamp flashers, pulse generation, logic clocks, tone generation, security alarms, pulse position modulation etc.

Bistable Mode: The 555 can operate as a flip-flop, if the discharge pin is not connected and no capacitor is used. Uses include bounce free latched switches etc.

5.4.1 TIMER IC555 AS ASTABLE MULTIVIBRATOR USED ALONG WITH IR LED

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Fig5.5: Astable Multivibrator ASTABLE MULTIVIBRATOR OPERATION: Astable or free running multivibrator is a two stage amplifier with AC-coupled feedback from output to input. One transistor stage is ON while other is OFF until the stages switch conducting states repeatedly at a specific frequency. The oscillation frequency is set by the resistor and capacitor values connected to the base terminal of each stage. This RC network determines how long the transistor stays in the OFF position. This circuit is not stable in either state. It continuously oscillates from one state to the other, in other words it produces a continuous train of pulses at any frequency we require. It usually generates a square wave. This is used to set the frequency of transmission of LEDs.

5.5 IR Sensors
This circuit has two stages, a transmitter unit and a receiver unit. The transmitter unit consists of an infrared LED and its associated circuitry. 5.5.1 IR TRANSMITTER:

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

The transmitter circuit consists of the following components:


IC 555 Resistors Capacitors IR LED

The IR LED emitting infrared light is put on in the transmitting unit. To generate IR signal, 555 IC based astable multivibrator is used. Infrared LED is driven through transistor BC 548. IC 555 is used to construct an astable multivibrator which has two quasi-stable states. It generates a square wave of frequency 38kHz and amplitude 5 volts. It is required to switch ON the IR LED.

Fig5.6: IR Transmitter

5.5.2 IR RECEIVER: The receiver circuit consists of the following components.


TSOP1738 (sensor) IC 555

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Resistors Capacitors

The receiver unit consists of a sensor and its associated circuitry. In receiver section, the first part is a sensor which detects IR pulses transmitted by IR-LED. Whenever a train crosses the sensor momentarily transmits through a low state. As a result the monostable is triggered and a short pulse is applied to the port pin of the 8051 microcontroller. On receiving a pulse from the sensor circuit, the controller activates the circuitry required for closing and opening of the gates and for the track switching. The IR receiver circuit is shown in the figure below.

Fig5.7: IR Receiver

5.6 FREQUENCY MODULATION 5.6.1 FM TRANSMITTER

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Fig5.8: FM Transmitter Block Diagram The microphone converts sound pressure wave to electrical signals. These audio voltages are amplified by the audio amplifier. The amplified audio is used to control the deviation of the frequency controlled oscillator. The oscillator frequency is at the carrier frequency, in the 88108 MHz FM band. The low power of the frequency modulated carrier is boosted by the Radio Frequency amplifier. The aerial is driven by the amplifier and produces an electromagnetic wave. Under normal conditions the transmitted signal will travel as far as the horizon. 5.6.2 FM

RECEIVER Fig5.9: FM Receiver Block Diagram Most of these blocks are discussed individually, and in more detail, on other pages. See filters, mixers, frequency changers, am modulation and amplifiers. The FM band covers 88-108 MHz. There are signals from many radio transmitters in this band inducing signal voltages in the

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

aerial. The RF amplifier selects and amplifies the desired station from the many. It is adjustable so that the selection frequency can be altered. This is called TUNING. In cheaper receivers the tuning is fixed and the tuning filter is wide enough to pass all signals in the FM band. The selected frequency is applied to the mixer. The output of an oscillator is also applied to the mixer. The mixer and oscillator form a FREQUENCY CHANGER circuit. The output from the mixer is the intermediate frequency (IF.) The IF is a fixed frequency of 10.7 MHz. No matter what the frequency of the selected radio station is, the IF is always 10.7 MHz. The IF signal is fed into the IF amplifier. The advantage of the IF amplifier is that its frequency and bandwidth are fixed, no matter what the frequency of the incoming signal is. This makes the design and operation of the amplifier much simpler. The amplified IF signal is fed to the demodulator. This circuit recovers the audio signal and discards the RF carrier. Some of the audio is fed back to the oscillator as an AUTOMATIC FREQUENCY CONTROL voltage. This ensures that the oscillator frequency is stable in spite of temperature changes. The audio signal voltage is increased in amplitude by a voltage amplifier. The power level is increased sufficiently to drive the loudspeaker by the power amplifier.

5.7 DC MOTOR
Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

Fig5.10: DC motor Motor means a permanent magnet, direct-current (DC) motor of the sort used in toys, models, cordless tools and robots. These motors are particularly versatile because both their speed and direction can be readily controlled; speed by the voltage or duty cycle of their power supply and direction by its polarity. We use a relay driver circuit to interface the motor and the Microcontroller. DC motor runs on low voltage DC. In our project DC motor is used for the mechanical movements of track changing setup. They can be controlled either by software or by hardware. In our project we control the DC motor using microcontroller.

5.8 ELECTRONIC SWITCHES


5.8.1 Relays

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

A rely is a mechanical switch operated by an electromagnet. The relatively small current that energizes the electromagnet (the coil) can control a larger current through the relay switch.

Fig5.11: Relay Driver Circuit

Relay driver circuit as shown in the diagram uses ICs ULN2003 and TDS-0502L. Here ULN2003 acts as driver for the relay and TDS-0502L is the relay IC. A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. Advantages are: Relays can switch AC and DC. Relays can switch high voltages. Relays are a better choice for switching large currents (> 5A). Relays can switch many contacts at once. Relays are components which allow a low-power circuit to switch a relatively high current on and off, or to control signals that must be electrically isolated from the controlling circuit. To make a relay operate, we have to pass a suitable pull-in and holding current (DC) through its energizing coil. And generally relay coils are designed to operate from a particular supply voltage often 12V or 5V. TDS-0502L is a relay IC which uses 5V 2A supply. Size of the IC is 21x10x12mm. It is an eight pin IC and it is designed for PCB mounting. We can solder wires directly to the pin.

ULN2003 LINEAR INTEGRATED CIRCUIT


The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It consists of seven NPN Darlington pairs that features high-voltage outputs with common-

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

cathode clamp diode for switching inductive loads. The collector-current rating of a single Darlington pair is 500mA. The Darlington pairs may be paralleled for higher current capability. Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED gas discharge), line drivers, and logic buffers. The ULN2003 has a 2.7kW series base resistor for each Darlington pair for operation directly with TTL or 5V CMOS devices. Suppression diodes are included for inductive load driving and the inputs are pinned opposite the outputs to simplify board layout. These versatile devices are useful for driving a wide range of loads including solenoids, relays DC motors, LED displays filament lamps, thermal print heads and high power buffers. ULN2003A are supplied in 16 pin plastic DIP packages with a copper lead frame to reduce thermal resistance. They are available also in small outline package (SO-16) as ULN2003D.

Fig5.12: ULN2003 PIN DIAGRAM

5.8.2 FEATURES

500mA rated collector current(Single output) High-voltage outputs: 50V Inputs compatible with various types of logic. TTL/CMOS/PMOS/DTL compatible inputs

Relay driver application Integrated suppression diodes form inductive loads Outputs can be paralleled for higher current

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

CHAPTER 6

SOFTWARE ASPECTS
START

6.1 Flowchart:
INITIALIZE I/O PORT DISPLAY SHATABDI EXPRESS

LCD INITIALIZATION RFID INITIALIZATION

IF THE TRAIN(TAG) CODE=046h

NO NO
YES
IF THE TRAIN(TAG)CODE=045h

DISPLAY MANGALORE TO GOA

STOP THE OTHER TRAIN(045)

CHANGE THE TRACK YES

PASS THE TRAIN(046) AND AFTER SOME DELAY BRING THE TRACK TO NORMAL POSITION

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

PASS THE OTHER TRAIN(045)

STOP

Fig6.1: Flow chart of project

6.2 CODE OF THE PROJECT


org 0030h mov p1,#00h mov p2,#00h mov p3,#0f0h /*Initialise p1 as O/P port*/ /*Initialise p2 as O/P port*/ /*Initialise p3 as half O/P port and other half as I/O port*/

/*Read RFID code serially */ mov tmod,#20h mov th1,#-3 mov scon,#50h start: nop mov r5,#13 mov r1,#40h setb tr1 up: clr ri rpt: jnb ri,rpt mov a,sbuf mov @r1,a inc r1 /*Store the read data into Ram*/ /*Serial comm mode config*/

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

djnz r5,up

/* Bring the RF data stored in ROM to RAM */ clr a mov dptr,#rfdat mov r0,#50h mov r2,#08

back1: clr a movc a,@a + dptr mov @r0,a inc dptr inc r0 djnz r2,back1

/*Check the RFID code of train with the stored database */ mov r2,#04h mov r0,#57h mov r1,#4ch acall compare jz last ajmp down last: setb p1.0 setb p1.2 acall display acall delay1 clr p1.0 clr p1.2 setb p1.1 acall delay1

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

down: nop ajmp start

/* Subroutines */ compare: nop cmp1: clr a mov a,@r1 xrl a,@r0 jz next1 sjmp next2 next1: dec r1 dec r0 djnz r2,cmp1 next2: ret

display: mov dptr,#mycom1 acall command mov dptr,#mydata1 acall mydata ret

command: nop command1:clr a movc a,@a+dptr acall comwrt jz retrn inc dptr sjmp command1 retrn: nop ret

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

mydata: nop mydata1:clr a movc a,@a+dptr acall datawrt inc dptr jz retn1 sjmp mydata1 retn1: ret

/* Display initilasation*/ comwrt: acall ready mov p2,a clr p3.5 clr p3.6 setb p3.7 clr p3.7 ret

/* Dataword initilasation*/ datawrt: acall ready mov p2,a setb p3.5 clr p3.6 setb p3.7 clr p3.7 ret

delay: mov r3,#250 here2: mov r4,#255

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

here:

djnz r4,here djnz r3,here2 ret

delay1:acall delay acall delay acall delay acall delay acall delay acall delay acall delay acall delay acall delay acall delay ret ready: setb p2.7 clr p3.5 setb p3.6 back2: clr p3.7 setb p3.7 jb p2.7,back2 ret

/* Display data*/ mycom1:db 38h,0fh,01h,06,85h,0 mydata1:db "MANGALORE TO GOA",0

/* Stored data base*/ org 400h rfdat: db "E584176B" END

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

CHAPTER 7

CONCLUSIONS AND FURTHER SCOPE


7.1 CONCLUSIONS
We know that Indian Railway is one of the largest and busiest railway network. Besides that, India is counted amongst countries which have railway system with the least advanced technology. Our project RFID IN ANTI-COLLISION SYTEM FOR TRAINS will be very user friendly and it offers a more efficient, secure way to avoid train collisions, because of least human intervention. It also assures good security for the trains.

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

7.2 SCOPE FOR FUTURE WORK


Using Doppler radar RFID we can find the speed of the train. As the tracking technology advances, railways of larger zones can be controlled and monitored.

Railways can install anti-collision device (ACD), which is an on-board train protection device, so as to reduce chances of collisions.

Bibliography

http://www.ieeexplore.org http://en.wikepedia.org http://www.google.com http://howstuffworks.com http://www.scribd.com http://www.kpsec.freeuk.com http://www.datasheetcatalog.com http://www.highimpactip.com http://electronicdesign.com http://www.technovelgy.com

Department of Electronics and Communication Engineering St. Joseph Engineering College

RFID TECHNOLOGY IN ANTI-COLLISION SYSTEM FOR TRAIN

http://www.hobbyprojects.com http://www.atmel.com

Department of Electronics and Communication Engineering St. Joseph Engineering College

You might also like