Escolar Documentos
Profissional Documentos
Cultura Documentos
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION:
Most of the accidents in high-ways are happening due to the drowsiness
of drivers, most often this symptom is found in long distance truck drivers, these
drivers may take some time to recognize the opposite vehicle, which is running at low
speed, resulting accident. This kind of accidents may happen due to the drunken
drivers also. So to increase safety an electronic warning system is essential to alert the
drivers. This kind of system can be installed in all types of vehicles, especially in
commercial vehicles, so that accident rate can be minimized. The warning system
designed here can be called as driver attention system, which raises an alarm and
energizes the display board automatically when the following vehicle came near to the
in-front running vehicle.
The system is designed with 89S52 microcontroller, the task is quite
simple, the following vehicle detection circuit is designed with infrared sensors, when
the IR signal is interrupted due to the following vehicle, the circuit generates high
signal and it is fed to microcontroller. It offers several advantages over conventional
multi-chip systems. There is a cost and space advantage as extra chip costs and
printed circuit board and connectors required to support multi-chip systems are
eliminated.
SOFTWARE REQUIREMENT:
1. KEIL MICRO VISION-3
2. MICRO FLASH
HARDWARE REQUIREMENT:
1. MICROCONTROLLER (89S52)
2. LM324.
3. ULTRASONIC SENSOR
4. LCD DISPLAY
SRTIST, NALGONDA 1
KEEP DISTANCE WARNING SYSTEM
1.2 AIM:
The aim of this system is to alert the following vehicle whenever it
came very close to the ahead vehicle; thereby to some extent accidents can be
avoided .Many accidents at High-ways are taking place due to the close running of
vehicles, all of sudden, if the in front vehicle driver reduces the speed or applied
breaks, then it is quite difficult to the following vehicle driver to control his vehicle,
resulting accidents avoid this kind of accident, the warning system, which contains
alarm and display system can arrange at rear side of each and every vehicle.
POWER
SUPPLY LCD DISPLAY
AT 89S52
MICRO
-CONTROLLE
R
ULTRASONIC
SENSOR
BUZZER
SRTIST, NALGONDA 2
KEEP DISTANCE WARNING SYSTEM
START
Initialization of Microcontroller
Initialization of LCD
Initialization of ultrasonic
If object NO
is
detected
yes
Buzzer on
STOP
STOP
1.5 CONCLUSION:
Hence, the circuit is designed such that whenever the infrared signal is
interrupted, logic high signal is generated and it is fed to microcontroller, on receipt of
this signal, the controller activates the display board and alarm automatically.
SRTIST, NALGONDA 3
KEEP DISTANCE WARNING SYSTEM
CHAPTER 2
DESCRIPTION OF MICROCONTROLLER
2.1 INTRODUCTION :
The 8051 is an original member of the 8051 family. There are two other
members in the 8051 family of microcontrollers. They are 8052 and 8031. All the
three microcontrollers will have the same internal architecture, but they differ in the
following aspects.
8031 has 128 bytes of RAM, two timers and 6 interrupts.
89S51 has 4KB ROM, 128 bytes of RAM, two timers and 6
interrupts.
89S52 has 8KB ROM, 128 bytes of RAM, three timers and
8 interrupts.
Of the three microcontrollers, 89S51 is the most preferable. Microcontroller
supports both serial and parallel communication.
In the concerned project 89S52 microcontroller is used. Here microcontroller
used is AT89S52, which is manufactured by ATMEL laboratories.
The AT89S52 provides the following standard features: 8Kbytes of Flash,
256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level
interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry.
In addition, the AT89S52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode
stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt
system to continue functioning. The Power down Mode saves the RAM contents but
freezes the oscillator, disabling all other chip functions until the next hardware reset.
The Idle Mode stops the CPU while allowing the RAM, timer/counters,
serial port and interrupt system to continue functioning. The Power down Mode
saves the RAM contents but freezes the oscillator disabling all other chip functions
until the next hardware reset.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
AT89C52 is a powerful microcomputer which provides a highly flexible and cost
effective solution to many embedded control applications.
SRTIST, NALGONDA 4
KEEP DISTANCE WARNING SYSTEM
SRTIST, NALGONDA 5
KEEP DISTANCE WARNING SYSTEM
VCC
Pin 40 provides Supply voltage to the chip. The voltage source is +5v
GND.
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. 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 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 bidirectional I/O port with internal pull-ups from pin 1 to 8.
The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to
Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external
count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively,
as shown in following table.
Port 1 also receives the low-order address bytes during Flash programming
and program verification.
SRTIST, NALGONDA 6
KEEP DISTANCE WARNING SYSTEM
Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to
28. The Port 2 output buffers can sink / source four TTL inputs. When 1s are written
to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs.
As inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application it uses strong internal pull-ups when emitting
1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI),
Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the
high-order address bits and some control signals during Flash programming and
verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups from pin 10 to
17. 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.
SRTIST, NALGONDA 7
KEEP DISTANCE WARNING SYSTEM
RST
Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this
pin, the microcontroller will reset and terminate all activities. A high on this pin for
two machine cycles while the oscillator is running resets the device.
ALE/PROG
Address Latch is an output pin and is active high. 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 AT89C52 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
SRTIST, NALGONDA 8
KEEP DISTANCE WARNING SYSTEM
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2
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
5.3. 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 .
SRTIST, NALGONDA 9
KEEP DISTANCE WARNING SYSTEM
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 hardware 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.
In the power down mode the oscillator is stopped, and the instruction that
invokes power down is the last instruction executed. The on-chip RAM and Special
Function Registers retain their values until the power down mode is terminated. The
only exit from power down is a hardware reset. Reset redefines the SFRs but does not
change the on-chip RAM. The reset should not be activated before VCC is restored to
its normal operating level and must be held active long enough to allow the oscillator
to restart and stabilize.
Table (2.3.3) Status of External Pins During Idle and Power Down Mode
SRTIST, NALGONDA 10
KEEP DISTANCE WARNING SYSTEM
2.4 TIMERS:
• Timer 0 and 1
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and
Timer 1 in the AT89S52. Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit
counter registers for timer/counters 0 and 1.
• Timer 2
SRTIST, NALGONDA 11
KEEP DISTANCE WARNING SYSTEM
There are no restrictions on the duty cycle of external input signal, but it
should for at least one full machine to ensure that a given level is sampled at least
once before it changes.
2.5 INTERRUPTS:
The AT89S52 has a total of six interrupt vectors: two external interrupts
(INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port
interrupt. These interrupts are all shown in Figure 2.5
SRTIST, NALGONDA 12
KEEP DISTANCE WARNING SYSTEM
SRTIST, NALGONDA 13
KEEP DISTANCE WARNING SYSTEM
CHAPTER-3
POWER SUPPLY
3.1 INTRODUCTION:
A transformer steps down high voltage AC mains to low voltage AC. Here we
are using a center-tap transformer whose output will be sinusoidal with 24V peak to
peak.
.
The low voltage AC output is suitable for lamps, heaters and special AC motors. It is
not suitable for electronic circuits unless they include a rectifier and a smoothing
capacitor. The transformer output is given to the rectifier circuit.
3.3 RECTIFIER:
A rectifier converts AC to DC, but the DC output is varying. There are several
types of rectifiers; here we use a bridge rectifier.
SRTIST, NALGONDA 14
KEEP DISTANCE WARNING SYSTEM
Smoothing:
The smoothing block smoothes the DC from varying greatly to a small ripple
and the ripple voltage is defined as the deviation of the load voltage from its DC
value. Smoothing is also named as filtering. Filtering is frequently effected by
shunting the load with a capacitor. The action of this system depends on the fact that
SRTIST, NALGONDA 15
KEEP DISTANCE WARNING SYSTEM
the capacitor stores energy during the conduction period and delivers this energy to
the loads during the no conducting period. In this way, the time during which the
current passes through the load is prolonging Ted, and the ripple is considerably
decreased. The action of the capacitor is shown with the help of waveform.
SRTIST, NALGONDA 16
KEEP DISTANCE WARNING SYSTEM
3.5 CONCLUSION:
We here by conclude that most of the digital logic circuits and processors need
a 5 volt power supply. To use these parts we include a regulated 5 volt source.
Unregulated power supply will be ranging from 9 volts to 24 volts DC . So,to make a
5 volt power supply, we use a LM7805 voltage regulator IC .
CHAPTER 4
SRTIST, NALGONDA 17
KEEP DISTANCE WARNING SYSTEM
ULTRASONIC SENSOR
4.1 INTRODUCTION :
• The PING))) has only has 3 connections, which include Vdd, Vss, and 1 I/O
pin.
• The 3-pin header makes it easy to connect using a servo extension cable, no
soldering required.
• Several sample codes are available using the Ping))) sensor.
SRTIST, NALGONDA 18
KEEP DISTANCE WARNING SYSTEM
Ultrasonic sensors (also known as transducers when they both send and receive)
work on a principle similar to radar or sonar which evaluate attributes of a target by
interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors
generate high frequency sound waves and evaluate the echo which is received back by
the sensor. Sensors calculate the time interval between sending the signal and
receiving the echo to determine the distance to an object.
This technology can be used for measuring: wind speed and direction
(anemometer), fullness of a tank, and speed through air or water. For measuring speed
or direction a device uses multiple detectors and calculates the speed from the relative
distances to particulates in the air or water. To measure the amount of liquid in a tank,
the sensor measures the distance to the surface of the fluid. Further applications
include: humidifiers, sonar, medical ultrasonography, burglar alarms, and non-
destructive testing. Systems typically use a transducer which generates sound waves
in the ultrasonic range, above 20,000 hertz, by turning electrical energy into sound,
then upon receiving the echo turn the sound waves into electrical energy which can be
measured and displayed. The technology is limited by the shapes of surfaces and the
density or consistency of the material. For example foam on the surface of a fluid in a
tank could distort a reading.
SRTIST, NALGONDA 19
KEEP DISTANCE WARNING SYSTEM
Transducers:
Detectors
Since piezoelectric crystal generate a voltage when force is applied to them, the same
crystal can be used as an ultrasonic detector. Some systems use separate transmitter
and receiver components while others combine both in a single piezoelectric
transceiver.
Use in medicine:
Use in industry;
Ultrasonic sensors are used to detect the presence of targets and to measure the
distance to targets in many automated factories and process plants. Sensors with an on
SRTIST, NALGONDA 20
KEEP DISTANCE WARNING SYSTEM
or off digital output are available for detecting the presence of objects, and sensors
with an analog output which varies proportionally to the sensor to target separation
distance are commercially available.
Ultrasonic sensors are commonly used for a wide variety of noncontact presence,
proximity, or distance measuring applications. These devices typically transmit a
short burst of ultrasonic sound toward a target, which reflects the sound back to the
sensor. The system then measures the time for the echo to return to the sensor and
computes the distance to the target using the speed of sound in the medium.
λ = c/f
where:
λ = wavelength
C= speed of light
F = frequency
Figure 2 is a plot of the wavelength of sound as a function of frequency at room
temperature in air.
BackgroundNoise
SRTIST, NALGONDA 21
KEEP DISTANCE WARNING SYSTEM
SRTIST, NALGONDA 22
4.3 Ultrasonic sensor drive circuit:
The inverter is used for the drive of the ultrasonic sensor. The two inverters are
KEEP DISTANCE WARNING SYSTEM
connected in parallel because of the transmission electric power increase.
The phase with the voltage to apply to the positive terminal and the negative terminal of the
sensor has been 180 degrees shifted. Because it is cutting the direct current with the capacitor,
about twice of Voltage of the inverter output are applied to the sensor.
Signalamplificationcircuit:
Generally, the positive and the negative power supply are used for the operational amplifier.
The circuit this time works with the single power supply of +9 V. Therefore, for the positive
input of the operational amplifiers, the half of the power supply voltage is appied as the bias
voltage and it is made 4.5 V in the central voltage of the amplified alternating current signal.
When using the operational amplifier with the negative feedback, the voltage of the positive
input terminal and the voltage of the negative input terminal become equal approximately. So,
by this bias voltage, the side of the positive and the side of the negative of the alternating
current signal can be equally amplified. When not using this bias voltage, the distortion causes
the alternating current signal.
Signal detector:
This circuit is the circuit which detects the ultrasonic which returned from the
measurement object. The output of the detection circuit is detected using the comparator. At the
circuit this time, the operational amplifier of the single power supply is used instead of the
comparator. The operational amplifier amplifies and outputs the difference between the
positive.
In case of the operational amplifier which doesn't have the negative feedback, at a
little input voltage, the output becomes the saturation state. So, when the positive input
becomes higher a little than the negative input, the difference is tens of thousands of times
amplified and the output becomes the same as the power supply almost. (It is the saturation
state) Oppositely, when the positive input becomes lower a little than the negative input, the
difference is tens of thousands of times amplified and the output becomes 0 V almost.(It is in
the OFF condition) This operation is the same as the operation of the comparator. However,
because the inner circuit is different about the comparator and the operational amplifier, the
comparator can not be used .
CHAPTER 5
LCD DISPLAY CIRCUIT
5.1 INTRODUCTION:
SRTIST, NALGONDA 23
The alphanumeric 16 character X 2line LCD requires 8data lines and also 3 control
signals and they are interfaced to 3664.By using 2 ports, port 0&3 data pins are connected to
KEEP DISTANCE WARNING SYSTEM
APPENDIX-THEORY OF MICROCONTROLLER
A micro-controller contains a CPU, clock circuitry, ROM, Ram and I/O
circuitry on a single integrated circuit package. The Micro-controller is therefore, a
self-contained device, which does not require a host of associated support chips for its
operation as conventional microprocessors do. It offers several advantages over
conventional multi-chip systems. There is a cost and space advantage as extra chip
costs and printed circuit board and connectors required to support multi-chip systems
are eliminated. The other advantages include cheaper maintenance, decreased
hardware design effort and decreased board density, which is relevant in portable
control equipment. The microcontroller that we use is AT89S52.
LCD DISPLAY
memory stores the data like intermediate results, variables and constants required for
the execution of the program. Program memory is invariably implemented using
EPROM, because it stores only program code which is to be executed and thus it need
not be written into. However, the data memory may be read from or written to and
thus it is implemented using RAM.
Gnd vcc preset rs the rw
Further, en memory
program d0 d1andd2datad3 d4 d5both
memory d6 may
d7 vcc gnd
be categorized as
on-chip (internal) and external memory, depending upon whether the memory
SRTIST, NALGONDA 24
KEEP DISTANCE WARNING SYSTEM
physically exists on the chip or it is externally interfaced. The 89S52 can address
8Kbytes on-chip memory whose map starts from 0000H and ends at 1FFFH. It can
address 64Kbytes of external program memory under the control of PSEN (low)
signal.
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. That means the
upper 128bytes have the same addresses as the SFR space but are physically separate
from SFR space. When an instruction accesses an internal location above address
7FH, the address mode used in the instruction specifies whether the CPU accesses the
upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing
access SFR space.
SRTIST, NALGONDA 25
KEEP DISTANCE WARNING SYSTEM
SRTIST, NALGONDA 26