inteligent railway system

106
Visualize Gate Control and Track Switching 1 INDEX Ch.No. Chapter Name Page No. 1 Introduction 01 2 Specification 03 3 Design Procedure 08 4 Hardware Principle of Operation 09 Hardware Details 10 Block Diagram 13 Circuit Diagram 14 5 Software Algorithm 17 Flowchart 19 Software Listing 23 6 Circuit Preparation(PCB making & Trouble Shooting) 66 7 Advantages, Disadvantages & Application 73 8 Future Scope 74 9 Cost Sheet 75 10 Conclusion 77 11 References 80 12 Datasheet 82 13 Photograph 102

Upload: ghanshyam-dusane

Post on 22-Jan-2018

166 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

1

INDEX

Ch.No. Chapter Name Page No.

1 Introduction 01

2 Specification 03

3 Design Procedure 08

4 Hardware

Principle of Operation 09

Hardware Details 10

Block Diagram 13

Circuit Diagram 14

5 Software

Algorithm 17

Flowchart 19

Software Listing 23

6 Circuit Preparation(PCB making &

Trouble Shooting)

66

7 Advantages, Disadvantages & Application 73

8 Future Scope 74

9 Cost Sheet 75

10 Conclusion 77

11 References 80

12 Datasheet 82

13 Photograph 102

Page 2: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

2

INTRODUCTION

Page 3: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

3

INTRODUCTION

Indian railway has the 2nd largest railway network in the world. As the 21st century is

moving ahead, the Indian railway system is also moving ahead in terms of technology. But then

also, till today our system have not been developed to such a level that it can able to avoid the

train accidents in India. In the last 2 years, total 46 major accidents occurred in which more than

9000 Indians and over 859 foreigners lost their lives.

Most of the train accidents in India occurs due to the miscommunication, bad weather

conditions (fog), human errors, non-update information about the train. Due to these reasons

many Indian people lost their life’s and also the foreigners. Today railway is one of the main

source for the transportation of people as well as goods in India. In train accidents almost 19% of

the total goods get wasted, it may be coal, steel, iron, petroleum, oil etc.

In today’s competitive world lot of things works on automation, this reduces use of

human resources to a great extent and because of this time and money are also saved. Which is

economically profitable in today’s life. In this system more work is done with less investment,

proper management and discipline is maintained.

As we want to solve the problems of accidental damage of railway system, to maximize

the people security, and to get the more information about railway position. We found the best

solution for that are “VISUALIZE GATE CONTROL AND TRACK SWITCHING” in

Railway system.

For this project we design a circuit which gives whole information about the Railway

system. In this project we use the IR sensors and it is placed before and after the Railway

Crossing so when any Train enters the area of Railway Crossing at that time gate is automatically

closed.

If two trains arrived on same track and cuts IR sensors in opposite directions the red

signals is given to both train to avoid the accident. If we want to switch the train on different

tracks then we can switch it using master control.

Page 4: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

4

SPECIFICATION

Page 5: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

5

Specification

IR Sensor

This is a simple yet effective IR proximity sensor built around the TSOP 1738 module.

The TSOP module is commonly found at the receiving end of an IR remote control system; e.g.,

in TVs, CD players etc. These modules require the incoming data to be modulated at a particular

frequency and would ignore any other IR signals. It is also immune to ambient IR light, so one

can easily use these sensors outdoors or under heavily lit conditions.

Such modules are available for different carrier frequencies from 32 kHz to 42 kHz. In

this particular proximity sensor, we will be generating a constant stream of square wave signal

using IC555 centered at 38 kHz and would use it to drive an IR led. So whenever this signal

bounces off the obstacles, the receiver would detect it and change its output. Since the TSOP

Page 6: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

6

1738 module works in the active-low configuration, its output would normally remain high and

would go low when it detects the signal (the obstacle).

Microcontroller 89S52

Compatible with MCS-51® Products

8K Bytes of In-System Programmable (ISP) Flash Memory

4.0V to 5.5V Operating Range

Fully Static Operation: 0 Hz to 33 MHz

Three-level Program Memory Lock

256 x 8-bit Internal RAM

32 Programmable I/O Lines

Three 16-bit Timer/Counters

Eight Interrupt Sources

Full Duplex UART Serial Channel

Low-power Idle and Power-down Modes

Interrupt Recovery from Power-down Mode

Watchdog Timer

Dual Data Pointer

Power-off Flag

Push –Pull Four Channel Driver with Diodes (L293D)

600mA output current capability per channel

1.2A peak output current per channel (non repetitive)

Enable Facility

Over Temperature Protection

Logical ”0” input voltage up to 1.5 V to 5V

High Noise Immunity

Internal Clamp Diodes

Page 7: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

7

MAX232

Operate from Single +5V Power Supply

+5V and +12V (MAX231/MAX239)

Low-Power Receive Mode in Shutdown (MAX223/MAX242)

Meet All EIA/TIA-232E and V.28 Specifications

Multiple Drivers and Receivers

3-State Driver and Receiver Outputs

Open-Line Detection (MAX243)

Voltage Regulator IC 7805

Output current in excess of 1A

Internal thermal overload protection

No external components required

Output transistor safe area protection

Internal short circuit current limit

Available in the aluminum TO-3 package

Page 8: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

8

DESIGN

PROCEDURE

Page 9: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

9

DESIGN PROCEDURE

a) HARDWARE:

• Principle of Operation:

1. We are using the Infrared sensor (IR) pairs for detecting the train. As the train

obstructs IR signals, IR will send the received signals to the controller indicating that

the train is arrived. When the train obstructs the 1st IR sensor, it will turn ON buzzer

for particular period of time and then the gate will automatically get closed.

2. The buzzer is basically used as a warning alert for people near the railway gate.

3. We can calculate the speed of train using distance between two IR sensors (fixed) and

the time difference required by train to obstruct the 2 IR sensors.

4. When the train is arriving from 1 side, the signal on the same track will indicate red

signal to opposite direction.

5. If we want to route the train on different tracks then we can switch the t racks using

master controller (PC).

6. These all are represented on computer (master controller) and provide master control

to operator. [I.e. gate status, signal status, tracks switching, speed measurement,

position of train.]

7. IR sensors are also used for the automatic railway gate control which is performed by

using the outputs of the IR sensors which are given to the DC motor used for the gate.

8. The status of the railway gate is represented on the PC and it is also controlled by the

master controller (PC).

Page 10: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

10

• HARDWARE DETAILS

1. MICROCONTROLLER 89S52

We are using ATMELS AT89c/s51 microcontroller. The controller executes instructions as

per the clock cycles; this clock is generated using a crystal which is connected to the XTAL1 &

XTAL2 pin of the microcontroller, the two capacitors C1 & C2 are connected between the two

XTAL pins & the ground. They are required for the crystal to oscillate.

A Power ON reset circuit is connected to the RESET pin of the microcontroller, the controller

must be reset properly whenever is power is turned on, which is done by applying a Vcc to the

reset pin & for normal operation of the controller the pin should be pulled low. So an RC (R1,

C3) circuit is connected to the RST (9) pin of the microcontroller. Whenever the power is turned

ON the Capacitor is fully charged & the RST pin gets 5 v. Then the capacitor slowly discharges

through the resistor & is then pulled to ground.

Microcontrollers Port 0 does not have an Internal Pull Up resistor so we need external Pull Up

resistors on port 0. For which we use 9-Pin SIP resistor which are basically eight resistors with

one end common.

Components: XTAL=11.0592 MHz, C1=C2= 33pf, R1=10kΩ, C=10uf

2. TSOP 1738 based proximity sensor

This is a simple yet effective IR proximity sensor built around the TSOP 1738 module.

The TSOP module is commonly found at the receiving end of an IR remote control system;

e.g., in TVs, CD players etc. These modules require the incoming data to be modulated at a

particular frequency and would ignore any other IR signals. It is also immune to ambient IR

light, so one can easily use these sensors outdoors or under heavily lit conditions.

Such modules are available for different carrier frequencies from 32 kHz to 42 kHz. In

this particular proximity sensor, we will be generating a constant stream of square wave signal

Page 11: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

11

using IC555 centered at 38 kHz and would use it to drive an IR led. So whenever this signal

bounces off the obstacles, the receiver would detect it and change its output.

1. POWER SUPPLY SECTION

We require 5 volts for microcontroller, LCD, EEPROM & approximately 12 volts for the

Relay. These voltages are generated from 230v line voltage. Initially A step down Transformer is

used to step down 230volts to 9olts, so a 0-9; 500ma step down transformer is used. The output

of the step down transformer is also AC, we convert this AC voltage into DC by using a Full

wave bridge rectifier consisting of Diodes D1, D2, D3 & D4. During the positive half cycle

diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct thus the

diodes keep switching the transformer connections so we get positive half cycles in the output.

Even though half wave & full wave rectifier give DC output, none of them provides a constant

output voltage. For this we require to smoothen the waveform received from the rectifier. This

can be done by using a capacitor at the output of the rectifier this capacitor is also called as

“FILTER CAPACITOR “or “SMOOTHING CAPACITOR” or “RESERVOIR CAPACITOR”.

Even after using this capacitor a small amount of ripple will remain.

We place the capacitor at the output of the rectifier the capacitor will charge to the peak

voltage during each half cycle & then will discharge its stored

energy slowly through the load while the rectified voltage drops to

zero, thus trying to keep the voltage as constant as possible. If we

go on increasing the value of the filter capacitor then the Ripple

will decrease. But then the costing will increase. The value of the

Page 12: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

12

Filter capacitor depends on the current consumed by the circuit, the frequency of the waveform

& the accepted ripple.

C=VrF/I

Where,

Vr= accepted ripple voltage.( should not be more than 10% of the voltage)

I= current consumed by the circuit in Amperes.

F= frequency of the waveform.

After filtering the rectifier output the signal is given to a voltage regulator. The maximum input

voltage that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the

regulator so the input voltage should be at least 2-3 Volts higher than the output voltage. If the

input voltage gets below the Vmin of the regulator due to the ripple voltage or due to any other

reason the voltage regulator will not be able to produce the correct regulated voltage. We require

5v output so we use IC 7805 where 78 indicates that it’s a positive series & the 05 indicates the

output voltage.

Another capacitor C4 is used after the voltage regulator, this is used to remove any ripples or

noise generated in the Vcc. D7 is an LED used to indicate the Power Status

Components : Transfo rmer: Step Down 0-9; 500ma, Diodes : 1n4007 (D1, D2, D3

and D4), Capac ito r (c11) = 1000uf, Vo ltage Regulato r= 7805, Capac itor C4 =

100uf, Resistor R10 =2.2KΩ. LED1 = 3mm Transparent white LED.

Page 13: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

13

BLOCK DIAGRAM:-

Micro

controller

8

9

S

5

2

MAX 232

DC MOTOR

DRIVER

(L293D) PC

LED

DC motor

Page 14: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

14

CIRCUIT DIAGRAM:-

IR SENSORS

Page 15: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

15

LAYOUT:-

Page 16: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

16

COMPONENT PLACEMENT & DESIGN :-

Page 17: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

17

b) SOFTWARE

ALGORITHM

Gate Controlling

1) start

2) initialize all i/o pins.

3) Open the gate

4) wait for sensor to be cut

5) send the sensor cut location to PC

5) Close the gate

6) wait for other sensor to be cut

7) send sensor cut location to PC

8) Open the gate

9) go to 4

10) Stop

Track Switching

1) Start

2) Initialize all I/O pins.

3) Wait for data from PC

4) If data received = cmd_track1_side1 then move track1 to side 1 and go to 3

5) If data received = cmd_track1_side2 then move track1 to side 2 and go to 3

6) If data received = cmd_track2_side1 then move track2 to side 1 and go to 3

7) If data received = cmd_track2_side2 then move track2 to side 2 and go to 3

Page 18: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

18

8) go to 3

9) stop

Anti-Collision System

1) Start

2) Initialize all i/o pins

3) show green led on both sides

4) wait for sensor to be cut

5) Show red led on other side

6) wait for second sensor to be cut

7) go to 3

8) stop

Page 19: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

19

FLOWCHART

Page 20: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

20

Gate Controlling

START

Initialize all I/O pins.

GATE OPEN

Send the Signal to

the PC

GATE CLOSE

Send the Signal to

Check the First

IR Sensor Cut

or Not

Check the

Second IR Sensor

Cut or Not

Page 21: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

21

Track Switching

START

Initialize all I/O pins.

Wait For Data from

PC

If Data

Received

Cmd_track1_side1 move to track1 to side 1

Cmd_track1_side2 move to track1 to side 2

Cmd_track2_side1 move to track2 to side 1

Cmd_track2_side2 move to track2 to side 2

STOP

Page 22: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

22

Anti-Collision System

START

Initialize all I/O pins.

Turn ON Green LED

on both Sides

Check the First

IR Sensor Cut

or Not

Turn ON RED LED

Check the

Second IR Sensor

Cut or Not

Turn OFF RED LED

& Turn ON Green

LED

Page 23: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

23

Software Listing

A] Assembly language programming

A51 MACRO ASSEMBLER MAIN

MACRO ASSEMBLER A51 V8.01

OBJECT MODULE PLACED IN main.OBJ

ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE main.asm SET(SMALL) DEBUG EP

LOC OBJ LINE SOURCE

1 ;$include (ini.inc)

0093 +1 2 SENSOR1 BIT p1.3 ;for gate

0092 +1 3 SENSOR2 BIT p1.2 ;for gate

0091 +1 4 gate_close_sensor bit P1.1

0090 +1 5 tracksw_fb1 bit P1.0

0096 +1 6 tracksw_fb2 bit P1.6

0094 +1 7 SENSOR3 BIT p1.4 ;for speed same tra

ck

0095 +1 8 SENSOR4 BIT p1.5 ;for same track

Page 24: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

24

+1 9

00B7 +1 10 led_red bit P3.7

00B6 +1 11 led_red1 bit P3.6

00B5 +1 12 led_green bit P3.5

00B4 +1 13 led_green1 bit P3.4

+1 14

+1 15

+1 16

+1 17

0083 +1 18 en1 bit P0.3 ;track swit

ch 2

0084 +1 19 in1a bit P0.4

0085 +1 20 in1b bit P0.5

+1 21

0080 +1 22 en2 bit P0.0 ;track swit

ch 1

0081 +1 23 in2a bit P0.1

0082 +1 24 in2b bit P0.2

+1 25

00A5 +1 26 en3 bit P2.5 ;gate contr

ol

00A3 +1 27 in3a bit P2.3

00A4 +1 28 in3b bit P2.4

+1 29

00A2 +1 30 en4 bit P2.2

Page 25: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

25

00A1 +1 31 in4a bit P2.1

00A0 +1 32 in4b bit P2.0

+1 33

+1 34

+1 35

00A6 +1 36 buzzer bit P2.6

+1 37

+1 38

+1 39

+1 40

+1 41

+1 42

+1 43

+1 44

+1 45

+1 46

+1 47

+1 48

0000 +1 49 GATE_CLOSE_F BIT 00H

0001 +1 50 track1_side1_f bit 01h

0002 +1 51 track2_side1_f bit 02h

+1 52

+1 53

+1 54

Page 26: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

26

A51 MACRO ASSEMBLER MAIN

0030 +1 55 delay0 equ 30h

0031 +1 56 delay1 equ 31h

0032 +1 57 DELAY2 EQU 32H

0033 +1 58 sensor_ram equ 33h

0034 +1 59 sametrack_ram equ 34h

+1 60

+1 61

0031 +1 62 s_location1 data '1'

0032 +1 63 s_location2 data '2'

0033 +1 64 s_location3 data '3'

0034 +1 65 s_location4 data '4'

0035 +1 66 s_gate_open data '5'

0036 +1 67 s_gate_close data '6'

0037 +1 68 s_track1_side1 data '7'

0038 +1 69 s_track1_side2 data '8'

0039 +1 70 s_track2_side1 data '9'

0030 +1 71 s_track2_side2 data '0'

+1 72

+1 73

0041 +1 74 cmd_track1_side1 data 'A'

0042 +1 75 cmd_track1_side2 data 'B'

0043 +1 76 cmd_track2_side1 data 'C'

0044 +1 77 cmd_track2_side2 data 'D'

Page 27: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

27

0045 +1 78 cmd_gate_open data 'E'

0046 +1 79 cmd_gate_close data 'F'

80

0000 81 org 0000h

0000 758160 82 MOV SP,#60H

0003 11E4 83 call stop

0005 C2A6 84 clr buzzer

0007 C2B4 85 clr led_green1

0009 C2B5 86 clr led_green

000B 1144 87 call delay

000D 1144 88 call delay

000F 1144 89 call delay

0011 11F9 90 call baudrate

0013 7448 91 mov a,#'H'

0015 3105 92 call send

0017 7469 93 mov a,#'i'

0019 3105 94 call send

001B D2A6 95 setb buzzer

96

001D 11B4 97 call GATE_close

001F 11CE 98 call gate_open

0021 753300 99 mov sensor_ram,#00h

0024 753400 100 mov sametrack_ram,#00h

0027 1144 101 call delay

0029 31C9 102 call track1_side1

Page 28: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

28

002B 1144 103 call delay

002D 31EC 104 call track2_side1

105 ; call receive

106 ;call send

107

002F 108 loop:

002F 115A 109 call check_gate

0031 315A 110 call check_same_track

0033 312E 111 CALL check_serial

0035 80F8 112 JMP LOOP

113

0037 114 Ldelay:

0037 7530FF 115 mov delay0,#0ffh

003A 116 l1_Ldelay:

003A 7531FF 117 mov delay1,#0ffh

003D 118 l2_Ldelay:

119 ; MOV DELAY2,#1

120 ; DJNZ DELAY2,$

Page 29: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

29

A51 MACRO ASSEMBLER MAIN

003D D531FD 121 djnz delay1,l2_Ldelay

0040 D530F7 122 djnz delay0,l1_Ldelay

0043 22 123 ret

124

125

0044 126 delay:

0044 7530FF 127 mov delay0,#0ffh

0047 128 l1_delay:

0047 7531FF 129 mov delay1,#0ffh

004A 130 l2_delay:

004A D531FD 131 djnz delay1,l2_delay

004D D530F7 132 djnz delay0,l1_delay

0050 22 133 ret

134

0051 135 sdelay:

0051 7F00 136 mov r7,#00h

0053 137 sl1_delay:

0053 7E01 138 mov r6,#01h

0055 DEFE 139 djnz r6,$

0057 DFFA 140 djnz r7,sl1_delay

0059 22 141 ret

142 ;$include (gate_control.inc)

005A +1 143 check_gate:

Page 30: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

30

005A 1161 +1 144 call check_sensor1

005C 118A +1 145 call check_sensor2

005E 22 +1 146 ret

+1 147

+1 148

+1 149

005F +1 150 R1_check_sensor1:

+1 151 ;NO OBSTACLE

005F D3 +1 152 SETB C

0060 22 +1 153 RET

+1 154

0061 +1 155 check_sensor1:

0061 3093FB +1 156 jnb SENSOR1,R1_check_sensor1

0064 7F30 +1 157 mov r7,#30h

0066 +1 158 deb1_loop:

0066 3093F8 +1 159 jnb SENSOR1,check_sensor1

0069 DFFB +1 160 djnz r7,deb1_loop

+1 161

006B 7431 +1 162 mov a,#s_location1

006D 3105 +1 163 call send

+1 164

006F 2093FD +1 165 jb sensor1,$

+1 166

0072 E533 +1 167 mov a,sensor_ram

0074 B40007 +1 168 cjne a,#00h,c1_check_sensor1

Page 31: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

31

0077 753301 +1 169 mov sensor_ram,#01h

007A C3 +1 170 CLR C

007B 11B4 +1 171 CALL GATE_CLOSE

+1 172 ; mov a,#'2'

+1 173 ; call send

007D 22 +1 174 RET

+1 175

+1 176

007E +1 177 c1_check_sensor1:

007E B40206 +1 178 cjne a,#02h,c2_check_sensor1

0081 11CE +1 179 call gate_open

0083 753300 +1 180 mov sensor_ram,#00h

0086 22 +1 181 ret

+1 182

0087 +1 183 c2_check_sensor1:

0087 22 +1 184 ret

+1 185

+1 186

Page 32: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

32

A51 MACRO ASSEMBLER MAIN

+1 187 ;**************************************

+1 188 ;**************************************

+1 189 ;**************************************

0088 +1 190 R1_check_sensor2:

0088 D3 +1 191 SETB C

0089 22 +1 192 RET

+1 193

+1 194

008A +1 195 check_sensor2:

008A 3092FB +1 196 jnb SENSOR2,R1_check_sensor2

008D 7F30 +1 197 mov r7,#30h

008F +1 198 deb2_loop:

008F 3092F8 +1 199 jnb SENSOR2,check_sensor2

0092 DFFB +1 200 djnz r7,deb2_loop

0094 2092FD +1 201 jb sensor2,$

+1 202

0097 7432 +1 203 mov a,#s_location2

0099 3105 +1 204 call send

009B 2092FD +1 205 jb sensor2,$

+1 206

009E E533 +1 207 mov a,sensor_ram

00A0 B40007 +1 208 cjne a,#00h,c1_check_sensor2

00A3 753302 +1 209 mov sensor_ram,#02h

Page 33: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

33

00A6 C3 +1 210 CLR C

00A7 11B4 +1 211 CALL GATE_CLOSE

+1 212 ; mov a,#'3'

+1 213 ; call send

00A9 22 +1 214 RET

+1 215

+1 216

00AA +1 217 c1_check_sensor2:

00AA B40106 +1 218 cjne a,#01h,c2_check_sensor2

00AD 11CE +1 219 call gate_open

+1 220 ; mov a,#'4'

+1 221 ; call send

00AF 753300 +1 222 mov sensor_ram,#00h

00B2 22 +1 223 ret

+1 224

00B3 +1 225 c2_check_sensor2:

00B3 22 +1 226 ret

+1 227

+1 228

+1 229

;***********************************************************************

+1 230

;***********************************************************************

+1 231

;***********************************************************************

+1 232

;***********************************************************************

Page 34: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

34

+1 233

;***********************************************************************

+1 234

;***********************************************************************

+1 235

;***********************************************************************

+1 236

;***********************************************************************

+1 237

+1 238

00B4 +1 239 GATE_CLOSE:

00B4 C2A6 +1 240 CLR buzzer

00B6 309104 +1 241 jnb gate_close_sensor,r1_GATE_CLOSE

+1 242 ; jb gate_close_f,r1_GATE_CLOSE

00B9 11EB +1 243 call forward

+1 244 ; call Ldelay

00BB 80F7 +1 245 jmp GATE_CLOSE

+1 246

00BD +1 247 r1_GATE_CLOSE:

00BD 11E4 +1 248 call stop

00BF D200 +1 249 setb gate_close_f

00C1 7436 +1 250 mov a,#s_gate_close

00C3 3105 +1 251 call send

00C5 D2A6 +1 252 SETB bUZZER

Page 35: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

35

A51 MACRO ASSEMBLER MAIN

00C7 22 +1 253 ret

+1 254

+1 255

00C8 +1 256 r1_GATE_open:

00C8 7436 +1 257 mov a,#s_gate_close

00CA 3105 +1 258 call send

00CC C3 +1 259 clr c

00CD 22 +1 260 ret

+1 261

+1 262

00CE +1 263 GATE_open:

00CE 3000F7 +1 264 jnb gate_close_f,r1_GATE_open

00D1 11F2 +1 265 call reverse

00D3 1137 +1 266 call Ldelay

00D5 1137 +1 267 call Ldelay

00D7 1137 +1 268 call Ldelay

00D9 1137 +1 269 call Ldelay

00DB 11E4 +1 270 call stop

00DD C200 +1 271 clr gate_close_f

00DF 7435 +1 272 mov a,#s_gate_open

00E1 3105 +1 273 call send

00E3 22 +1 274 ret

+1 275

Page 36: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

36

+1 276

+1 277

+1 278

00E4 +1 279 stop:

00E4 C2A5 +1 280 clr en3

00E6 C2A3 +1 281 clr in3a

00E8 C2A4 +1 282 clr in3b

00EA 22 +1 283 ret

+1 284

00EB +1 285 forward:

00EB D2A5 +1 286 setb en3

00ED D2A3 +1 287 setb in3a

00EF C2A4 +1 288 clr in3b

00F1 22 +1 289 ret

+1 290

+1 291

00F2 +1 292 reverse:

00F2 D2A5 +1 293 setb en3

00F4 C2A3 +1 294 clr in3a

00F6 D2A4 +1 295 setb in3b

00F8 22 +1 296 ret

+1 297

+1 298

;***********************************************************************

+1 299

;***********************************************************************

Page 37: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

37

+1 300

;***********************************************************************

+1 301

;***********************************************************************

302

303 ;$include (serial.inc)

+1 304

;**********************************************************************************

+1 305

;**********************************************************************************

+1 306

;**********************************************************************************

00F9 +1 307 baudrate:

00F9 759850 +1 308 mov scon,#50h

00FC 758921 +1 309 mov tmod,#21h ;Timer 1 in Auto-reload mode , TIMER 0 FOR

GETTING COUNT

FROM SUB PLC

00FF 758DFD +1 310 mov th1,#0fDh ;Reload value for 4800 baud @ 11.059 Mhz

0102 D28E +1 311 setb tcon.6 ;Turn on timer 1

0104 22 +1 312 ret

+1 313

;**********************************************************************************

+1 314

;**********************************************************************************

+1 315

;**********************************************************************************

+1 316

;**********************************************************************************

0105 +1 317 send:

Page 38: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

38

A51 MACRO ASSEMBLER MAIN

0105 F599 +1 318 mov sbuf,a

0107 +1 319 lsend1:

0107 3099FD +1 320 jnb scon.1,lsend1

010A C299 +1 321 clr scon.1

010C 22 +1 322 ret

+1 323

;**********************************************************************************

+1 324

;**********************************************************************************

+1 325

+1 326

;**********************************************************************************

+1 327

;**********************************************************************************

010D +1 328 receive:

010D 3098FD +1 329 jnb scon.0,receive

0110 C298 +1 330 clr scon.0

0112 E599 +1 331 mov a,sbuf

0114 22 +1 332 ret

+1 333

;**********************************************************************************

+1 334

;**********************************************************************************

+1 335

+1 336

;**********************************************************************************

Page 39: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

39

+1 337

;**********************************************************************************

0115 +1 338 newline:

0115 740A +1 339 mov a,#10

0117 3105 +1 340 call send

0119 740D +1 341 mov a,#13

011B 3105 +1 342 call send

011D 22 +1 343 ret

+1 344

;**********************************************************************************

+1 345

;**********************************************************************************

011E +1 346 send_dptr_string:

011E E4 +1 347 clr a

011F 93 +1 348 movc a,@a+dptr

0120 7003 +1 349 jnz c1_send_dptr_string

0122 02012B +1 350 ljmp r1_send_dptr_string

+1 351

0125 +1 352 c1_send_dptr_string:

0125 3105 +1 353 call send

0127 A3 +1 354 inc dptr

0128 02011E +1 355 ljmp send_dptr_string

012B +1 356 r1_send_dptr_string:

012B 22 +1 357 ret

+1 358

;**********************************************************************************

+1 359

;**********************************************************************************

Page 40: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

40

+1 360

;**********************************************************************************

+1 361

;**********************************************************************************

012C +1 362 r1_check_serial:

012C C3 +1 363 clr c

012D 22 +1 364 ret

+1 365

012E +1 366 check_serial:

012E 3098FB +1 367 jnb scon.0,r1_check_serial

0131 C298 +1 368 clr scon.0

0133 E599 +1 369 MOV A,SBUF

0135 B44103 +1 370 cjne a,#cmd_track1_side1,c1_check_serial

0138 31C9 +1 371 call track1_side1

013A 22 +1 372 ret

+1 373

+1 374

013B +1 375 c1_check_serial:

013B B44203 +1 376 cjne a,#cmd_track1_side2,c2_check_serial

013E 31D9 +1 377 call track1_side2

0140 22 +1 378 ret

+1 379

+1 380

0141 +1 381 c2_check_serial:

0141 B44303 +1 382 cjne a,#cmd_track2_side1,c3_check_serial

0144 31EC +1 383 call track2_side1

Page 41: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

41

A51 MACRO ASSEMBLER MAIN

0146 22 +1 384 ret

+1 385

+1 386

0147 +1 387 c3_check_serial:

0147 B44403 +1 388 cjne a,#cmd_track2_side2,c4_check_serial

014A 31FC +1 389 call track2_side2

014C 22 +1 390 ret

+1 391

+1 392

014D +1 393 c4_check_serial:

014D B44503 +1 394 cjne a,#cmd_gate_open,c5_check_serial

0150 11CE +1 395 call gate_open

0152 22 +1 396 ret

+1 397

+1 398

0153 +1 399 c5_check_serial:

0153 B44603 +1 400 cjne a,#cmd_gate_close,c6_check_serial

0156 11B4 +1 401 call gate_close

0158 22 +1 402 ret

+1 403

+1 404

0159 +1 405 c6_check_serial:

0159 22 +1 406 ret

Page 42: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

42

407

408 ;$include(display.inc)

409 ;$include (sametrack.inc)

015A +1 410 check_same_track:

015A 3161 +1 411 call check_sametracksensor1

015C 3197 +1 412 call check_sametracksensor2

015E 22 +1 413 ret

+1 414

+1 415

+1 416

+1 417

+1 418

015F +1 419 R1_check_sametracksensor1:

+1 420 ;NO OBSTACLE

015F D3 +1 421 SETB C

0160 22 +1 422 RET

+1 423

0161 +1 424 check_sametracksensor1:

0161 3094FB +1 425 jnb SENSOR3,R1_check_sametracksensor1

0164 7F30 +1 426 mov r7,#30h

0166 +1 427 deb1_loopa:

0166 3094F8 +1 428 jnb SENSOR3,check_sametracksensor1

0169 DFFB +1 429 djnz r7,deb1_loopa

016B 7433 +1 430 mov a,#s_location3

016D 3105 +1 431 call send

Page 43: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

43

016F 2094FD +1 432 jb sensor3,$

+1 433

0172 E534 +1 434 mov a,sametrack_ram

0174 B4000C +1 435 cjne a,#00h,c1_check_sametracksensor1

0177 C2B6 +1 436 clr led_red1

0179 D2B4 +1 437 setb led_green1

017B D2B5 +1 438 setb led_green

017D D2B7 +1 439 setb led_red

017F 753401 +1 440 mov sametrack_ram,#01h

0182 22 +1 441 ret

+1 442

+1 443

0183 +1 444 c1_check_sametracksensor1:

0183 B4020E +1 445 cjne a,#02h,c2_check_sametracksensor1

0186 C2B5 +1 446 clr led_green

0188 C2B4 +1 447 clr led_green1

018A D2B7 +1 448 setb led_red

018C D2B6 +1 449 setb led_red1

Page 44: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

44

A51 MACRO ASSEMBLER MAIN

018E 753400 +1 450 mov sametrack_ram,#00h

0191 1137 +1 451 CALL LDELAY

0193 22 +1 452 ret

+1 453

+1 454

+1 455

0194 +1 456 c2_check_sametracksensor1:

0194 22 +1 457 ret

+1 458

+1 459

+1 460 ;*****************************************************************

+1 461 ;*****************************************************************

+1 462 ;*****************************************************************

+1 463 ;*****************************************************************

+1 464

0195 +1 465 R1_check_sametracksensor2:

+1 466 ;NO OBSTACLE

0195 D3 +1 467 SETB C

0196 22 +1 468 RET

+1 469

0197 +1 470 check_sametracksensor2:

0197 3095FB +1 471 jnb SENSOR4,R1_check_sametracksensor2

019A 7F30 +1 472 mov r7,#30h

Page 45: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

45

019C +1 473 deb1_loopb:

019C 3095F8 +1 474 jnb SENSOR4,check_sametracksensor2

019F DFFB +1 475 djnz r7,deb1_loopb

01A1 7434 +1 476 mov a,#s_location4

01A3 3105 +1 477 call send

01A5 2095FD +1 478 jb sensor4,$

+1 479

+1 480

01A8 E534 +1 481 mov a,sametrack_ram

01AA B4000C +1 482 cjne a,#00h,c1_check_sametracksensor2

01AD C2B7 +1 483 clr led_red

01AF D2B5 +1 484 setb led_green

01B1 D2B4 +1 485 setb led_green1

01B3 D2B6 +1 486 setb led_red1

01B5 753402 +1 487 mov sametrack_ram,#02h

01B8 22 +1 488 ret

+1 489

+1 490

01B9 +1 491 c1_check_sametracksensor2:

01B9 B4010C +1 492 cjne a,#01h,c2_check_sametracksensor2

01BC C2B5 +1 493 clr led_green

01BE C2B4 +1 494 clr led_green1

01C0 D2B7 +1 495 setb led_red

01C2 D2B6 +1 496 setb led_red1

01C4 753400 +1 497 mov sametrack_ram,#00h

Page 46: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

46

01C7 22 +1 498 ret

+1 499

01C8 +1 500 c2_check_sametracksensor2:

01C8 22 +1 501 ret

502

503 ;$include (trackswitching.inc)

01C9 +1 504 track1_side1:

01C9 309004 +1 505 jnb tracksw_fb1,r1_track1_side1

01CC 5131 +1 506 call track1_close

01CE 80F9 +1 507 jmp track1_side1

+1 508

01D0 +1 509 r1_track1_side1:

01D0 5123 +1 510 call track1_stop

01D2 D201 +1 511 setb track1_side1_f

01D4 7437 +1 512 mov a,#s_track1_side1

01D6 3105 +1 513 call send

01D8 22 +1 514 ret

+1 515

Page 47: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

47

A51 MACRO ASSEMBLER MAIN

+1 516

01D9 +1 517 track1_side2:

01D9 30010B +1 518 jnb track1_side1_f,r1_track1_side2

01DC 512A +1 519 call track1_open

01DE 510F +1 520 call track_delay

01E0 5123 +1 521 call track1_stop

01E2 7438 +1 522 mov a,#s_track1_side2

01E4 3105 +1 523 call send

01E6 22 +1 524 ret

+1 525

01E7 +1 526 r1_track1_side2:

01E7 7438 +1 527 mov a,#s_track1_side2

01E9 3105 +1 528 call send

01EB 22 +1 529 ret

+1 530

+1 531

+1 532

+1 533

;*********************************************************************

+1 534

;*********************************************************************

+1 535

;*********************************************************************

Page 48: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

48

+1 536

;*********************************************************************

+1 537

01EC +1 538 track2_side1:

01EC 309604 +1 539 jnb tracksw_fb2,r1_track2_side1

01EF 5146 +1 540 call track2_close

01F1 80F9 +1 541 jmp track2_side1

+1 542

01F3 +1 543 r1_track2_side1:

01F3 5138 +1 544 call track2_stop

01F5 D202 +1 545 setb track2_side1_f

01F7 7439 +1 546 mov a,#s_track2_side1

01F9 3105 +1 547 call send

01FB 22 +1 548 ret

+1 549

+1 550

01FC +1 551 track2_side2:

01FC 30020B +1 552 jnb track2_side1_f,r1_track2_side2

01FF 513F +1 553 call track2_open

0201 510F +1 554 call track_delay

0203 5138 +1 555 call track2_stop

0205 7430 +1 556 mov a,#s_track2_side2

0207 3105 +1 557 call send

0209 22 +1 558 ret

+1 559

020A +1 560 r1_track2_side2:

Page 49: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

49

020A 7430 +1 561 mov a,#s_track2_side2

020C 3105 +1 562 call send

020E 22 +1 563 ret

+1 564

+1 565

+1 566

+1 567

+1 568

;*********************************************************************

+1 569

;*********************************************************************

+1 570

;*********************************************************************

+1 571

;*********************************************************************

020F +1 572 track_delay:

020F 7530FF +1 573 mov delay0,#0ffh

0212 +1 574 l1_track_delay:

0212 7531FF +1 575 mov delay1,#0ffh

0215 +1 576 l2_track_delay:

0215 753201 +1 577 MOV DELAY2,#1

0218 D532FD +1 578 DJNZ DELAY2,$

021B 00 +1 579 NOP

021C D531F6 +1 580 djnz delay1,l2_track_delay

Page 50: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

50

A51 MACRO ASSEMBLER MAIN

021F D530F0 +1 581 djnz delay0,l1_track_delay

0222 22 +1 582 ret

+1 583

;*********************************************************************

+1 584

;*********************************************************************

+1 585

;*********************************************************************

+1 586

;*********************************************************************

+1 587

0223 +1 588 track1_stop:

0223 C280 +1 589 clr en2

0225 C281 +1 590 clr in2a

0227 C282 +1 591 clr in2b

0229 22 +1 592 ret

+1 593

+1 594

+1 595

022A +1 596 track1_open:

022A D280 +1 597 setb en2

022C D281 +1 598 setb in2a

022E C282 +1 599 clr in2b

0230 22 +1 600 ret

+1 601

Page 51: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

51

+1 602

0231 +1 603 track1_close:

0231 D280 +1 604 setb en2

0233 C281 +1 605 clr in2a

0235 D282 +1 606 setb in2b

0237 22 +1 607 ret

+1 608

+1 609

+1 610

+1 611

;*********************************************************************

+1 612

;*********************************************************************

+1 613

;*********************************************************************

+1 614

;*********************************************************************

+1 615

0238 +1 616 track2_stop:

0238 C283 +1 617 clr en1

023A C284 +1 618 clr in1a

023C C285 +1 619 clr in1b

023E 22 +1 620 ret

+1 621

+1 622

+1 623

023F +1 624 track2_open:

Page 52: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

52

023F D283 +1 625 setb en1

0241 D284 +1 626 setb in1a

0243 C285 +1 627 clr in1b

0245 22 +1 628 ret

+1 629

+1 630

0246 +1 631 track2_close:

0246 D283 +1 632 setb en1

0248 C284 +1 633 clr in1a

024A D285 +1 634 setb in1b

024C 22 +1 635 ret

636

637 end

Page 53: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

53

A51 MACRO ASSEMBLER MAIN

SYMBOL TABLE LISTING

------ ----- -------

N A M E T Y P E V A L U E ATTRIBUTES

BAUDRATE. . . . . . . . . C ADDR 00F9H A

BUZZER. . . . . . . . . . B ADDR 00A0H.6 A

C1_CHECK_SAMETRACKSENSOR1 C ADDR 0183H A

C1_CHECK_SAMETRACKSENSOR2 C ADDR 01B9H A

C1_CHECK_SENSOR1. . . . . C ADDR 007EH A

C1_CHECK_SENSOR2. . . . . C ADDR 00AAH A

C1_CHECK_SERIAL . . . . . C ADDR 013BH A

C1_SEND_DPTR_STRING . . . C ADDR 0125H A

C2_CHECK_SAMETRACKSENSOR1 C ADDR 0194H A

C2_CHECK_SAMETRACKSENSOR2 C ADDR 01C8H A

C2_CHECK_SENSOR1. . . . . C ADDR 0087H A

C2_CHECK_SENSOR2. . . . . C ADDR 00B3H A

C2_CHECK_SERIAL . . . . . C ADDR 0141H A

C3_CHECK_SERIAL . . . . . C ADDR 0147H A

C4_CHECK_SERIAL . . . . . C ADDR 014DH A

C5_CHECK_SERIAL . . . . . C ADDR 0153H A

C6_CHECK_SERIAL . . . . . C ADDR 0159H A

Page 54: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

54

CHECK_GATE. . . . . . . . C ADDR 005AH A

CHECK_SAMETRACKSENSOR1. . C ADDR 0161H A

CHECK_SAMETRACKSENSOR2. . C ADDR 0197H A

CHECK_SAME_TRACK. . . . . C ADDR 015AH A

CHECK_SENSOR1 . . . . . . C ADDR 0061H A

CHECK_SENSOR2 . . . . . . C ADDR 008AH A

CHECK_SERIAL. . . . . . . C ADDR 012EH A

CMD_GATE_CLOSE. . . . . . D ADDR 0046H A

CMD_GATE_OPEN . . . . . . D ADDR 0045H A

CMD_TRACK1_SIDE1. . . . . D ADDR 0041H A

CMD_TRACK1_SIDE2. . . . . D ADDR 0042H A

CMD_TRACK2_SIDE1. . . . . D ADDR 0043H A

CMD_TRACK2_SIDE2. . . . . D ADDR 0044H A

DEB1_LOOP . . . . . . . . C ADDR 0066H A

DEB1_LOOPA. . . . . . . . C ADDR 0166H A

DEB1_LOOPB. . . . . . . . C ADDR 019CH A

DEB2_LOOP . . . . . . . . C ADDR 008FH A

DELAY . . . . . . . . . . C ADDR 0044H A

DELAY0. . . . . . . . . . N NUMB 0030H A

DELAY1. . . . . . . . . . N NUMB 0031H A

DELAY2. . . . . . . . . . N NUMB 0032H A

EN1 . . . . . . . . . . . B ADDR 0080H.3 A

EN2 . . . . . . . . . . . B ADDR 0080H.0 A

EN3 . . . . . . . . . . . B ADDR 00A0H.5 A

EN4 . . . . . . . . . . . B ADDR 00A0H.2 A

Page 55: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

55

FORWARD . . . . . . . . . C ADDR 00EBH A

GATE_CLOSE. . . . . . . . C ADDR 00B4H A

GATE_CLOSE_F. . . . . . . B ADDR 0020H.0 A

GATE_CLOSE_SENSOR . . . . B ADDR 0090H.1 A

GATE_OPEN . . . . . . . . C ADDR 00CEH A

IN1A. . . . . . . . . . . B ADDR 0080H.4 A

IN1B. . . . . . . . . . . B ADDR 0080H.5 A

IN2A. . . . . . . . . . . B ADDR 0080H.1 A

IN2B. . . . . . . . . . . B ADDR 0080H.2 A

IN3A. . . . . . . . . . . B ADDR 00A0H.3 A

IN3B. . . . . . . . . . . B ADDR 00A0H.4 A

IN4A. . . . . . . . . . . B ADDR 00A0H.1 A

IN4B. . . . . . . . . . . B ADDR 00A0H.0 A

L1_DELAY. . . . . . . . . C ADDR 0047H A

L1_LDELAY . . . . . . . . C ADDR 003AH A

L1_TRACK_DELAY. . . . . . C ADDR 0212H A

L2_DELAY. . . . . . . . . C ADDR 004AH A

L2_LDELAY . . . . . . . . C ADDR 003DH A

Page 56: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

56

A51 MACRO ASSEMBLER MAIN

L2_TRACK_DELAY. . . . . . C ADDR 0215H A

LDELAY. . . . . . . . . . C ADDR 0037H A

LED_GREEN . . . . . . . . B ADDR 00B0H.5 A

LED_GREEN1. . . . . . . . B ADDR 00B0H.4 A

LED_RED . . . . . . . . . B ADDR 00B0H.7 A

LED_RED1. . . . . . . . . B ADDR 00B0H.6 A

LOOP. . . . . . . . . . . C ADDR 002FH A

LSEND1. . . . . . . . . . C ADDR 0107H A

NEWLINE . . . . . . . . . C ADDR 0115H A

P0. . . . . . . . . . . . D ADDR 0080H A

P1. . . . . . . . . . . . D ADDR 0090H A

P2. . . . . . . . . . . . D ADDR 00A0H A

P3. . . . . . . . . . . . D ADDR 00B0H A

R1_CHECK_SAMETRACKSENSOR1 C ADDR 015FH A

R1_CHECK_SAMETRACKSENSOR2 C ADDR 0195H A

R1_CHECK_SENSOR1. . . . . C ADDR 005FH A

R1_CHECK_SENSOR2. . . . . C ADDR 0088H A

R1_CHECK_SERIAL . . . . . C ADDR 012CH A

R1_GATE_CLOSE . . . . . . C ADDR 00BDH A

R1_GATE_OPEN. . . . . . . C ADDR 00C8H A

R1_SEND_DPTR_STRING . . . C ADDR 012BH A

R1_TRACK1_SIDE1 . . . . . C ADDR 01D0H A

R1_TRACK1_SIDE2 . . . . . C ADDR 01E7H A

Page 57: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

57

R1_TRACK2_SIDE1 . . . . . C ADDR 01F3H A

R1_TRACK2_SIDE2 . . . . . C ADDR 020AH A

RECEIVE . . . . . . . . . C ADDR 010DH A

REVERSE . . . . . . . . . C ADDR 00F2H A

SAMETRACK_RAM . . . . . . N NUMB 0034H A

SBUF. . . . . . . . . . . D ADDR 0099H A

SCON. . . . . . . . . . . D ADDR 0098H A

SDELAY. . . . . . . . . . C ADDR 0051H A

SEND. . . . . . . . . . . C ADDR 0105H A

SEND_DPTR_STRING. . . . . C ADDR 011EH A

SENSOR1 . . . . . . . . . B ADDR 0090H.3 A

SENSOR2 . . . . . . . . . B ADDR 0090H.2 A

SENSOR3 . . . . . . . . . B ADDR 0090H.4 A

SENSOR4 . . . . . . . . . B ADDR 0090H.5 A

SENSOR_RAM. . . . . . . . N NUMB 0033H A

SL1_DELAY . . . . . . . . C ADDR 0053H A

SP. . . . . . . . . . . . D ADDR 0081H A

STOP. . . . . . . . . . . C ADDR 00E4H A

S_GATE_CLOSE. . . . . . . D ADDR 0036H A

S_GATE_OPEN . . . . . . . D ADDR 0035H A

S_LOCATION1 . . . . . . . D ADDR 0031H A

S_LOCATION2 . . . . . . . D ADDR 0032H A

S_LOCATION3 . . . . . . . D ADDR 0033H A

S_LOCATION4 . . . . . . . D ADDR 0034H A

S_TRACK1_SIDE1. . . . . . D ADDR 0037H A

Page 58: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

58

S_TRACK1_SIDE2. . . . . . D ADDR 0038H A

S_TRACK2_SIDE1. . . . . . D ADDR 0039H A

S_TRACK2_SIDE2. . . . . . D ADDR 0030H A

TCON. . . . . . . . . . . D ADDR 0088H A

TH1 . . . . . . . . . . . D ADDR 008DH A

TMOD. . . . . . . . . . . D ADDR 0089H A

TRACK1_CLOSE. . . . . . . C ADDR 0231H A

TRACK1_OPEN . . . . . . . C ADDR 022AH A

TRACK1_SIDE1. . . . . . . C ADDR 01C9H A

TRACK1_SIDE1_F. . . . . . B ADDR 0020H.1 A

TRACK1_SIDE2. . . . . . . C ADDR 01D9H A

TRACK1_STOP . . . . . . . C ADDR 0223H A

TRACK2_CLOSE. . . . . . . C ADDR 0246H A

TRACK2_OPEN . . . . . . . C ADDR 023FH A

TRACK2_SIDE1. . . . . . . C ADDR 01ECH A

TRACK2_SIDE1_F. . . . . . B ADDR 0020H.2 A

TRACK2_SIDE2. . . . . . . C ADDR 01FCH A

TRACK2_STOP . . . . . . . C ADDR 0238H A

Page 59: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

59

A51 MACRO ASSEMBLER MAIN

TRACKSW_FB1 . . . . . . . B ADDR 0090H.0 A

TRACKSW_FB2 . . . . . . . B ADDR 0090H.6 A

TRACK_DELAY . . . . . . . C ADDR 020FH A

REGISTER BANK(S) USED: 0

ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)

Page 60: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

60

B] Visual Basic programming

Option Explicit

Dim InputStringBuffer As String

Dim WriteStringBuffer As String

Dim Tagno As String

'Dim count As Integer

Private Sub cmdconnect_Click()

If cmdconnect.Caption = "CONNECT" Then

MSComm1.CommPort = txtcommport.Text

MSComm1.PortOpen = True

cmdconnect.Caption = "DISCONNECT"

MSComm1.RThreshold = 1

ElseIf cmdconnect.Caption = "DISCONNECT" Then

MSComm1.PortOpen = False

cmdconnect.Caption = "CONNECT"

End If

End Sub

Private Sub Command1_Click()

MSComm1.Output = "E"

End Sub

Private Sub Command2_Click()

MSComm1.Output = "A"

Page 61: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

61

End Sub

Private Sub Command3_Click()

MSComm1.Output = "F"

End Sub

Private Sub Command4_Click()

MSComm1.Output = "B"

End Sub

Private Sub Command5_Click()

MSComm1.Output = "C"

End Sub

Private Sub Command6_Click()

MSComm1.Output = "D"

End Sub

Private Sub Form_Load()

Open "d:\attendance_logs.txt" For Append As #1

Close #1

End Sub

Page 62: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

62

Private Sub MSComm1_OnComm()

'Dim count As Integer

If MSComm1.CommEvent = comEvReceive Then

Text1.Text = ""

Text1.Text = MSComm1.Input

If Text1.Text = 1 Then Label3.Caption = " C.S.T. Crossing"

If Text1.Text = 2 Then Label3.Caption = " C.S.T. Crossing"

If Text1.Text = 3 Then Label3.Caption = " KALYAN JUNCTION"

If Text1.Text = 4 Then Label3.Caption = " KALYAN JUNCTION"

If Text1.Text = 5 Then Label5.Caption = " OPEN "

If Text1.Text = 6 Then Label5.Caption = " CLOSE "

If Text1.Text = 7 Then Label1.Caption = " SIDE 1 "

If Text1.Text = 8 Then Label1.Caption = " SIDE 2 "

If Text1.Text = 9 Then Label2.Caption = " SIDE 1 "

If Text1.Text = 0 Then Label2.Caption = " SIDE 2 "

If Text1.Text = 1 Then

If Timer2.Enabled = True Then

Timer2.Enabled = False

Text2.Text = (100000 / Val(Text4.Text)) / 20

Label7.Caption = Mid((100000 / Val(Text4.Text)) / 20, 1, 4)

Timer2.Enabled = False

Else

Text4.Text = 1

Timer2.Enabled = True

Page 63: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

63

End If

End If

If Text1.Text = 2 Then

If Timer2.Enabled = True Then

Timer2.Enabled = False

Text2.Text = (100000 / Val(Text4.Text)) / 20

Label7.Caption = Mid((100000 / Val(Text4.Text)) / 20, 1, 4)

Timer2.Enabled = False

Else

Text4.Text = 1

Timer2.Enabled = True

End If

End If

If Text1.Text = 3 Then

If Timer1.Enabled = True Then

Timer1.Enabled = False

Text2.Text = (100000 / Val(Text3.Text)) / 20

Label6.Caption = Mid((100000 / Val(Text3.Text)) / 20, 1, 4)

Timer1.Enabled = False

Else

Text3.Text = 1

Timer1.Enabled = True

End If

Page 64: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

64

End If

If Text1.Text = 4 Then

If Timer1.Enabled = True Then

Timer1.Enabled = False

Text2.Text = (100000 / Val(Text3.Text)) / 20

Label6.Caption = Mid((100000 / Val(Text3.Text)) / 20, 1, 4)

Timer1.Enabled = False

Else

Text3.Text = 1

Timer1.Enabled = True

End If

End If

End If

End Sub

Private Sub Timer1_Timer()

'Dim count As Integer

Timer1.Enabled = True

'count = count + 1

Text3.Text = Text3.Text + 1

End Sub

Private Sub Timer2_Timer()

Timer2.Enabled = True

Text4.Text = Text4.Text + 1

End Sub

Page 65: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

65

Software Display Screen

Page 66: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

66

CIRCUIT

PREPARATION

Page 67: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

67

CIRCUIT PREPARATION

PCB Designing and manufacturing

Printed Circuit Board Layout:

The PCB layout for circuit is an attach in annexure D.Board consist of insulating material

mostly copper-clad boards are used instead of copper, silver and gold can also be used but, as

copper is chipper mostly it is preferable. The material conducting pattern serves as conducting

medium for electronic component that are assembled on board components are mounted by lead

passing through holes that are drilled or punched on the based material and foil. These leads are

solder to the conducting pattern to form complete PCB in glass, glass epoxy, and epoxy paper

phenolic etc.The copper foil on the base material is developed by the process of electrode

position ion etching process.

Some of the elements are used are as follows:

Fecl3

Chromic acid, etc.

But fecl3 is most commonly used in etching process .PCB acts as a heat sink.

ARTWORK OF PCB:

Perfect artwork is mostly important process in production of PCB.The circuit is initially

tested and location of components is fixed. Artwork is the drawing showing conduction pattern

on PC.After testing the circuit rough layout is prepared on paper then that layout is transferred on

PCB by using PCB side. The artwork can also be prepared on transparent paper with sticking

tapes and self adhesive in various ranges.

Page 68: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

68

FILMING OF PCB:

To prepare a PCB at home following procedure is adopted

Measure the dimensions of all components e.g.resister, capacitor, inductor; etc. are prepared a

layout using component mounting rules:

Using the trace paper or carbon paper draw the mirror image of the figure.

Draw this image on cu cladding of PCB by using PCB pen, pencil, tapes and pads then

drill the holes by using drilling machine.

After drilling points the conductor tracks by using oil paints of good quality and live it

for drying.

After drying the points put the PCB in fecl3 solution for etching. If you want fast etching

add some drop of HCL during etching unwanted cu dissolved in fecl3.

After etching washes it with water and if you remove the point then used acetone.

Then mount the component opposite side of tracks.

Cut the leads of proper length and solder all the terminal of the components.

In this PCB is fabricated manually.

For PCB designing you should have following things:

Detail circuit diagram.

Physically each component with you.

To determine the size of PCB.

Layout and filming.

PCB manufacturing

Page 69: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

69

Tracing of the layout from paper to copper clad:

First of all circuit layout is taken on tracing paper with exact dimension of all component.

Now placing this paper on copper clad under carbon paper, trace the layout the copper clad. It

should be notice that the tracing on the clad should be accurate.

Applying non etching material on the layout:

Applying non etching material on layout is done manually.The non etching material are

drafting aids, oil paints, etc.on the PCB drafting aids are used, because more linearity conducting

are obtained .the drafting’s aids are different shapes and z-size for every component are should

be no crack on the drafting aids, because due to at this after etching their will be no conduction

between two lines.

Etching procedure:

After applying the non etching on the copper clad then this copper clad is kept in fecl3

solution for etching procedure. The etching procedure longs for the about 5 or 6 hours. During

the etching procedure the copper under the drafting aids does not get etches while all other

copper on the clad get etched and only the layout remains.

Cleaning the PCB and remaining non etch materials:

Page 70: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

70

After the etching and cleaning of PCB is done. It is done with the help of soap solution

and brush. To remove the transfer pattern with the cotton swab-dipped in the pattern remover

solution. Again wash with the soap and water then dry it.

• Drilling:-

After the PCB is ready, drilling is necessary. Drilling is done with the help of hand drill

or machine. For mounting of component proper drilling (holes) are necessary. The holes are of

dimension so that the terminals of each component and pin of the IC can easily pass through it to

make contact with conducting line on the PCB.

Small drills for PCB use usually come with either a set of collets of various sizes or a 3-jaw

chuck. For accuracy, however, 3-jaw chucks aren't brilliant, and small drill sizes below 1mm

quickly form grooves in the jaws, preventing good grip. Need of good strong light on the board

when drilling to ensure accuracy. Typical hole sizes is 0.8mm.

Component Placement & Design:-

The basic steps required for Component Placement & Design.

Set snap grid, visible grid, and default track/pad sizes.

Throw down all the components onto the board.

Divide and place components into functional “building blocks” where possible.

Identify layout critical tracks on circuit and route them first.

Page 71: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

71

Place and route each building block separately, off the board.

Move completed building blocks into position on main board.

Route the remaining signal and power connections between blocks.

This is by no means a be-all and end-all check list; it’s highly variable depending on many

factors. The best way to start layout is to get all components onto the screen first and place them

down manually.

• Soldering:-

It is process of joining two metals together by the use of solder alloy to form a reliable

electrical path.

Soldering considerations need to taken into account when laying out board. There are

three basic soldering techniques - hand, wave, and reflow. Hand soldering is the traditional

method typically used for prototypes and small production runs. Major impacts when laying out

board include suitable access for the iron, and thermal relief for pads.

Procedure of soldering:

1) clean all components, terminals and substrates

2) Apply flux

3) Place the soldering iron with right tip size, touching both the lid and pad.

4) From initially a heat bridge between the soldering iron and the lead pad junction with a

little solder to increase the thermal linkage area.

5) Feed the solder wire starting from the heat bridge all around the lead.

6) Remove the solder and soldering iron simultaneously.

7) There should not be any relative movement between the components under solidification

and the working table.

8) Check the joint

Page 72: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

72

Solder Mask:-

A solder mask is a thin polymer coating on your board which surrounds pads to help

prevent solder from bridging between pins. This is essential for surface mount and fine pitch

devices. The solder mask typically covers everything except pads and vias.

• Electrical Testing:-

We have finished PCB checked for electrical continuity and shorts at the time of

manufacture. This is done with an automated “flying probe” or “DMM”. It checks that the

continuity of the tracks matches your PCB file.

Trouble Shooting:

The different protocols that we tested were Sony, Fujitsu, NEC, Fairchild etc. But this

was unable to detect IR sensor, so we had used RC5 by Phillips.

The intensity of RC5 protocol was very high. Hence it was try to reduce by using an

insulation tape.

The only problem was with the line of sight .the solution to this is that the transmitter and

receiver should match with line of sight to detect.

Page 73: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

73

ADVANTAGES,

LIMITATIONS &

Page 74: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

74

APPLICATIONS

ADVANTAGES, DISADVANTAGES,

FUTURE SCOPE

ADVANTAGES:-

1. Large amount of accidents can be avoided.

2. Continuous updates of train position at master control.

3. Large amount of man power is saved and thereby reduction in the cost of wages for

railway is possible.

4. Controlling of various features by the master controller.

5. Well management can be possible due to sufficient data.

6. Possibility of human error is avoided.

7. Flawless track switching is possible due to the master controller.

DISADVANTAGES:-

1. Due to use of IR sensors, the major drawback is the line of sight and cause fake

detection.

2. Accidents due to absence of track cannot be overcome.

3. Implementation cost is high.

4. We cannot identify the name of train running on the track.

FUTURE SCOPE:-

1. “SHIELD” technology or the anti collision devices can be used to avoid train collision.

2. GPS system can be used to get the updated information about the train.

3. Weight sensors can be used for the automatic railway control.

Page 75: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

75

4. Track vacancy detection can be possible due to ATP code transmission.

COSTSHEET

Page 76: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

76

Cost Sheet

Page 77: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

77

Sr.no. Components Quantity Cost Total

1 Microcontroller IC 89S52 1 70/- 70/-

2 Crystal 11.0592Mhz. 1 8/- 8/-

3 Diode 1N4007 4 1/- 4/-

4 Resistor 10kΩ 10 1/- 10/-

5 Resistor 2.2kΩ 10 1/- 10/-

6 Resistor 220Ω 3 1/- 3/-

7 Capacitor 1000uf 2 10/- 20/-

8 Capacitor 100uf 5 2/- 10/-

9 Capacitor 10uf 4 1/- 4/-

10 Capacitor 33pf 4 3/- 12/-

11 8 pin Connector 2 10/- 20/-

12 2 pin Connector 6 5/- 30/-

13 Transistor BC 547 2 1/- 2/-

14 Heat Sink 1 25/- 25/-

15 DC Motor 2 125/- 250/-

16 IC L293D 1 50/- 50/-

17 IR Sensor 4 125/- 500/-

18 LED 5 2/- 10/-

19 MAX 232 1 50/- 50/-

20 LCD 16x2 1 130/- 130/-

21 Resistor Package 2 10/- 20/-

22 IC BASE 4 10/- 40/-

23 Transformer 0-12V/500ma 1 150/- 150/-

24 IC 7805 1 10/- 10/-

25 IC 7812 1 10/- 10/-

26 Train Set 1 900/- 900/-

Total 2398/-

Page 78: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

78

CONCLUSION

Page 79: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

79

CONCLUSION

CONCLUSION:

In today’s industrial scenario, to survive in the global competition, every Agro-

based industry is forced to use automated process. Today’s industrial scenario demands use of

automated process because of global competition.

Automation system is more advantageous than manual system related parameters

are speed, time saving, accuracy, man power etc Knowing working principle, configuration

procedure & trouble shooting techniques along with designing of logic is a key factor in

industrial automation. It can be considered as the first serious attempt to fulfill the requirements

for a universal industry system. The automation standard provides a common set of compatible

services and capabilities to all industrial users.

Hence it is suggested that we put in more resources to research on new horizons

as early as possible for a better life for us!!

Page 80: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

80

REFERENCE

REFERENCES

Page 81: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

81

Books:-

Microcontroller and embedded system. :- Mazidi

Principle of electronics:-V.K. Mehta

Applied Electronics:-R.S. Seddha

Digital principle & application:-Malvino & Leach

Real time operating system:- Dr. K.K.V. Prasad

Websites:-

www.houstuff.com

www.DNAtechindia.com

www.wikipedia.com

www.altavista.com

Search Engine:-

www.google.com

www.yahoo.com

www.altavista.com

Magazines:-

Electronics for you

Electronics express

Page 82: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

82

DATASHEET

&

PHOTOGRAPH

Page 83: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

83

Page 84: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

84

Page 85: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

85

Page 86: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

86

Page 87: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

87

Page 88: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

88

Page 89: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

89

Page 90: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

90

Page 91: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

91

Page 92: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

92

Page 93: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

93

Page 94: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

94

Page 95: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

95

Page 96: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

96

Page 97: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

97

RS232

Pin Signal Pin Signal

1 Data carrier detect 6 Data set ready

2 Received data 7 Request to send

3 Transmitted data 8 Clear to send

4 Data terminal ready 9 Ring indicator

5 Signal ground

Page 98: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

98

Page 99: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

99

Page 100: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

100

Page 101: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

101

Page 102: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

102

Page 103: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

103

Page 104: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

104

PHOTOGRAPH

Page 105: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

105

Page 106: INTELIGENT RAILWAY SYSTEM

Visualize Gate Control and Track Switching

106