Vous êtes sur la page 1sur 51

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

1. INTRODUCTION TO EMBEDDED SYSTEMS


Present project is designed using AT89S52 microcontroller to avoid railway accidents happening at unattended railway gates, if implemented in spirit. This project utilizes two powerful IR transmitters and two receivers; one pair of transmitter and receiver is fixed at up side (from where the train comes) at a level higher than a human being in exact alignment and similarly the other pair is fixed at down side of the train direction. Sensor activation time is so adjusted by calculating the time taken at a certain speed to cross at least one compartment of standard minimum size of the Indian railway. We have considered 5 seconds for this project. Sensors are fixed at 1km on both sides of the gate. We call the sensor along the train direction as foreside sensor and the other as aft side sensor. When foreside receiver gets activated, the gate motor is turned on in one direction and the gate is closed and stays closed until the train crosses the gate and reaches aft side sensors. When aft side receiver gets activated motor turns in opposite direction and gate opens and motor stops. Buzzer will immediately sound at the fore side receiver activation and gate will close after 5 seconds, so giving time to drivers to clear gate area in order to avoid trapping between the gates and stop sound after the train has crossed. The same principle is applied for track switching. Considering a situation wherein an express train and a local train are traveling in opposite directions on the same track; the express train is allowed to travel on the same track and the local train has to switch on to the other track. Two sensors are placed at the either sides of the junction where the track switches. If theres a train approaching from the other side, then another sensor placed along that direction gets activated and will send an interrupt to the controller. The interrupt service routine switches the track. Indicator lights have been provided to avoid collisions. Here the switching operation is performed using a stepper motor. Assuming that within a certain delay, the train has passed the track is switched back to its original position, allowing the first train to pass without any interruption. This concept of track switching can be applied at 1km distance from the stations.

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

1.1 EMBEDDED SYSTEM:


An embedded system is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few predefined tasks, usually with very specific requirements. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Personal digital assistants (PDAs) or handheld computers are generally considered embedded devices because of the nature of their hardware design, even though they are more expandable in software terms. This line of definition continues to blur as devices expand. With the introduction of the OQO Model 2 with the Windows XP operating system and ports such as a USB port both features usually belong to "general purpose computers", the line of nomenclature blurs even more.

Examples of Embedded Systems:


Cellular telephones and telephone switches Engine controllers and antilock brake controllers for automobiles Household appliances including microwaves, washing machines , TV.

1.2 BLOCK DIAGRAM:


2
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

IR SECTION 1

LCD

IR SECTION 2

A T 8 9 S 5 2

RED LED 1

GREEN LED 1

RED LED 2 CRYSTAL OSCILLATOR

GREEN LED 2

RESET CIRCUIT

L293D

STEPPER MOTOR

Fig 1.1: Block diagram of automatic railway gate control system

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

CIRCUIT DIAGRAM:

Fig 1.2: circuit diagram of automatic railway gate control system

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

1.3 HARDWARE IMPLEMENTATION Micro Controller (AT89S52)


Totally 40-pin DIP package manufactured with CMOS Technology.

Power supply
A variable regulated power supply, also called a variable bench power supply, is One where you can continuously adjust the output voltage to your requirements.

L293D (motor driver)


Racially L293D 16DIP/ULN 2003 IC is used to drive the stepper motor.

Stepper motor
This is used to open and close the gates automatically when it is rotated clock wise or anticlockwise direction.

Proximity Sensor
Two IR sensor pairs (IC 555) are used for transmitting and receiving signals.

Buzzer Alarm
When the security system detects an intruder, the microcontroller activates the Buzzer alarm and the telephone auto dialer.

1.4 SOFTWARE REQUIREMENTS


Keil Vision. Languages: Embedded (Or) Assembly language.

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

2. MICROCONTROLLER ARCHITECTURE (AT89S52)


2.1 GENERAL DESCRIPTION
The 8051 is an original member of the 8051 family. There are two other members in the 8051 family of microcontrollers. They are 8052 and 8031. All the three microcontrollers will have the same internal architecture, but they differ in amount of memory and the number of timers. In the concerned project 8052 microcontroller is used. Here microcontroller used is AT89S52, which is manufactured by ATMEL laboratories.

2.1.1 FEATURES OF AT89S52


AT89S52 has 8kB Flash and 256 bytes of data RAM 32 I/O lines, three 16-bit timer/counters, an Eight-vector two level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The power down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset. The Flash program memory supports both parallel programming and in Serial In-system Programming(ISP). The 89S52 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running. By combining a versatile 8-bit CPU with Flash on a monolithic chip. The Atmel AT89S52 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications. 6
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Fig 2.1: Pin diagram of AT89S52

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

2.1.2 PIN DESCRIPTION


VCC Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND Pin 20 is the ground.

Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order, address/data bus during accesses to external program and data memory. In this mode, P0 has internal pullups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively.

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Port Pin Alternate Functions P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control) Port 1 also receives the low-order address bytes during Flash programming and program verification. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table.

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Port Pin Alternate Function Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Alternate Functions RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory Write strobe) RD (external data memory read strobe)

Table 2.1: Port pins & their alternate functions Port 3 also receives some control signals for Flash programming and programming verification. RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH.

PSEN

10

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Program Store Enable is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP External Access Enable EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier

Oscillator Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, Either a quartz crystal or ceramic resonator may be used.

11

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

2.2 AT89S52 BLOCK DIAGRAM DESCRIPTION


A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 1. Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. Timer 2 Registers Control and status bits are contained in registers T2CON (shown in Table 2) and T2MOD (shown in Table 4) for Timer 2. The register pair (RCAP2H, RCAP2L) are the capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode. Interrupt registers the individual interrupt enable bits are in the IE register. Two priorities can be set for each of the sixinterrupt sources in the IP register.

Fig.2.2 Top View of AT89S52 Microcontroller

12

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Fig. 2.3 AT89S52 Microcontroller Architecture 13


SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Table 2.2: Timer/Counter2 control register

2.3 DATA MEMORY EEPROM and RAM:


The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. That means the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address 14
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing access SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

Timer 0 and 1
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89S51.

Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 3. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency. In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count 15
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle

Table 2.3: Timer 2 operating modes

2.4 REGISTERS
Registers: In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8052 registers are 8bit registers. In the 8052 there is only one data type: 8bits. The 8bits of a register are shown in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above registers are 8-bits, except DPTR and the program counter.

16

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

3. REGULATED POWER SUPPLY


3.1 DESCRIPTION
A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide. Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need to build a regulated 5 volt source. Usually you start with an unregulated power supply ranging from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the Microcontroller Beginner Kit.).

3.1.1 CIRCUIT FEATURES:

Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA

Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot

Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation Availability of components: Easy to get, uses only very common basic components

Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects

17

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Un regulated DC 8-18V power supply Power supply current: Needed output current + 5 mA

3.2.1 BLOCK DIAGRAM:

Fig 3.1: Block diagram of regulated power supply

3.2.2 CIRCUIT DIAGRAM:

18

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Fig 3.2: circuit diagram of regulated power supply

TRANSFORMER:
Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the AC input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.

Fig. 3.3 transformer functioning

RECTIFIER:
19
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

A rectifier converts AC to DC, but the DC output is varying. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. The Bridge rectifier is a circuit, which converts an AC voltage to dc voltage using both half cycles of the input ac voltage.

Fig. 3.4: Bridge rectifier

FILTER:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.

Fig 3.5: Capacitor Filter REGULATOR: 20


SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Eliminates ripple by setting DC output to a fixed voltage. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels. PIN DESCRIPTION: Pin No 1 2 3 Function Input voltage (5V-18V) Ground (0V) Regulated output; 5V (4.8V-5.2V) Name Input Ground Output

TABLE 3.1: PIN DESCRIPTION OF 7805

4. LIGHT EMITING DIODES


It is a semiconductor diode having radioactive recombination. It requires a definite amount of energy to generate an electron-hole pair. The same energy is released when an electron recombines with a hole. This released energy may result in the emission of photon and such a recombination. Hear the amount of energy released when the electro reverts from the conduction band to the valence band appears in the form of radiation. Alternatively the released energy may result in a series of phonons causing lattice vibration. Finally the released energy may be transferred to another electron. The recombination radiation may be lie in the infra-red and visible light spectrum. In forward is peaked around the band gap energy and the phenomenon is called injection luminescence. I n a junction biased in the avalanche break down region, there results a spectrum of photons carrying much higher energies. Almost White light then gets emitted from micro-plasma breakdown region in silicon junction. Diodes having radioactive recombination are termed as Light Emitting Diode, abbreviated as LEDs.

21

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

In gallium arsenide diode, recombination is predominantly a radiation recombination and the probability of this radioactive recombination far exceeds that in either germanium or silicon. Hence Ga As LED has much higher efficiency in terms of Photons emitted per carrier. The internal efficiency of Ga As LED may be very close to 100% but because of high index of refraction, only a small fraction of the internal radiation can usually come out of the device surface. In spite of this low efficiency of actually radiated light , these LEDs are efficiency used as light emitters in visual display units and in optically coupled circuits, The efficiency of light generation increases with the increase of injected current and with decreases in temperature. The light so generated is concentrated near the junction since most of the charge carriers are obtained within one diffusion length of the diode junction. The following are the merits of LEDs over conventional incandescent and other types of lamps 1. Low working voltages and currents 2. Less power consumption 3. Very fast action 4. Emission of monochromatic light 5. small size and weight 6. No effect of mechanical vibrations 7. Extremely long life Typical LED uses a forward voltage of about 2V and current of 5 to 10mA. Ga As LED produces infra-red light while red, green and orange lights are produced by gallium arsenide phosphide (Ga As) and gallium phosphide (Gap).

4.1: Light Emitting Diodes (LEDs):

Example:

Circuit symbol:
Fig. 4 LED

Function:
22
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

LEDs emit light when an electric current passes through them.

Connecting and soldering:


LEDs must be connected the correct way round, the diagram may be labeled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you can see inside the LED the cathode is the larger electrode (but this is not official identification risk is small unless you are very slow. No special precautions are needed for soldering. an

Testing an LED:
Never connect an LED directly to a battery or power supply! It will be destroyed almost instantly because too much current will pass through and burn it out. LEDs must have a resistor in series to limit the current to a safe value, for quick testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or less. Remember to connect the LED the correct way round!

4.2 COLORS of LEDs:


LEDs are available in red, orange, amber, yellow, green, and blue and white. Blue and white LEDs are much more expensive than the other colors. The color of an LED is determined by the semiconductor material, not by the coloring of the 'package' (the plastic body). LEDs of all colors are available in uncolored packages which may be diffused (milky) or clear (often described as 'water clear'). The colored packages are also available as diffused (the standard (type) or transparent. 23
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Tri-color LEDs:
The most popular type of tri-color LED has a red and a green LED combined in one package with three leads. They are called tri-color because mixed red and green light appears to be yellow and this is produced when both the red and green LEDs are on. The diagram shows the construction of a tri-color LED. Note the different lengths of the three leads. The centre lead (k) is the common cathode for both LEDs; the outer leads (a1 and a2) are the anodes to the LEDs allowing each one to be lit separately, or both together to give the third color. Tri-color LEDs are can designed for any application where wash lights are needed. Smooth and output even makes these lights perfect for front light applications.it eliminates multi colored shadows.

Bi-color LEDs:
A bi- color LED has two LEDs wired in 'inverse parallel' (one forwards, one backwards) combined in one package with two leads. Only one of the LEDs can be lit at one time and they are less useful than the tri-color LEDs described above.

4.3: Calculating an LED resistor value:


An LED must have a resistor connected in series to limit the current through the LED; otherwise it will burn out almost instantly.

24

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

The resistor value, R is given by

R = (VS - VL) / I

VL=LED voltage.

voltage

(usually

2V,

but

4V

for

blue

and

white

LEDs)

I = LED current (e.g. 20mA), this must be less than the maximum permitted, VS =supply

Working out the LED resistor formula using Ohm's law: Ohm's law says that the resistance of the resistor, R = V/I, Where: V=voltage across resistor I=current through resistor.

4.4 LEDs IN GATE CONTROL SYSTEM: Warning for Road users:


At that moment the train arrival is sensed on either of the gate, road users are warned about the train approach by RED signal placed to caution the road users passing through the gate .RED signal appears for the road user, once the train cuts the relay sensor placed before the 5Kms before the gate .A buzzer is for train, when there is any obstacle; signal is made RED for train in order to slow done its speed before 5km from gate.

Initial Signal Display:


Signals are placed near gate each at a specified distance. Train may be approaching gate at either direction so all four signals are made RED initially to indicate gate is OPENED and vehicles are going through gate. The road user signals are made GREEN so that they freely move through gate. Buzzer is OFF since there is no approach of train and users need not be warned. 25
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

5. L293D PUSH-PULL FOUR CHANNEL DRIVER


FEATURES OF L293D:
600mA OUTPUT CURRENT CAPABILITY PER CHANNEL 1.2A PEAK OUTPUT CURRENT (non repetitive) PER CHANNEL ENABLE FACILITY OVERTEMPERATURE PROTECTION LOGICAL "0" INPUT VOLTAGE UP TO 1.5 V (HIGH NOISE IMMUNITY) INTERNAL CLAMP DIODES

5.1: DESCRIPTION
The Device is a monolithic integrated high voltage, high current four channel driver designed to accept standard DTL or TTL logic levels and drive inductive loads (such as relays solenoids, DC and stepping motors) and switching power transistors. 26
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

To simplify use as two bridges each pair of channels is equipped with an enable input. A separate supply input is provided for the logic, allowing operation at a lower voltage and internal clamp diodes are included. This device is suitable for use in switching applications at frequencies up to 5 kHz. The L293D is assembled in a 16 lead plastic package which has 4 center pins connected together and used for heat sinking. The L293DD is assembled in a 20 lead surface mount which has 8 center pins connected together and used for heat sinking. The ULN2001A, ULN2002A, ULN2003 and ULN2004Aare high Voltage, high current Darlington arrays each containing seven open collector Darlington pairs with common emitters. Darlington pairs are back to back connection of two transistors with some source resistors.

BLOCK DIAGRAM:

Fig 5.1: Block diagram of L293D

PIN CONNECTIONS:
27
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

28

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

5.2 ASSEMBLY INSTRUCTIONS:


1. Check the components supplied in the Kit against the Component list and identify all the components. 2. It is generally best to solder the lowest height components first. Solder the components in the following order: 3. Jumpers, resistors, diodes, IC base, transistors and other components. 4. Take care of terminals polarity while soldering diodes, LED s and electrolytic capacitors. 5. Identify the terminals of transistors and solder them in correct direction. 6. Connect the LCD with the help of 16-pin male-female work-strip connector. 7. Use flux cored lead to avoid dry solderability. 8. Inspect the solder points against dry solder / excess solder 9. Now insert the preprogrammed microcontroller in the IC base firmly. 10. Adjust the 10K preset (near LCD) to correct contrast display level of LCD. 11. Ensure that the ac voltage to the kit is 12V. For this, use 230/12V step down transformer with 500mA or more current rating. 12. Use heat sink for voltage regulator, if required.

5.3 ADVANTAGES:
Efficient way of speed control of DC motor. Produces more torque.

29

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Produces less noise.

5.4 APPLICATIONS:
Industries. Home appliance.

6. STEPPER MOTOR
6.1 DESCRIPTION:
A stepper motor (or step motor) is a brushless, synchronous electric motor that can divide a full rotation into a large number of steps. The motor's position can be controlled precisely, without any feedback mechanism (see open loop control). Stepper motors are similar to switched reluctance motors (which are very large stepping motors with a reduced pole count, and generally are closed-loop commutated).

Fig .6 Stepper Motor

6.1.1: FUNDAMENTALS OF OPERATION


Stepper motors operate differently from normal DC motors, which rotate when voltage is applied to their terminals. Stepper motors, on the other hand, effectively have multiple "toothed" electromagnets arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external control circuit, such as a microcontroller. To 30
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

make the motor shaft turn, first one electromagnet is given power, which makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth are thus aligned to the first electromagnet, they are slightly offset from the next electromagnet. So when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to align with the next one, and from there the process is repeated. Each of those slight rotations is called a "step," with an integral number of steps making a full rotation. In that way, the motor can be turned by a precise angle.

6.2 STEPPER MOTOR CHARACTERISTICS


Stepper motors are constant power devices. As motor speed increases, torque decreases. The torque curve may be extended by using current limiting drivers and increasing the driving voltage. Steppers exhibit more vibration than other motor types, as the discrete step tends to snap the rotor from one position to another. This vibration can become very bad at some speeds and can cause the motor to lose torque. The effect can be mitigated by accelerating quickly through the problem speed range, physically damping the system, or using a micro-stepping driver. Motors with a greater number of phases also exhibit smoother operation than those with fewer phases.

6.2.1: OPEN-LOOP VS CLOSED LOOP COMMUTATION


Steppers are generally commutated open loop, i.e. the driver has no feedback on where the rotor actually is. Stepper motor systems must thus generally be over engineered, especially if the load inertia is high, or there is widely varying load, so that there is no possibility that the motor will lose steps. This has often caused the system designer to consider the trade-offs between a closely sized but expensive servomechanism system and an oversized but relatively cheap stepper. A new development in stepper control is to incorporate a rotor position feedback (e.g. an encoder or resolver), so that the commutation can be made optimal for torque generation according to actual rotor position. This turns the stepper motor into a high pole count brushless servo motor, with exceptional low speed torque and position resolution. An advance on this technique is to normally run the motor in open loop mode, and only enter 31
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

closed loop mode if the rotor position error becomes too large -- this will allow the system to avoid hunting or oscillating, a common servo problem. There are three main types of stepper motors: 1. Permanent stepper 2. Hybrid synchronous stepper 3. Variable reluctance stepper.

32

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

7. LCD
7.1 DESCRIPTION:
Liquid crystal display (LCD) has material which combines the properties of both liquid and crystals. They have a temperature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped together in an order form similar to a crystal. A model described here is for its low price and great possibilities most frequently used in practice. It is based on the HD44780 microcontroller ( Hitachi) and can display messages in two lines with 16 characters each. It displays all the alphabets, Greek letters, punctuation marks, mathematical symbols etc. In addition, it is possible to display symbols that user makes up on its own. Automatic shifting message on display (shift left and right), appearance of the pointer, backlight etc. are considered as useful characteristics. These components are specialized for being used with the microcontrollers, which means that they cannot be activated by standard IC circuits. They are used for writing different messages on a miniature LCD.

7.2 PIN FUNCTIONS:

Fig. 7.1 LCD

33

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Control Signals It's function = 0 Writes character in display R/W = 1 Reads from display = 0 Selects command register = 1 Selects Data register to display RS/DI character = 0 Disables the display = 1 Enables the display

En

Table 7.1: LCD control signals description LCD displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8 x 80 pixels of the display. Hitachi LCD displays have a standard ASCII set of characters plus Japanese, Greek and mathematical symbols. This display contains two internal byte-wide registers, one for command and second for characters to be displayed. There are three control signals called R/W, DI/RS and En. The table given below will tell you what the use of these three signals is. By making RS/DI signal 0 you can send different commands to display. These commands are used to initialize LCD, to select display pattern, to shift cursor or screen etc. The different commands and their functions are as given below

34

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tri-state which means they are in a state of high impedance (as though they are disconnected) and this means they do not interfere with the operation of the microcontroller when the display is not being addressed. The LCD also requires 3 "control" lines from the microcontroller. Enable (E) When (E) line is high, the LCD checks the state of the two control lines and

responds accordingly. When E is low, the LCD is disabled. Read/Write (R/W) When it is low, data is written to the LCD. When it is high, data is read from the LCD. Register select (RS) When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD. Bits Function RS/DIR/W D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 0 0 0 0 0 1 Clear LCD memory, Home cursor 0 0 0 0 0 0 0 0 1 0 Clear and Home cursor only s = 1/0 : Shift screen/cursor, I/O = 1/0 0 0 0 0 0 0 0 1 I/O s : shift R/L D = 1/0 : Screen On/Off. C = 1/0 : 0 0 0 0 0 0 1 D C B cursor On/Off. B = 1/0 : Cursor blink/no blink S/C = 1/0 : Screen / Cursor. R/L = 1/0 : Shift one space right / left D/L = 1/0 : 8/4 bits per character. N = 1/0 : 2/1 rows of char. F = 1/0 : 510/57 dots/char. Write to char. RAM address after this Writes to display RAM address after this BF = 1/0 : display is busy/not busy Write byte to last RAM chosen
SRTIST/ECE

S/C R/L 0

0 0 0

0 0 0 1 0

0 0 1

0 1

DL N

Char address

Display data address

BF Current address Character type 35

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Character type

Read byte from last RAM chosen

Table 7.2: LCD bits and their functions

Read data from data lines (if it is reading).


Reading data from the LCD is done in the same way, but control line R/W has to be high. When we send a high to the LCD, it will reset and wait for instructions. Typical instructions sent to LCD display after a reset are: turning on a display, turning on a cursor and writing characters from left to right. When the LCD is initialized, it is ready to continue receiving data or instructions. If it receives a character, it will write it on the display and move the cursor one space to the right. The Cursor marks the next location where a character will be written. When we want to write a string of characters, first we need to set up the starting address, and then send one character at a time. Characters that Before we access DD RAM after defining a special character, the program must set the DD RAM address. Writing and reading data from any LCD memory is done from the last address, which was set up using set-address instruction. Once the address of DD RAM is set, a new written character will be displayed at the appropriate place on the screen. Until now we discussed the operation of writing and reading to an LCD as if it were an ordinary memory. But this is not so. The LCD controller needs 40 to 120 microseconds (uS) for writing and reading. Other operations can take up to 5 mS. During that time, the microcontroller can not access the LCD, so a program needs to know when the LCD is busy. We can solve this in two ways. One way is to check the BUSY bit found on data line D7. This is not the best method because LCD's can get stuck, and program will then stay forever in a loop checking the BUSY bit. The other way is to introduce a delay in the program. The delay has to be long enough for the LCD to finish the operation in process. Instructions for writing to and reading from an LCD memory are shown in the previous table. At the beginning we mentioned that we needed 11 I/O lines to communicate with an LCD. However, we can communicate with an LCD through a 4-bit data bus. Thus we can 36
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

reduce the total number of communication lines to seven. The wiring for connection via a 4-bit data bus is shown in the diagram below. In this example we use an LCD display with 2x16 characters.

LCD SCREEN:
LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built in backlight (blue or green diodes). When used during operating, a resistor for current limitation should be used (like with any LE diode).

Fig.7.2 LCD Configuration

7.3 FEATURES:

16 Characters x 2 Lines 5x7 Dot Matrix Character + Cursor HD44780 Equivalent LCD Controller/driver Built-In 4-bit or 8-bit MPU Interface Standard Type Works with almost any Microcontroller Maximum input voltage: 5.3VDC 37
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Operating input voltage: 5VDC 8-bit interface data bus Controller: HD47780 equivalent 14 pin/terminals

8. IR SENSORS
8.1 INTRODUCTION:
This infrared sensor also called as IR sensors, consists of two parts: 1. IR transmitter circuit 2. IR receiver unit

8.2 IR TRANSMITTER UNIT:

Fig. 8.1 IR Transmitter unit The transmitter circuit consists of the following components: 1. IC 555 2. Resistors 38
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

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

8.3 IR RECEIVER UNIT:

Fig. 8.2 IR Receiver unit The receiver circuit consists of the following components: 1. TSOP1738 (sensor) 2. IC 555 3. Resistors 4. Capacitors

39

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

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

9. SOFTWARE DESCRIPTION
ABOUT SOFTWARE
Software used: *Keil software for c programming 9.1 ABOUT KEIL SOFTWARE: Keil compiler is software used where the machine language code is written and compiled. After compilation, the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Keil compiler also supports C language code. 9.2 STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL AND HOW TO COMPILE IT: Install the Keil Software in the PC in any of the drives. After installation, an icon will be created with the name Keil uVision3. Just drag this icon onto the desktop so that it becomes easy whenever you try to write programs in keil. Double click on this icon to start the keil compiler.

40

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

A page opens with different options in it showing the project workspace at the leftmost corner side, output window in the bottom and an ash coloured space for the program to be written.

Now to start using the keil, click on the option project. A small window opens showing the options like new project, import project, open project etc. Click on New project. A small window with the title bar Create new project opens. The window asks the user to give the project name with which it should be created and the destination location. The project can be created in any of the drives available. You can create a new folder and then a new file or can create directly a new file.

After the file is saved in the given destination location, a window opens where a list of vendors will be displayed and you have to select the device for the target you have created.

The most widely used vendor is Atmel. So click on Atmel and now the family of microcontrollers manufactured by Atmel opens. You can select any one of the microcontrollers according to the requirement.

When you click on any one of the microcontrollers, the features of that particular microcontroller will be displayed on the right side of the page. The most appropriate microcontroller with which most of the projects can be implemented is the AT89C51. Click on this microcontroller and have a look at its features. Now click on OK to select this microcontroller.

A small window opens asking whether to copy the startup code into the file you have created just now. Just click on No to proceed further. Now you can see the TARGET and SOURCE GROUP created in the project workspace. Now click on File and in that New. A new page opens and you can start writing program in it. After the program is completed, save it with any name but with the .asm extension. Save the program in the file you have created earlier.

41

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

You can notice that after you save the program, the predefined keywords will be highlighted in bold letters. Now add this file to the target by giving a right click on the source group. A list of options open and in that select Add files to the source group. Check for this file where you have saved and add it.

Right click on the target and select the first option Options for target. A window opens with different options like device, target, output etc. First click on target. Since the set frequency of the microcontroller is 11.0592 MHz to interface with the PC, just enter this frequency value in the Xtal (MHz) text area and put a tick on the Use on-chip ROM. This is because the program what we write here in the keil will later be dumped into the microcontroller and will be stored in the inbuilt ROM in the microcontroller.

Now click the option Output and give any name to the hex file to be created in the Name of executable text area and put a tick to the Create HEX file option present in the same window. The hex file can be created in any of the drives. You can change the folder by clicking on Select folder for Objects.

Now to check whether the program you have written is errorless or not, click on the icon exactly below the Open file icon which is nothing but Build Target icon. You can even use the shortcut key F7 to compile the program written.

To check for the output, there are several windows like serial window, memory window, project window etc. Depending on the program you have written, select the appropriate window to see the output by entering into debug mode.

The icon with the letter d indicates the debug mode. Click on this icon and now click on the option View and select the appropriate window to check for the output. After this is done, click the icon debug again to come out of the debug mode. The hex file created as shown earlier will be dumped into the microcontroller with the help of software called PROLOAD.

9.3 PROLOAD: 42
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Proload is software which accepts only hex files. Once the machine code is converted into hex code, that hex code has to be dumped into the microcontroller placed in the programmer kit and this is done by the Proload. Programmer kit contains a microcontroller on it other than the one which is to be programmed. This microcontroller has a program in it written in such a way that it accepts the hex file from the keil compiler and dumps this hex file into the microcontroller which is to be programmed. As this programmer kit requires power supply to be operated, this power supply is given from the power supply circuit designed above. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply, a source is required. Thus this is accomplished from the power supply board with an output of 12volts or from an adapter connected to 230 V AC.

Install the Proload Software in the PC. Now connect the Programmer kit to the PC (CPU) through serial cable. Power up the programmer kit from the ac supply through adapter. Now place the microcontroller in the GIF socket provided in the programmer kit. Click on the Proload icon in the PC. A window appears providing the information like Hardware model, com port, device type, Flash size etc. Click on browse option to select the hex file to be dumped into the microcontroller and then click on Auto program to program the microcontroller with that particular hex file.

The status of the microcontroller can be seen in the small status window in the bottom of the page. After this process is completed, remove the microcontroller from the programmer kit and place it in your system board. Now the system board behaves according to the program written in the microcontroller.

43

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

The following sections list the Vision3 commands that can be reached by menu commands, toolbar buttons, and keyboard shortcuts. The Vision3 commands are grouped mainly based on the appearance in the menu bar:

File Menu and File Commands Edit Menu and Editor Commands o Outlining Menu o Advanced Menu o Selecting Text Commands View Menu Project Menu and Project Commands Debug Menu and Debug Commands Flash Menu Peripherals Menu Tools Menu SVCS Menu Window Menu Help menu

10. CODING
Program written in C language:
#include<at89x52.h> /********************* Port Initialization ***************************************/ #define motor P2 #define ir1 P1_1 #define ir2 P1_0 #define red P3_4 #define yellow P3_5 #define green P3_6 /******************** generating a delay of 1 sec ********************************/ Delay () { int i; for (i=0;i<=2500;i++); 44
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

} /******************** generating a delay of 10 sec ********************************/ delay1() { int i; for (i=0;i<=25000;i++); } /******************** Rotating motor in clockwise direction ***********************/ motor_cw () { int j; for (j=0;j<4;j++) { P2=0x66; Delay (); P2=0x33; delay(); P2=0x99; delay(); P2=0xcc; delay(); } } /******************* Rotating motor in anti clockwise direction *******************/ motor_acw() { int j; for(j=0;j<4;j++) { P2=0x66; delay(); P2=0xcc; delay(); P2=0x99; delay(); P2=0x33; delay(); 45
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

} } /******************* Beginning of the main program ********************************/ main() { unsigned int a=0, b=1; /* Initialising temporary variables */ while(1) { red=1; yellow=1; green=0;

/* Red light off */ /* Yellow light off */ /* Green light on */

if((ir1==0 || ir2==0) && a==0) /* Condition to check the arrival of the train */ { motor_cw(); /* Closing the gate */ red=0; yellow=1; green=1; for(;((ir1==1 && ir2==0) || (ir1==0 && ir2==1));) /* Condition for the gate to be closed while the train is present at the two sensors */ { if((ir1==1 && ir2==1) || (ir1==1 || ir2==1) || (ir1==0&ir2==0)) { a=1; b=0; } } if((ir1==0 && ir2==1 ) || (ir2==0 && ir1==1)||(ir1==1 && ir2==1)) /* Condition for the gate to be closed while the train is in between the two sensors */ { for(;(ir1==1 && ir2==1);) ; a=1; b=0; } }

46

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

if((ir2==1 && ir1==1) && b==0) /* Condition to check the departure of train from the railway crossing */ { red=1; yellow=0; motor_acw(); /* Opening the gate */ delay(); delay1(); yellow=1; green=0; delay(); delay1(); delay(); green=1; b=1; a=0; } }

47

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

11. APPLICATIONS&ADVANTAGES
APPLICATIONS:
Real time transport systems. Same principle can be used for automatic track switching. Garage door opening.

Fig.11.1 Track changing unit

ADVANTAGES:
Accident avoidance. Human Resource. Safety and quality of services.

48

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

12. CONCLUSION
The accidents are avoided at places where there is no person manning the railway crossing gates. Here we use the stepper motor to open and close the gates automatically when it is rotated clockwise or anticlockwise direction. When the train arrives in a particular direction the transmitter IR senses and generates appropriate signal, then at the same time the receiver IR receives the signal and generates an interrupt. When the interrupt is generated the stepper motor rotates in clockwise direction. When the interrupt ends the stepper motor rotates in anti clock wise direction.

SCOPE OF PROJECT
This project is developed in order to help the INDIAN RAILWAYS in making its Based on the responses and reports obtained as a result of the significant

present working system a better one, by eliminating some of the loopholes existing in it. development in the working system of INDIAN RAILWAYS, this project can be further extended to meet the demands according to situation. This can be further implemented to have control room to regulate the working of

the system. Thus becomes the user friendliness. This circuit can be expanded and used in a station with any number of platforms

as per the usage. Additional modules can be added with out affecting the remaining modules. This

allows the flexibility and easy maintenance of the developed system. This system consists of following features over manual system: 49 There is no time lag to operate the device. Accuracy.
SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

Simulation is provided to reflect the present status of the system. End user can operate this without knowing about electronics.

13. BIBLIOGRAPHY
BOOKS REFERRED

Kenneth .J. Ayala The 89C51 Microcontroller Architecture programming and Applications, Pen ram International. D.RoyChoudary and Sail Jain L.I.C, New Age International. Principles of Electronics by V.K.MEHTA. Communication Systems by Simon Hawkins.

WEB REFERENCES

http://www.scribd.com/ http://www.datasheets.com/ http://www.atmel.com/ http://www.learn-c.com/adc0809.pdf

50

SRTIST/ECE

AUTOMATIC RAILWAY GATE CONTROL SYSTEM

51

SRTIST/ECE

Vous aimerez peut-être aussi