Académique Documents
Professionnel Documents
Culture Documents
ABSTRACT
The purpose of this project is to develop an automatic railway gate system that
uses the microcontroller as a main function of design. The principle objective of this
project was to design an automatic railway gate control by microcontroller. This project
deals to develop a prototype of railway gate that function automatically by using
microcontroller. Besides that, the interfacing program also had been developed for the
integration part. The operation using microcontroller (AT89S52) that integrated with
other circuits involved such as power supply, IR sensor, light and buzzer, gate motor and
LCD display. All the circuits will be combining to demonstrate the operation of
microcontroller (AT89S52). This system will make improvement towards the manually
operation before this. Human supervision will be considered if there are problems
occurred while this system was operated.
CONTENTS
CHAPTER TITLE
PAGE
PROJECT TITLE
ii
STUDENTS DECLARATION
iii
SUPERVISORS DECLARATION
iv
DEDICATION
ACKNOWLEDGEMENT
vi
ABSTRACT
vii
ABSTRAK
viii
CONTENTS
ix
LIST OF TABLES
xii
LIST OF FIGURES
xiii
LIST OF APPENDICES
xvi
INTRODUCTION
1.1
Project Introduction
1.2
Project Objectives
1.3
Problem Statement
1.4
Scope of Works
1.5
Methodology
1.6
Report Structure
II
LITERATURE REVIEW
2.1
Previous System
2.2
2.3
10
Microcontroller
10
2.3.1 AT89S52
11
2.4
Programming Language
13
2.5
Infrared Sensor
14
2.5.1 IR Transmitter
14
2.5.2 IR Receiver
15
2.6
Motor Theory
16
2.7
H-Bridge
17
2.7.1 L293D
III
18
2.8
LCD
19
2.9
Proteus VSM
20
23
METHODOLOGY
26
3.1
Project Methodology
26
3.2
28
3.3
System Flow
29
Hardware Assembly
30
31
xi
IV
33
4.1
System Explanation
33
4.2
36
36
38
39
40
41
44
46
47
47
48
4.4
50
4.5
Hardware Description
53
53
57
4.3
IV
59
5.1
Conclusion
59
5.2
Recommendation
60
REFERENCES
61
xii
LIST OF TABLES
NO.
TITLE
PAGE
43
xiii
LIST OF FIGURES
NO.
TITLES
PAGE
2.2.1
2.2.2
12
12
2.5.1
14
Infrared sensor
14
15
2.6.1
Stepper motor
16
2.6.2
Servo motor
16
2.6.3
DC motor
17
2.7.1
17
18
19
2.8
LCD
19
2.9.1
Proteus VSM
20
2.9.2
21
2.9.3
21
2.9.4
Components selection
22
2.9.5
Parameter settings
22
xiv
2.9.6
Simulation buttons
23
2.10.3
24
2.10.4
Example program
25
2.10.5
Compile summary
25
3.2
28
3.3
29
30
3.4.1
31
4.1.1
33
4.2.1.1
36
37
4.2.1.3
37
38
39
4.2.4.1
40
4.2.5.1
41
4.2.6.1
44
4.2.7.1
46
47
4.3.2.1
48
4.3.2.2
49
4.4.1
52
4.5.1.1
53
4.5.1.2
53
54
55
xv
55
56
57
58
xvi
LIST OF APPENDICES
NO.
TITLES
PAGE
Gantt Chart
63
65
CHAPTER I
INTRODUCTION
1.1
Project Introduction
In general, this project utilizes the importance of microcontroller as a main
design. It used to provide improvement into manual system that exist nowadays.
Microcontroller is a small unit of controller that acted following the instruction
programmed. All the circuits included in this prototype were designed following the
suitability of AT89S52.
This automatic railway gate system was operated after signal received from the
IR sensor. This signal used to trigger the AT89S52 for operating the gate motor and
alarm indicators by instruction programmed.
Electronic applications used to enable this system operated in automatic mode.
The computer usage must be fully utilized to building up a system that encourage
implementing of the technology.
2
1.2
Project Objectives
The microcontroller (AT89S52) is use to demonstrate the integration of computer
ii.
iii.
1.3
Problem Statement
Nowadays, the railway gate is operating by manual operation. It is operating in
the area that there are railway line junction with the road. The railway gate management
has to employ workers to be on duty for control the operation. Due to this, the worker
will manually open and close the gate with under supervision.
This prototype will introduce the automatic railway gate operation. This system
will make improvement towards the manually operation before this. Human supervision
will be considered if there are problems occurred while this system was operated.
This is an idea to perform computer integration with mechanical structure to
simulate what the system can do. Control system with computer applications will make
the management or consumer become more effective. Therefore, this is the best example
in develop railway gate management system become more efficient.
3
1.4
Scope of Works
This project covered the operation of automatic railway gate control by using
microcontroller (AT89S52). The circuits involved such as power supply, IR sensor, light
and buzzer, gate motor and LCD display.
All of these operations will be combining to demonstrate the operation of
microcontroller (AT89S52).
The operations of microcontroller works follow the instruction programmed. The
combining circuits were constructed on Proteus software to seen whether that circuits
was right or not. After that, the hardware part was constructed after all the simulation
being done.
IR sensor circuit is providing signal to triggered the AT89S52. The sensed signal
wills active the gate motor and LCD display. Alarm and indication light circuit was
provided as additional part of this system.
Additional elements can be added without affecting the remaining elements. This
allows the flexibility of the developed system.
4
1.5
Methodology
This project began with the research of the proposed title. The result of that
research is then discussed with the supervisor. Once the title of project was approved, the
background of study for this project was explored.
AT89S52 was chosen as a microcontroller. Then, the circuits simulation was
performed. In the other hand, the instruction programmed also being built for the
interfacing part. After all being settled, the construction of hardware part was started
after the components were being chosen.
In all the steps done there are troubleshooting part to resolve the problems facing.
Between hardware part and instruction programmed built, there are integrated step that
allows the AT89S52 to simulate all the operations of the system.
After all the part is complete to built, some analysis should being made to show
what the solution of the problems occurred. It involving the comparison between the
research that had been done before this.
5
1.6
Report Structure
Chapter 1 introduced the project as a whole. The early and basic explanations
were mentioned in this chapter. This chapter consisted of the project introduction and
objectives, problem statements, scope of work, and the simplified methodology.
Chapter 2 is literature review. Past projects system were taken into consideration
when completing this chapter. The ways those projects and researches had been done
were compared with what this project. These comparisons were done to understand what
this project is all about and where it stands.
Chapter 3 is methodology. It explained how this project came to be. This chapter
explained the part most important of all, the flow this project. What had been researched
and what needed to be done was explained in this chapter.
Chapter 4 concentrated on the result and discussion of this project. What had
been done was explained in diagrams and written programs. The expected results also
mentioned in this chapter.
Chapter 5 was the final chapter in this report. The conclusions and
recommendations were placed in this chapter. In other words, the conclusion was the
summary of what had been done throughout this project. After the project was done,
recommendations were made and any expansions or upgrades that might be done in the
future were suggested.
CHAPTER II
LITERATURE REVIEW
2.1
Previous System
At present scenario, in the level crossing line the railway gate is operated
normally by a gate keeper. This happen when the railway line is cross over the road and
there are a gate that have to be controlled. The gate keeper work after receiving the
information about the train arrival from the nearer station. When the train starts to leave
the station, the particular station delivers the information to give the signal for gate
keeper to get ready. This is the operation are followed for operating the railway gates.
In addition, this automatic railway gate system can contribute a lot of benefit
either to the road user or to the railway management. This type of gate can be
implementing in the level crossing where the chances of accidents are higher. The
computer integration will be use to provide addition in the latest technology.
7
2.2
8
Lighting signal also provided at the certain distance as pre cautionary step for
driver. Meanwhile, the nearer station also will provide an indication alarm to remind
them about the crossing train. If anything happened at the gates, this alarm will alert the
station. LCD display will show the arrival of the train to cross the gate as additional
features of this system.
Sensor
LCD
Motor
AT89S52
Microcontroller
Buzzer
Lighting
Alarm
DESIGN
CALLS:
V Diagram
In this place we need to discuss the role of simulation software, real-time systems
and data acquisition in dynamic test applications. Traditional testing is referred to as
static testing where functionality of components is tested by providing known inputs
and measuring outputs. Today there is more pressure to get products to market faster
and reduce design cycle times.
This has led to a need for dynamic testing where components are tested while in use
with the entire system either real or simulated. Because of cost and safety concerns,
simulating the rest of the system with real-time hardware is preferred to testing
components in the actual real system.
The diagram shown on this slide is the V Diagram that is often used to describe
the development cycle. Originally developed to encapsulate the design process of
software applications, many different versions of this diagram can be found to describe
different product design cycles. Here we have shown one example of such a diagram
representing the design cycle of embedded control applications common to automotive,
aerospace and defense applications.
In this diagram the general progression in time of the development stages is
shown from left to right. Note however that this is often an iterative process and the
actual development will not proceed linearly through these steps. The goal of rapid
development is to make this cycle as efficient as possible by minimizing the iterations
required for a design. If the x-axis of the diagram is thought of as time, the goal is to
narrow the V as much as possible and thereby reduce development time.
The y-axis of this diagram can be thought of as the level at which the system
components are considered. Early on in the development, the requirements of the
overall system must be considered. As the system is divided into sub-systems and
components, the process becomes very low-level down to the point of loading code onto
individual processors. Afterwards components are integrated and tested together until
such time that the entire system can enter final production testing. Therefore the top of
the diagram represents the high-level system view and the bottom of the diagram
represents a very low-level view.
Notes:
Reason for shape, every phase of design requires a complimentary test phase.
High-level to low-level view of application.
An embedded system is any computer system hidden inside a product other than
a computer.
There will encounter a number of difficulties when writing embedded system
software in addition to those we encounter when we write applications
Program installation you will need special tools to get your software
into embedded systems
Processor hogs computing that requires large amounts of CPU time can
complicate the response problem
2.2 APPLICATIONS
1. MILITARY AND AEROSPACE
2. COMMUNICATION
3. INDUSTRIAL
APPLICATIONS
2.3 CLASSIFICATION
1.
2.
3.
2.
Circuit Diagram
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 a.c
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.
Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating
D.C. 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.
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.
Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an
electrical regulator designed to automatically maintain a constant voltage level. In this
project, power supply of 5V and 12V are required. 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.
Notice in the above diagram that a relay uses an electromagnet. This is a device
consisting of a coil of wire wrapped around an iron core. When electricity is applied to
the coil of wire it becomes magnetic, hence the term electromagnet. The A B and C
terminals are an SPDT switch controlled by the electromagnet.
When electricity is
applied to V1 and V2, the electromagnet acts upon the SPDT switch so that the B and C
terminals are connected. When the electricity is disconnected, then the A and C terminals
are connected. It is important to note that the electromagnet is magnetically linked to
the switch but the two are NOT linked electrically.
CHAPTER 3
AT89S52
5.1 INTRODUCTION
Today, micro controllers have become an integral of all automatic and semiautomatic machines. Remote controllers, hand-held communication devices, dedicated
controllers, have certainly improved the functional, operational and performance based
specifications.
Microcontrollers are single chip microcomputers, more suited for control and
automation of machines and process. Microcontrollers have central processing unit
(CPU), memory, I/O units, timers and counters, analog to digital converters (ADC),
digital to analog converters (DAC), serial ports, interrupt logic, oscillator circuitry and
many more functional blocks on chip.
All these functional block on a single Integrated Circuit (IC), result into a
reduced size of control board, low power consumption, more reliability and ease of
integration within an application design. The usage of micro controllers not only reduces
5.2 FEATURES
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000
Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Two 16-bit Timer/Counters
Six Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
5.3 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmels high-density non-volatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pin out.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional on-volatile memory programmer. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which
PIN CONFIGURATION
BLOCK DIAGRAM
VCC
Supply voltage.
GND
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 may also be configured to be the multiplexed low order
address/data bus during accesses to external program and data memory. In this mode P0
has internal pull ups.
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 pulledlow will source current (IIL) because of the internal pull ups. Port
1 also receives the low-order address bytes during Flash programming and 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 use 16-bit addresses (MOVX @
DPTR). In this application, it uses strong internal pull ups when emitting 1s. During
accesses to external data memory that use 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
AT89C51 as listed below:
PORT PIN
ALTERNATE FUNCTIONS
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
Port 3 also receives some control signals for Flash programming and 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 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. With the
bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89C51 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, for parts that
require 12-volt VPP.
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, as shown in Figure 1. Either a
quartz crystal or ceramic resonator may be used.
To drive the device from an external clock source, XTAL2 should be left unconnected
while XTAL1 is driven as shown in Figure 2. There are no requirements on the duty
cycle of the external clock signal, since the input to the internal clocking circuitry is
through a divide-by-two flip-flop, but minimum and maximum voltage high and low
time specifications must be observed.
IDLE MODE
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active.
The mode is invoked by software. The content of the on-chip RAM and all the special
functions registers remain unchanged during this mode. The idle mode can be terminated
by any enabled interrupt or by a hardware reset.
It should be noted that when idle is terminated by a hard ware reset, the device normally
resumes program execution, from where it left off, up to two machine cycles before the
internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM
in this event, but access to the port pins is not inhibited.
To eliminate the possibility of an unexpected write to a port pin when Idle is terminated
by reset, the instruction following the one that invokes Idle should not be one that writes
to a port pin or to external memory.
Basic Specifications
Power requirements
User connector
Connector pinout
Serial Input
Operating Temperature
0 to 50 C
Initialization
Instruction prefix
LCD type
6 o'clock
ASCII Value
Clear screen
Home cursor
Hide cursor
12
14
16
20
24
28
128 + location
128
128 + n
192
192 + n
64 + address
RELAYS:
History
Electromagnetic relays were once the main ingredient in automated machinery. Factories
used to control everything from conveyors to robots with huge panels filled with
hundreds of relays clacking away, each in turn. This method had several drawbacks, but
for years it was the only method available.
Recently, Programmable Logic Controllers (PLCs) have replaced banks of relays
for automation needs. Relays are still used in small applications where a PLC would be
overkill. They come in several varieties to suit a wide range of applications.
Relays have a huge number of uses, but a few very common ones constitute the vast
majority. Holding circuits are used to hold power on until the connection is Broken by
another signal. This is achieved by connecting one of the relay's own contacts to its coil
once the relay is turned on, it stays on. . Relays are also useful for allowing one signal
to switch connections at two or more different voltages since the contacts are isolated
from each other. But most often, they are used to switch connections that are at different
voltages than the control power.
In many cases, control power and signals generated by sensors are generated at
low voltages. This is for reasons of safety and efficiency. Low voltage signals, however,
are inefficient for doing high-wattage work, so a relay is used to allow the low voltage
which
is
thrown
by
an
switch.
The
solenoid
of
most
Electromagnet
Spring
Switching contacts
relays construction
simply opens and closes an electrical circuit, just like the light switch on a wall.
When the relay is de-energized or turned off there is an electrical connection between
NC and Common hence normally closed. In the off state there is not a connection
between NO and common, hence normally open.
When the relay is energized or turned on the NO and C makes an electrical connection
and the electrical connection between NC and C is removed.
magnetic
field
attracts
an
If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a spike of voltage and might cause damage to circuit components. If
the coil is designed to be energized with AC, a small copper ring can be crimped to the
end of the solenoid. This "shading ring" creates a small out-of-phase current, which
increases the minimum pull on the armature during the AC cycle.
Relay operation
4.7.4
CHOOSING OF RELAY:
supply voltage
coil resistance
passes a current of
30mA. This is OK for a 555 timer IC (maximum output current 200mA), but it is too
much for most ICs and they will require a transistor to amplify the current.
2.Relays come in all shapes and sizes for different applications and they have various
switch contact configurations. Double Pole Double Throw (DPDT) relays are common
and even 4-pole types are available. You can therefore control several circuits with one
relay or use one relay to control the direction of a motor.
3.It is easy to tell when a relay is operating - you can hear a click as the relay switches
on and off and you can sometimes see the contacts moving.
4.7.6
Disadvantages :
Being mechanical though, relays do have some disadvantages over other methods of
electrical isolation:
1.Their parts can wear out as the switch contacts become dirty - high voltages and
currents cause sparks between the contacts.
2.They cannot be switched on and off at high speeds because they have a slow response
and the switch contacts will rapidly wear out due to the sparking.
3.Their coils need a fairly high current to energize, which means some micro-electronic
circuits can't drive them directly without additional circuitry.
4.The back-emf created when the relay coil switches off can damage the components
that are driving the coil. To avoid this, a diode can be placed across the relay coil, as
will be seen in any Electronics in Meccano circuits that use relays with sensitive
components.
4.7.7
Applications:
Relays are used:
allowed to escape slowly. The time period can be varied by increasing or decreasing the
flow rate. For longer time periods, a mechanical clockwork timer is installed.
SOFTWARE REQUIRED
The Keil tool chain consists of the following executables located in the c:\c51eval\bin
directory:
Vision uvw51e.exe
C Compiler c51.exe
Assembler a51.exe
Linker bL51.exe
dScopedsw51.exe
Vision IDE
Vision is a Windows based front end for the C Compiler and Assembler. It was
developed in the USA as was the printed manual set. Compiler, Assembler and Linker
options are set with simple mouse clicks. Vision runs on Windows 3.1, 95 and NT.
The Compiler, Assembler and Linker are DOS executables. They can be accessed with
your favorite batch files if you prefer. This provides maximum flexibility. This
Integrated Development Environment (IDE) has been expressly designed with the user
in mind. A full function editor is included. All IDE functions are intuitive via pull down
menus with prompted selections. An extensive Help utility is included. External
executables can be run from within Vision. This includes emulator software.