You are on page 1of 45


First we would like to thank the omniscient, omnipotent, omnipresent God by virtue of whom we are able to complete this project. We are grateful to Mrs. Anamika Bhatia, our head of department for her valuable guidance, support and co-operation extend by her. Then we would like to thank Colonel Rakesh Sharma sir and our project coordinator and cocoordinator for their kind cooperation, help and never ending support. We would also like to thank Mr. Sudakar chauhan sir without whom our project would not have been successful in all means. We are also thankful to Mr. Kamal Ghanshala (Chairman, GEU Dehradun) for providing us labs and facilities which proved to be very useful for our project. In the end, we convey our sincere thanks to all those people who directly or indirectly helped us.

Aman Pant Amit Bharti Kumar Govind

In the recent time, we have seen a lot of railway accidents and yet Indian Railways have not implemented any effective Anti-Collision System which can avoid such type of accidents. So, we come up with a project Anti-Collision System (Railways) which can avoid such type of railway accidents. In this project, we have used Microcontroller, LCD panel, Wireless TransReceiver Unit (Zigbee), MAX 232, different ICs and power supply. Microcontroller is the heart of our project, it acts as an interface among LCD, Motor, Max 232,Potentiometer,LEDs and Transreceiver (Zigbee).


TABLE OF CONTENTS 1. Introduction 1.1 2. Introduction of project.....9 Block Diagram....10 2.2.1 Transmitter......10 2.2.2 Reciever.. 11 3. 4. 5. Simulation Diagram.13 PCB Layout....14 Components Description


5.3 Block


5.4PIN Description21
6 7 8 9


10 11 12 13 14 15 16 17

DIODE.34 RESISTOR...37 MOTOR...39 LCD..40 MAX 232.41 IC 7805.42 WORKING..43 Bibilography and refrence44


The idea of antiocollision system for railways clicked to our mind,because we have seen a lot of railway accidents recently in the past,yet railways have not implemented any such system in their railway network.altough konkan railway have patented a anticollison system and that is expected to come in picture in 2014 still that is specifically meant for deccan railways and doesnt cater the need of whole Indian railway network. 17 rail accidents was reported in 2010 in which 5 alone takes place in UP due to dense fog condition,out of which in 19 July 2010 Sainthia train collision occurred in Sainthia, West Bengal, India, when the Uttar Banga Express collided with the Vananchal Express. Casualties stand at 63 people dead and more than 165 people injured, with many still trapped in wreckage and 8 May 2010 West Bengal, the Gyaneshwari Express train collision, a suspected Naxalite terrorist attack kills at least 170 people, was the disastrous one.

To prevent such rail accidents and to provide safety to the millions of passengers who suffer daily from trains we come up with the idea of anticollision system for railways, it not only warns driver before condition of collision but also automatically stop the train to prevent such collision.






MAX 232







MAX 232

ATMEL (8 c )





S.No Name Of Component 1. Microcontroller 2. LCD

Value/Type ATMEL 8 Hitachi HD44780

Quantity 2 2

3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.

Transistor Crystal Oscillator Driver/Receiver Transreceiver Voltage Regulator Potentiometer D.C Motor Electrolytic Capacitor Ceramic Capacitor LED Diode Resistor Switch Connector Wires

2N2222A 14.7456MHz MAX-232 ZigBee IC 7805 100K 6-12V 10F,1000F 33F Red,Blue,Green 1N4007 .330K,1K Button,DPDT Programmable

2 2 2 2 2 2 2 8,2 4 2,2,2 2 4,6 4,2 1







ATMEGA 8 Features
High-performance, Low-power AVR - 8-bit Microcontroller

Advanced RISC Architecture 130 Powerful Instructions Most Single-clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 16 MIPS Throughput at 16 MHz On-chip 2-cycle Multiplier High Endurance Non-volatile Memory segments 8K Bytes of In-System Self-programmable Flash program memory 512 Bytes EEPROM 1K Byte Internal SRAM Write/Erase Cycles: 10,000 Flash/100,000 EEPROM Data retention: 20 years at 85C/100 years at 25C (1) Optional Boot Code Section with Independent Lock Bits


In-System Programming by On-chip Boot Program True Read-While-Write Operation Programming Lock for Software Security Peripheral Features Two 8-bit Timer/Counters with Separate Prescaler, one compare Six Channels 10-bit Accuracy Byte-oriented Two-wire Serial Interface Programmable Serial USART Master/Slave SPI Serial Interface Programmable Watchdog Timer with Separate On-chip Oscillator On-chip Analog Comparator Special Microcontroller Features Power-on Reset and Programmable Brown-out Detection Internal Calibrated RC Oscillator External and Internal Interrupt Sources Five Sleep Modes: Idle, ADC Noise Reduction, Power-save I/O and Packages 23 Programmable I/O Lines 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF


Operating Voltages 2.7 - 5.5V (ATmega8L) 4.5 - 5.5V (ATmega8) Power Consumption at 4 Mhz, 3V, 25C Active: 3.6 mA Idle Mode: 1.0 mA Power-down Mode: 0.5 A


Pin Configurations

The ATmega8 is a low-power CMOS 8-bit microcontroller based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to optimize power consumption versus processing speed.




Pin Descriptions
VCC :-Digital supply voltage. GND:- Ground.


Port B(PC7..PB0) :- is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active,even if the clock is not running. Port C (PC5..PC0) :- Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D (PD7..PD0) :- Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active,even if the clock is not running.

RESET (Reset input):- A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. The Shorter pulses are not guaranteed to generate a reset.


AVCC:- AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. AREF:- AREF is the analog reference pin for the A/D Converter.These pins are powered from the analog supply and serve as 10-bit ADC channels. Basic Function:- The main function of the CPU core is to ensure correct program execution. The CPU must therefore be able to access memories, perform calculations, control peripherals, and handle interrupts.


Interfacing Of Data Bus With Different Units


In order to maximize performance and parallelism, the AVR uses a Harvard architecture with separate memories and buses for program and data. Instructions in the Program memory are executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the Program memory. This concept enables instructions to be executed in every clock cycle. The Program memory is In-System Reprogrammable Flash memory.The fast-access Register File contains 32 x 8-bit general purpose working registers with a single clock cycle access time. This allows single-cycle Arithmetic Logic Unit (ALU) operation. In a typical ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File in one clock cycle. Six of the 32 registers can be used as three 16-bit indirect address register pointers for Data Space addressing enabling efficient address calculations. One of the these address pointers can also be used as an address pointer for look up tables in Flash Program memory. These added function registers are the 16-bit X, Y and Z-register.The ALU supports arithmetic and logic operations between registers or between a constant and a register. Single register operations can also be executed in the ALU.After an arithmetic operation, the Status Register is updated to reflect information about the result of the operation.The Program flow is provided by conditional and unconditional jump and call instructions, able to directly address the whole address space. Most AVR instructions have a single 16-bit word format. Every Program memory address contains a 16- or 32-bit instruction.

Program Flash memory space is divided in two sections, the Boot program section and the Application program section. Both sections have dedicated Lock Bits for write and read/write protection. The SPM instruction that writes into the Application Flash memory section must reside in the Boot program section.During interrupts and subroutine calls, the return address Program Counter (PC) is stored on the Stack. The Stack is effectively allocated in the general data SRAM, and consequently the Stack size is only limited by the total SRAM size and the usage of the SRAM. All user programs must initialize the SP in the reset routine (before subroutines or interrupts are executed). The Stack Pointer SP is read/write accessible in the I/O space.The data SRAM can easily be accessed through the five different addressing modes supported in the AVR architecture.The memory spaces in the AVR architecture are all linear and regular memory maps. A flexible interrupt module has its control registers in the I/O space with an additional global interrupt enable bit in the Status Register. All interrupts have a separate Interrupt Vector in the Interrupt Vector table. The interrupts have priority in accordance with their Interrupt Vector position. The lower the Interrupt Vector address, the higher the priority.The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers, SPI, and other I/O functions. The I/O Memory can be accessed directly, or as the Data Space locations following those of the Register File, 0x20 - 0x5F.


The transistors function is to amplify an electric current. Many different kinds of transistors are used in analog circuits, for different reasons. This is not the case of digital circuits. In a digital circuit, only two values matters, on and off. The amplification ability of transistor is not relevant in digital circuit. In many cases, a circuit is built with integrated circuits (ICs). Transistors are often used in digital circuits as buffer to protect ICs. For example, when powering an electromagnetic switch (called a relay), or when controlling a light emitting diode (In any case).

Two different symbol are used for the transistor.

PNP Type

NPN Type
The name (standard part number) of the transistor, as well as the type and the way it is used is shown below. 2SAXXXX PNP type high frequency 2SBXXXX PNP type low frequency 2SCXXXX NPN type high frequency 2SDXXXX NPN type low frequency The direction of the current flow differs between the NPN and PNP type. When the power supply is the side of positive (plus), the NPN type is easy to use.

Here we are using zigbee transreceiver for wireles communication. ZigBee is the specification of a low-cost, low-power wireless communications solution, meant to be integrated as the main building block of ubiquitous networks. It is maintained by the ZigBee Alliance, which develops the specification and certifies its proper implementation. ZigBee builds upon the physical layer and medium access control defined in IEEE standard 802.15.4 for low-rate WPAN's. The specification goes on to complete the standard by adding four main components: network layer,


application layer, ZigBee device objects (ZDO's) and manufacturer-defined application objects which allow for customization and favor total integration. These are responsible for a number of tasks, which include keeping of device roles, management of requests to join a network, device discovery and security. Its network layer natively supports three types of topologies: both star and tree typical networks and generic mesh networks. Every network must have one coordinator device, tasked with its creation, the control of its parameters and basic maintenance. Within star networks, the coordinator must be the central node. The main functions of the network layer are to enable the correct use of the MAC sublayer and provide a suitable interface for use by the next upper layer, namely the application layer. The routing protocol used by the Network layer is AODV. In order to find the destination device, it broadcasts out a route request to all of its neighbors. The neighbors then broadcast the request to their neighbors, etc until the destination is reached. Once the destination is reached, it sends its route reply via unicast transmission following the lowest cost path back to the source. Once the source receives the reply, it will update its routing table for the destination address with the next hop in the path and the path cost.

The application layer is the highest-level layer defined by the specification, and is the effective interface of the ZigBee system to its end users. It comprises the majority of components added by the ZigBee specification: both ZDO and its management procedures, together with application objects defined by the manufacturer, are considered part of this layer.


Zigbee protocol stack

As one of its defining features, ZigBee provides facilities for carrying out secure communications, protecting establishment and transport of cryptographic keys, cyphering frames and controlling devices. It builds on the basic security framework defined in IEEE 802.15.4. This part of the architecture relies on the correct management of symmetric keys and the correct implementation of methods and security policies.



Light emitting diode must be chosen according to how they will be used, because there are various kinds. The led are available in several colours. The most common colours are red and green, but there are even blue ones. The device on the far right in the photograph combines a red LED and green LED in one package. The component lead in the middle is common to both LEDs as for the remaining two leads; one side is for green, the other for the red LED. When both are tuned ON simultaneously, it becomes orange. When an LED is new out of package, the polarity of the device can be determined by looking at the leads. The longer leads are the anode sides, and the shortest one is the cathode side. The polarity of an LED can also be determined using a resistor meter or even a 1.5 V battery.

When using a test meter to determine polarity, set the meter to a low resistance measurement range. Connect the probe of the meter to the LED. If the polarity is correct, the LED will glow. If the LED does not glow, switch the meter probes to the opposite leads on the LED.

A capacitor can store charge and its capacity to store charge is called capacitance. Capacitors consists of two conducting plates, separated by an insulating material (known as dielectric). The two plates are joined with two leads. The dielectric could be air, mica , paper ceramic, polyester, polystyrene etc. The dielectric gives name to the capacitor. Like paper capacitor, mica capacitor etc.

Types of capacitors :


Capacitor can be broadly classified in two categories, i.e., Electrolytic capacitor and Non-Electrolytic capacitor as shown in the figure above.

Electrolytic Capacitor:

Electrolytic capacitors have an electrolyte as a dielectric. When such an electrolyte is charged, chemical changes take place in the electrolyte. If its one plate is charged positively, same plate must be charged positively in the future. We call such capacitor as polarized. Normally we see electrolytic capacitor as polarized capacitor and the leads are marked with positive or negative on the can. Non-electrolytic capacitors have dielectric material such


as paper, mica or ceramic. Therefore, depending upon the dielectric, these capacitor are classified.

Mica Capacitor:
It is sandwich of several thin metal plates separated by thin sheet of mica. Alternate plates are connected together and leads attached for outside connections. The total assembly is encased in a plastic capsule or Bakelite case. Such capacitor have small capacitance value (50 to 500pf) and high working voltage (500V and above). The mica capacitors have excellent characteristics under stress of temperature variation and high voltage application. These capacitor are now replaced by ceramic capacitor.

Ceramic Capacitor:

Such capacitor have disc or hollow tabular shaped dielectric made of ceramic material such as titanium dioxide and barium titanic. Thin coating of silver compound is deposited on both sides of dielectric disc, which acts as capacitor plates. Leads are attached to each sides of the dielectric disc and whole unit is encapsulated in a moisture proof coating. Disc type capacitors have very high value up to 0.001uf. Their working voltage range from 3V to 60000V. These capacitor have very low leakage current. Breakdown voltage is very high.



Diode are polarized, which means that they must be inserted into the PCB the correct way round. This is because an electric current will only flow through them in one direction (like air will only flow one way through a tyre valve). Diode have two connections, an anode and a cathode. The cathode is always identified by a dot, ring or some other mark.

The PCB is often marked with a +sign for the cathode end. Diodes come in all shapes and sizes. They are often marked with a type number. Detailed characteristics of a diode can be found by looking up the type number in a data book. If you know how to measure resistance with a meter then test some diodes. A good one has low resistance in one direction and high in other. They are specialized type of diode available such as the zener and light emitting diode (LED).



When a small voltage is applied to the diode in the forward direction, current flows easily. Because the diode has a certain amount of resistance, the voltage will drop slightly as current flow through the diode. A typical diode causes a voltage drop about 0.6-1V (VF) (In the case of silicon diode almost 0.6V). This voltage drop needs to be taken into consideration in a circuit which uses many diodes in series. Also, the amount of current passing through the diodes must be considered. When voltage is applied in the reverse direction through a diode, the diode will have a great resistance to current flow. Different diodes have different characteristics when reverse-biased. A given diode should be selected depending on how it will be used in the circuit.


The current that will flow through a diode biased in the reverse direction will vary from several mA to just A, which is very small.

Voltage regulation diode (Zener Diode):

The circuit symbol is

It is used to regulate voltage, by taking advantage of the fact that Zener Diodes tend to stabilize at a certain voltage when that voltage is applied in the opposite direction.

Light emitting diode:

The circuit symbol is

This type of Diode emits light when current flows through it in the forward direction (Forward biased).

Variable capacitance diode :

The circuit symbol is


The current does not flow when applying the voltage of the opposite direction to the diode. In this condition, the diode has a capacitance like the capacitor. It is a very small capacitance. The capacitance of the diode changes when changing voltage. With the change of this capacitance, the frequency of the oscillator can be changed.

The flow of charge (or current) through any material, encounter an opposing force similar in many respect to mechanical friction. This opposing force is called resistance of the material. It is measured in ohms. In some electric circuits resistance is deliberetly introduced in the form of resistor. Resistors are of following types:

1. Wire wound resistors. 2. Carbon resistors. 3. Metal film resistors.

Wire Wound Resistors:

Wire wound resistors are made from a long (usually Ni-Chromium) wound on a ceramic core. Longer the length of the wire, higher is the resistance. So depending on the value of resistor required in a circuit, the wire is cut and wound in a ceramic core. This entire assembly is coated with a ceramic metal. Such resistors are available in power of 2 watts to several hundred


watts and resistance value from 1 Ohm to 100K Ohms. Thus wire wound resistors are used for high currents.

Carbon Resistor:
Carbon resistors are divided into three types: a. Carbon composition resistors are made by mixing carbon grains with binding material (glue) and module in the forms of rods. Wire leads are inserted at the two ends. After this an insulating material seals the resistor. Resistor are available in power rating of 1/10, 1/8, 1/4, 1/2, watts and value from 1 ohm to 20 ohms. b. Carbon film resistors are made by deposition carbon film on a ceramic rod. They are cheaper than carbon composition resistors. c. Cement film resistors are made of thin carbon coating fired onto a solid ceramic substrate. The main purpose is to have more precise resistance values and greater stability with heat. They are made in a small square with leads.

Metal Film Resistor:


They are also called thin film resistors. They are made of thin metal coating deposited on a cylindrical insulating support. The high resistance values are not precise in value; however, such resistors are free of induction effect that is common in wire wound resistors at high frequency.

Variable resistors:
Potentiometer is a resistor where value can be set depending on the requirement. Potentiometer is widely used in electronic systems. Examples are volume control, tons control, brightness and contrast control of radio or T.V. sets.

Fusible Resistors:
These resistors are wire wound type and are used in T.V. circuits for protection. They have resistance of less than 15 ohms. Their function is similar to a fuse made flow off whenever current in the circuit exceeds the limit.



Motor is an electromechanical device or digital motor as it can move in discrete steps and traverse through 360 degrees. Now a days many computer peripherals contain one or more motors.

The two main characteristics of motors are synchronism and constant step size. The brushed DC electric motor generates torque directly from DC power supplied to the motor by using internal commutation, stationary permanent magnets, and rotating electrical magnets. Like all electric motors or generators, torque is produced by the principle of Lorentz force, which states that any current-carrying conductor placed within an external magnetic field experiences a torque or force known as Lorentz force. Advantages of a brushed DC motor include low initial cost, high reliability, and simple control of motor speed. Disadvantages are high maintenance and low life-span for high intensity uses. Maintenance involves regularly replacing the brushes and springs which carry the electric current, as well as cleaning or replacing the commutator. These components are necessary for transferring electrical power from outside the motor to the spinning wire windings of the rotor inside the motor.

A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals(LCs). LCs do not emit light is an electronically-modulated optical device made up of any


number of pixels filled with liquid crystals and arrayed in front of alight source (backlight) or reflector to produce images in colour or monochrome.

Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent electrodes, and two polarizing filters, the axes of transmission of which are (in most of the cases) perpendicular to each other. With no actual liquid crystal between the polarizing filters, light passing through the first filter would be blocked by the second (crossed) polarizer. In most of the cases the liquid crystal has double refraction. Before applying an electric field, the orientation of the liquid crystal molecules is determined by the alignment at the surfaces of electrodes. Table of Pin Description of LCD :


The MAX232 is an integrated circuit that converts signals from an RS232 serial port to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs

from a single + 5 V

supply via on-chip charge pumps and external capacitors. This makes it useful for implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V to + 5 V range, as power supply design does not need to be made more complicated just for driving the RS-232 in this case.

When a MAX232 IC receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15 V, and changes TTL Logic 1 to between -3 to -15 V, and vice versa for converting from RS232 to TTL.

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA-232 voltage levels from a single 5-V supply.


RS232 Line Type & Logic Level

RS232 Voltage

TTL Voltage to/from MAX232

Data Transmission (Rx/Tx) Logic 0

+3 V to +15 V


Data Transmission (Rx/Tx) Logic 1

-3 V to -15 V


Max-232(operating circuit)



IC 7805 :

Three terminal positive fixed voltage regulators:

These voltage regulators are monolithic integrated circuits designed as fixed voltage. These regulators employ internal current limiting, thermal shutdown, and safe area compensation. With adequate heat sinking they can deliver output current in excess of 1.0A. Although designed primarily as fixed voltage regulator, these devices can be used with external component to obtain adjustable voltages and currents.


The two blocks represent the two trains having Anti-Collision System.

ACD (ANTICOLLISION microcontroller,LCD Communication switches,transistor,LED

DEVICE) consists of a panel and Wireless Unit,Potentiometer,button etc.

If the two trains are on same track,heading towards each other and if it comes in the range of transreceiver then the red LED will glow and a warning message is displayed on the LCD panel and both the trains will automatically stop. If the two trains are on same track moving in the same direction then ACD will check for speed and if the speed of rear end train is more then the rear end train will automatically stop without affecting the front end train .

The rear end train will not move until any of the train changes the track. As ACD will detect the collision, the red LED will glow and a warning message is displayed on the LCD panel. The green LED indicates of trains. the smooth movement




INTEGERATED ELECTRONICS (TMH edition 1991) By Jacob Millman & Christos C. Halkias


Kenneth J. Ayala The 8051 Microcontroller Architecture, Programming and application. Stewart The 8051 Microcontroller

3. James


Hardware, Software and Interfacing (Pearson).


Raj Kamal Microcontrollers: Architecture, Programming, Interfacing and System Design Pearson edition 2005



Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin D. McKinlay The 8051 Microcontroller and Embedded Systems ( PHI of India Ltd., New Delhi 2nd Edition 2006.

Through Internet :
1. 2. 3. 4. 5. 6. 7.