Vous êtes sur la page 1sur 43

1

CHAPTER -1

INTRODUCTION TO EMBEDDED SYSTEM

An embedded system is a computer system designed to perform one or a few


dedicated functions often with real-time computing constraints. It is embedded as part of a
complete device often including hardware and mechanical parts. By contrast, a general-
purpose computer, such as a personal computer (PC), is designed to be flexible and to meet
a wide range of end-user needs. Embedded systems control many devices in common use
today.

Embedded systems are controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processors (DSP). The key characteristic,
however, is being dedicated to handle a particular task, which may require very powerful
processors. For example, air traffic control systems may usefully be viewed as embedded,
even though they involve mainframe computers and dedicated regional and national
networks between airports and radar sites. (Each radar probably includes one or more
embedded systems of its own).

Since the embedded system is dedicated to specific tasks, design engineers can
optimize it to reduce the size and cost of the product and increase the reliability and
performance. Some embedded systems are mass-produced, benefiting from economies of
scale. Physically embedded systems range from portable devices such as digital watches
and MP3 players, to large stationary installations like traffic lights, factory controllers, or
the systems controlling nuclear power plants. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure. In general, "embedded system" is not a strictly
definable term, as most systems have some element of extensibility or programmability.
For example, handheld computers share some elements with embedded systems such as the
operating systems and microprocessors which power them, but they allow different
applications to be loaded and peripherals to be connected. Moreover, even systems which
don't expose programmability as a primary feature generally need to support software
updates. On a continuum from "general purpose" to "embedded", large application systems
will have subcomponents at most points even if the system as a whole is "designed to
2

perform one or a few dedicated functions", and is thus appropriate to call "embedded". A
modern example of embedded system is shown in

In many ways, programming for an embedded system is like programming PC 15 years


ago. The hardware for the system is usually chosen to make the device as cheap as
possible. Spending an extra dollar a unit in order to make things easier to program can cost
millions. Hiring a programmer for an extra month is cheap in comparison. This means the
programmer must make do with slow processors and low memory, while at the same time
battling a need for efficiency not seen in most applications. Below is a list of issues
specific to the embedded field.

1.1 HISTORY
In the earliest years of computers in the 193040s, computers were sometimes
dedicated to a single task, but were far too large and expensive for most kinds of tasks
performed by embedded computers of today. Over time however, the concept
of programmable controllers evolved from traditional electromechanical sequencers, via
solid state devices, to the use of computer technology.

One of the first recognizably modern embedded systems was the Apollo Guidance
computer, developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At
the project's inception, the Apollo guidance computer was considered the riskiest item in
the Apollo project as it employed the then newly developed monolithic integrated circuits
to reduce the size and weight. An early mass-produced embedded system was the
Autonetics D-17 guidance computer for the minuteman missile, released in 1961. It was
built from transistor logic and had a hard disk for main memory. When the Minuteman II
went into production in 1966, the D-17 was replaced with a new computer that was the
first high-volume use of integrated circuits.

1.2 TOOLS
Embedded development makes up a small fraction of total programming. There's
also a large number of embedded architectures, unlike the PC world where 1 instruction set
rules, and the Unix world where there's only 3 or 4 major ones. This means that the tools
are more expensive. It also means that they're lowering featured, and less developed. On a
3

major embedded project, at some point you will almost always find a compiler bug of
some sort.

Debugging tools are another issue. Since you can't always run general programs on
your embedded processor, you can't always run a debugger on it. This makes fixing your
program difficult. Special hardware such as JTAG ports can overcome this issue in part.
However, if you stop on a breakpoint when your system is controlling real world hardware
(such as a motor), permanent equipment damage can occur. As a result, people doing
embedded programming quickly become masters at using serial IO channels and error
message style debugging.

1.3 RESOURCES
To save costs, embedded systems frequently have the cheapest processors that can do
the job. This means your programs need to be written as efficiently as possible. When
dealing with large data sets, issues like memory cache misses that never matter in PC
programming can hurt you. Luckily, this won't happen too often- use reasonably efficient
algorithms to start, and optimize only when necessary. Of course, normal profilers won't
work well, due to the same reason debuggers don't work well. Memory is also an issue.
For the same cost savings reasons, embedded systems usually have the least memory they
can get away with. That means their algorithms must be memory efficient (unlike in PC
programs, you will frequently sacrifice processor time for memory, rather than the
reverse). It also means you can't afford to leak memory. Embedded applications generally
use deterministic memory techniques and avoid the default "new" and "malloc" functions,
so that leaks can be found and eliminated more easily. Other resources programmers
expect may not even exist. For example, most embedded processors do not have
hardware FPUs (Floating-Point Processing Unit). These resources either need to be
emulated in software, or avoided altogether.
4

1.4 REAL TIME ISSUES


Embedded systems frequently control hardware, and must be able to respond to them
in real time. Failure to do so could cause inaccuracy in measurements, or even damage
hardware such as motors. This is made even more difficult by the lack of resources
available. Almost all embedded systems need to be able to prioritize some tasks over
others, and to be able to put off/skip low priority tasks such as UI in favor of high priority
tasks like hardware control.
5

CHAPTER-2

NEED OF EMBEDDED SYSTEMS

The uses of embedded systems are virtually limitless, because every day new
products are introduced to the market that utilizes embedded computers in novel ways. In
recent years, hardware such as microprocessors, microcontrollers, and FPGA chips have
become much cheaper. So when implementing a new form of control, it's wiser to just buy
the generic chip and write your own custom software for it. Producing a custom-made chip
to handle a particular task or set of tasks costs far more time and money. Many embedded
computers even come with extensive libraries, so that "writing your own software"
becomes a very trivial task indeed. From an implementation viewpoint, there is a major
difference between a computer and an embedded system. Embedded systems are often
required to provide Real-Time response. The main elements that make embedded systems
unique are its reliability and ease in debugging.

2.1 DEBUGGING
Embedded debugging may be performed at different levels, depending on the facilities
available. From simplest to most sophisticate they can be roughly grouped into the
following areas:
Interactive resident debugging, using the simple shell provided by the embedded
operating system (e.g. Forth and Basic)
External debugging using logging or serial port output to trace operation using either a
monitor in flash or using a debug server like the Remedy Debugger which even works for
heterogeneous multi core systems.
An in-circuit debugger (ICD), a hardware device that connects to the microprocessor
via a JTAG or Nexus interface. This allows the operation of the microprocessor to be
controlled externally, but is typically restricted to specific debugging capabilities in the
processor.
An in-circuit emulator replaces the microprocessor with a simulated equivalent,
providing full control over all aspects of the microprocessor.
A complete emulator provides a simulation of all aspects of the hardware, allowing all
of it to be controlled and modified, and allowing debugging on a normal PC.
6

Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop its
operation. The view of the code may be as assembly code or source-code.

Because an embedded system is often composed of a wide variety of elements, the


debugging strategy may vary. For instance, debugging a software (and microprocessor)
centric embedded system is different from debugging an embedded system where most of
the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing
number of embedded systems today use more than one single processor core. A common
problem with multi-core development is the proper synchronization of software execution.
In such a case, the embedded system design may wish to check the data traffic on the
busses between the processor cores, which requires very low-level debugging, at signal/bus
level, with a logic analyzer, for instance.

2.2 RELIABILITY
Embedded systems often reside in machines that are expected to run continuously for years
without errors and in some cases recover by them if an error occurs. Therefore the software
is usually developed and tested more carefully than that for personal computers, and
unreliable mechanical moving parts such as disk drives, switches or buttons are avoided.
Specific reliability issues may include:
The system cannot safely be shut down for repair, or it is too inaccessible to repair.
Examples include space systems, undersea cables, navigational beacons, bore-hole
systems, and automobiles.
The system must be kept running for safety reasons. "Limp modes" are less tolerable.
Often backup s is selected by an operator. Examples include aircraft navigation,
reactor control systems, safety-critical chemical factory controls, train signals, engines on
single-engine aircraft.
The system will lose large amounts of money when shut down: Telephone switches,
factory controls, bridge and elevator controls, funds transfer and market making,
automated sales and service.
A variety of techniques are used, sometimes in combination, to recover from
errorsboth software bugs such as memory leaks, and also soft errors in the hardware:
7

Watchdog timer that resets the computer unless the software periodically notifies the
watchdog
Subsystems with redundant spares that can be switched over to
software "limp modes" that provide partial function
Designing with a Trusted Computing Base (TCB) architecture[6] ensures a highly
secure & reliable system environment
An Embedded Hypervisor is able to provide secure encapsulation for any subsystem
component, so that a compromised software component cannot interfere with other
subsystems, or privileged-level system software.
8

CHAPTER 3

EXPLANATION OF EMBEDDED SYSTEMS

3.1 SOFTWARE ARCHITECTURE


There are several different types of software architecture in common use.

Simple Control Loop:


In this design, the software simply has a loop. The loop calls subroutines, each of which
manages a part of the hardware or software.

Interrupt Controlled System:


Some embedded systems are predominantly interrupt controlled. This means that tasks
performed by the system are triggered by different kinds of events. An interrupt could be
generated for example by a timer in a predefined frequency, or by a serial port controller
receiving a byte. These kinds of systems are used if event handlers need low latency and
the event handlers are short and simple .Usually these kinds of systems run a simple task in
a main loop also, but this task is not very sensitive to unexpected delays. Sometimes the
interrupt handler will add longer tasks to a queue structure. Later, after the interrupt
handler has finished, these tasks are executed by the main loop. This method brings the
system close to a multitasking kernel with discrete processes.

Cooperative Multitasking:
A non-preemptive multitasking system is very similar to the simple control loop scheme,
except that the loop is hidden in an API. The programmer defines a series of tasks, and
each task gets its own environment to run in. When a task is idle, it calls an idle routine,
usually called pause, wait, yield, nop (stands for no operation), etc.The advantages
and disadvantages are very similar to the control loop, except that adding new software is
easier, by simply writing a new task, or adding to the queue-interpreter.

Primitive Multitasking:
In this type of system, a low-level piece of code switches between tasks or threads based
on a timer (connected to an interrupt). This is the level at which the system is generally
considered to have an "operating system" kernel. Depending on how much functionality is
9

required, it introduces more or less of the complexities of managing multiple tasks running
conceptually in parallel.

As any code can potentially damage the data of another task (except in larger
systems using an MMU) programs must be carefully designed and tested, and access to
shared data must be controlled by some synchronization strategy, such as message queues,
semaphores or a non-blocking synchronization scheme.Because of these complexities, it is
common for organizations to buy a real-time operating system, allowing the application
programmers to concentrate on device functionality rather than operating system services,
at least for large systems; smaller systems often cannot afford the overhead associated with
a generic real time system, due to limitations regarding memory size, performance, and/or
battery life.

Microkernels And Exokernels:


A microkernel is a logical step up from a real-time OS. The usual arrangement is that the
operating system kernel allocates memory and switches the CPU to different threads of
execution. User mode processes implement major functions such as file systems, network
interfaces, etc.

In general, microkernels succeed when the task switching and intertask


communication is fast, and fail when they are slow. Exokernels communicate efficiently by
normal subroutine calls. The hardware and all the software in the system are available to,
and extensible by application programmers. Based on performance, functionality,
requirement the embedded systems are divided into three categories:

3.2 STAND ALONE EMBEDDED SYSTEM


These systems takes the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc.., process them and
produces desired output. This entire process of taking input, processing it and giving
output is done in standalone mode. Such embedded systems comes under stand alone
embedded systems.Eg: microwave oven, air conditioner etc..
10

3.3 REAL-TIME EMBEDDED SYSTEMS


Embedded systems which are used to perform a specific task or operation in a specific time
period those systems are called as real-time embedded systems. There are two types of
real-time embedded systems.

Hard Real-time embedded systems:

These embedded systems follow an absolute dead line time period i.e.., if the tasking
is not done in a particular time period then there is a cause of damage to the entire
equipment.

Eg: consider a system in which we have to open a valve within 30 milliseconds. If


this valve is not opened in 30 ms this may cause damage to the entire equipment. So in
such cases we use embedded systems for doing automatic operations

Eg: Consider a TV remote control system, if the remote control takes a few
milliseconds delay it will not cause damage either to the TV or to the remote control.
These systems which will not cause damage when they are not operated at considerable
time period those systems comes under soft real-time embedded systems.

3.4 NETWORK COMMUNICATION EMBEDDED SYSTEMS


A wide range network interfacing communication is provided by using embedded systems.

Eg:Consider a web camera that is connected to the computer with internet can be
used to spread communication like sending pictures, images, videos etc.., to another
computer with internet connection throughout anywhere in the world.

Consider a web camera that is connected at the door lock.

Whenever a person comes near the door, it captures the image of a person and sends
to the desktop of your computer which is connected to internet. This gives an alerting
message with image on to the desktop of your computer, and then you can open the door
lock just by clicking the mouse. Fig: 2.2 show the network communications in embedded
systems.
11

Fig 3.1: Network Communication Embedded Systems

3.5 DIFFERENT TYPES OF PROCESSING UNITS


The central processing unit (c.p.u) can be any one of the following microprocessor,
microcontroller, digital signal processing.

Among these Microcontroller is of low cost processor and one of the main advantage
of microcontrollers is, the components such as memory, serial communication interfaces,
analog to digital converters etc.., all these are built on a single chip. The numbers of
external components that are connected to it are very less according to the application.

Microprocessors are more powerful than microcontrollers. They are used in major
applications with a number of tasking requirements. But the microprocessor requires many
external components like memory, serial communication, hard disk, input output ports
etc.., so the power consumption is also very high when compared to microcontrollers.

Digital signal processing is used mainly for the applications that particularly involved
with processing of signals
12

3.6 APPLICATIONS OF EMBEDDED SYSTEMS

3.6.1 Consumer applications


At home we use a number of embedded systems which include microwave oven,
remote control, vcd players, dvd players, camera etc.

Fig 3.2 Automatic Coffee Makes Equipment

3.6.2 Office automation


We use systems like fax machine, modem, printer etc

3.6.3 Industrial automation


Today a lot of industries are using embedded systems for process control. In
industries we design the embedded systems to perform a specific operation like monitoring
temperature, pressure, humidity ,voltage, current etc.., and basing on these monitored
levels we do control other devices, we can send information to a centralized monitoring
station.
13

Fig 3.3 Robot

In critical industries where human presence is avoided there we can use robot which are
programmed to do a specific operation.

3.6.4 Computer networking


Embedded systems are used as bridges routers etc..

Fig 3.4 Computer Networking


14

CHAPTER -4

HARDWARE IMPLEMENTATION

The main components used in this project is :

ARDUINO UNO
ULTRA SONIC SENSOR
LCD 16*2 MODULE
BUZZER
LED
BREAD BOARD

4.1 INTRODUCTION TO ARDUINO UNO

An Arduino is an open source microcontroller development board. In plain English,


you can use the Arduino to read sensors and control things like motors and lights. This
allows you to upload programs to this board which can then interact with things in the real
world. With this, you can make devices which respond and react to the world at large.

For instance, you can read a humidity sensor connected to a potted plant and turn on
an automatic watering system if it gets too dry. Or, you can make a stand-alone chat server
which is plugged into your internet router. Or, you can have it tweet every time your cat
passes through a pet door. Or, you can have it start a pot of coffee when your alarm goes
off.
Basically, if there is something that is in any way controlled by electricity, the
Arduino can interface with it in some manner. And even if it is not controlled by
electricity, you can probably still use things like motors and electromagnets, to interface it.

The possibilities of the Arduino are almost limitless. As such, there is no way that
one single tutorial can cover everything you might ever need to know. That said, I've done
my best to give a basic overview of the fundamental skills and knowledge that you need to
get your Arduino up and running. If nothing more, this should function as a springboard
into further experimentation and learning.
15

4.1.1 Different Types of Arduinos


There are a number of different types of Arduinos to choose from. This is a brief overview
of some of the more common types of Arduino boards you may encounter which are
explained.

Arduino Uno
The most common version of Arduino is the Arduino Uno. This board is what most people
are talking about when they refer to an Arduino. In the next step, there is a more complete
rundown of its features.

Arduino NG, Diecimila, and the Duemilanove (Legacy Versions)


Legacy versions of the Arduino Uno product line consist of the NG, Diecimila, and the
Duemilanove. The important thing to note about legacy boards is that they lack particular
feature of the Arduino Uno. Some key differences:

The Diecimila and NG use an ATMEGA168 chips (as opposed to the more powerful
ATMEGA328),

Both the Diecimila and NG have a jumper next to the USB port and require manual
selection of either USB or battery power.

The Arduino NG requires that you hold the rest button on the board for a few seconds
prior to uploading a program.

Arduino Mega 2560


The Mega is the second most commonly encountered version of the Arduino family. The
Arduino Mega is like the Arduino Uno's beefier older brother. It boasts 256 KB of memory
(8 times more than the Uno). It also had 54 input and output pins, 16 of which are analog
pins, and 14 of which can do PWM. However, all of the added functionality comes at the
cost of a slightly larger circuit board. It may make your project more powerful, but it will
also make your project larger.
16

Arduino Mega ADK


This is one of the specialized version of the Arduino, which is basically an Arduino Mega
that has been specifically designed for interfacing with Android smartphones.

ArduinoLilyPad
The LilyPad was designed for wearable and e-textile applications. It is intended to be sewn
to fabric and connected to other sewable components using conductive thread. This board
requires the use of a special FTDI-USB TTL serial programming cable. For more
information, the Arduino LilyPad page is a decent starting point.

4.1.2 Arduino Uno Features


Some of the key features of the Arduino Uno include:

An open source design. The advantage of it being open source is that it has a large
community of people using and troubleshooting it. This makes it easy to find someone to
help you debug your projects.

An easy USB interface . The chip on the board plugs straight into your USB port and
registers on your computer as a virtual serial port. This allows you to interface with it as
through it were a serial device. The benefit of this setup is that serial communication is an
extremely easy (and time-tested) protocol, and USB makes connecting it to modern
computers really convenient.

Very convenient power management and built-in voltage regulation. You can connect
an external power source of up to 12v and it will regulate it to both 5v and 3.3v. It also can
be powered directly off of a USB port without any external power.

An easy-to-find, and dirt cheap, microcontroller "brain." The ATmega328 chip retails
for about $2.88 on Digikey. It has countless number of nice hardware features like timers,
PWM pins, external and internal interrupts, and multiple sleep modes. Check out the
official datasheet for more details.

A 16mhz clock. This makes it not the speediest microcontroller around, but fast
enough for most applications.

32 KB of flash memory for storing your code.


17

13 digital pins and 6 analog pins. These pins allow you to connect external hardware
to your Arduino. These pins are key for extending the computing capability of the Arduino
into the real world. Simply plug your devices and sensors into the sockets that correspond
to each of these pins and you are good to go.

An ICSP connector for bypassing the USB port and interfacing the Arduino directly as
a serial device. This port is necessary to re-bootload your chip if it corrupts and can no
longer talk to your computer.

An on-board LED attached to digital pin 13 for fast an easy debugging of code.

And last, but not least, a button to reset the program on the chip.

The Arduino has two different types of input pins, those being analog and digital.

To begin with, lets look at the digital input pins.


Digital input pins only have two possible states, which are on or off. These two on and off
states are also referred to as:
HIGH or LOW

1 or 0

5V or 0V.

This input is commonly used to sense the presence of voltage when a switch is opened or
closed.

Digital inputs can also be used as the basis for countless digital communication protocols.
By creating a 5V (HIGH) pulse or 0V (LOW) pulse, you can create a binary signal, the
basis of all computing. This is useful for talking to digital sensors like a PING ultrasonic
sensor.
For a simple example of a digital input in use, connect a switch from digital pin 2 to 5V, a
10K resistor from digital pin 2 to ground, and run the following code:

File --> Examples --> 2.Digital --> Button


The 10K resistor is called a pull-down resistor because it connects the digital pin to
ground when the switch is not pressed. When the switch is pressed, the electrical
connections in the switch has less resistance than the resistor, and the electricity no longer
18

connects to ground. Instead, electricity flows between 5V and the digital pin. This is
because electricity always chooses the path of least resistance.

4.1.3 ARDUINO PIN DIAGRAM AND DESCRIPTION:

Fig 4.1 Arduino Pin

The Arduino Uno R3 is a open source microcontroller board based on the ATmega328
chip. This Board has 14 digital input/output pins, 6 analog input pins, Onboard 16 MHz
ceramic resonator, Port for USB connection, Onboard DC power jack, An ICSP header and
a microcontroller reset button. It contains everything needed to support the
microcontroller. Using the board is also very easy, simply connect it to a computer with a
USB cable or power it with DC adapter or battery to get started.

The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial
driver chip. Instead, it features the Atmega16U2Atmega8U2 up to version R2)
programmed as a USB-to-serial converter. While the Arduino UNO can be powered via the
USB connection or with an external power supply, the power source is selected
automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or
battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the
board's power jack. Also leads from a battery can be inserted in the Gnd and Vin pin
headers of the Power connector. The board can operate on an external supply of 6 to 20
19

volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts
and the board may be unstable. If using more than 12V, the voltage regulator may overheat
and damage the board. The recommended range is 5v to 12v for Arduino Uno.

Operating Voltage: 5V.

Input Voltage: 7-12V.

Digital I/O Pins: 14 (of which 6 provide PWM output).

Analog Input Pins: 6.

DC Current: 40mA.

Flash Memory: 32 KB.

SRAM: 2 KB.

EEPROM: 1 KB.

Clock Speed: 16 MHz.

Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin
can provide or receive a maximum of 40 mA and has an internal pull-up resistor of 20-50
kOhms.
Serial: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial
chip.

External Interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value. See the attachInterrupt()
function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.
20

LED: There is a built-in LED connected to digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, its off.

The Uno has 6 analog inputs, labelled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5 volts,
though is it possible to change the upper end of their range using the AREF pin and the
analogReference() function. Additionally, some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire
library.

There are a couple of other pins on the board:

AREF: Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.

4.1.4 Applications of Arduino Uno :


DIY project prototyping.
Developing varied varieties of projects that require a code based control.
Automation System development.
Learning AVR programming

4.2 LCD MODULE

LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. These modules are preferred over seven
segments and other multi segment LEDs. The reasons being: LCDs are economical; easily
programmable; have no limitation of displaying special & even custom characters (unlike
in seven segments), animations and so on.

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines.
In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data.
21

The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it, clearing
its screen, setting the cursor position, controlling display etc. The data register stores the
data to be displayed on the LCD. The data is the ASCII value of the character to be
displayed on the LCD. Click to learn more about internal structure of a LCD.

4.2.1 Description

Fig 4.2 LCD Module


22

Pin No Function Name


1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
Selects command register when low; and data Register
4
register when high Select
Low to write to the register; High to read from
5 Read/write
the register
Sends data to data pins when a high to low pulse
6 Enable
is given
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-

Table No. 4.1 LCD

4.3 ULTRA SONIC SENSOR


The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like
bats do. It offers excellent non-contact range detection with high accuracy and stable
readings in an easy-to-use package. From 2cm to 400 cm or 1 to 13 feet. It operation is
not affected by sunlight or black material like Sharp rangefinders are (although
acoustically soft materials like cloth can be difficult to detect). It comes complete with
ultrasonic transmitter and receiver module.
23

Fig 4.3 Ultrasonic Sensor

4.3.1 Features
Power Supply :+5V DC

Quiescent Current : <2mA

Working Current: 15mA

Effectual Angle: <15

Ranging Distance : 2cm 400 cm/1 13ft

Resolution : 0.3 cm

Measuring Angle: 30 degree

Trigger Input Pulse width: 10Us

Dimension: 45mm x 20mm x 15mm

Trig : Trigger (INPUT)

Echo: Echo (OUTPUT)

GND: GND

4.3.2 Working Principle Of Ultrasonic Sensor:

These sensors are of two types:

Ultrasonic Transmitter Before transmitting the ultrasonic wave, transducer is used to


generate the ultrasonic waves. The transducer is given a signal to intermittently produce
24

ultrasonic waves. After that the ultrasonic transmitter sends the waves at a predetermined
distance frontward. The maximum range for which obstacle can be detected depends on the
range of ultrasonic sensors used.

Ultrasonic Receiver If the ultrasonic wave detects the obstacle, it will produce a
reflected wave. An ultrasonic receiver is used for receiving the ultrasonic waves reflected
from the obstacle. The received ultrasonic wave is converted into a reception signal with
the help of a transducer. The signal is amplified by an amplifier (operational amplifier).
The amplified signal is compared with the reference signal, to detect components in
amplified signal due to obstacles on the road.

The ultrasonic sensor transmits sound waves and receives sound reflected from an
object. When ultrasonic waves are incident on an object, diffused reflection of the energy
takes place over a wide solid angle which might be as high as 180 degrees. Thus some
fraction of the incident energy is reflected back to the transducer in the form of echoes. If
the object is very close to the sensor, the sound waves returns quickly, but if the object is
far away from the sensor, the sound waves takes longer to return. But if objects are too far
away from the sensor, the signal takes so long to come back (or is very weak when it
comes back) that the receiver cannot detect it.: The sensor uses the time it takes for the
sound to come back from the object in front to determine the distance of an object.

Fig 4.4 Working Of Sensor

The distance to the object (L) can then be calculated through the speed of ultrasonic waves
(v) in the medium by the relation, where, t is the time taken by the wave to reach back to
the sensor and is the angle between the horizontal and the path taken as shown in the
25

figure. If the object is in motion, instruments based on Doppler shift are used. The
ultrasonic sensor can measure distances in centimetres and inches. It can measure from 0 to
2.5 meters, with a precision of 3 cm. HCSR04 range sensor HC-SR04 is a commonly used
module for non-contact distance measurement for distances from 2cm to 400cm. It has 4
pins: VCC 5V, input power; TRIG Trigger Input; ECHO Echo Output; GND
Ground Fig. 3: A trigger signal is provided to TRIG input, a HIGH signal of at least 10S
duration. This enables the module to transmit eight 40KHz ultrasonic burst. If there is an
obstacle in-front of the module, it will reflect those ultrasonic waves. If the signal comes
back, the ECHO output of the module will be HIGH for duration of time taken for sending
and receiving ultrasonic signals. The Obstacle Depends obstacle from the sensor and it will
be about 38ms if there is no obstacle.

Fig 4.5 Timing diagram of sensor


26

4.4 BUZZER
A buzzer or beeper is an audio signaling device, which may be mechanical,
electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm
devices, timers, and confirmation of user input such as a mouse click or keystroke.

Fig 4.6 Buzzer

4.5 LED
A light-emitting diode (LED) is a two lead semiconductor light source. It is a p-n
junction diode that emits light when activated.
When a suitable voltage is applied to the leads, electrons are able to recombine with
electron holes within the device, releasing energy in the form of photons. This effect is
called electroluminescence.

Fig 4.7 LED


27

CHAPTER-5

SOFTWARE IMPLEMENTATION

The software used in this project is the ARDUINO IDE software 8.1.3.

Arduino is a prototype platform (open-source) based on an easy-to-use hardware and


software. It consists of a circuit board, which can be programMed (referred to as a
microcontroller) and a ready-made software called Arduino IDE (Integrated Development
Environment), which is used to write and upload the computer code to the physical board.
Arduino provides a standard form factor that breaks the functions of the micro-controller
into a more accessible packages.

The key features are

: Arduino boards are able to read analog or digital input signals from different sensors
and turn it into an output such as activating a motor, turning LED on/off, connect to the
cloud and many other actions

. You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading software).

Unlike most previous programmable circuit boards, Arduino does not need an extra piece
of hardware (called a programmer) in order to load a new code onto the board. You can
simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of C++,
making it easier to learn to program. Finally, Arduino provides a standard form factor
that breaks the functions of the micro-controller into a more accessible package.

5.1 PROCEDURE
After learning about the main parts of the Arduino UNO board, we are ready to learn
how to set up the Arduino IDE. Once we learn this, we will be ready to upload our
program on the Arduino board.

In this section, we will learn in easy steps, how to set up the Arduino IDE on our
computer and prepare the board to receive the program via USB cable.
28

Step 1: First you must have your Arduino board (you can choose your favorite board) and
a USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega
2560, or Diecimila, you will need a standard USB cable

Step 2: Download Arduino IDE Software. You can get different versions of Arduino IDE
from the Download page on the Arduino Official website. You must select your software,
which is compatible with your operating system (Windows, IOS, or Linux). After your file
download is complete, unzip the file.

Step 3: Power up your board. The Arduino Uno, Mega, Duemilanove and Arduino Nano
automatically draw power from either, the USB connection to the computer or an external
power supply. If you are using an Arduino Diecimila, you have to make sure that the board
is configured to draw power from the USB connection. The power source is selected with a
jumper, a small piece of plastic that fits onto two of the three pins between the USB and
power jacks. Check that it is on the two pins closest to the USB port. Connect the Arduino
board to your computer using the USB cable. The green power LED (labeled PWR) should
glow.

Step 4: Launch Arduino IDE. After your Arduino IDE software is downloaded, you need
un zip the folder. Inside the folder, you can find the application icon with an infinity label
(application.exe). Double click the icon to start the IDE.

Step 5: Open your first project. Once the software starts, you have two options: Create a
new project. Open an existing project example.

To create a new project, select File --> New.


To open an existing project example, select File -> Example -> Basics -> Blink
Step 6: Select your Arduino board. To avoid any error while uploading with the board
connected to your computer. Go to Tools -> Board and select your board.ading your
program to the board, you must select the correct Arduino board name, which matches

Here, we have selected Arduino Uno board according to our tutorial, but you must
select the name matching the board that you are using.

Step 7: Select your serial port. Select the serial device of the Arduino board. Go to Tools -
> Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually
29

reserved for hardware serial ports). To find out, you can disconnect your Arduino board
and re-open the menu, the entry that disappears should be of the Arduino board. Reconnect
the board and select that serial port

Step 8: Upload the program to your board. Before explaining how we can upload our
program to the board, we must demonstrate the function of each symbol appearing in the
Arduino IDE toolbar

Now, simply click the "Upload" button in the environment. Wait a few seconds; you
will see the RX and TX LEDs on the board, flashing. If the upload is successful, the
message "Doneuploading" will appear in the status bar.
30

5.2 CIRCUIT DIAGRAM

Fig 5.1 Circuit Diagram


31

5.3 PROGRAM CODE


////Collision Warning System////

#include <LiquidCrystal.h> // includes the LiquidCrystal Library

LiquidCrystal lcd(6,7,8,9,10,11); // Creates an LCD object. Parameters: (rs, enable, d4, d5,
d6, d7)

const int trigPin = 12;

const int echoPin = 13;

int buzz = 2;

long duration;

int distance;

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin 13 as an outp

lcd.begin(16,2);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

Serial.begin(9600);

// the loop function runs over and over again forever

void loop()

// Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds


32

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance= duration*0.034/2;

// Prints the distance on the Serial Monitor

if(distance <= 40 && distance >= 20)

digitalWrite(3, HIGH);

delay(100);

lcd.clear();

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will
be displayed

lcd.print("Distance: "); // Prints string "Distance" on the LCD

lcd.print(distance); // Prints the distance value from the sensor

lcd.print(" cm");

delay(10);

//lcd.clear();

// digitalWrite(3, LOW);

// turn the LED on (HIGH is the voltage level)

else

{
33

digitalWrite(3, LOW); // turn the LED off by making the voltage LOW

delay(100);

if(distance <= 20)

digitalWrite(4, HIGH);

delay(100);

digitalWrite(buzz,HIGH);

delay(100);

lcd.clear();

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will
be displayed

lcd.print("Distance: "); // Prints string "Distance" on the LCD

lcd.print(distance); // Prints the distance value from the sensor

lcd.print(" cm");

delay(10);

/*tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);
34

delay(100);

noTone(buzz);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);*/

else

digitalWrite(4, LOW); // turn the LED off by making the voltage LOW

delay(100);

digitalWrite(buzz,LOW);

delay(100); // wait for a second


35

5.4 FLOW CHART

Fig 5.2 Flowchart


36

5.5 ADVANTAGES

Intersection collision warning systems are designed to detect and warn drivers
of approaching traffic and potential right-of-way violations at intersections.
Obstacle detection systems use vehicle-mounted sensors to detect obstructions,
such as other vehicles, road debris, or animals in a vehicle's path or projected path
and alert the driver.
Forward collision warning systems, often known as rear end collision
avoidance systems, warn drivers that they are in a conflict situation with a lead
vehicle. These conflicts can arise when the lead vehicle is stopped, slowing, or
travelling at a constant speed.

Enabling drivers to be aware of their environment, even if line of sight is not


present.
Implementing a low cost device that can be adapted to any providing a system
that is easily installed and maintain.
Using a decentralized system that can be used in dense traffic.
37

CHAPTER-6

OPERATING PROCEDURE

The hardware you gather in first step, now connect all them to controller through wires.
Sensor to controller pin information :-

Sensor has four pins VCC, Trig, Echo and GND. Connect...

VCC pin to 5V on controller

GND pin to GND on controller

Trig pin to pin-12 on controller

Echo pin to pin-13 on controller

Piezo Buzzer to controller pin information :-

Piezo buzzer has two pin.

Connect one pin to pin-2 on controller

Connect another pin to GND on controller

Red LED to controller pin information :-

Red LED has two pin.


Connect one pin to pin-4 on controller

Connect another pin to GND on controller

Blue LED to controller pin information :-


Red LED has two pin.

Connect one pin to pin-3 on controller

Connect another pin to GND on controller

LCD Connections

Connect lcd pin 1 to GND

Connect lcd pin 2 to VCC

Connect lcd pin 3 to GND


38

Connect lcd pin 4 to 6

Connect lcd pin 5 to GND

Connect lcd pin 6 to 7

LCD PINS 7,8,9,10 are not connected.

Connect lcd pin 11 to 8

Connect lcd pin 12 to 9

Connect lcd pin 13 to 10

Connect lcd pin 14 to 11

Connect lcd pin 15 to VCC

Connect lcd pin 16 to GND

Controller to Computer connection information :-


You have USB data cable that you got while buying arduino. By this data cable you
connect computer to arduino board.Now launch the arduino IDE. After connecting to
computer you must have to select board and port from menu Arduino software and then
compile and upload the program into arduino.

6.1 WORKING
The basic idea behind this project is to avoid accident and prevent collision. It is a
precautionary measure that alerts the driver .The initial stage begins from the ultrasonic
sensor that identifies the vehicle in the front and back side. If the car is more than 40CM,
no warning is given means it is safe zone. If the car reaches to 20 cm it alerts the driver by
giving blue color light will glow that will show the notification and alerts the driver . At
distance below 20 cm distance red color light will alerts us that we are in danger zone by
producing a buzzer sound .At the same time the distance between one vehicle and another
vehicle will displayed in LCD. Wire connections are made from the bread board to the
LCD, aurdino kit to the ultrasonic sensors and finally bread board to the aurdino kit. This
project will make easy calculation of an distance between one vehicle and another vehicle
for the driver.
39

Fig 6.1 Working

Let me explain you that how this system works.


It defined three different zones.
Zone 1 :- No warning

Zone 2 :- Only visual warning (In this zone driver has to pay attention)

Zone 3 :- Both visual and audio warning ( Driver has to take necessary action to avoid
collision)
40

CHAPTER-7

RESULTS
The project Arduino based collision prevention warning system was designed and is
found that the designed hardware and software has shown consistently faithful readings
and also proved to be accurate.

Fig 7.1 Hardware Result Image

Fig 7.2 Software Result Image


41

CHAPTER-8

CONCLUSION
In this paper we proposed and implement the collision prevention system. The basic idea
behind this project is to avoid collision and for detecting the obstacle. It is a precautionary
measure that alerts the driver .the initial stage begins from the ultrasonic sensor that
identifies the vehicle in the front and back side. .At 20 meter distance blue color light will
alerts us. When it reaches below 20meter distance red color light will alerts us we are in
danger zone by producing buzzer sound. At the same time the distance between one
vehicle and another vehicle was displayed in LCD. Wire connections are made from the
bread board to the LCD to aurdino kit and to the ultrasonic sensors and finally bread board
to the aurdino kit. This project will make easy calculation of an distance between one
vehicle and another vehicle for the driver. Using this system we may avoid many accidents
happened due to the following system .The system comprises, very low cost components
such as ultrasonic sensor, LCD and LEDs.
42

CHAPTER -9

FUTURE SCOPE
In this paper we proposed and implement the collision prevention system. Using this
system we may avoid many accidents happened due to the following system .The system
comprises, very low cost components such as ultrasonic sensor, LCD and LEDs. This
system might have many advantage such as:

Use the knows the distance about following vehicle


In future, we are going to reduce the speed of one vehicle according to the following
distance of other vehicle.
By this system, we may prevent many accidents and INDIA will become a accident less
country.
43

CHAPTER 10

REFERENCES
https://www.youtube.com/watch?v=ontlwqrzfxo

http://howtomechatronics.com/tutorial.

https://plus.google.com/+Howtomechatr...

https://wapclub.xyz/.../

www.instructables.com/id/Arduino-LCD-Project-for-Measuring-Distance

www.toptechboy.com/arduino/lesson-20-arduino-lcd-project-for-measuring-distance-

Vous aimerez peut-être aussi