Escolar Documentos
Profissional Documentos
Cultura Documentos
1.ABSTRACT
OBJECTIVE: The aim of this project is to Automate unmanned railway gate using
mechatronics.
PROJECT DEFINATION:
The objective of this project is to manage the control system of railway gate using
the microcontroller. When train arrives at the sensing point alarm is triggered at the
railway crossing point so that the people get intimation that gate is going to be closed.
Then the control system activates and closes the gate on either side of the track. once the
train crosses the other end control system automatically lifts the gate. For mechanical
operation of the gates DC geared motors are employed. Here we are using embedded
controller built around the 8051 family (AT89C52) for the control according to the data
pattern produced at the input port of the micro controller, the appropriate selected action
will be taken.. The logic is produced by the program written in Embedded C language.
The software program is written, by using the KEIL/SPJ micro vision environment. The
program written is then converted in HEX code after simulation and burned on to
microcontroller using FLASH micro vision.
Page 1
Page 2
IR
Engine
Sensor
IR Out
put
Sensor
IR Input
Sensor
8051
micro
controller
IR
Engine
Sensor
Geared Motor
-1 Engine
Geared Motor
-1 Railway
Gate
Geared Motor
-2 Engine
Geared Motor
-2 Railway
Railway
Signals
Red and green
Page 3
2.INTRODUCTION
Introduction:
The objective of this project is to manage the control system of railway gate using
the microcontroller. When train arrives at the sensing point alarm is triggered at the
railway crossing point so that the people get intimation that gate is going to be closed.
Then the control system activates and closes the gate on either side of the track. once the
train crosses the other end control system automatically lifts the gate. For mechanical
operation of the gates geared motors are employed. Here we are using embedded
controller built around the 8051 family (AT89C52) for the control according to the data
pattern produced at the input port of the micro controller, the appropriate selected action
will be taken.. The logic is produced by the program written in Embedded C language.
The software program is written, by using the KEIL micro vision environment. The
program written is then converted in HEX code after simulation and burned on to
microcontroller using FLASH micro vision.
AT89C51 Microcontroller
The Micro controller (AT89C51) is a low power; high performance CMOS 8-bit
micro controller with 4K bytes of Flash programmable and erasable read only memory
(PEROM). The on-chip Flash allows the program memory to be reprogrammed in-system
or by a conventional non-volatile memory programmer. By combining a versatile 8-bit
CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer,
which provides a highly flexible and cost-effective solution to many embedded control
applications. By using this controller the data inputs from the smart card is passed to the
parallel port of the pc and accordingly the software responds. The IDE for writing the
embedded program used is KEI L software.
Page 4
3.CIRCUIT DIAGRAM
Page 5
Page 6
4.COMPONENTS
The project consists of three main parts:
8051 microcontroller
IR Transmitter
IR Receiver
DC motor Circuit
8051 CONTROLLER
The I/O ports of the 8051 are expanded by connecting it to an 8255 chip. The 8255 is
programmed as a simple I/O port for connection with devices such as LEDs, geared DC
motors and sensors.
The following block diagram shows the various devices connected to the different
ports of an 8255. The ports are each 8-bit and are named A, B and C. The individual ports
of the 8255 can be programmed to be input or output, and can be changed dynamically.
The control register is programmed in simple I/O mode with port A, port B and port C
(upper) as output ports and port C (lower) as an input port.
IR CIRCUITS
This circuit has two stages: a transmitter unit and a receiver unit. The transmitter
unit consists of an infrared LED and its associated circuitry.
IR TRANSMITTER
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 38kHz and amplitude 5Volts.
It is required to switch ON the IR LED.
IR RECEIVER:
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. The IR receiver circuit is shown in the figure below.
Page 7
As you can see in the circuit, three pins are needed for interfacing a DC motor (A, B,
Enable). If you want the o/p to be enabled completely then you can connect Enable to
VCC and only 2 pins needed from controller to make the motor work.
As per the truth mentioned in the image above its fairly simple to program the
microcontroller. Its also clear from the truth table of BJT circuit and L293D the
programming will be same for both of them, just keeping in mind the allowed
combinations of A and B. We will discuss about programming in C as well as assembly
for running motor with the help of a microcontroller.
Page 9
5.EMBEDDED SYSTEMS
Introduction:
An Embedded system is a combination of computer hardware and software, and
perhaps additional mechanical or other parts, designed to perform a specific function.
Embedded systems are usually a part of larger, complex system. Dedicated
applications, designed to execute specific activities, are implemented and embedded in
systems. These embedded applications are required to collaborate with the other
components of an enclosed system. Embedded application components interact mostly
with the non-human external environment. They continuously collect data from sensors
or other computer components and process data within real-time constraints. Embedded
systems are usually associated with dedicated hardware and specific software.
Collaborative application
Understand
Understanduser
user
requirements
requirements
Choose
Chooseoptimum
optimum
electronic
electronicchip
chip
S/W Side
H/W Side
HLL/ALL
HLL/ALL
Algorithm
Algorithm
Coding/Editing
Coding/Editing
Compiling/Assembling
Compiling/Assembling
Assembling
Assembling
components
components
Debugging
Debugging
Testing
Testing
Testing
Testing
Simulator
Simulator
S/W
S/W
H/W
H/W
DOWNLOAD
ICE
ICE(In
(InCircuit
Circuit
Emulator)
Emulator)
Embedded
EmbeddedProduct
Product
Page 11
Introduction:
Unlike software designed for general-purpose computers, embedded software
cannot usually be run on other embedded system without significant modification. This is
mainly because of the incredible variety in the underlying hardware. The hardware in
each embedded system is tailored specifically to the application, in order to keep system
costs low. As a result, unnecessary circuitry is eliminated and hardware resources are
shared whenever possible.
In order to have software, there must be a place to store the executable code and
temporary storage for runtime data manipulation. These take the form of ROM and RAM,
respectively. All embedded systems also contain some type of inputs and outputs. It is
almost always the case that the outputs of the embedded system are a function of its
inputs and several other factors. The inputs to the system usually take the form of sensors
Page 12
Memory
Memory
Inputs
Inputs
Processor
Processor
Outputs
Outputs
Processing power
Memory
Development cost
Number of Units
Expected Lifetime
Reliability
Processing power
This is the amount of processing power necessary to get the hob done. A common
way to compare processing power is the MIPS (millions of instructions per second)
rating. Other important features of the processor need to be consider is register width,
typically ranges from 8 to 64 bits.
Page 13
Memory:
The amount of memory (ROM and RAM) required holding the executable
software and data it manipulates. The amount of memory required can also affect the
processor selection. In general, the register width off a processor establishes the upper
limit of the amount of memory it can access.
Development cost:
The development cost of the hardware and software design processes is a fixed,
one-time cost, so it might be that money is no object or that this is the only accurate
measure of system cost.
Number of units:
The tradeoff between production cost and development cost is affected most by
the number of units expected to be produced and sold.
Expected lifetime:
This indicates how long must the system continue to function? This affects all
sorts of design decisions from the selection of hardware components to how much the
system may cost to develop and produce.
Reliability:
How reliable must the final product be? If it is a childrens toy, it doesnt always
have to work right, but if it is part of a space shuttle or a car, it had sure better do what it
is supposed to each and every time.
The Basic Design REALTIME:
Designing Embedded systems is a challenging task. Most of the challenge comes
from the fact that Embedded systems have to interact with real world entities. These
interactions can get fairly complex. A typical Emebbed system might be interacting with
thousands of such entities at the same time. For example, a telephone switching system
Page 14
nodes, it is likely that the system may not be able to meet the Realtime
requirement due to even mild congestion. Thus a simpler architecture has a better
chance of meeting the Realtime requirements.
Page 15
Is the Operating System suitable? Assign high priority to tasks that are involved
in processing Realtime critical events. Consider preemptive scheduling if
Realtime requirements are stringent. When choosing the operating system, the
interrupt latency and scheduling variance should be verified.
o Scheduling variance refers to the predictability in task scheduling times.
For example, a telephone switching system is expected to feed dialtone in
less than 500 ms. This would typically involve scheduling three to five
tasks within the stipulated time. Most operating systems would easily meet
these numbers as far as the mean dialtone delay is concerned. But general
purpose operating systems would have much higher standard deviation in
the dialtone numbers.
o Interrupt Latency refers to the delay with which the operating system can
handle interrupts and schedule tasks to respond to the interrupt. Again,
Embedded Systems based on real-time operating systems would have
much lower interrupt latency.
6.MICROCONTROLLER
Introduction:
Microcontrollers are "embedded" inside some other device (often a consumer
product) so that they can control the features or actions of the product. Another name for
a microcontroller, therefore, is "embedded controller."
Microcontrollers are dedicated to one task and run one specific program. The
program is stored in ROM (read-only memory) and generally does not change.
Page 16
A microcontroller has a dedicated input device and often (but not always) has a
small LED or LCD display for output. A microcontroller also takes input from the
device it is controlling and controls the device by sending signals to different
components in the device.
For example, the microcontroller inside a TV takes input from the remote control
and displays output on the TV screen. The controller controls the channel selector,
the speaker system and certain adjustments on the picture tube electronics such as
tint and brightness. The engine controller in a car takes input from sensors such as
the oxygen and knock sensors and controls things like fuel mix and spark plug
timing. A microwave oven controller takes input from a keypad, displays output on
an LCD display and controls a relay that turns the microwave generator on and off.
A microcontroller is often small and low cost. The components are chosen to
minimize size and to be as inexpensive as possible.
Features
BLOCK DIAGRAM:
Page 18
PIN CONFIGURATIONS:
Page 19
PIN DESCRIPTION
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
Page 20
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
Page 21
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
Page 22
PSEN
PSEN
is activated twice
/VPP
External Access Enable 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
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.
Page 23
Page 24
oscillate
back
and
front
at
the
resonant
frequency
of
crystal.
f=12 ((1+C/CP)/(LC)))
Quartz crystal exhibits a property called the piezo-electric effect that is they
produce an electric voltage. When subjected to pressure along certain direction of the
crystal because of this property quartz crystal has important application in electronics
industry for controlling the frequency of radio waves.When piezo-electric crystal is used
in place of LC circuit for higher frequency stability, the oscillator is called as crystal
oscillator.
Page 25
Mode
Idle
Idle
Powerdown
Powerdown
Program
ALE
PSEN
Port 0
Port 1
Port 2
1
1
1
1
Data
Float
Data
Data
Data
Data
Address Data
Internal
Data
Data
Data
Data
External
Float
Data
Data
Data
Memory
Internal
External
Port3
LB1
LB2
LB3
Protection Type
from
external
Flash is disabled
Same as mode 2, also verify is disabled
Same as mode 3, also external execution is
disabled
RST
PSEN
Bit-1
Bit-2
Bit-3
Write
Lock
ALE/PROG
EA
P3.7
H/12V H
H/12V H
H/12V H
H/12V H
Chip Erase
H
L
Read Signature
H
L
H
Byte
Note: Chip Erase requires a 10 ms PROG pulse.
Page 28
Page 29
Symbol
1/tCLCL
tCLCL
techs
talc
talc
techs
Parameter
Oscillator Frequency
Clock Period
High Time
Low Time
Rise Time
Fall Time
Min
0
41.6
15
15
Max
24
20
20
Units
MHz
ns
ns
ns
ns
ns
7.HARDWARE DISCRIPTION
7.1 STEPER MOTOR
Introduction:
Geared motors convert electrical energy into precise mechanical motion. These
motors rotate a specific incremental distance per each step. The number of steps executed
controls the degree of rotation of the motors shaft. This characteristic makes step motors
excellent for positioning applications. For example, a 1.8 step motor executing 100 steps
will rotate exactly 180 with some small amount of non-cumulative error. The speed of
Page 30
The diagram above shows a typical step motor based system. All of these parts
must be present in one form or another. Each components performance will have an
effect on the others. By altering the frequency of the pulse train, the pulse generator can
instruct the motor to accelerate, run at a speed, decelerate or stop. A pulse generator must
be present otherwise the motor will not move. Next is the motor driver.
The driver takes the pulses from the pulse generator and determines how and
when the windings should be energized. The windings must be energized in a specific
sequence to generate motion. Finally there is the step motor itself. A step motor has two
primary parts; the rotor, the moving piece, and the stator, the stationary piece. The stator
contains coils of wire called windings. The rotor spins on bearings or bushings inside the
stator. All step motors operate through the principle of the rotor following a rotating
magnetic field created by sequencing the flow of current through the stator windings.
Each NMB step motor has two phases, which are groups of electrically connected
windings. As current is passed through each phase, the motor takes steps or small
Page 31
Page 32
7.2 CAPACITORS
Introduction:
An electrolytic capacitor is a type of capacitor typically with a larger capacitance
per unit volume than other types, making them valuable in relatively high-current and
low-frequency electrical circuits. This is especially the case in power-supply filters,
where they store charge needed to moderate output voltage and current fluctuations, in
rectifier output, and especially in the absence of rechargeable batteries that can provide
similar low-frequency current capacity. They are also widely used as coupling capacitors
in circuits where AC should be conducted but DC should not; the large value of the
capacitance allows them to pass very low frequencies.
Page 33
Construction
Aluminum electrolytic capacitors are constructed from two conducting aluminum
foils, one of which is coated with an insulating oxide layer, and a paper spacer soaked in
electrolyte. The foil insulated by the oxide layer is the anode while the liquid electrolyte
and the second foil act as cathode. This stack is then rolled up, fitted with pin connectors
and placed in a cylindrical aluminum casing. The two most popular geometries are axial
leads coming from the center of each circular face of the cylinder, or two radial leads or
lugs on one of the circular faces. Both of these are shown in the picture
Polarity
In aluminum electrolytic capacitors, the layer of insulating aluminum oxide on the
surface of the aluminum plate acts as the dielectric, and it is the thinness of this layer that
allows for a relatively high capacitance in a small volume. The aluminum oxide layer can
withstand an electric field strength of the order of 109 volts per meter. The combination of
high capacitance and high voltage result in high energy density.
Unlike most capacitors, electrolytic capacitors have a voltage polarity
requirement. The correct polarity is indicated on the packaging by a stripe with minus
signs and possibly arrowheads, denoting the adjacent terminal that should be more
negative than the other. This is necessary because a reverse-bias voltage will destroy the
center layer of dielectric material via electrochemical reduction (see redo reactions).
Without the dielectric material the capacitor will short circuit, and if the short circuit
current is excessive, then the electrolyte will heat up and either leak or cause the
capacitor to explode.
Modern capacitors have a safety valve, typically either a scored section of the can,
or a specially designed end seal to vent the hot gas/liquid, but ruptures can still be
dramatic. Electrolytic can withstand a reverse bias for a short period of time, but they will
conduct significant current and not act as a very good capacitor. Most will survive with
no reverse DC bias or with only AC voltage, but circuits should be designed so that there
is not a constant reverse bias for any significant amount of time. A constant forward bias
is preferable, and will increase the life of the capacitor.
Page 34
These are the different schematic symbols for electrolytic capacitors. The minus or N
marked side of the physical capacitor is equivalent to the node opposite to the plus sign
on its symbolic equivalent. Tip: Take notice of the shape of the symbols and the
placement of the positive and negative nodes, because most schematics do not print the
"+", but rely on the symbol itself instead.
note: caps in metal can have the color mark at the minus side !
axial: the minus wire is connected to the case, the plus wire is isolated.
radial = single ended: a vertical color stripe indicates the minus side.
Electrolyte
The electrolyte is usually boric acid or sodium borate in aqueous solution together
with various sugars or ethylene glycol which are added to retard evaporation. Care should
be taken to avoid ingestion of or eye contact with the electrolyte, and any areas of the
body where skin contact has occurred should be washed in good time. It is important to
follow safe working practice and to use appropriate protective equipment, notably gloves
and safety glasses, when working with the electrolyte. Some very old tantalum
electrolytic, often called "Wet-slug", contain the more hazardous sulfuric acid, however
most of these are no longer in service due to corrosion.
Page 35
Page 36
Super capacitor
MC and BC series super capacitors (up to 3000 farad capacitance) produced by Maxwell
Technologies
Super capacitors, also known as ultra capacitors or electrochemical double layer
capacitors (EDLC), are electrochemical capacitors that have an unusually high energy
density when compared to common capacitors, typically on the order of thousands of
times greater than a high-capacity electrolytic capacitor. For instance, a typical D-cell
sized electrolytic capacitor will have a storage capacity measured in microfarads, while
the same size super capacitor would store several farads, an improvement of about 10,000
times. Larger commercial super capacitors have capacities as high as 5,000 farads.
Super capacitors have a variety of commercial applications, notably in "energy
smoothing" and momentary-load devices. Some of the earliest uses were motor startup
capacitors for large engines in tanks and submarines, and as the cost has fallen they have
started to appear on diesel trucks and railroad locomotives. More recently they have
become a topic of some interest in the green energy world, where their ability to quickly
soak up energy makes them particularly suitable for regenerative braking applications,
whereas batteries have difficulty in this application due to slow charging times. If the
LEES or Ester devices can be commercialized, they will make an excellent replacement
for batteries in all-electric cars and plug-in hybrids, as they combine quick charging,
temperature stability and excellent safety properties.
Page 37
Page 38
Technology advantages
Due to the capacitor's high number of charge-discharge cycles (millions or more
compared to 2001000 for most commercially available rechargeable batteries) there
were no disposable parts during the whole operating life of the device, which makes the
device environmentally friendly. storing energy from other sources for load balancing
purposes and then using any excess energy to charge the batteries only at opportune
times.
Other advantages of super capacitors compared with rechargeable batteries are
extremely low internal resistance or ESR, high efficiency (up to 97-98%), high output
power, extremely low heating levels, and improved safety. According to ITS (Institute of
Transportation Studies, Davis, CA) test results, the specific power of super capacitors can
exceed 6 kW/kg at 95% efficiency
The idea of replacing batteries with capacitors in conjunction with novel
alternative energy sources became a conceptual umbrella of the Green Electricity (GEL)
Initiative, introduced by Dr. Alexander Bell.
Page 39
For example, a resistor with bands of yellow, violet, red, and gold will have first
digit 4 (yellow in table below), second digit 7 (violet), followed by 2 (red) zeros:
4,700 ohms. Gold signifies that the tolerance is 5%, so the real resistance could lie
anywhere between 4,465 and 4,935 ohms.
Resistors manufactured for military use may also include a fifth band which
indicates component failure rate (reliability); refer to MIL-HDBK-199 for further details.
The Standard EIA Color Code Table per EIA-RS-279 is as follows:
Page 40
100
Brown 1
101
1% (F)
100 pap
Red
102
2% (G)
50 pap
Orange 3
103
15 pap
Yellow 4
104
25 pap
Green 5
105
0.5% (D)
Blue
106
0.25% (C)
Violet 7
107
0.1% (B)
Grey
108
0.05% (A)
White 9
109
Gold
0.1
5% (J)
Silver
0.01
10% (K)
None
20% (M)
Note: red to violet are the colors of the rainbow where red is low energy and violet is
higher energy.
Page 41
CIRCUIT DIAGRAM:
7805
1
230 V
AC
SUPPL
4
Y TRANSFORMER
50 HZ
IN4007
2
6
1 100u
IN400
7
1k
1
2 1000u
1f
LED
POWER SUPPLY:
To run the electronic gadget at home it is provided by some power supply. The
microcontroller used (at89c51) requires 12v D.C supply. The DTMF receiver used
(mt8870) requires 5v D.C. so design of these regulated power supply is also an important
part in hardware design. The A.C power supply from mains is taken and regulated using
the rectifiers.
For design of a regulated power supply components used are:
Transformer.
Diodes.
Rectifiers.
Regulated IC chips.
Capacitive filters.
Trans former:
A transformer is required to couple the mains to the actual power supply circuit.
This is required to isolate the mains from the actual regulated power supply circuit and
the other part of the kit. This isolation eliminates the dame of the kit to any power supply
variations or from a faulty shock.
Page 42
i2
V1
V2
V1 = i2 = n1
V2 i1 n2
Diodes:
In bride rectifier four diodes are used. The specifications of diodes are chosen
as:
PIV > input voltage.
Si diode is better.
Power dissipation is kept fixed with respect to current through the diode.
Junction capacitance need not be considered for frequencies <1 kHz.
RECTIFIERS:
Rectification is a process of conversion of AC to DC. Here, the AC of transformer
output is given to the rectifier input, which converts it to DC output. Basically, bridge
rectifiers or diodes arranged in bridge called Diode arrangement are used for power
supply design.
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve
full-wave rectification. This is a widely used configuration, both with individual diodes
wired as shown and with single component bridges where the diode bridge is wired
internally
Page 43
Page 44
Capacitors:
Capacitive filters are used stabilized or perfect regulation of the voltage. The
capacitive filters are opted because, they are more efficient. But they are also more costly.
Different types of capacitors are:
1. Ceramic capacitors.
2. Electrolyte capacitors.
3. Paper/Mica capacitors.
4. Silver capacitors.
5. Tantalum capacitors.
Ceramic, Paper/Mica, Silver are nonpolarized capacitors. Electrolyte and Tantalum
are polarized capacitors. For high frequency, Ceramic capacitors are used. For low
frequencies, Electrolyte capacitors are used.
Page 45
ULN2803buffer:
Features:
500-mA Rated Collector Current (Single
Output)
High-Voltage Outputs . . . 50 V
description/ordering information:
The ULN2803A is a high-voltage, highcurrent Darlington transistor array. The device
consists of eight nun Darlington pairs that feature high-voltage outputs with commoncathode clamp diodes for switching inductive loads. The collector-current rating of each
Darlington pair is 500 mA. The Darlington pairs may be connected in parallel for higher
current capability.
Applications include relay drivers, hammer drivers, lamp drivers, display drivers
(LED and gas discharge), line drivers, and logic buffers. The ULN2803A has a 2.7kseries base resistor for each Darlington pair for operation directly with TTL or 5-V
CMOS devices.
Page 46
Logic diagram:
Page 47
M NEMONICS
A useful mnemonic for remembering the first ten color codes matches the first letter
of the color code, by order of increasing magnitude. There are many variations:
Bad Beer Rots Our Young Guts But Vodka Goes Well
Bright Boys Rave Over Young Girls But Veto Getting Wed
B. B. R O Y of Great Britain has a Very Good Wife
Big Boys Race Our Young Girls But Violet Generally Wins
Better Be Right Or Your Great Big Venture Goes West
Black Beauty Ran Over Yellow Grass By Violent Grey Waters
Bad Boys Race Over Yonder Green But Victory Goes Wanting
Black Birds Roam Over Your Garden But Vultures Go West
Bye Bye Rosie Off You Go Birmingham Via Great Weston
The word "Bad" in the first mnemonic and "Bright" in the second mnemonic are often
replaced with the word "Black" since black comes before brown in the color code. While
the second mnemonic is certainly the most offensive of these, all except the third lack a
sobriety that might be desirable, especially in a teaching context. A more staid memory
aide uses the fact that the central part of the code follows the color spectrum, without the
i for indigo. That is,
The most common variation of the mnemonic for the EIA color code generally
doesn't stay posted on this page for long due to its choice of words which is more
offensive to many today than when it was originated (mid 1920's). Refer to the discussion
for details.
Besides the ten colors of the main value code, the tolerance code is often
remembered as "for Gold or Silver" appended to the more offensive mnemonic, or "Get
Some Now" where Now refers to none for 20%.
If it is difficult to recall that black comes before brown in the color code, it may
be helpful to use the position of white at the end of the color code as a key to remember
that black (and not brown) is at the beginning.
Page 48
Examples
Green-Blue-Black-Black-Brown
o 560 1%
Red-Red-Orange-Gold
o 22,000 5%
Yellow-Violet-Brown-Gold
o 470 5%
Blue-Gray-Black-Gold
o 68 5%
Note: The sizes of the resistors depend only on the power they can dissipate, and do not
affect their value.
Page 49
Enough current flows to make the LED light up, but not so much that the LED is
damaged. Later in this Chapter, you will find out how to calculate a suitable value for this
resistor. (LEDs are described in detail in Chapter 5.)
The 'box' symbol for a fixed resistor is popular in the UK and Europe. A 'zig-zag'
symbol is used in America and Japan:
Resistors are used with transducers to make sensor subsystems. Transducers are
electronic components which convert energy from one form into another, where one of
the forms of energy is electrical. A light dependent resistor, or LDR, is an example of
an input transducer. Changes in the brightness of the light shining onto the surface of
the LDR result in changes in its resistance. As will be explained later, an input transducer
is most often connected along with a resistor to to make a circuit called a potential
divider. In this case, the output of the potential divider will be a voltage signal which
reflects changes in illumination.
Microphones and switches are input transducers. Output transducers include
loudspeakers, filament lamps and LEDs. Can you think of other examples of transducers
of each type?
Page 50
How can the value of a resistor be worked out from the colours of the bands?
Each color represents a number according to the following scheme:
Number
Color
black
brown
red
orange
yellow
green
blue
violet
grey
white
The first band on a resistor is interpreted as the FIRST DIGIT of the resistor
value. For the resistor shown below, the first band is yellow, so the first digit is 4:
Page 51
Color
1%
brown
2%
red
5%
gold
10%
silver
When you want to read off a resistor value, look for the tolerance band, usually
gold, and hold the resistor with the tolerance band at its right hand end. Reading resistor
values quickly and accurately isn't difficult, but it does take practice!
Page 52
8.SOFTWARE DISCRIPTION
8.1
KEIL MICROVISION
Introduction:
Keil development tools for the 8051 Microcontroller Architecture support every
level of software developer from the professional applications engineer to the student just
learning about embedded software development.
The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time
Kernels, Single-board Computers, and Emulators support all 8051 derivatives and help
you get your projects completed on schedule
The Keil 8051 Development Tools are designed to solve the complex problems facing
embedded software developers.
When starting a new project, simply select the microcontroller you use from the
Device Database and the Vision IDE sets all compiler, assembler, linker, and
memory options for you.
Numerous example programs are included to help you get started with the most
popular embedded 8051 devices.
The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN,
UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM
Modules) of your 8051 device. Simulation helps you understand hardware
configurations and avoids time wasted on setup problems. Additionally, with
simulation, you can write and test applications before target hardware is available.
When you are ready to begin testing your software application with target
hardware, use the MON51, MON390, MONADI, or FlashMON51 Target
Monitors, the ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to
download and test program code on your target system.
The Vision3 IDE offers numerous features and advantages that help you quickly and
successfully develop embedded applications. They are easy to use and are guaranteed to
help you achieve your design goals.
The Vision3 IDE and Debugger is the central part of the Keil development tool chain.
Vision3 offers a Build Mode and a Debug Mode.
In the Vision3 Build Mode you maintain the project files and generate the application.
In the Vision3 Debug Mode you verify your program either with a powerful CPU and
peripheral simulator or with the Keil ULINK USB-JTAG Adapter (or other AGDI
drivers) that connect the debugger to the target system. The ULINK allows you also to
download your application into Flash ROM of your target system.
Page 54
The tabs of the Output Window provides: Build messages and fast error access;
Debug Command input/output console; Find in Files results with quick file
access.
The Memory Window gives access to the memory areas in display various
formats.
The Watch & Call Stack Window allows you to review and modify program
variables and displays the current function call tree.
The Workspace is used for the file editing, disassembly output, and other debug
information.
The Peripheral Dialogs help you to review the status of the on-chip peripherals
in the microcontroller.
Vision3 IDE
The Vision3 IDE combines project management, a rich-featured editor with
interactive error correction, option setup, make facility, and on-line help. Use Vision3 to
create your source files and organize them into a project that defines your target
application. Vision3 automatically compiles, assembles, and links your embedded
application and provides a single focal point for your development efforts.
Library Manager
The library manager allows you to create object library from the object files
created by the compiler and assembler. Libraries are specially formatted, ordered
program collections of object modules that may be used by the linker at a later time.
When the linker processes a library, only those object modules in the library that are
necessary to create the program are used.
Linker/Locator
The Linker/Locator creates an executable program file using the object modules
extracted from libraries and those created by the compiler and assembler. An executable
program file (also called absolute object module) contains no reloadable code or data. All
code and data reside at fixed memory locations.
Page 56
Vision3 Debugger
The Vision3 symbolic, source-level debugger is ideally suited for fast, reliable
program debugging. The debugger includes a high-speed simulator that let you simulate
an microcontroller system including on-chip peripherals and external hardware. The
Vision3 Debugger provides several ways for you to test your programs on real target
hardware.
Use the Keil ULINK USB-JTAG adapter for Flash downloading and software test
of your program via on-chip debugging system like the Embedded ICE macro cell
that is integrated in many ARM devices.
Use the AGDI interface to attach use the Vision3 Debugger front end with your
target system using other debuggers like Monitor, In-System Debugger, or
Emulator.
At Keil Software, we are dedicated to provide you with the best embedded
development tools and documentation available. If you have suggestions or comments
regarding any of the on-line manuals accompanying this product, please contact us. If
you think you have discovered a problem with the software, do the following before
calling technical support.
1. Read the sections in this manual that pertains to the job or task you are trying to
accomplish.
2. Make sure you are using the most current version of the software and utilities.
Check www.keil.com/update to make sure that you have the latest software
version.
3. Isolate the problem to determine if it is a problem with the assembler, compiler,
linker, debugger, or another development tool.
4. Further isolate software problems by reducing your code to a few lines.
If you are still experiencing problems after following these steps, report them to
our technical support group. Please include your product serial number and version
number. We prefer that you send the problem via email. If you contact us by fax, be sure
to include your name and telephone numbers (voice and fax) where we can reach you.
Try to be as detailed as possible when describing the problem you are having. The
more descriptive your example, the faster we can find a solution. If you have a singlepage code example demonstrating the problem, please email it to us. If possible, make
Page 57
The menu bar provides menus for editor operations, project maintenance,
development tool option settings, program debugging, external tool control,
window selection and manipulation, and on-line help.
The toolbar buttons allow you to rapidly execute Vision3 commands. A Status
Bar provides editor and debugger information. The various toolbars and the status
bar can be enabled or disabled from the View Menu commands.
Keyboard shortcuts offer quick access to Vision3 commands and may be
configured via the menu command Edit Configuration - Shortcut Key.
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:
CREATING APPLICATIONS
Home Creating Applications
This chapter describes the Build Mode of Vision3 and is grouped into the
following sections:
Page 58
Project Target and File Groups: shows how to create application variants
and organized the files that belong to a project.
Tips and Tricks: provides information about the advanced features of the
Vision3 Project Manager.
CREATE PROJECT
Home Creating Applications Create Project
Vision3 is a standard Windows application and started by clicking on the
program icon. About the Environment describes the different window areas of
Vision3.
Vision3 includes a project manager which makes it easy to design applications
for an ARM based microcontroller. You need to perform the following steps to create
a new project:
The section provides a step-by-step tutorial that shows you how to create a
simple Vision3 project.
PROJECT TARGETS
AND
FILE GROUPS
Page 59
The Project Workspace shows all groups and the related files. Files are built
and linked in the same order as shown in this window. You can move file positions
with Drag & Drop. You may select a target or group name and Click to rename it.
The local menu opens with a right mouse Click and allows you for each item:
to
to
to
to
In the build toolbar you can quickly change the current project target to build.
PROJECT COMPONENTS
Home Dialogs Project
You may add, delete, or re-arrange the items with the list box buttons in
Project Targets, Groups, and Files.
Project Targets
Shows all Project Targets in your project. Project Targets let you create
several programs form a single project. You may need one target for testing
and another target for a release version of your application.
Groups
Page 60
Files
Shows all File Groups in your current project. File Groups let you group
associated files together in a project. This is useful for grouping files into
functional blocks or for identifying engineers in your software team.
FILE EXTENSIONS
Home Creating Applications Tips and Tricks File Extensions
The dialog Project Components, Environment and Books allows you to
set the file extension for the various file types of a project. You can enter several
extensions when you separate them by semi-colon. The file extensions are project
specific.
Page 61
Debugging
Home Debugging
This chapter describes the Debug Mode of Vision3 and shows you how to use the
user interface to test a sample program. Also discussed are simulation mode and the
different options available for program debugging.
You can use Vision3 Debugger to test the applications you develop. The
Vision3 Debugger offers two operating modes that are selected in the Options for
Target Debug dialog.
Page 62
including the serial port, external I/O, and timers. The peripheral set is
selected when you select a CPU from the device database for your target.
Use Advanced GDI drivers, like the ULINK Debugger to interface to your
target hardware. For Vision3 various drivers are available that interface to:
o JTAG/OCDS Adapter: which connects to on-chip debugging systems
like the ARM Embedded ICE.
o Monitor: that may be integrated with user hardware or is available on
many evaluation boards.
o Emulator: which connects to the CPU pins of the target hardware.
o In-System Debugger: which is part of the user application program
and provides basic test functions.
o Test Hardware: such as the Infineon Smartcard ROM Monitor RM66P
or the Philips Smarm Box.
Flash Programming
Home Flash Programming
Vision3 integrates Flash Programming Utilities in the project environment. All
configurations are saved in context with your current project.
You may use external command-line driven utilities (usually provided by the chip
vendor) or the Keil ULINK USB-JTAG Adapter. The Flash Programming Utilities are
configured under Project - Options - Utilities.
Flash Programming may be started from the Flash Menu or before starting the
Vision3 Debugger when you enable Project - Options - Utilities - Update Target
before Debugging.
The Files page in the Project Workspace shows the source files that compose
the MEASURE project. The three application related source files that are located in
the Source Files group. The function of the source files is described below. To open
a source file, double-click on the filename.
Page 63
Measures: contains the main C function for the measurement system and
the interrupt routine for timer 0. The main function initializes all peripherals of
the ARM and performs command processing for the system. The timer
interrupt routine, timer0, manages the real-time clock and the measurement
sampling of the system.
MCommand.C: processes the display, time, and interval commands. These
functions are called from main. The display command lists the analog values
in floating-point format to give a voltage between 0.00V and 5.00V.
GetLine.C: contains the command-line editor for characters received from
the serial port.
IRQ.S: is an interface module for the interrupt service routine.
Testing Measure
Home Example Programs Measure: A Remote Measurement System Testing
Measure
Page 64
Page 65
Page 66
Program Execution
Home Example Programs Measure: A Remote Measurement System
Program Execution
Before you begin simulating MEASURE, open the Serial Window #1 that
displays the serial output with the View menu or the Debug toolbar. You may
disable other windows if your screen is not large enough.
You can use the Step toolbar buttons on assembler instructions or source
code lines. If the Disassembly Window is active, you single step at assembly
instruction basis. If an editor window with source code is active, you single step at
source code level.
Call Stack
Home Example Programs Measure: A Remote Measurement System Call
Stack
Vision3 internally tracks function nesting as the program executes. The Call
Stack page of the Watch Window shows the current function nesting. A double
click on a line displays the source code that called the selected function.
Breakpoints Dialog
Home Example Programs Measure: A Remote Measurement System
Breakpoints Dialog
Page 67
Description
Reset CPU.
If program execution is halted begin executing the MEASURE program.
After a few seconds, Vision3 halts execution. The program counter line in the debug
window marks the line in which the breakpoint occurred.
Page 68
9.CODING
Program written in C language
#include<stdio.h>
#include<reg51.h>
void delay(into);
void medley(void);
sit sen1=P1^0;
sit sen2=P1^1;
sit buzz=P1^3;
sit sig1=P1^4;
sit sig2=P1^5;
sit laser=P1 ^6;
void close();
void open();
void buzzer();
into m=10000;
void main()
{
P0=P2=P3=0x00;
P1=0xff;
buzzer();
sig1=0x00; //train stop/road go
sig2=0x01;
open();
for(;;)
{
if(sen1==0x00)
{
sig1=0x01; sig2=0x00; //train go/road stop
buzzer();
close();
medley();
while(sen2==0x01){}
while(sen2==0x00){}
sig1=0x00; sig2=0x01; //train stop/road go
buzzer();
open();
}
if(sen2==0x00)
{
sig1=0x01; sig2=0x00; //train go/road stop
buzzer();
close();
medley();
while(sen1==0x01){}
Page 69
Page 71
10. CONCLUSIONS :
Hence the Unmanned railway gates operate according to the data input from
sensors to microcontroller. First an alarm is triggered and then the gate is operated.
Specifications:
Page 73
11. BIBLIOGRAPHY
Name of the sites:
1. www.mitel.databook.com
2. www.atmel.databook.com
3. www.franklin.com
4. www.keil.com
References:
www.8052.com/tutorial.phtml
8051 microcontroller by Kenneth J. Ayala
www.electronicsforu.com/electronicsforu/articles/hits.asp?id=1431
Page 74