0% found this document useful (0 votes)
9 views92 pages

Wireless Sensors for Railway Safety

The project report titled 'Wireless Sensors Based Accident Prevention System for Railways' aims to enhance railway safety by utilizing wireless sensor networks (WSN) to monitor train locations and prevent accidents at unmanned railway gates. The system is designed to address issues such as mismanagement during signaling and the risk of two trains on the same track, employing advanced embedded systems for real-time monitoring. The report outlines the project's objectives, methodologies, and technological frameworks, emphasizing the need for improved safety measures in railway operations.

Uploaded by

vamsisisi10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views92 pages

Wireless Sensors for Railway Safety

The project report titled 'Wireless Sensors Based Accident Prevention System for Railways' aims to enhance railway safety by utilizing wireless sensor networks (WSN) to monitor train locations and prevent accidents at unmanned railway gates. The system is designed to address issues such as mismanagement during signaling and the risk of two trains on the same track, employing advanced embedded systems for real-time monitoring. The report outlines the project's objectives, methodologies, and technological frameworks, emphasizing the need for improved safety measures in railway operations.

Uploaded by

vamsisisi10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

WIRELESS SENSORS BASED ACCIDENT PREVENTION

SYSTEM FOR RAILWAYS

A Project Report submitted


in partial fulfilment for the award of the degree of
BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING
By

LANKA MANICHANDRA U20EC079


NAGOTHI THRISHA U20EC103
NANNURI SISINDR U20EC108

Under the guidance of


Dr. F. VINCY LLOYD
PROFESSOR/ECE

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BHARATH INSTITUTE OF HIGHER EDUCATION AND RESEARCH
(Deemed to be University Estd u/s 3 of UGC Act, 1956)
CHENNAI 600073, TAMILNADU, INDIA

DECEMBER 2023
BHARATH INSTITUTE OF HIGHER EDUCATION AND RESEARCH
BHARATH INSTITUTE OF SCIENCE AND TECHNOLOGY
CHENNAI – 600073, INDIA.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING

BONAFIDE CERTIFICATE

This is to certify that the project report entitled WIRELESS SENSORS BASED
ACCIDENT PREVENTION SYSTEM FOR RAILWAYS by LANKA
MANICHANDRA (U20EC079), NAGOTHI THRISHA (U20EC103), NANNURI
SISINDRI (U20EC108) to the Department of Electronics and Communication Engineering,
Bharath institute of Higher Education and Research, in partial fulfilment for the award of the
degree of B. Tech in (Electronics and Communication Engineering) is a Bonafide record
of project work carried out by the under my supervision. The content of this report, in full or
in parts, have not been submitted to any other institution or university for the award of any
other degree.

SUPERVISOR HEAD OF THE DEPARTMENT


Dr. F. VINCY LLOYD Dr. B. KALAISELVI
Professor, Associate Professor/HOD,
Department of ECE Department of ECE
BIHER, BIHER,
Chennai - 600073 Chennai - 600073

Submitted for the Project Viva-Voce examination held on ……...…………………...


INTERNAL EXAMINER EXTERNAL EXAMINER

DECLARATION

We declare that this project report titled WIRELESS SENSORS BASED ACCIDENTS
PREVENTION SYSTEMS FOR RAILWAYS submitted in partial fulfilment of the
degree of B. Tech in (Electronics and Communication Engineering) is a record of
original work carried out by us under the supervision of Dr. F. VINCY LLOYD and has
not formed the basis for the award of any other degree or diploma, in this or any other
Institution or University. In keeping with the ethical practice in reporting scientific
information, due acknowledgements have been made wherever the findings of others have
been cited.

LANKA MANICHANDRA
(U20EC079)

NAGOTHI THRISHA

(U20EC103)

NANNURI SISINDRI

(U20EC108)

PLACE: CHENNAI

DATE:
ACKNOWLEDGEMENT

First, we wish to thank the almighty who gave us good health and success throughout our
project work.

We express our deepest gratitude to our beloved President Dr. J. Sundeep Aanand and
Managing Director Dr.E. Swetha Sundeep Aanand for providing us the necessary facilities
for the completion of our project.

We take great pleasure in expressing sincere thanks to Pro Chancellor Dr. K. Vijaya Baskar
Raju, Vice Chancellor Dr. M. Sundararajan, Registrar Dr. S. Bhumi Nathan, and
Additional Registrar Dr. R. Hari Prakash for backing us in this project. We thank our Dean
Academics Dr.M. Sundararaj for providing sufficient facilities for the completion of this
project.

We thank our Dean, School of Electrical Sciences Dr.S. Prakash for his encouragement and
valuable guidance.

We record indebtedness to our Head, Department of Electronics and Communication


Engineering Dr.B. Kalaiselvi for her immense care and encouragement towards us
throughout the course of this project.

We also take this opportunity to express a deep sense of gratitude to our Project Coordinator
and supervisor Dr.F. VINCY LLOYD for her cordial support, valuable information, and
guidance, she helped us in completing this project through various stages.

We thank our department faculty, supporting staff and friends for their help and guidance to
complete this project.
L. MANICHANDRA (U20EC079)
N. THRISHA (U20EC103)
N. SISINDRI (U20EC108)
ABSTARCT 1

This project titled “WIRELESS SENSORS BASED ACCIDENT PREVENTION SYSTEM


FOR RAILWAYS” deals in regularizing the traffic, monitoring the location of the train to
make it easy for the customers and signaling at the unmanned. Railway gate and monitoring
the location of the train to make it easy for the customers. The word Traction means “any
operation related to the track”.
The main objective of the project is to avoid accidents at the unmanned railway gate, two
trains coming on the same track, mismanagement during signaling and power transmission as
no technology has evolved in monitoring the position of the train. This can be achieved by
using the WSN.
Around the earth there are 24 satellites allocated to six orbits where each orbit consists of
four satellites. The principle used to position and locate the objects is ‘Trilateration’.
This system is used for surveillance and to position the aircrafts at present. In other countries
like United States, United Kingdom, Europe this system is followed to track the location of
the trains and their position too. This project has been designed similarly to bring this state of
art of technology to our country.
As the demonstration cannot be done by using the satellites, here it is done by using the
wireless communication [FM]. This project consists of a real-time train track model and the
objective is achieved by using the embedded systems and software like Visual Basic 6.

CONTENTS
BONAFIDE CERTIFICATE ……………………………………………………

DECLARATION ……………………………………………………………………
ACKNOWLEDGEMENT …………………………………………………………. 2

ABSTRACT ………………………………………………………………………… 1

CHAPTER - 1

1. INTRODUCTION ………………………………………………………………. 5-6

CHAPTER-2

2. LITERATURE REVIEW ………………………………………………………. 2-8

2.1 BLOCKING SYSTEMS ………………………………………………………. 9

2.2 MODERNIZATION OF INDIAN RAILWAYS ……………………………… 10

2.3 AUTOMATION ……………………………………………………………. 10-11

SPECIFICATIONS ……………………………………………………………….......

CHAPTER-3

3. BLOCK DIAGRAMS ………………………………………………………… 12

3.1 MAIN BLOCK DIAGRAM …………………………………………………. 12

3.2 EMBEDDED BLOCK DIAGRAM …………………………………………. 13

3.3 POWER SUPPLY BLOCK DIAGRAM ……………………………………. 13

3.4 IR EMISSION AND DETECTION …………………………………………. 14

CHAPTER-4

4. PIC MICROCONTROLLER ………………………………………………… 15-16

4.1 ARCHITECTURE ……………………………………………………...…... 16-17

4.2 CORE FEATURES …………………………………………………………. 17-18

4.3 PERIPHERAL FEATURES ………………………………………………... 18-24

4.4 DESIGN FEATURES ………………………………………………………. 24-28

4.5 MEMORY ORGANISATION …………………………………………….. 28-34

4.6 RS-232 …………………………………………………………………….... 34-37

CHAPTER-5
5. HARDWARE ………………………………………………………………… 38 3

5.1 POWER SUPPLY UNIT …………………………………………………… 38

5.2 SENSORS …………………………………………………………………... 38-39


5.3 I.R. DETECTOR ……………………………………………………………. 39
5.4 I.R. EMITTER …...…………………………………………………………. 40-42
5.5 STEPPER MOTOR ………………………………………………………… 42-46
5.6 OPTO COUPLER ……………………………………………………….…. 46-49

5.7 ELECTRO MECHANICAL RELAYS …………………………….….…... 50-53

CHAPTER-6

6. ADVANTAGE OF USING PC WITH PIC…………………………………….. 54

CHAPTER-7

7. CIRCUIT DIAGRAMS AND OPERATIONS ………………………………… 55

7.1 POWER SUPPLY CIRCUIT DIAGRAM ………………………………….. 55-58

7.2 EMBEDDED CIRCUIT DIAGRAM ……………………………………… 59-60

7.3 IR EMISSION AND DETECTION CIRCUIT DIAGRAM ……………… 61-62

CHAPTER-8

CODING ………………………………………………………………………. 63-77

CHAPTER-9

9. FUTURE ENHANCEMENTS …………………………………………………. 78

CHAPTER-10

10. CONCLUSION ………………………………………………………………… 79

CHAPTER-11

11. APPENDIX ……………………………………………………………………. 81

11.1 PIC 16F877A-PIN DIAGRAM ……………………………………………… 82

11.2 74LS14-PIN DIAGRAM …………………………………………………….. 83

11.3 LM339-PIN DIAGRAM ……………………………………………………… 84


11.4 MAX232-PIN DIAGRAM ……………………………………………………. 85 4

CHAPTER-12

12. BIBLIOGRAPHY ……………………………………………………………… 86

CHAPTER 1
1. INTRODUCTION 5

Signaling is the method of regularizing the Railway track and the gate for the train to
pass through without any problem. This project titled “WIRELESS SENSORS BASED
ACCIDENT PREVENTION SYSTEM FOR RAILWAYS” deals in regularizing the traffic,
monitoring the location of the train to make it easy for the customers. The word Traction
means “any operation related to the track”.
The main objective of the project is to avoid accidents at the unmanned railway gate, two
trains coming on the same track, mismanagement during signaling and power transmission as
no technology has evolved in monitoring the position of the train. This can be achieved by
using the WSN.
WSN- Wireless Sensors Networks plays vital role in finding out the position of a moving
object in the globe. WSN system saves time, life, cost in many ways to the society along with
greater security. Worldwide for almost all the surveillance need people started using WSN. It
consists of a sensing system coupled with a local transmitter, base station to receive various
transmissions from different locations, a satellite for communication, a computer along with
powerful software for proper informative needs and decision making.
Presently, the method used for signaling at both manned and unmanned railway gate are
through telephones, where information are passed and warning bells for the gatekeepers to
close the gate that lead to major accidents. The technology that we have used in our project is
the advance embedded controller interfaced with the PC. The following are the objectives of
this project:

 Wireless sensor networking (WSN)


 Developing Virtual instrumentation system of the events.
 Prevention of accidents
 Identifying the faulty tracks
 Identifying two trains on the same track
 Tripping of HT during abnormal conditions
 Low power gate drive mechanism
 To avoid accidents at the unmanned gate.
 Regularization of the rail traffic.
 Assuring the entire train passing
 Annunciation of an ongoing.
 Speed indication on to the stations. 6

 Developing integrative hardware network.


 Real time sensor model is developed.
 Animation and graphics.

The WSN has been used to position the train located at distant locations. The data acquired at
every base station is transmitted to the satellites in the medium earth orbit. Through the
downlink the data is transmitted to the base station where the processing of the data is done.
The operation is explained below with an example.
Automatic traction system has sensors placed at the 2 nd, 4th and 6th Kilometers on either side
of the unmanned railway gate. The sensor placed at the 6 th Kilometers is a metal detector.
This detects the presence of the train and the information is passed to the control room, also a
voice output stating the arrival of the train at the 6 th kilometer is heard. When the train
approaches the 4th Kilometer, its presence is sensed by the IR Sensor and simultaneously the
gate is initiated to close. The gate closes completely when the train is between 2 nd and 4th
kilometer. Light indicating signaling, is conveyed at the 2 nd kilometer IR Sensor for the
extreme safety. Now the train crosses the gate without any problem and when the last bogie
of the train passes the 4th kilometer sensor on the other side of the gate, the gate opens
automatically.
In the case of any problem, the information is passed to the control room. This is an
indication for the persons at the control room to clear the obstacle at the gate. An indication
to the driver to stop the train is that the red light at the 2 nd kilometer glows. Thus effective and
efficient signaling is done near the unmanned railway gate and accidents are avoided.

CHAPTER 2

2. LITERATURE REVIEW

Since in post Independence India, Industrialization was taking place on large scale with
emphasis on indigenization of several products, the Railway Workshop at Podanur also
imbibed the impetus for growth in its initial formation stage itself.
Initially the Workshops were engaged in manufacture of Mechanical Signaling equipment 7
and gradually manufacturing of Electro-Mechanical and Electrical Signaling equipment was
taken up in pace with the advancement taking place in Technologies and also to meet the
requirements of Indian Railway organization.
By the year 1963, Electrical Signaling Reverser, Lever Lock Circuit Controllers of types,
were started to be manufactured regularly in the Workshop; besides the Heppers Key
Transmitter, Disc Indicators, Thermostat Contacts, Arm & Light Repeater, Luminous
Indicators and Token Exchangers etc.
A big leap in the indigenization of Signaling products took place during the years 1967 to
1971, with the development of Non-Vital Plug in Type Relays, Point Machine & Token Less
Block Instrument etc. During this period in addition to manufacture of 1200 Non-Vital Plug
in Type Relays, equipment such as centralized Traffic control system including master &
field location panels and Automatic train recorders were also developed and manufactured at
Signal and Telecommunication Workshops, Podanur.
In the year 1973, under expansion stage II, an order for components and drawings for plug in
Type `Q' Relays were placed for WESTINGHOUSE BRAKE & SIGNAL /LONDON.
Further during this period, installation of Modern Machine Tools like numerically controlled
Milling Machine, Jig Boring Machine, Jig Grinding Machine, Profile Grinding Machine &
Electric Discharge Machine also took place. The regular production of `Q' Relays was
commenced in the year 1974-75 on a small scale.
In the year 1976 development and manufacture of Vigilance Control Device i.e., Drivers
Alertness Alarm Device was carried out as per RDSO Design. The extensive field trials and
manufacturing of these devices took place almost simultaneously. Development of Electronic
Axle Counter Mark I was taken up in the year 1977 as per the design supplied by
RDSO/LKO. Production of Three Position DC Polarized Relay ITI Design was also

commenced in the year 1978. In the year 1980, Development of Electrically Operated Lifting
Barrier Gates took place and regular production of GRS Apparatus Cases was taken up in that
year. Export of Signaling Equipment such as Electric Signal Reversers, Track feed
Resistance, Transformer Rectifiers and Shelf Type Relays to Nigerian Railways through
"IRCON" was made in the year 1982.
In 1986-87 Plug in type "Q" Relays for Special applications viz. QSPA1, QBAT & Q JI were
developed, and Signal Control Panels for Metro Railways/ CALCUTTA were manufactured
and supplied. The modified version of Electric Lifting Barrier Gate with high reliability was
developed and after field trials, manufacturing started in the year 1986 itself. Similarly, 8
Electronic Timer and Axle Counter Mark II (RDSO DESIGN) were developed in this year.
In the year 1990 Axle counter mark II production was started, following the RDSO/LKO
design. In the year 1991 import substitute code-receiving relay namely QB 3 was developed
to replace the imported EKDB relays of M/S KAYOSON electric company Japan thus
resulting in tremendous saving in foreign exchange. In the year 1993-1994 development of
IRS Rotary Type Locking High Thrust Point Machine as per the RDSO design and also
development of Universal Axle Counter was under taken. In the year 1995-1996, IRS Rotary
Type Locking High Point Machine was introduced in the production line. Besides this,
production of Universal Type Axle Counter was taken up. Further development of Token
fewer Block Instrument with Q relay was undertaken. In the year 1996-1997 bulk production
of Token less Block Instrument with Q relay, QBA 1 relay started.

2.1 BLOCKING SYSTEMS

Indian railways use a variety of blocking systems.

1. Token less block system:


This is usually done in double line routes, and basically works like the block instruments in
the UK although the instruments are of modern manufacture. Instead of bell codes the Station
Master speaks through the telephone to the instrument.

2. Single line Token less block system:

This is present is in single line routes. I don't know how they operate the block system, but
the old practice of putting tokens in cane rings has been removed. In these routes usually the
semaphore signals are replaced.

3. Single line Token blocking:


This is the practice which I like. It has all the qualities of an old Railway system. The 9
line is single, the signals are semaphore, and then there is the passing of tokens in a cane
ring which looks like a tennis racket. It is in this system that I heard about all these Neal's
ball tokens, Neal's tablet tokens etc.

4. Track circuit Signaling:


Thanks to this, the practice of setting up points and then changing the signals is now gone in
all major stations (at least in the main lines of the station). Now just by giving the signal on
the branch line for a train to enter a main line, just the signal switch for the home signal on
the branch line, is operated, the required points are automatically set. And since the points
have been set, the Home Signal on the main line cannot be altered. Now the Station Master
can also get the position of the train on his signal panel.

2.2 MODERNIZATION OF INDIAN RAILWAYS

Regarding the modernization of Indian railways, the maximum improvement has taken place
in the reservation system, which is fully computerized. However, in Signaling and
positioning, the method followed is still the British one, but the instruments and equipment
are basically Indian. Moreover, there is also track circuiting and interlocking of signals,
railway gates in major lines. Along with all these features you will be able to see a signalman
at the dead of the night peeping out of his box, with the classic Indian railway signal lantern
in his hand!
Many Britishers who were in India still looks upon the railway with nostalgia. Ruskin Bond
(he settled in India) has written numerous stories based on the railways and the sincerity of
the Indian railway man (especially in the ranks of porters, lines men and cabin men).
A device, known as auxiliary warning system (AWS) is to be introduced on the Chennai
Beach and Gummidipoondi section of railways for improving the passenger safety.
The main advantage of the system, stated to be the first of its kind in Southern Railway, is
that trains would automatically stop if drivers jump the red signal by mistake. At present, the
system is available only in the suburban services in Mumbai. The Railway Board has
sanctioned Rs.6.45 crores for the scheme.
2.3 AUTOMATION 1

Automation is a technology concern with the application of mechanical and


computer-based system operate and control.
This technology includes
 Automatic positioning using wireless transmitter and receiver (GPS)
 Automatic material handling
 Computer system for data collection and decision-making.
 FB control and computer process control. Our project is limited to the field of
automatic positioning. The type of automation used in the project is programmable
automation. In this type of automation, a program in VB Lang controls the operation
so that the system can read and interpret them. New Panis can be prepared and
entered for different applications.

Reasons for automation.


 Increase in accuracy and precision
 Decrease in cost
 Decrease in labor force
 Increase in safety.
CHAPTER 3 1

3. BLOCK DIAGRAMS

3.1 MAIN BLOCK DIAGRAM

Wireless Wireless
transmitter Receiver

Rs
Sensor Sensor Schmitt 232
from track from track Trigger Con

PIC
Mechanical Stepper Tr. Power Opto
16F877 BASE
Model Motor Drivers Isolator STATION
A

Motor Signaling
Power Relay Output’s
Supply

BASE
STATION
3.2 BLOCK DIAGRAM OF PIC16F877A 1

Analog Power Digital Power


Supply
Supply

External C
Crystal USART P
Oscillator PIC16F877A U

Logic I/O
Synchronous
Connector
Switch

Analog Ref 8 channel


Voltage 5V Analog Input

3.3 POWER SUPPLY BLOCK DIAGRAM

Positive
Step Down Positive Voltage
Bridge
Transformer Charge Regulator LPF
Rectifier
Capacitor IC 7812 +5v
1

3.4 IR EMISSION AND DETECTION

IR Infra Transistor Schmitt


Emitter
Detector Driver Trigger
1

CHAPTER 4

4. DESIGN OF SYSTEM HARDWARE

HARDWARE DESIGN

The single board is designed around the PIC Micro controller to accomplish the above-
mentioned system requirements.
The hardware section is divided into three subsections as follows:
(1) PIC Micro controller
(2) Max 232 and RS232
(3) Power supply unit

PERIPHERAL INTERFACE CONTROLLER

GENERAL DESCRIPTION OF EMBEDDED CONTROLLER


Embedded is the advanced development of microcontroller along with some
direct industrial functions. Some of the direct industrial functions are ADC, DAC, PWM,
USART, Supporting codes, timer, sensor etc. It is mainly used for communication purpose. It
does not need dynamic link library (DLL). The version of embedded controller used is
16F877A.
It consists of reduced instruction set computation (RISC). It avoids a lot of electronic
components, so it is easy to detect failure . It is easy to interface with PC.

PIC MICROCONTROLLER

Peripheral Interface Controller (PIC) is enhanced version of microcontrollers. It is an


embedded controller. PIC microcontroller contains several families. They are classified as
three categories.
1. Low End Family:
It has 33 instructions. For example, PIC 12XXX
2. Mid-Range Family:
It has 35 instructions. For example, PIC 16XXX
3. High End Family: 1

It has 77 instructions. For example, PIC 17XXX and PIC 18XXX.

4.1 ARCHITECTURE

Two types of Architecture are followed.


I). Van-Neuman Architecture:
The width of address and data bus is same.
II). Haward Architecture:
The bus width of address and data may not be same. Pipelining is possible
here.
Microcontrollers have built-in peripherals, they are:
1. Memory
a. Program Memory (E.g., PROM, Flash memory)
b. Data Memory (E.g., RAM, EEROM)
2. I/O Ports
3. ADC
4. Timers
5. USART

6. Interrupt Controllers
7. PWM / Capture

Port A
PM DM Port B
I/O
Port C
Port D
Port E

CPU Ports

Timer /
Counter PWM/
Capture

ADC

USART

OSC WDT
1

4.2 MICROCONTROLLER CORE FEATURES:

• High-performance RISC CPU


• Only 35 single word instructions to learn
• All single cycle instructions except for program branches which are two cycles
• Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
• 4K x 14 words of Program Memory,256 x 8 bytes of Data Memory (RAM)
• Interrupt capability (up to 14 internal/external interrupt sources)
• Eight level deep hardware stack
• Direct, indirect, and relative addressing modes
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
• Programmable code-protection
• Power saving SLEEP mode
• Selectable oscillator options
• Low-power, high-speed CMOS EPROM technology
• Fully static design
• In-Circuit Serial Programming(ISC
• Wide operating voltage range: 2.5V to 5.5V
• High Sink/Source Current 25/25 mA
• Commercial and Industrial temperature ranges
• Low-power consumption:
- < 2 mA @ 5V, 4 MHz
- 22.5 mA typical @ 3V, 32 kHz
-< 1 mA typical standby current
1

4.3 PERIPHERAL FEATURES:

The PIC 16F877A has five serial ports namely A, B, C, D and E. It has five parallel ports
namely:
1. PSP (Parallel Slave Port 8 bit wide)
2. SSP (Serial Synchronous Port)
3. MSP (Master Serial Synchronous Port)
4. I2C (Inter Integrated Circuit)
5. SPI (Serial Peripheral Interface)

 256 × 8 bytes data memory


 8k × 14 words program memory
 It has three timers
o Timer 0 – 8-bit timer
o Timer 1 – 16-bit timer
o Timer 2 – 8-bit timer

12-bit 10 channel
o 12-bit accuracy
o No external hardware multiplexer is needed Sleep mode processor
o No power will be consumed during ideal condition Built in temperature sensor

o Built in RAM and EPROM


RAM is used to control ADC. MSB is stored in RAM when LSB is outputted.
 PWM:
Two captures compare PWM module. PWM is used as DAC.
 Programmable Low voltage detection Circuitry.
 USART:

Universal Synchronous Asynchronous Receiver And Transmitter


It converts serial data into parallel and vice versa. For instrumentation standard MAX-485
data converter should be used.
This external data converter amplifies the incoming 5V (from PIC) by four times and gives 1
20V output i.e. -10V to +10V. Similarly, incoming 20V (from PC) is reduced as 5V by the
same MAX 485 converter. MAX 485 can be replaced by MAX 232 for computer standard.
This is known as Quader – Puller action.

PERIPHERAL INTERFACE CONTROLLER

Some of the companies manufacturing Embedded Controllers: -


 Motorola (MC)
 Atmel (ATM)
 Philips (PHL)
 Signetics (SG)
 Cyprus (CYPRUS)

 Micro Chip Company (PIC)

 Micro Chip Company is the first company to be recognized as the Embedded Solutions
Company.
 World’s largest Embedded Controller Produced company until 2002 i.e., 600 millions. By
2004 expecting to reach 1000 millions.
 PIC 16F877A – has 10 channels & 12-bit accuracy.
 PIC is Highly Flexible & Versatile – its development tool is inexpensive.
 PIC Micro Controller converts data in serial form to parallel form.
 It has 21 inputs designed for Digital I/O operation & 10 inputs for Analog operation.
 Its BAUD rate is 9600 bps. So, it can work at a high speed.

 It includes a RAM in which the whole data is dumped & permanent data are stored in
EPROM.
 It also includes Sensors for detecting various changes in the surroundings like Flame
Occurrence, Obstacle Interference etc.,
 An inbuilt ADC adds to its advantage be detecting the Temperature and Pressure changes in
the environment.
 PIC controls the Relay; thereby controlling the Power Supply to the Motor. 1

General Features of PIC:

 High Performance RISC CPU


Only 35 instructions are available, hence easy programming is possible which increase the
processing speed.
 Operating Speed
It operates at a speed of 20 MHz
 Watch Dog Timer
It is used to find Communication Error with its own on chip RC oscillator for reliable
operation.
 Low Power Consumption
 High Sink / Source Current

In PIC, Source Current = Sink Current. The output of the Embedded Controller can be used
to drive printer, relays, solenoid valves etc. No need of driver circuit.

 No need for DLL


PIC is Compatible to all computer language. Assembly to C, Assembly to VB, C to Assembly
are all converted directly without a Dynamic Link Library.

4.3 PERIPHERAL FEATURES

The PIC 16F877A has five serial ports namely A, B, C, D and E.


1. Port D - RD 0 to RD 7
2. Port B - RB 0 to RB 7
3. Port C - RC 0 to RC 7
4. Port A - RA 0 to RA 5
5. Port E - RE 0 to RE 2

It has five parallel ports namely:


1. PSP (Parallel Slave Port 8 bit wide) 2

2. SSP (Serial Synchronous Port)


3. MSP (Master Serial Synchronous Port)

4. I2C (Inter Integrated Circuit)


5. SPI (Serial Peripheral Interface)

Additional Peripheral Features of the PIC are :-


 Built In ADC
The ADC converts known voltages into unknown fractions. The ADC is built in PIC. It
consists of 10 channels and each channel has a 12 - bit accuracy. i.e., 10 different analog
inputs can be given simultaneously. Since it has a 12-bit accuracy, the given voltage will be
converted to the power of 12. Its accuracy is in steps of 1mV.
Data Memory 256 * 8 bytes of data memory.
 Program Memory
4K * 14 words of program memory.
 Timers

It has three timers. They are: -


 Timer 0 – 8-bit timer
 Timer 1 – 16-bit timer
 Timer 2 – 8-bit timer
 Sleep Mode Processor
No Power Supply will be consumed during IDLE condition.
 Programmable Low Voltage Detection Circuitry
When the voltage becomes High or Low, the PIC will Switch OFF itself.
 Built in Thermal Shut Down
If the chip is heated beyond 25 mA, then PIC will Switch OFF Automatically. This
shows that the Process Instrumentation Controller has no failure.
2

Built in RAM and EPROM

RAM is used to control ADC. MSB is stored in RAM when LSB is Outputted. This does not
require an External Memory. It can by itself act as a Single Chip Process.

Built in USART

USART is Universal Synchronous Asynchronous Receiver And Transmitter. It converts


serial data into parallel and vice versa. This external data converter amplifies the incoming
5V (from PIC) by four times and gives 20V output i.e. -10V to +10V. Similarly, incoming
20V (from PC) is reduced as 5V by RS-232 converter. This is known as Quader – Puller
Action.

Built in Logic I / O Ports

PIC does not require any additional chips for executing Logical Operations. All Parallel
Operations can be done directly.

Built in Internal and External ADC reference facility

Reference could be done both Internally as well as Externally. If we provide the reference
Externally, then 2 channels must be allocated for that. Hence only 8 channels out of the total
10 channels can be used. In Internal reference all the 10 channels can be used.
2

4.4 DESIGN FEATURES:

 Individual Power Supply for Analog and Digital circuits is required to avoid drift on
analog portion.
 Double regulated filtered reference source is needed to ensure safest ADC operation.
 External clock source must be used which enables the user to design the required speed.
 External CPU synchronous circuit must be designed in case of PC requirement.
 Switch is used to synchronize the Embedded Controller with the PC to get the COM OK
signal.
 External RS – 232 should be used for Data Conversion.
 External Power on Reset Circuit is needed to Clear Memory.
The data memory is partitioned into multiple banks which contain general purpose registers
and special function registers. Bits RP 1 and RP 0 are bank select bits.

RP 1 RP 0 Bank no.
0 0 0
0 1 1
1 0 2
1 1 3

Each bank extends up to 7F H (128 bytes). The lower locations of each bank are reserved for
the Special Function Register. Above the special function registers are General Purpose
Registers, implemented as Static RAM. In all banks the bottom most 16 bits are called Access
Banks. The data’s stored in these locations can be accessed irrespective of the bank number.

Status Register:

The status register contains arithmetic status of ALU, Reset and Bank Select Bits for Data
Memory.
The bits Z, DC, C are set or reset according to the device logic.
2

IRP RP 1 RP 0 TO PD Z DC C

 IRP - Register Bank Select bit.


 1 - Bank 2 & 3
 0 - Bank 0 & 1
 RP 1, RP 0 - Bank selection bits

 TO -Time Out bit


 1- After Power Up, CLRWDT instruction or SLEEP instruction
 0 - A WDT time out occurred

 PD - Power-down bit
 1 - After power-up or by the CLRWDT instruction
 0 - By execution of the SLEEP instruction
 Z - Zero Bit
 1 - The result of an arithmetic or logic operation is zero
 0 - The result of an arithmetic or logic operation is not zero
 DC - Digit carry / borrow bit
 1 - A carry-out from the 4th low order bit of the result occurred
 0 - No carry-out from the 4th low order bit of the result
 C - Carry / borrow bit
 1 - A carry-out from the most significant bit of the result occurred
 0 - No carry-out from the most significant bit of the result occurred

General Features:

High Performance RISC CPU


Only 35 instructions are available, hence easy programming is possible which increase the 2
processing speed.
 Operating Speed
 9600 baud rates
 Power On Reset
Whenever the PIC is reset, the program counter reaches the known address.
 Watch Dog Timer
It is used to find Communication Error with its own On chip RC oscillator for reliable
operation.
 Low Power Consumption
 High Sink / Source Current
 The output of the Embedded Controller can be used to drive printer, relays, solenoid valves
etc. No need of driver circuit.
 Compatible to all computer language No need of DLL (Dynamic Link Library)

 Individual power supply for Analog and Digital circuits is required to avoid drift on
analog portion.
 Double regulated filtered reference source is needed to ensure safest ADC operation.
 External clock source must be used which enables the user to design the required
speed.
 External CPU Synchronous circuit must be designed in case of PC requirement.
 Switch is used to synchronize the Embedded Controller with the PC to get COMOK
signal.
 External RS-232 should be used for data conversion.

4.5 MEMORY ORGANIZATION:


There are two memory blocks in PIC microcontroller. Each block has its own bus so that
concurrent access can occur]
1. Program Memory
2. Data Memory 2

Program Memory Organization:

PIC 87X has a 13-bit program counter capable of addressing 8k × 14 program memory space.
Each device has 4k × 14 words of program space.
The reset vector is at 0000H
Receiving Interrupt vector is at 0004H
PIC has hardware stack with 8-bit width. It needs jump instruction to access subroutines.
Push and Pop instructions cannot be used since there is no software stack is available.

Program memory is organized as page 0, page1 up to page3 each having 2K memories. Page
address should be mentioned in PC latch for executing the instructions available in some
other pages.
2

Program Memory Organization

0000H Reset Vector Program Counter

Interrupt Vector Stack Level 1

}
0004H Page 0 Stack Level 2

On-Chip
0005H Page 1 Program
memory
Stack Level 8
07FFH
Page 2
0800H
Page 3

0FFFH
1000H

3FFFH

Data Memory Organization:

The data memory is partitioned into multiple banks which contain general purpose registers
and special function registers.
Bits RP1 and RP0 are bank select bits.
RP1 RP0 Bank no
0 0 0 2

0 1 1
1 0 2
1 1 3
Each bank extends up to 7FH (128 bytes). The lower locations of each bank are
reserved for the special function register. Above the special function registers are General
purpose registers, implemented as Static RAM.
In all banks the bottom most 16 bits are called access banks. The datas stored in these
locations can be accessed irrespective of the bank number.

Status Register:
The status register contains arithmetic status of ALU, Reset and bank select bits for data
memory.
The bits Z, DC, C are set or reset according to the device logic.

IRP RP1 RP0 TO PD Z DC C


IRP - Register Bank Select bit. 2

1- Bank 2 & 3
0- Bank 0 & 1
RP1, RP0 - Bank selection bits

TO - Time Out bit


1- After Power Up, CLRWDT instruction or SLEEP instruction
0- A WDT time out occurred
PD - Power-down bit
1- After power-up or by the CLRWDT instruction
0- By execution of the SLEEP instruction
Z - Zero bit
1- The result of an arithmetic or logic operation is zero
0- The result of an arithmetic or logic operation is not zero
DC - Digit carry / borrow bit
1 - A carry-out from the 4th low order bit of the result occurred
0 - No carry-out from the 4th low order bit of the result
C - Carry / borrow bit
1 - A carry-out from the most significant bit of the result occurred
0 - No carry-out from the most significant bit of the result occurred

INTCON REGISTER:
The INTCON register is a readable and writable register which contains various
enable and flag bits for the TMRO register overflow, RB port change and external RBO/INT
pin interrupts.

GIE PEIE T0IE INTE RBIE T0IF INTF RBIF


Bit 7: GIE: Global Interrupt Enable bit 2

1 - Enables all un-masked interrupts


0 - Disables all interrupts
Bit 6: PEIE: Peripheral Interrupt Enable bit
1 - Enables all un-masked peripheral interrupts
0 - Disables all peripheral interrupts
Bit 5: T0IE: TMR0 Overflow Interrupt Enable bit
1 - Enables the TMR0 interrupt
0 - Disables the TMR0 interrupt
Bit 4: INTE: RB0/INT External Interrupt Enable bit
1 - Enables the RB0/INT external interrupt
0 - Disables the RB0/INT external interrupt
Bit 3: RBIE: RB Port Change Interrupt Enable bit
1 - Enables the RB port change interrupt
0 - Disables the RB port change interrupt
Bit 2: T0IF: TMR0 Overflow Interrupt Flag bit
1 - TMR0 register has overflowed
0 - TMR0 register did not over flow
Bit 1: INTF: RB0/INT External Interrupt Flag bit
1 - The RB0/INT external interrupt occurred
0 - The RB0/INT external interrupt did not occur
Bit 0: RBIF: RB Port Change Interrupt Flag bit

1 - At least one of the RB7:RB4 pins changed state


0 - None of the RB7:RB4 pins have changed state

OPTION REGISTER:

RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0

RBPU - Weak Pull up Enable bit


INTEDG - Interrupt Edge Select bit 3

T0CS - Timer0 clock source select bit


T0SE - Timer0 source edge select bit
PSA - Pre scalar Assignment bit
0 - Timer0 is enabled
1 - Watch dog timer is enabled
PS2, PS1, PS0 - Pre scalar

PERSONEL COMPUTER

In personal computer, data transfer takes place serially. RS-232standard is used for serial
communication. PIC Micro controller is linked to PC through the RS-232 port. The PC
displays the menu for selecting the calibrating equipment and all the calibration results
graphically and in tabular form. The user can access the calibration data to get calibration
reports, comparison graphs etc at any time using the menu offered in the PC.

4. 6 RS 232

The most common communication interface for short distance is RS-232. RS-232 defines a
serial communication for one device to one computer communication port, with speeds up to
19,200 baud. Typically, 7 or 8 bits (on/off) signal are transmitted to represent a character or
digit. The 9-pin connector is used. The pin details are given below.

The PIC Micron controllers are supported with a full range of hardware and software
development tools. The used PIC16F877A device comes in 40 pin packages To communicate
with the PIC we are using RS232 port of the computer. So we have to initialize the port
before using it. To initialize and to communicate with the PIC, the file COM.C defines and
uses several functions. The functions and their definitions are given below.

TxD- TxD+COM+5V COM

   

   
3
+12V
CTS
RxD+
RxD-

Fig:3. RS-232 9- PIN CONNECTOR

4.2.2. ADC RELATED FUNCTIONS:


void Set Reference (int ref);
This function is used to set the INTERNAL or EXTERNAL reference for the ADC. The
parameter ref can accept any one of the two values. They are
1. INTERNAL_REF
2. EXTERNAL_REF
For example,
Set Reference (INTERNAL_REF);
float GetAdcCh (int Chno);
This function is used to get the specified channel's (Chno) digital value from ADC. The
parameter Chno can accept a range of values from 0 t0 9, which is the channel number.
This function must be called before performing any digital input / output operation. It is used
to specify the bits of the register act as either input or output.

Register D:

Register B:
Reserved Bits
cannot alter

Register C:
Can be configured
as input or output.

Register A:
3

Configurable bits can be either zero or one according to the initialization. If the particular bit
is to be used as a input port then write '1' to it else '0' for output. For Example, initialize Port
("[1ffffffff]");
Above statement mention all registers bits are act as input port.

MAX232

The Max 232 is a dual RS-232 receiver / transmitter that meets all EIA RS232C specifications while
using only a +5V power supply. It has 2 onboard charge pump voltage converters which generate +10V and –
10V power supplies from a single 5V power supply. It has four level translators, two of which are RS232
transmitters that convert TTL\ CMOS input levels into + 9V RS232 outputs. The other two-level translators are

RS232 receivers that convert RS232 inputs to 5V TTL\CMOS output level. These receivers have a
nominal threshold of 1.3V, a typical hysteresis of 0.5V and can operate up to + 30V input.
1. Suitable for all RS232 communications.
2. +12V power supplies required.
3. Voltage quadrapular for input voltage up to 5.5V (used in power supply Section of
computers, peripherals, and modems).
Three main sections of MAX232 are
1. A dual transmitter
2. A dual receiver
3. +5V to + 10V dual charge pump voltage converter.

CHAPTER 5

5. HARDWARE

5.1POWER SUPPLY UNIT


UREG
VCC
3
REG
D1
1 3
IN OUT
IN5408

J3 D2
R17

2200/50V
1 R9 C4

10MFD/63V1
2 IN5408

D6

IN5408 L9

D7

IN5408

As we all know any invention of latest technology cannot be activated without the
source of power. So, it this fast-moving world we deliberately need a proper power source
which will be apt for a particular requirement. All the electronic components starting from
diode to Intel IC’s only work with a DC supply ranging from +5v. We are utilizing for the
same, the most cheapest and commonly available energy source of 230v-50Hz and stepping
down, rectifying, filtering and regulating the voltage.

5.2 SENSORS

It is quiet nature that a third person may enter in a exchange without prior permission and
request from the authorities, which may create hazardous problem for his life, in such case a
sensor is required to find out that case and to keep in form to the computer for further actions.
We use INFRARED EMITTER and DETECTOR to overcome the problem. In early days to
find out human entry in unauthorized places achieved by using LDR'S and LIGHT

OPERATED SYSTEM, which had a problem, that may work in sunlight and cross-sectional
luminaries and provides false information to monitoring station.

To avoid this we are using invisible INFRARED RADIATION SYSTEM, which is harmless.
In basic I.R. rays has highest wavelength than the existing VIBGYOR color spectrum.
According to manufacturer's instruction we found that applying electric current to GALLIUM
ARSENIDE semiconductor material can generate I.R. rays.
3

Here we are using a current limiting resistor to safeguard I.R. EMITTER as well as to
produce enough ray’s density, which is necessary to drive I.R. DETECTOR. We have used
1K resistor from 5V dc to the I.R. EMITTER to restrict current flow beyond 5mA. Even
though I.R. EMITTER can withstand up to 35mA, we have used 5mA due to shortest
distance. If the distance is more we have to increase the current flow to the emitter. Beyond
the limitation of I.R. EMITTER can be achieved by using additional lenses (OPTICAL
SYSTEM) in front of the emitter.

5.3 I.R. DETECTOR:

I.R. DETECTOR is having reverse characteristics of the I.R. EMITTER. That is we cannot
consume more current from it on account of positive sensitivity. For the above grounds we
have used 100K from the supply Voltage. So, the sink current will be as per the OHM's
LAW I=V/R. So, 5/100K will be less than a microampere which may improve the detecting
characteristics. I.R. DETECTOR will conduct as long as the rays falls on it. So, the level will
be low which may goes to CUT OFF RANGE, whenever there is no rays. Status will be
high. From the above we are clearly known that if there is no entry signal will be low, if there
is entry signal will be high. I.R. DETECTOR drives a NPN transistor which provides inverse
output at collector end and given to a two stages SCHMITT TRIGGER. Which will give at
ultimate inversion of the I.R. DETECTOR. (If there is no entry = high). If there is any entry
the signal output of SCHMITT TRIGGER will be low, which creates a false information to
the computer.

5.4 I.R. EMITTER

Early emitters, both visible and infrared, suffered from low power output
deterioration(degradation) when compared to present day devices. Emitter chip materials,
commonly referred to as III-V compounds, are combinations of elements from the III and V
columns of the periodic chart. The P-N junction is formed by either diffusing or epitaxially
growing the junction. Typical materials used for emitters include GALLIUM ARSENIDE 3
and GALLIUM ALUMINUM ARSENIDE, among others.
When a forward bias current flows through the emitter's P-N junction, photons are emitted.
The total output power is a function of the forward current, and is measured in mW.
Likewise, the axial radiant intensity of an emitting device, which is the portion of the total
emitted power radiated within a specified cone angle directly on axis, is also a function of
this forward current, and is measured in mW per steradian. Motorola's line of emitter does
operate at wavelengths of either 660,850, or 940 nanometers. This encompasses the red and
the near I.R. portions of the electromagnetic frequency spectrum. Emitters of various
wavelengths are produced for the purpose of optimizing system with a variety of applications
and environments. The 940nm emitters are the most cost effective, however, their spectral
emission is not ideally matched to that of the Silicon detectors. Most applications can
tolerate certain justified by the devices lower price. Almost all optoisolators, for example,
use the 940nm emitter.
The 850nm emitters are not well matched to silicon, but are ideal or use in plastic fiber optic
systems. Plastic fiber has a characteristic attenuation curve, which reaches a minimum at
660nm. This attenuation is the predominant factor to consider when designing a plastic fiber
system. The above emitters find wide usage in a variety of isolating, remote control and fiber
optic applications.
Newly developed materials and refinements in chip processing and handling have led to more
efficient and more reliable emitters. New packaging techniques have made low-cost plastic
devices suitable for applications formerly requiting glass-lensed units, by providing efficient
modeled-in lenses. In this way, higher on-axis radiant intensities can be achieved, for a given

amount of total radiated power. A narrow radiation angle provides for a lower drive current
when operating in a configuration where the opto detector is on-axis with the power into an
optical fiber. When a very wide or off-axis viewing angle is required, such as in remote-
control emitters are generally used.
Motorola's selection of emitters includes the low-cost plastic Case 422A devices, such as
MLED91, MLED96 and MLED97. Also in a plastic package is the remote-control emitter,
MLED81. Metal and glass packages, such as the TO-18(MLED930) are utilized in
applications where high axial intensity or absolute hermetic are essential. Advances made in
emitter technology over the years have eliminated many of the problems of early-day devices.
Even the problem of degradation of emitter power output over time has been brought to a
level, which is tolerable and predictable. When coupled to a silicon detector, today's 3
devices can be expected to lead a long and useful life.

DETECTORS:

As emitters have developed over the years, photo detectors have also advanced dramatically.
Early phototransistors and photo diodes were soon joined by photo darlington detectors, and
then by light-activated SCRs. Innovations in design have created devices having higher
sensitivity, speed and voltage capabilities.
Recent developments in detector technology have led to larger and more complex circuit
integration. Photo detectors incorporating SCHMITT TRIGGER logic outputs are becoming
increasingly popular in applications requiring very fast speed, hysteresis for noise immunity,
and logic level outputs.
Motorola introduced the world's first photo-triac driver, a planar silicon device capable of
controlling loads on an ac power line. The zero-crossing triac driver, also a Motorola
development, followed this. This device stands as a classic circuitry, photo-optic technology;
high voltage solid-state physics and field effect transistor (FET) technology are all
incorporated on a monolithic integrated circuit chip inside this device.
Future trends point to even higher performance characteristics and more circuit integration in
photo detectors. Detectors, are like emitters, are available in plastic and in lensed metal
packages.
3

5.5 STEPPER MOTOR

A stepper motor can be considered as a digital electro mechanical device where each step
command pulse results in a movement of the shaft by a discrete angle a called step angle of
the motor. Stepper motor is a device, which converts digital pulses into precise angular steps.
Because of the simple control and compatibility with digital systems, the stepper motor is
used.
Types of stepper motor
The large varieties of stepper motors can be divided into three categories.
(i) Variable reluctance stepper motor.
(ii) Permanent magnet stepper motor.
(iii) Hybrid stepper motor.

IMPORTANT FEATURES OF STEPPER MOTOR:

1. They are compatible with digital systems and do not require digital to analog conversion
at the input, as do conventional servos, when used with digital system or a computer.

2. While simple open loop control is good enough for the control of position and speed, it
can also be used in closed loop position and speed control systems with either analog or
digital feedback.
3. A wide range of step angles is available off the shelf from most manufacturers in the
range of 1.8o to 90o. The range of Torque is 1NM to 50NM.
4. Bi-directional control is available.
5. Maximum torque occurs at low pulse rates. The stepper motor can therefore accelerate 3
its load easily.
6. Low speed is possible without a reduction gear.
7. Moment of Inertia is usually low.
8. The starting current is low.
9. Multiple stepper motors driven from the same source can maintain perfect
synchronization.

SPECIFICATIONS:

Motor Type : Bi-Polar Stepper Motor


Magnetism : Permanent Magnet Type
Volt : 12V
Current : 0.6 Amps
Torque : 3 Kg
Address : 300-31F
Protection : Opto Isolator.
Slot : ISA – 8 Bit
Name : Proto Type Address.

Working of stepper motor:

Stepper motors do as their name suggests they “step” a little bit at a time. Stepper
motors differ them DC motors in their torque speed relationship DC motors generally are not
very good at producing high torque at low speeds, without the air of generating mechanism.
Stepper motors, on the other hand work in the opposite manner. They produce the higher
torque at low speeds.
Stepper motors also have another characteristics holding torque, which is not present
in DC motors. Holding torque allows a stepper motor to hold its position firmly when not
turning. Stepper motors don’t simply responding to a OK signals. They have several
windings, which need to be energized in the correct sequence before the motor shaft will 3
rotate.
Reversing the order of the sequence will cause the sequence will cause the motor to
rotate the other way considering a single permanent magnet rotor with a signal north south
pole and a four-tooth starter, driven by a pair of winding, connected to a DC supply voltage
and ground respectively. The loop tooth becomes a north pole and becomes a south pole.
This pushes the rotor into a stable position at 45 o, where rotor poles line up between opposite
poles of two windings.
When polarity of winding is reversed by switching supply voltage and ground, the
rotor advances 90o to new stable position at 45o. This means that has 90o step angle. The
number of sequence steps and switching pattern will vary with motor construction and the
manufacturer.
The proceeding sequence is called full step mode because each step advances the
stepper by the amount specified as its step angle. A step motor can be made to rotate one half
step angle by operating it in the half step mode. If only one step winding is energized, the
motor will come to equilibrium directly under its opposite pole half way between two fuel
steps shown. 90o step angle motor is now a 45o step angle motor. In the half step mode only
one coil is energized every other step to give a eight step sequence.

Sequential switching of supply to the two phases of the motor causes the stepping
action. Bifilar winding of stepper motor has certain advantages. Each of the 2 phases of
motor has double winding with a centre tap switching the supply from 1 side to another of a
phase causes reversal of magnetic polarity without actual reversing the polarity of supply 4
step input sequences gives 1.8o.
The specified torque of any stepping motor is the torque at standstill. This torque is
directly proportional to the current in the winding as the switching sequence starts, the
inductive reactance of the winding, which increases with the frequency of switching, oppose
the rise of current to desired level within the time given for one step depending upon the
speed of stepping. This is mainly due to l/r tike constant of winding. The drop is current
level causes drop in torque as the speed increases. In order to improve torque at high speed it
is necessary to maintain current at the desired level.

SUMMARY OF OPERATION - STEPPER DRIVER LOGIC


4

Opto-coupler:
It consists of opto-emitter and phototransistor in opto-emitter exists infrared radiation which
in turn drives the phototransistor.

Pre-driver:
We cannot directly couple the TIP122 (NPN) to the opto-coupler since it requires large
current for driving. We use the driver SL100 to boost the current level.

Driver:
The main principle of the driver is to amplify the current. It amplifies the 50mA current to2A,
which is needed to drive the motor.

Control logic:
It consists of an SL100 and relays. Whenever we need to rotate the stepper motor we input
high level through Ports of PIC microcontroller to SL100 70msec before. So SL100 produce
logic low. Now the coil is energized and the 24v is connected to the coil of the driver by the
relay.

Pull down resistor:

10kohms resistor is used. It is used to verify the input of pre-driver stage which is
low. When the IR detector is not conducting, the collector to emitter is high. Now the input
at pre driver (SL100) may be high or low. But it should be low to make it sure we are using
pull down resistor.
When the TIP 122 transistor have high input signal its base collector to emitter
resistance is relatively low. So it produces a low output signal. When the output signal is low
the coil is energized. Now the motor can move forward (or) reverse as per the pattern given
in the software routine.
An reverse biased diode is connected is parallel with the coil. When the coil is
demagnetizing it produces high back emf, which can destroy TIP 122, which is in the cut off
state. This can be avoided by this diode.

5.6 OPTO- COUPLER


4

It has a LED driving a photo transistor. This is a much more sensitive opto-coupler
than the LED photo diode. The idea is that any change in Vs produces changes in LED
current, which changes the current through the transistor. In turn this produces a changing
voltage across the collector-emitter terminals. Therefore a signal voltage is coupled from the
input circuit to the output circuit.
The big advantage of an opto coupler is the electrical isolation between the input and output
circuits. Stated another way the common for the input circuit is different from the common
for the output circuit. Because of this, no conductive path exists between the two circuits.
This means that you can ground one of the circuits floats the other. For instance the input
circuit can be grounded to the chassis of the equipment while the common of the output side
is ungrounded.
It consists of Opto-emitter and Phototransistor. An Opto coupler is essential to
prevent the computer from hazardous conditions like voltage transients, back emf, and high
voltage spikes.

We use Stepper motors for our gate operations. Normally when we pass DC current to a coil;
it will get Electro-magnetized. When we pass the DC source it won’t get demagnetize. If it
is not demagnetized, back EMF is produced which can create kick back current to subsequent
devices or associated circuits. To avoid the above problems we require a device, which can
isolate electrically & couples by other means. Opto-emitters anode is connected to 5v supply
(Logic 1). The cathode is connected to the buffers output. When logic 1 is given to the input
of LS7406 we get logic 0 as the output. Sink current of Opto-emitter is lower than that of
LS7406.
Now this Opto-emitter emits IR rays. This drives the phototransistor whose collector is
forced to 24v. When IR rays are emitted from the Opto-emitter the phototransistor conducts.
The collector to emitter resistance becomes low, so the 24v will appear to emitter. It is given
as input for the pre driver (CL100). We have used CNY 17-2 Opto-coupler. It consists of
Gallium Arsenide IR emitting diode optically coupled to a monolithic silicon phototransistor
detector.

Advantages are:
1) Closely matched current transfer ratio (CTR) that has less conversion losses.
2) Guaranteed 70 volts V (Br.) CEO minimum.
4

Application:
1) Feedback control circuits.
2) General purpose switching circuits.
3) Interfacing and coupling systems of different potentials and references.

The Opto-coupler gets the output from PIC. The Opto consists of two transducers one at the
input and other at the output. The input transducer is an LED or photodiode, which converts
digital output into light signal. The light signal is then observed by the phototransistor, which
is the output of transducer. The phototransistor then converts the light signal into
corresponding analog signal. The main advantage of the Opto coupler is to provide isolation
between the PIC and the stepper driver such that the back emf produced by the stepper motor
is being prevented from affecting the PIC chip and PC.

The pre driver receives the output from the Opto-coupler. The pre driver is a transistor
(CL100), which boosts the current. It is an NPN transistor, which gets the output from the
opto coupler from its base. The transistor is on when the output from the opto coupler is more
than 24V. The output from the transistor is low and +24V is grounded.
The power driver accepts the negative analog signal from the pre driver and amplifier
it to the required level. The +ve voltage from the power supply unit is fed to the power driver
by means of relay, which is set on the receiver’s negative voltage from the transistor control
logic and +ve from the power supply unit. The power driver runs the stepper motor in
response to the current pulses received by it. The stepper motor is filled in mechanical model
for gate control.
The detector may be photo conductor, photo diode, Photo FET, photo triac, photo SCR or
integrated photo diode amplifier. Various results in a wide variety of input characteristics.
Characteristics such as coupling efficiency [effect of IRED (Infra-red emitting Diode) current
on the output device), speed of response, voltage drops, current capability and VI – curves
vary from model to model. The characteristics must be considered especially when
performing substitutions.
The only common characteristics is that input is dielectrically isolated from the output. The
opto coupler is designed as a solid-state replacement for mechanical relays and pulse
transformers. Functionally, the opto coupler is similar to its older mechanical counter part
because it offers high degree of isolation between the inputs and output terminals. Some of 4
the improvements offered by the solid-state devices are as follows:
 Faster operating speed
 Positive (no bounce) action.
 Small size
 Insensitivity to vibration and shock.
 No moving parts to stick
 Compatibility with many logic and microprocessor circuits
 Frequency response from DC to 100 KHz.
Isolation is a very important factor of the opto coupler.

OPTO-COUPLER

FIG:5. OPTO COUPLER

The input stage of a opto coupler consists of an efficient GAAS. Infra-red emiting diode
(IRED). The output stage of the basic optocoupler is a photo transistor. One method of
dielectric isolation has a thin layer between the input and output stages; another method uses
air gap to attain greater electrical isolation. Regardless of whether an air gap or IR
transmitting glass is used to separate the input and output circuits, the operating
characteristics are basically identical

5.7 ELECTRO MECHANICAL RELAYS

Relays are electromagnetic switches, which provides contact between two


mechanical elements. Relays have a coil which works on 12V dc Power supply and provides
DPDT Action as an output. In general relays provide potential free contacts which can be
used for universal function like DC, AC voltage switching and to control bigger electrical 4
switch gears.
Protective relaying is necessary for almost every electrical plant and no part of
the power system is left [Link] choice of protection depends upon several aspects
such as
# Type and rating of the protected equipment.
# Its importance.
# Location and cost.
#Probable abnormal conditions between generators and final load points.
There are several electrical equipment and machines of various ratings. Each needs certain
adequate protection. The protective relaying senses the abnormal condition in a part of the

power system and isolates that parts from the healthy part from the healthy part of system and
isolates.
The relays used in this project are compact, self-contained devices which respond to
abnormal conditions (relays can distinguish normal and abnormal condition).

SENSORS

IR sensor, hall effect proximity sensors are used for this project to identify the
train crossing and Gate closing. Whenever the train is passed the sensor position logical info
will be passed to embedded system. Similarly whenever there is a obstacle while the Gate is
closing info is passed to the embedded controller.

SIGNAL CONDITION AND CONVERSION

All the sensors and transducers need not produce direct electrical output e.g.
LDR, thermistor. In our project we have used two types of passive transducer which needs
external excitation power source. The sensor may produce resistance as a output for physical
variations. So this need a conversion when it is to be connected to a electronic circuit. Some
sensors may produce direct electrical/electronic output which may have some unwanted
transducers tied with it. Before giving to a controller all sorts of cut off transducers is 4
essential. This is called conditioning.

SCHIMITT TRIGGERS

They are regenerative comparatives which work between two thresholds. This is to
avoid linear change in logic ckt (0 or1).

OPTOCOUPLER (Optically coupled electrically isolated):

MCT2E is used in our project to create isolation between stepper motor Circuit and
embedded circuit optocouplers create galvanic isolation between two electronic circuit. This
is necessary to avoid Back emf’s, which may be generated by stepper motor while switching
off.

Transistor power divider:


To amplify the Current of optocoupler to meet the motor require. We use powers. This can
handle up to 5A and can drive motors up to 60Kg/Cm/torque. But we use only
7Kg/Cm/torque.

STEPPER MOTOR:
It is a inertia use motor which can be started and stopped with full rpm (instant start and stop)
(time determination (FB))

Electrical Advantages of stepper motor:


Speed will not change even if we change the voltage applied. It, Ct and mechanical torque
applied it. Only by changing the pulse time period speed will change.

Signaling output:

Simulation LED’s.
Relays:
Whenever motor operation is not required, the PS will be stopped. Switched off. Because
stepper motor will consume enormous current. when it is stopped.
4

RS232:
All PIC’s series of embedded has build in USART is used to convert Parallel data to serial
and series to parallel. But when serial data is to be transmitted to long distance. USART will
not respond for that.

When a embedded system to be integrated with the computer that must meet a standard called
RS 232 (recommended Std 232). Accounting and Rs.232 two different CPU’s can be joined
within 50 feet’s. For our project we use RS 232 to give a real time demo with the computer.

Pre driver:
Pre driver transistor is used to protect the opto coupler from overloading as well as to switch
the power from (SL100) which requires 1mA for its base and can amplify the current up to
250mA. This is used as a switching inverting amplifier.

Power Driver:
Which receives signals from pre driver and amplifies up to 5000mA transistor used for this
application is TIP 122. Base current requirement is 10mA. This is suitable to drive small
motor to 70Kg/Cm motor. To improve still higher version, we can use BOX 132 transistor
which can work at higher speed. BOX 132 is 60 amps 200 V transistor.

Diagnostic LED’s:
LED play’s vital role in fault timing and circuit operation. We can deliver pulse from the PC
whenever pulses given to the motor, thin LED’s glows whenever this LEDs are perfectly
glowing. We can ensure the electronics pan of the Robot.

Relay driver:
Relay is essential for power saving of the robotics. Whenever the motor is not in operation,
the motor can be put off to reduce power, otherwise two coils of each motor will be energized
continuously even the motor is not running power should not be put off in case of Robot is
working against the Gravity.
4

Stepper power supply:


Separate power supply is used to run the stepper motor. Power transformer rectifier, filter
used to ensure perfect pure DC to stepper motor.

CHAPTER 6

6. ADVANTAGES OF USING PC WITH PIC

VISUAL BASIC 6

The Microsoft VB programming system for windows is an exciting advance for


anyone who is involved in writing window base applications. With this event driven
programming engine and innovative, easy to use visual design tools, VB lets you take full
advantage of the window graphical environment to built powerful application quickly.
As more people began to use computers the isotonic and complicated languages used
for programming became more of an obstacle. A language called BASIC was developed to
counteract this. Its simplicity made it easy for the users to write amazing programs.
Over the years this programming language was enhanced and developed. The demand
for faster, simpler, smaller and easy to use software led to the development of Microsoft
quick Base. This was in line with the programming language technology of the 1980’s but an
even bigger change was on the horizon namely, graphical user interface (GUI).
With the advent of windows, users are able to work in a graphically rich environment.
This made application much easier to learn and use. It also facilitated the use of multiple
windows on the screen enabling to run more than one program at a time.
Although this environment was like a boon to the user, life was suddenly a lot
together for programmers. A simple program to display a message on the screen, which could
be written in four lines in MSDOS now, ran to two or three pages.
PROGRAMMING FOR WINDOW WITH VB 4

The VB programming system packages up the complexity of windows in a truly


amazing way. It provides simplicity and ease of use without sacrificing performance or the
graphical features that make window such a pleasant environment to work in Menus, fonts,
dialog, boxes etc are easily designed and these features require no more than a few lines of
programming to control.
It is one of the first languages to support event driven programming a style of program
especially suited to graphical user interface. The aim in modern computer application is to
have the user in charge.
Instead of writing a program that plots out every step in precise order, the programmer
writes a program that responds the user’s action like choosing a command, moving the mouse
etc. Instead of writing on large program, the programmer creates an application, which is a
collection of cooperating many programs. With VB such an application can be written with
unprecedented speed and case.
This project has been done with a virtual view of the traction of the train. It represents
the animated view of the moving train with boogies with the multimedia effects etc.

FEATURES:

 Improved performance
 A data base creation tool
 Visual data access with the data control so that it is possible to create data
browsing application without writing code.
 A new OLE (object linking and embedding) control that allows in place editing.
 A collection of common dialog boxes that streamline common user interface
tasks.
 The ability to create pop-up menus anywhere in the application.
4

FLOWCHART

START

Initialize PIC &


USART

Get digital values from the


sensors

Check the position of the train

If train Close the gate


is near
gate

Open the gate

Send multimedia o/p stating


the position of the train w.r.t
station 2

Send multimedia o/p stating the position of


the train w.r.t station 2

Exit END

Y/N
5

CHAPTER 7

[Link] DIAGRAMS

7.1 POWER SUPPLY UNIT:

As we all know any invention of latest technology cannot be activated without the source of
power. So it this fast-moving world we deliberately need a proper power source which will be
apt for a particular requirement. All the electronic components starting from diode to Intel
IC’s only work with a DC supply ranging from -+5v to -+12v. We are utilizing for the
same, the cheapest and commonly available energy source of 230v-50Hz and stepping down,
rectifying, filtering and regulating the voltage. This will be dealt briefly in the forth-coming
sections.

STEP DOWN TRANSFORMER:


When AC is applied to the primary winding of the power transformer it can either be 5
stepped down or up depending on the value of DC needed. In our circuit the transformer of
230v/15-0-15v is used to perform the step-down operation where a 230V AC appears as 15V
AC across the secondary winding. One alteration of input causes the top of the transformer to
be positive and the bottom negative. The next alteration will temporarily cause the reverse.
The current rating of the transformer used in our project is 2A. Apart from stepping down AC
voltages, it gives isolation between the power source and power supply circuitries.

RECTIFIER UNIT:

In the power supply unit, rectification is normally achieved using a solid state diode.
Diode has the property that will let the electron flow easily in one direction at proper
biasing condition. As AC is applied to the diode, electrons only flow when the anode and
cathode is negative. Reversing the polarity of voltage will not permit electron flow.

A commonly used circuit for supplying large amounts of DC power is the bridge
rectifier. A bridge rectifier of four diodes (4*IN4007) are used to achieve full wave
rectification. Two diodes will conduct during the negative cycle and the other two will
conduct during the positive half cycle. The DC voltage appearing across the output
terminals of the bridge rectifier will be somewhat less than 90% of the applied rms value.
Normally one alteration of the input voltage will reverse the polarities. Opposite ends of
the transformer will therefore always be 180 deg out of phase with each other.

For a positive cycle, two diodes are connected to the positive voltage at the top
winding and only one diode conducts. At the same time one of the other two diodes
conducts for the negative voltage that is applied from the bottom winding due to the
forward bias for that diode. In this circuit due to positive half cycleD1 & D2 will conduct
to give 10.8v pulsating DC. The DC output has a ripple frequency of 100Hz. Since each
altercation produces a resulting output pulse, frequency = 2*50 Hz. The output obtained
is not a pure DC and therefore filtration has to be done.

FILTERING UNIT:
5

Filter circuits which are usually capacitors acting as a surge arrester always follow
the rectifier unit. This capacitor is also called as a decoupling capacitor or a bypassing
capacitor, is used not only to ‘short’ the ripple with frequency of 120Hz to ground but
also to leave the frequency of the DC to appear at the output. A load resistor R1 is
connected so that a reference to the ground is maintained. C1R1 is for bypassing ripples.
C2R2 is used as a low pass filter, i.e., it passes only low frequency signals and bypasses
high frequency signals. The load resistor should be 1% to 2.5% of the load.

1000f/25v : for the reduction of ripples from the pulsating.

10f/25v : for maintaining the stability of the voltage at the load side.

O, 1f : for bypassing the high frequency disturbances.

VOLTAGE REGULATORS:

The voltage regulators play an important role in any power supply unit. The primary
purpose of a regulator is to aid the rectifier and filter circuit in providing a constant DC
voltage to the device. Power supplies without regulators have an inherent problem of
changing DC voltage values due to variations in the load or due to fluctuations in the AC
liner voltage. With a regulator connected to the DC output, the voltage can be maintained
within a close tolerant region of the desired output. IC7805, IC7812 and IC7912 is used
in this project for providing +05V, +12v and –12v DC supply.

Specifications:

Resistors R1 and R2 maintain line load regulation.

At the secondary side of the transformer,


Applied voltage = 15v

Conducting drop across the diodes = 2*0.6= 1.2v.


5

Without capacitor:
Vavg = (15-1.2) v = 13.8c pulsating DC
Frequency = 100Hz

With capacitor:
V=Vavg *1.414(form factor) = 19.51v.
Frequency = 0Hz

With 7805 voltage regulator:


V0= +5v
With 7812 voltage regulator:
V0= +12v

With 7912 voltage regulator:


V0= -12v
5

7.2 PIC CIRCUIT DIAGRAM


5

From the circuit it can be seen that the reference analog supply after being regulated by the
9v regulator enters the zener diode through the resistance R4 where it is again regulated to 5v
since the zener diode used here has a cut off of 5v. Thus, we have a double regulated
completely filtered analog reference source. R6 is a potential divider used for setting the 5
dynamic response range of the reference supply. This means that the reference 5v can be used
as it is or it can be made into a fraction of the 5v for example 1v so that readings in this range
can be read with more precision. This is because the ADC has 10-bit resolution, which can be
totally used for representing the 1v rather than 5v.

The pins 2-5, 7-10, 35 and 36 are used as the 10 channels of the ADC. To these pins the
analog inputs to be processed by the ADC are given. Y1 is the crystal oscillator used. It is of
10 MHz and gives a baud rate of 9600 bits/s. The capacitors C2 and C3 are used as
decoupling capacitors to remove the high frequency noise signals.

The capacitor C1 is in the off condition when power is switched off. When the power is
switched on or reset then this capacitor gets charged through the resistor R2 and then through
R1 this appears at the MCLR pin of the PIC. This is the memory clear pin and thus the
memory is cleared and is ready for use as soon as power is switched on. S1 is the
synchronous switch which is also used for the same operation and for PC and PIC
synchronous operation.

7.3 INTRUDER DETECTION

Sensor:

- Infra red emitter/detector.


5

IR emitter:
Symbol and operation of IR Emitter is very similar to ordinary LED, Light Emitting Diode. LED
emits ordinary light. IR emitter generates infrared. IR emitter is made up of Gallium arsenide. If we
pass the current to gallium arsenide it produces IR rays. Current applied to the sensor is directly
proportional to the rays emitted. We’ve connected 1k resistors to +5v and to the emitter.
I = 5v/1k = 5m amps.

If we decrease the resistance, current will increase thereby rays production will also increase. More
ray’s density allows for the longer length operation. More than IR, if we use lens in front of the IR
emitter it allows us work with 10m also.
The rays emitted are sent to IR detector, which is placed straight to the (90) IR emitter. IR detector
concept is, whenever rays are incident, it conducts. Resistance b/w anode and cathode reduces. When
no rays are incident the anode and cathode resistance is infinite.
A 100k resistor is used to pull-up the detector, when it doesn’t get IR. When ray’s incident, anode of
the detector is low. When no rays, anode is high.
NPN transistor coupled with the detector conducts only when the Base gets logic high. Whenever no
interruption transistor will be Cut-off, status of the collector is logical high. Output of the Schmitt
trigger is logic low.
During interruption, IR detector is cut-off and anode is pulled high. Transistor conducts, status of the
collector is low. Final o/p of the Schmitt is logic high.
When no interruption - low
When interruption - high
5

If we decrease the resistance, current will increase thereby rays production will also increase. More ray’s
density allows for the longer length operation. More than IR, if we use lens in front of the IR emitter it
allows us work with 10m also.
The rays emitted are sent to IR detector, which is placed straight to the (90) IR emitter. IR 5 detector
concept is, whenever rays are incident, it conducts. Resistance b/w anode and cathode reduces. When no
rays are incident the anode and cathode resistance is infinite.

A 100k resistor is used to pull-up the detector, when it doesn’t get IR. When ray’s incident, anode of the
detector is low. When no rays, anode is high.

NPN transistor coupled with the detector conducts only when the Base gets logic high. Whenever no
interruption transistor will be Cut-off, status of the collector is logical high. Output of the Schmitt trigger is
logic low.

During interruption, IR detector is cut-off and anode is pulled high. Transistor conducts, status of the
collector is low. Final o/p of the Schmitt is logic high.

When no interruption - low


When interruption - high
6

CHAPTER 8

CODING
EMBEDDED PROGRAM:
PROCESSOR PIC16F877A

#include "[Link]"

BUFFER1 EQU 0X20


BUFFER2 EQU 0X21
BUFFER3 EQU 0X22
BUFFER4 EQU 0X23
PCKSTA EQU 0X24
PCKEND EQU 0X25
PCKRDY EQU 0X26
TEMP EQU 0X27

H_BYTE EQU 0X28


L_BYTE EQU 0X29
R0 EQU 0X2A ; RAM Assignments
R1 EQU 0X2B
R2 EQU 0X2C

BYTE0EQU 0X2D
BYTE1EQU 0X2E
BYTE2EQU 0X2F
BYTE3EQU 0X30

COUNT EQU 0X31

ORG 0X0000
GOTO START

ORG 0X0004
GOTO GetPACK

ORG 0X0020
NosofAN
ADDWF PCL,F
RETLW 0X86
RETLW 0X8E
RETLW 0X80
RETLW 0X84
RETLW 0X80
RETLW 0X82
RETLW 0X89
RETLW 0X80 6
RETLW 0X06

ORG 0X0035
GetPACK
BTFSSPCKSTA,0
GOTO ItsSTA
MOVLW '}'
SUBWF RCREG,W
BTFSSSTATUS,Z
GOTO StVALUE
BSF PCKEND,0
BCF PCKSTA,0
GOTO ExINT

StVALUE
BTFSSRCREG,6
GOTO StNUM

MOVLW 0X0F
ANDWF RCREG,0
ADDLW 0X09

StNOW
MOVWF INDF
INCF FSR,F
GOTO ExINT

StNUM
MOVLW 0X0F
ANDWF RCREG, W
GOTO StNOW

ItsSTA
MOVLW '{'
SUBWF RCREG, W
BTFSSSTATUS, Z
GOTO ExINT
BSF PCKSTA,0
MOVLW 0X20
MOVWF FSR
ExINT
RETFIE

ORG 0X0100
START

CLRWDT
BSF INTCON, PEIE
;;; Buffer Clear ;;; 6

MOVLW 0X0020
MOVWF FSR

CLRF INDF
INCF FSR,F
BTFSSFSR,4
GOTO $-3

;;; Default I/O pin Initilization ;;;

BSF STATUS,RP0
MOVLW 0XFF
MOVWF TRISD
MOVLW 0XFF
MOVWF TRISB
MOVLW 0X3F
MOVWF TRISA
MOVLW 0X07
MOVWF TRISE
MOVLW 0XBF
MOVWF TRISC

;;; ADC Initilization ;;;

MOVLW 0X80
MOVWF ADCON1
BCF STATUS,RP0

MOVLW 0X81
MOVWF ADCON0

;;; USART Initilization ;;;

MOVLW 0X90
MOVWF RCSTA

BSF STATUS,RP0

MOVLW 0X26
MOVWF TXSTA

MOVLW 0X40
MOVWF SPBRG

BSF PIE1,RCIE
BSF INTCON,GIE
6
BCF STATUS,RP0
CALL SNDMSG

WaitPCK
BTFSSPCKEND,0
GOTO WaitPCK

;;;; FIRST PROTOCOL ;;;;

MOVLW 0X01
SUBWF BUFFER1,W

BTFSSSTATUS,Z
GOTO IIndPCK

MOVLW 0X0A
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO InitB

SWAPF BUFFER3,W
IORWF BUFFER4,W

BSF STATUS,RP0
MOVWF TRISA
BCF STATUS,RP0

InitB
MOVLW 0X0B
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO InitC

SWAPF BUFFER3,W
IORWF BUFFER4,W

BSF STATUS,RP0
MOVWF TRISB
BCF STATUS,RP0

InitC
MOVLW 0X0C
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO InitD

SWAPF BUFFER3,W
IORWF BUFFER4,W
6
BSF STATUS,RP0
MOVWF TRISC
BCF STATUS,RP0

InitD
MOVLW 0X0D
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO InitE

SWAPF BUFFER3,W
IORWF BUFFER4,W

BSF STATUS,RP0
MOVWF TRISD
BCF STATUS,RP0

InitE
MOVLW 0X0E
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO ExINIT0

SWAPF BUFFER3,W
IORWF BUFFER4,W

BSF STATUS,RP0
MOVWF TRISE
BCF STATUS,RP0

ExINIT0
GOTO ExfrmPCK

;;; SECOND PROTOCOL ;;;

IIndPCK

MOVLW 0X02
SUBWF BUFFER1,W

BTFSSSTATUS,Z
GOTO IIIrdPCK

MOVFBUFFER2,W
CALL NosofAN
BSF STATUS,RP0
MOVWF ADCON1
BCF STATUS,RP0
GOTO ExfrmPCK 6

;;; THIRD PROTOCOL ;;;

IIIrdPCK

MOVLW 0X03
SUBWF BUFFER1,W

BTFSSSTATUS,Z
GOTO IVthPCK

BSF STATUS,RP0
DrWAITS
BTFSSTXSTA,TRMT
GOTO DrWAITS
BCF STATUS,RP0

MOVLW '{'
MOVWF TXREG

MOVLW 0X0A
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndB

BSF STATUS,RP0
DrWAITA
BTFSSTXSTA,TRMT
GOTO DrWAITA
BCF STATUS,RP0

MOVFPORTA,W
MOVWF TXREG
GOTO ExDRPCK

SndB
MOVLW 0X0B
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndC
BSF STATUS,RP0
DrWAITB
BTFSSTXSTA,TRMT
GOTO DrWAITB
BCF STATUS,RP0

MOVFPORTB,W
MOVWF TXREG
GOTO ExDRPCK
6
SndC
MOVLW 0X0C
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndD
BSF STATUS,RP0
DrWAITC
BTFSSTXSTA,TRMT
GOTO DrWAITC
BCF STATUS,RP0

MOVFPORTC,W
MOVWF TXREG
GOTO ExDRPCK

SndD
MOVLW 0X0D
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndE
BSF STATUS,RP0
DrWAITD
BTFSSTXSTA,TRMT
GOTO DrWAITD
BCF STATUS,RP0

MOVFPORTD,W
MOVWF TXREG
GOTO ExDRPCK

SndE
MOVLW 0X0E
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO ExDRPCK
BSF STATUS,RP0
DrWAITE
BTFSSTXSTA,TRMT
GOTO DrWAITE
BCF STATUS,RP0

MOVFPORTE,W
MOVWF TXREG

ExDRPCK
BSF STATUS,RP0
DrWAITL
BTFSSTXSTA,TRMT
GOTO DrWAITL
BCF STATUS,RP0 6

MOVLW '}'
MOVWF TXREG

GOTO ExfrmPCK

;;; FOURTH PROTOCOL ;;;

IVthPCK

MOVLW 0X04
SUBWF BUFFER1,W

BTFSSSTATUS,Z
GOTO VthPCK

BSF STATUS,RP0
ArWAITS
BTFSSTXSTA,TRMT
GOTO ArWAITS
BCF STATUS,RP0

MOVLW '{'
MOVWF TXREG

BCF STATUS,C
RLF BUFFER2,F
RLF BUFFER2,F
RLF BUFFER2,W

ANDLW 0X38
IORLW 0X81
MOVWF ADCON0

MOVLW 0X00
MOVWF TEMP
ArACQT
DECFSZ TEMP,F
GOTO ArACQT

BSF ADCON0,GO
ConWAIT
BTFSC ADCON0,GO
GOTO ConWAIT

MOVFADRESH,W ;
MOVWF H_BYTE ;
BSF STATUS,RP0 6
MOVFADRESL,W ;
BCF STATUS,RP0
MOVWF L_BYTE ; H_BYTE:L_BYTE =
ADRESH:ADRESL

CALL B2_BCD ;CONVERT THE AD RESULT INTO BCD


CALL UP_CNV_SIG ;UNPACK AND C
CALL TRANS_SIG

BSF STATUS,RP0
ArWAITE
BTFSSTXSTA,TRMT
GOTO ArWAITE
BCF STATUS,RP0

MOVLW '}'
MOVWF TXREG

GOTO ExfrmPCK

;;; FIFTH PROTOCOL ;;;

VthPCK

MOVLW 0X05
SUBWF BUFFER1,W

BTFSSSTATUS,Z
GOTO ExfrmPCK

MOVLW 0X0A
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndtoB

SWAPF BUFFER3,W
IORWF BUFFER4,W
MOVWF PORTA

SndtoB
MOVLW 0X0B
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndtoC

SWAPF BUFFER3,W
IORWF BUFFER4,W
MOVWF PORTB
SndtoC 6
MOVLW 0X0C
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndtoD

SWAPF BUFFER3,W
IORWF BUFFER4,W
MOVWF PORTC

SndtoD
MOVLW 0X0D
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO SndtoE

SWAPF BUFFER3,W
IORWF BUFFER4,W
MOVWF PORTD

SndtoE
MOVLW 0X0E
SUBWF BUFFER2,W
BTFSSSTATUS,Z
GOTO ExfrmPCK

SWAPF BUFFER3,W
IORWF BUFFER4,W
MOVWF PORTE

ExfrmPCK
BCF PCKEND,0
GOTO WaitPCK

;INPUT = PACKE BCD IN H_BYTE, L_BYTE


;OUTPUT = ASCII VALUE IN R0,R1,R2

UP_CNV_SIG
MOVFR2,W
ANDLW 0X0F
ADDLW 0X30
MOVWF BYTE0
SWAPF R2,W
ANDLW 0X0F
ADDLW 0X30
MOVWF BYTE1
MOVFR1,W
ANDLW 0X0F
ADDLW 0X30 7
MOVWF BYTE2
SWAPF R1,W
ANDLW 0X0F
ADDLW 0X30
MOVWF BYTE3
RETURN

TRANS_SIG
BSF STATUS,RP0 ;SELECT BANK1
TS0
BTFSSTXSTA,TRMT
GOTO TS0
BCF STATUS,RP0 ;SELECT BANK0
MOVFBYTE3,W
MOVWF TXREG

BSF STATUS,RP0 ;SELECT BANK1


TS1
BTFSSTXSTA,TRMT
GOTO TS1
BCF STATUS,RP0 ;SELECT BANK0
MOVFBYTE2,W
MOVWF TXREG

BSF STATUS,RP0 ;SELECT BANK1


TS2
BTFSSTXSTA,TRMT
GOTO TS2
BCF STATUS,RP0 ;SELECT BANK0
MOVFBYTE1,W
MOVWF TXREG

BSF STATUS,RP0 ;SELECT BANK1


TS3
BTFSSTXSTA,TRMT
GOTO TS3
BCF STATUS,RP0 ;SELECT BANK0
MOVFBYTE0,W
MOVWF TXREG 7
RETURN

B2_BCD

BCF STATUS,0 ; CLEAR THE CARRY BIT


MOVLW .16
MOVWF COUNT
CLRF R0
CLRF R1
CLRF R2
LOOP16
RLF L_BYTE, F
RLF H_BYTE, F
RLF R2, F
RLF R1, F
RLF R0, F
;
DECFSZ COUNT, F
GOTO ADJDEC
RETLW 0
;
ADJDEC
MOVLW R2
MOVWF FSR
CALL ADJBCD
; 7
MOVLW R1
MOVWF FSR
CALL ADJBCD
;
MOVLW R0
MOVWF FSR
CALL ADJBCD
;
GOTO LOOP16
;
ADJBCD
MOVLW 3
ADDWF 0,W
MOVWF TEMP
BTFSC TEMP,3 ; TEST IF RESULT > 7
MOVWF 0
MOVLW 30
ADDWF 0,W
MOVWF TEMP
BTFSC TEMP,7 ; TEST IF RESULT > 7
MOVWF 0 ; SAVE AS MSD
RETLW 0

SNDMSG

MWAIT0
BTFSSPIR1,TXIF 7
GOTO MWAIT0

MOVLW '{'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW1
DECFSZ TEMP,F
GOTO SGW1

MWAIT1
BTFSSPIR1,TXIF
GOTO MWAIT1

MOVLW '1'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW2
DECFSZ TEMP,F
GOTO SGW2

MWAIT2
BTFSSPIR1,TXIF
GOTO MWAIT2 7

MOVLW '6'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW3
DECFSZ TEMP,F
GOTO SGW3

MWAIT3
BTFSSPIR1,TXIF
GOTO MWAIT3

MOVLW 'F'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW4
DECFSZ TEMP,F
GOTO SGW4

MWAIT4
BTFSSPIR1,TXIF
GOTO MWAIT4
7
MOVLW '8'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW5
DECFSZ TEMP,F
GOTO SGW5

MWAIT5
BTFSSPIR1,TXIF
GOTO MWAIT5

MOVLW '7'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW6
DECFSZ TEMP,F
GOTO SGW6

MWAIT6
BTFSSPIR1,TXIF
GOTO MWAIT6
MOVLW '7' 7
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW7
DECFSZ TEMP,F
GOTO SGW7

MWAIT7
BTFSSPIR1,TXIF
GOTO MWAIT7

MOVLW 'A'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW8
DECFSZ TEMP,F
GOTO SGW8

MWAIT8
BTFSSPIR1,TXIF
GOTO MWAIT8

MOVLW '}'
MOVWF TXREG

MOVLW 0X00
MOVWF TEMP
SGW9
DECFSZ TEMP,F
GOTO SGW9
RETURN
END
7

CHAPTER 9

9 FUTURE ENHANCEMENT

We have wider scopes for developing this project. The primary enhancement is the tract
diversion technique, which can be achieved using the same embedded controller.

Synchronized mimic panel can be expanded such that the annunciation of all the ongoing
trains can be monitored from the centralized control department.
7

Enhanced version of this project is that transmitters and receivers replace the cable
connecting the sensors. During implementation of this project it can be done by using the
satellites. There are more than 24 satellites round the globe, which are used only for the
positioning and locating the objects exactly up to 30 meters. Placing the tiny GPS receiver in
or on the object one can locate or position the distant or lost objects.

CHAPTER 10

10 CONCLUSION

The automatic traction system at the unmanned railway gate, which uses the advanced
features of the micro controller together with the IR sensors and the metal detectors, proves to
be effective in achieving the objectives.
7

Saving human life, protection against accidents and the communicable mechanical
system are the salient features and the added advantage of this project. It is cost effective.

Expensive hardware and non-reliability of cables due to temperature drift are the only
limitations of this project.

It is applicable at every unmanned railway gate providing reliable and uninterruptible


service to the Railways.
8

CHAPTER 11
11 APPENDIX 8

CIRCUIT DIAGRAM

VCC
VCC 5
3
4
R43 L1 1
2
J1 R29
U5
1 R15 RL1
2 1 2
3

3 R1 J4
4 2 Q1
5 R30
6 5 1
R16 U5 UREG 3 2
7
1

8 3 4 4 3
R2 R44 L2
3

9 1 4
10 2 Q2 2 5
R31 6
U1
U5 7
R17 1 16 8
RL2
3 1

5 6 2 1B 1C 15 9
R3 2B 2C
3 14 10
2 Q3 R32 4 3B 3C 13
5 4B 4C 12
R18 U5 6 5B 5C 11 5 CON10
6B 6C
3 1

9 8 7 10 3
R4 7B 7C 4
2 Q4 9 R45 L3 1
COM 8
R33 2
R19 U5
1

11 10
R5 RL3
3

2 Q5
R34

R20 U5
5
1

13 12 3
R6
3

4
2 Q6 R35 R46 L4 1
2
U6
R21
3 1

1 2
R7
RL4
2 Q7
R36

R22 U6
1

3 4
R8
3

5
2 Q8 3
R37 4
R47 L1 1
R23 U6 2
1

5 6
R9
3

2 Q9
R38 RL5

R24 U6
3 1

9 8
R10
5
2 Q10 3
R39
4
U6 R48 L2 1
R25
3 1

11 10 2 J5
R11
J2 2 Q11 1
R40 RL6 2
1 3
2 R26 U6 4
1

3 13 12 5
4 R12
3

6
5 VCC 2 Q12 5 7
6 R41 3 8
7 U7 U7 4 9
8 UREG R27 R49 L3 1 10
3 1

9 1 2 3 4 2
R13
10
2 Q13
R42
RL7
R28 H1
1
3 1

R14 2
2 Q14 3
1

U7 U7
5 6 9 8

H2
1
2
3

5
3
4
R50 L1 1
2

RL8
1
U4 3
2
5
3
4
R51 L2 1
4 2
U4 6 U2
5
1
1B 1C
16 RL9
7408 2 15
3 2B 2C 14
4 3B 3C 13
5 4B 4C 12
6 5B 5C 11 5
7 6B 6C 10 3
7B 7C 4
9 R52 L3 1
COM 8
2

RL10

5
3
UREG 4
R53 L4 1
2
U3
RL15
1 16 H3 RL11
1B 1C 5
2 15 3 1
3 2B 2C 14 2
3B 3C 4
4 13 1 3
5 4B 4C 12
5B 5C 2
6 11
7 6B 6C 10 5
7B 7C 3
9 4
COM 8 R54 L1 1
RL16 2
J7
5
3 1
4 2 RL12
1 3
2

5 J6
3
4 1
R55 L2 1 2
R58 2 3
R57
4
5
L1 RL13 6
L1
7
8
9
10
5
3
4
R56 L3 1
2

RL14
VCC
8

11.1 PIN DIAGRAM –PIC16F877A


8

11.2 PIN DIAGRAM-74LS14


8

11.3 LM339-PIN DIAGRAM


8

11.4 MAX-2332 PIN DIAGRAM


8
CHAPTER12

12 BIBILIOGRAPHY

REFERENCE BOOKS

1. Visual Basic for windows


- ROSS NELSON

2. Electrical Engineering
- B.L. THERAJA

3. Linear integrated circuits


- GAYKWARD

4. PIC Micro controllers


- MYKE PREDKO

WEBSITE REFERENCES

1. [Link]

2. [Link]

3. [Link]
8

You might also like