Professional Documents
Culture Documents
buzzer
Micro controller
IR receiver
Power
Supply
Max 232
Controller
Unit
Crystal
&
reset ckt.
GSM module
Stepper
motor
Fire sensor T RF
ran ID
sm
e
ter
LCD
IR Transmitter
Obstacle sensor
Element
Micro controller
IR receiver
Railway
Gate
Stepper
motor
Re RFI
ce D
ive
rs
Railway Crossing
Introduction
NowadayinIndiathousandsofpeoplearedeathduetorailwayaccidentbecauseofno
protectioinmainrail.ToavoidthisweselectourprojectRailway Monitoring by using
GSM.InthisprojectweAssestherailwaybeforeabout1feetfromrailway using
sensor.Whenrailwayisautomaticallydetecteditgivesignaltounitofmicrocontroller
whichautomaticallyturngsmwithdataandsignalindicationtocontrolroomandalso
apply break. Again fire break out in the bogie it will be detected using sensor and
automaticallysendthedatatoremotelocation.Inourproject
1. Microcontrollerunit.
2. distancesensor.
3. max232
4. gsmmodule
5. Regulatedpowersupply
6. LCDdisplay
7. Firesnesor
ultrasonicsensor:
ultrasonic waves are invisible and operated at 36 kHz freq. this sensor are
connectedatoppositesideofrailwaytruckandproducesinvisiblebeamof36kHz.freq.
when railway cross this beams then it cur beam and give interrupt signal to micro
controllerunit.Thissensorareplacebeforeandafterof1feetmeterawayfromrailway
crossing.
Regulatedpowersupply:
Forourprojectwereq.regulatedpowersupplyof+5vformicrocontroller&
+12vforsteppermotorthisvoltageisgeneratedusingstepdowntransformer,fullwave
voltagerectifier,filtercondenserandregulatedpowersupplyIC78xx.
BuzzerandSignal:
Forarrivaloftrainatcrossingpointwegiveaudioandvisualindicationofbuzzer
andsignalforpeoplewhenthisindicationpeoplestoptherevehiclebeforecrossingpoint
andwaitforgatecloseandpassingoftrain.
Microcontroller:
Description
TheAT89C51isalowpower,highperformanceCMOS8bitmicrocomputerwith4K
bytesofFlashprogrammableanderasablereadonlymemory(PEROM).Thedeviceis
manufacturedusingAtmelshighdensitynonvolatilememorytechnologyandis
compatiblewiththeindustrystandardMCS51instructionsetandpinout.Theonchip
Flashallowstheprogrammemorytobe
reprogrammedinsystemorbyaconventionalnonvolatilememoryprogrammer.By
combiningaversatile8bitCPUwithFlashonamonolithicchip,theAtmelAT89C51is
apowerfulmicrocomputerwhichprovidesahighlyflexibleandcosteffectivesolutionto
manyembeddedcontrolapplications.
MicrocontrollerIC89c51isheartofourproject.WeselectthisMicrocontrollerICfor
ourprojectforfollowingno.ofadvantages.
1) Internal 64K bytes of electrically erasable programmable read only memory for
feedingprogramsothatthereisnoneedofexternalEPROM.
2)Four8biti/po/pportoutofwhichweuseoneporttoreadnoato/pofDTMFdecoder
andotherportissuetoconnectrelayforoperatingdevicesthroughit.
3) Operating voltage of 3.5 to 6V D.C. which is easily available by using voltage
regulatorIC.
4)Internal128byteRAMtostoretemporallystorageofdata.Inwhichwecanfeedtook
uptabletoturnON/OFFrelay.
5)Two16bittime/counterarepresentfortiming&countingpurpose.
6)4external&2internalinterruptareavailable.
Microcontrollercanreadthedata(forthecorrespondingkeypress)availableato/pof
DTMFdecoder&storeinmemory&comparetheno.forwhichdevicesturnON&
OFF.Ifcomparisonisequalthenoperaterelay&generateassurancetone.Forfeed
backtopersonatremotelocationsothatheconfirmaboutrelayordeviceONor
OFF.
BlockDiagramOf89c51Microcontrollerisgivenbelow.
Crystal&ResetCircuit:
12MHz quartz ceramic crystal is connected between pin XTAL1, & XTAL2 of
Microcontrollertoproducemachinecycleforfetch&
executionofinstruction.Andatpin9RSTpinweconnectR.Cn/wtoprovidereset
pulsewhenpoweristurnONsothatprogramexecutionstartsfrommemorylocation
0000H.
PowerSupply:
ForourallICwerequire5VD.C.supplywhichcanbegeneratedbystepdown
transformer,fullwavebridgerectifier,filtercondenser&voltageregulatorIC7805.
12Vsupplyforrelayisgeneratedseparatelyusingthesameprocedureasabove.
Thissupplyrequirementcanbefulfilledinourcaseusingthebatterybackupand
providingrechargefacilitytoit.
Hardware
2.3.1 Microcontroller
2.3.1.1 Selection Criteria
1. The first and the foremost criterion for selecting a microcontroller is that it must meet
the task at hand efficiently and cost effectively. In analyzing the need of a
microcontroller based project we must see whether an 8 bit, 16 bit, 32 bit
microcontroller can best handle the computing need of the task most efficiently.
Among other consideration in this category are speed, power consumption, amount of
on chip RAM and ROM, the number of sufficient I/O ports and cost per unit.
2. Second how easy is it to develop product around it. Key considerations are the
availability of an assembler, debugger, emulator and technical support.
3. Its ready availability in needed quantity, both now and in future.
Taking all these considerations we have chosen ATMEL at89c51 microcontroller.
2.3.1.2 Brief History of 8051
2.4 Software
3.3TUTORIAL ON MICROCONTROLLER
The at89c51c51 microcontroller is from the 8051 family of microcontrollers. The
basis features of all the controllers in this family are the same, except for a few
differences from device to device. The features of the Atmel IC at89c51 is discussed in
detail below.
3.3.1
Memory Organization
The basic block diagram of the family of the 80x51 is as shown below in the
figure.
Fig. 3.8
All 80x51 devices have separate address spaces for program and data memory.
The logical separation of program and data memory allows the data memory to be
accessed by 8-bit addresses, which can be quickly stored and manipulated by an 8-bit
CPU. Program memory (ROM, EPROM) can only be read, not written to. There can
be up to 64k bytes of program memory. In the at89c51,there is 4K Bytes of
Reprogrammable Flash Memory(Program Memory) and 128 x 8-bit Internal RAM
(Data Memory).
3.3.2
3.6.2.1 Description
Special Function Registers (SFRs) ate area of memory that control
functionality of the processor. SFRs are accessed as if they were normal Internal
RAM. The only difference is that Internal RAM is from address 00h through 7Fh
whereas SFR registers exist in the address range of 80h through FFh. Each SFR has
an address (80h through FFh) and a name. The following chart provides a graphical
presentation of the 80Cc51's SFRs, their names, and their address.
Fig. 3.9
As you can see, although the address range of 80h through FFh offer 128 possible
addresses, there are only 19 SFRs in a standard 80C51. All other addresses in the SFR
range (80h through FFh) are considered invalid. Writing to or reading from these
registers may produce undefined values or behavior. There are 3 categories of SFRs
namely I/O, control and other.
Whether a given I/O line is high or low and the value read from the line are
controlled by the I/O SFRs. The control SFRs in some way control the operation or
the configuration of some aspect of the 80x51. For example, TCON controls the
timers, SCON controls the serial port.The remaining SFRs, are "other SFRs." These
SFRs can be thought of as auxillary SFRs in the sense that they don't directly
configure the 80x51 but obviously the 80x51 cannot operate without them. For
example, once the serial port has been configured using SCON, the program may read
or write to the serial port using the SBUF register.
3.6.2.2 Overview of all SFRs
This section will endeavor to quickly overview each of the standard SFRs
found in the above SFR chart map. This section is to just give you a general idea of
what each SFR does.
SP (Stack Pointer, Address 81h): This is the stack pointer of the microcontroller.
This SFR indicates where the next value to be taken from the stack will be read from
in Internal RAM. If you push a value onto the stack, the value will be written to the
address of SP + 1. That is to say, if SP holds the value 07h, a PUSH instruction will
push the value onto the stack at address 08h. This SFR is modified by all instructions
which modify the stack, such as PUSH, POP, LCALL, RET, RETI, and whenever
interrupts are provoked by the microcontroller.
DPL/DPH (Data Pointer Low/High, Addresses 82h/83h): The SFRs DPL and
DPH work together to represent a 16-bit value called the Data Pointer. The data
pointer is used in operations regarding external RAM and some instructions involving
code memory. Since it is an unsigned two-byte integer value, it can represent values
from 0000h to FFFFh (0 through 65,535 decimal).
PCON (Power Control, Addresses 87h): The Power Control SFR is used to
control the power control modes. Certain operation modes allow the to go into a type
of "sleep" mode which requires much less power. These modes of operation are
controlled through PCON. Additionally, one of the bits in PCON is used to double the
effective baud rate of the serial port.
TCON (Timer Control, Addresses 88h, Bit-Addressable): The Timer Control
SFR is used to configure and modify the way in which the two timers operate. This
SFR controls whether each of the two timers is running or stopped and contains a flag
to indicate that each timer has overflowed. Additionally, some non-timer related bits
are located in the TCON SFR. These bits are used to configure the way in which the
external interrupts are activated and also contain the external interrupt flags which are
set when an external interrupt has occured.
TMOD (Timer Mode, Addresses at89c51h): The Timer Mode SFR is used to
configure the mode of operation of each of the two timers. Using this SFR your
program may configure each timer to be a 16-bit timer, an 8-bit autoreload timer, a
13-bit timer, or two separate timers. Additionally, you may configure the timers to
only count when an external pin is activated or to count "events" that are indicated on
an external pin.
TL0/TH0 (Timer 0 Low/High, Addresses 8Ah/8Ch): These two SFRs, taken
together, represent timer 0. Their exact behavior depends on how the timer is
configured in the TMOD SFR; however, these timers always count up. What is
configurable is how and when they increment in value.
TL1/TH1 (Timer 1 Low/High, Addresses 8Bh/8Dh): These two SFRs, taken
together, represent timer 1. Their exact behavior depends on how the timer is
configured in the TMOD SFR; however, these timers always count up. What is
configurable is how and when they increment in value.
P1 (Port 1, Address 90h, Bit-Addressable): This is input/output port 1. Each bit
of this SFR corresponds to one of the pins on the microcontroller. For example, bit 0
of port 1 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will
send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a
low level.
SCON (Serial Control, Addresses 98h, Bit-Addressable): The Serial Control
SFR is used to configure the behavior of the on-board serial port. This SFR controls
the baud rate of the serial port, whether the serial port is activated to receive data, and
also contains flags that are set when a byte is successfully sent or received.
SBUF (Serial Control, Addresses 99h): The Serial Buffer SFR is used to send
and receive data via the on-board serial port. Any value written to SBUF will be sent
out the serial port's TXD pin. Likewise, any value which it receives via the serial
port's RXD pin will be delivered to the user program via SBUF. In other words,
SBUF serves as the output port when written to and as an input port when read from.
IE (Interrupt Enable, Addresses A8h): The Interrupt Enable SFR is used to
enable and disable specific interrupts. The low 7 bits of the SFR are used to
enable/disable the specific interrupts, where as the highest bit is used to enable or
disable ALL interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled
regardless of whether an individual interrupt is enabled by setting a lower bit.
P3 (Port 3, Address B0h, Bit-Addressable): This is input/output port 3. Each bit
of this SFR corresponds to one of the pins on the microcontroller. For example, bit 0
of port 3 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will
send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a
low level.
IP (Interrupt Priority, Addresses B8h, Bit-Addressable): The Interrupt Priority
SFR is used to specify the relative priority of each interrupt. An interrupt may either
be of low (0) priority or high (1) priority. An interrupt may only interrupt interrupts of
lower priority. For example, if we configure so that all interrupts are of low priority
except the serial interrupt, the serial interrupt will always be able to interrupt the
system, even if another interrupt is currently executing. However, if a serial interrupt
is executing no other interrupt will be able to interrupt the serial interrupt routine
since the serial interrupt routine has the highest priority.
PSW (Program Status Word, Addresses D0h, Bit-Addressable): The Program
Status Word is used to store a number of important bits that are set and cleared by
instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the
overflow flag, and the parity flag. Additionally, the PSW register contains the register
bank select flags which are used to select which of the "R" register banks are
currently selected.
ACC (Accumulator, Addresses E0h, Bit-Addressable): The Accumulator is one
of the most-used SFRs, since it is involved in so many instructions. The Accumulator
resides as an SFR at E0h, which means the instruction MOV A,#20h is really the
same as MOV E0h,#20h. However, it is a good idea to use the first method since it
only requires two bytes whereas the second option requires three bytes.
B (B Register, Addresses F0h, Bit-Addressable): The "B" register is used in two
instructions: the multiply and divide operations. The B register is also commonly
used by programmers as an auxiliary register to temporarily store values.
3.6.3 Timers/Counters
3.6.3.1 General Description
The MCS-51 has two 16 bit Timer/ Counter register Timer 0 and Timer 1. Both
can be configured to operate either as timers or event counter. Microcontroller can be
used as timer or counter as you need. Microcontroller will act as timer when switch
position on upper and microcontroller will act as counter when switch position on
lower by controlling C/T bit on TMOD register. The diagram below shows the logic
of the timer/counter circuit.
Fig. 3.10
The timer/counter is controlled by the two registers TMOD and TCON. Both the
timers share these registers. The layout of both these registers is given below.
Timer/ Counter Mode Control ( TMOD ) Register
TIMER 1
GATE
C/T
TIMER 0
M1
M0
GATE
C/T
M1
M0
GATE: Gating control when set. Timer/ Counter X is enabled only while INTx
pin is high and TRx control pin is set
C/T : Timer or Counter Selector cleared for Timer operation (input from internal
system clock) and set for counter operation (input from Tx input pin)
M0 M1 : Indicates the mode of the Timer/ Couner
Timer/ Counter Control ( TCON ) Register
MSB
TF1
LSB
TR1
TF0
TR0
IE1
IT1
IE0
IT0
M0
Operating
8 bit auto reaload Timer/ Counter THx holds a value which is tobe
reloaded into TLx each time it overflows
run flag (TR1) does not clear the registers. Mode 0 operation is the same for the
Timer 0 as for Timer 1.
Fig. 3.11
Fig. 3.12
Fig. 3.13
Fig 3.14
IC DESCRIPTION
4.1.1 MICROCONTROLLER ATMEL ATat89c51
4.1.1.1 Features
Brown-out Detection
Green
(Pb/Halide-free/RoHS
Compliant)
Packaging
Endurance: 1,000
Write/Erase Cycles
4.1.1.2.
Description
The ATat89c51 is a low-voltage, high-performance CMOS 8-bit
4.1.1.3.
Pin Diagram
Fig. 4.1
4.1.1.4.
Fig. 4.2
4.1.1.5.
VCC
Pin Description
Supply voltage.
GND
Ground.
Port 1
Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal
pullups. P1.0 and P1.1 require external pullups. P1.0 and P1.1 also serve as the
positive input (AIN0) and the negative input (AIN1), respectively, of the on-chip
precision analog comparator. The Port 1 output buffers can sink 20 mA and can
drive LED displays directly. When 1s are written to Port 1 pins, they can be used
as inputs. When pins P1.2 to P1.7 are used as inputs and are externally pulled low,
they will source current (IIL) because of the internal pullups. Port 1 also receives
code data during Flash programming and verification.
Port 3
Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal
pullups. P3.6 is hard-wired as an input to the output of the on-chip comparator
and is not accessible as a general- purpose I/O pin. The Port 3 output buffers can
sink 20 mA. When 1s are written to Port 3 pins they are pulled high by the
internal pullups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) because of the pullups. Port 3
also serves the functions of various special features of the ATat89c51 as listed
below: Port 3 also receives some control signals for Flash programming and
verification.
Port
Pin
Alternate Functions
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
RXD
TXD
INT0
INT1
T0
T1
RST
Reset input. All I/O pins are reset to 1s as soon as RST goes high. Holding the
RST pin high for two machine cycles while the oscillator is running resets the
device. Each machine cycle takes 12 oscillator or clock cycles.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2
Output from the inverting oscillator amplifier.
16 pin/terminals
4.1.5.2 Description
This is a 16 character by 2 line display, with the standard HD44780
chipset. It works great with any microcontroller and it is very easy to interface. This LCD
has 8-bit parallel interface. It is possible to use all 8 bits plus 3 control signals or 4 bits
plus the control signals.
Fig. 4.6
Fig. 4.7
Fig. 4.8
5.RESULT
Upon initial inspection of the circuit operation, multiple problems were noted.
The input signal is transmitted from the cell phone but it is not detected by the
receiver. Troubleshooting of the circuit was undertaken to isolate causes of circuit
failure. The original and expected results of various components of the circuit are as
follows
1) Power Supply: - The power supply is mainly used to give the regulated 5V
output to all the components. But due to interference between ground and output
there is glitch in the output. So we have used capacitor to decouple them and
hence the power supply gives the 5V regulated output.
2) Microcontroller:- The microcontroller is mainly used for controlling and
performing the action of motor driver. But due to wrong selection of crystal
oscillator and decoupling. The controller time cycle is disturbed. So by using
capacitor to decouple these problems are solved.
3) Relay Driver:- The relay driver is mainly used for the controlling of the supply
to transformer. The relay driver requires signal from microcontroller to
operate.the relay takes 12v and 20ma. So we have connected it directly to relay
driver ckt cannot connect directly to microcontroller. So that it will satisfy the
surge current requirement of the relay.
4) Result of Debugging:- After debugging the circuits individual modules, it was
found that each of them function as were expected, and with some modifications
the output of each components is right and consistent.
6. CONCLUSION
5.1 Conclusion:Overall the project was satisfactorily completed. Components functioned properly
in isolation and with interconnection. There is problem in circuit due to interference
between decoder and motor driver but when we separate the two components apart from
each other then whole circuit works properly.
Generally the commercial project are overpriced, the main goal of this project was
that the low cost with global connectivity and controllability is possible. The total cost
was expected to be less when selecting hardware components clearly this goal has been
achieved.
Core objective of Railway monitoring using gsm successfully achieved,
microcontroller AT89c51 controller is the main brain and has burned program in it.
The project is a grant success and real time output
achieved.