You are on page 1of 30

Abstract

Now a days so many useful technologies are coming out to make our life style more comfort
luxuries and secure.

Especially in mobile field so application are being developed to give us more information and
entertainment. This project is designed with combination of two latest and more demanding
technologies that are AVR and embedded systems.

The AVR is a modified Harvard architecture 8-bit RISC single-chip microcontroller, which was
developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-
chip flash memory for program storage, as opposed to one-time programmable ROM,,
or EEPROM used by other microcontrollers at the time. In todays world ROBOTICS is a fast
growing and interesting field. ROBOT has sufficient intelligence to cover the maximum area of
provided space. It has an infrared sensor which are used to sense the obstacles coming in
between the path of ROBOT. It will move in a particular direction and avoid the obstacle which
is coming in its path.Autonomous Intelligent Robots are robots that can perform desired tasks in
unstructured environments without continuous human guidance. The minimum number of
gearmotor allows the walking robot to minimize the power consumption while construct a
program that can produce coordination of multi-degree of freedom for the movement ofthe robot.
It is found that two gearmotors are sufficient to produce the basic walking robot and one voltage
regulators are needed to control the load where it is capable of supplying enough current to drive
two gearmotors for each wheel.

In our project we have used Microcontroller 8051 .

1
Certificate

The work presented in this report entitled Edge avoider robot submitted to the Department of
Electronics Technology, Guru Nanak Dev University, Amritsar, is the original work carried
by team of four members Komal , Mehak , Varunpreet Kaur , Mehpreet Singh from January
,2016 to May ,2016 under my guidance. This work has not been submitted in any other degree
/diploma in this/any other college/university. This report is fit to be considered for the award of
degree of Bachelor of Technology in Electronics and Communication.

Date: April 27th, 2016

Komal Mehak Varunpreet Kaur Mehpreet Singh

Er. Jasdeep Singh

(Supervisor)

Department of Electronics Technology

Guru Nanak Dev University

Amritsar

2
Acknowledgment

Perseverance, inspiration and motivation have always play a key role in any venture. It is not just
the brain that matters most but that which guides them. The character, heart and generous
qualities and progressive forces. What was conceived just as an idea materialized slowly into
concrete facts. The metamorphosis took endless hours of toil, had its moments of frustration, but
in the end of everything seemed to have sense.

At this level of understanding it is very often difficult to understand wide spectrum of knowledge
without proper guidance and advice. Hence, we take this opportunity to express our heartfelt
gratitude to our project guide ER.JASDEEP SINGH to had faith in us and allow us to work on
this project.

We would also like to thank DR. ML SINGH (HOD Electronics) for providing us opportunity
to learn new things throughout the period of word undertaken which has been instrumented in
the success of our project and also for the immense interest, valuable guidance, constant
inspiration and kind co-operation.

We also acknowledge our profound sense of gratitude to all our teachers who have been
instrumental for providing us the technical knowledge and moral support to complete the project
with full understanding.

We thank our friends and family for their moral support to carve out this project and above all
GOD for removing all the hurdles in the way.

3
Contents

Abstract 1

Certificate 2

Acknowledgment 3

Contents 4

List of figures 6

Chapter 1: Introduction to Embedded Systems 7

1.1 Real Life Examples of Embedded Systems 7

1.2 Embedded Systems in the Home Environment 7

1.3 Embedded systems at work 8

1.4 Embedded Systems in Leisure Activities 9

Chapter 2: Microcontrollers 11

2.1 Microcontroller 8051 11

Chapter 3: Components of the project 15

3.1 IR Sensor 15

3.2 Seven Segment Display 18

3.3 Motor Driver IC 21

Chapter 4: Interfacing with Microcontrollers 23

4.1 Interfacing of components with microntroller8051 23

4
4.1.1 Interfacing of Seven Segment Display 23

4.1.2 Interfacing of Motor Driver IC 24

Chapter 5: Programming using embedded C. 25

5.1 Program for interfacing with 8051 27

Chapter 6: Conclusions. 29

References.. 30

5
List of figures

Fig 1.1 Embedded systems at home

Fig 1.2 Navigation system and portable music player

Fig 2.1Architecture of 8051

Fig 3.1 IR sensor

Fig 3.2 Seven Segment display

Fig 3.3 Motor driver IC

Fig 4.1 Interface with seven segment display

Fig 4.2 Interface with Motor Driver IC

6
Chapter 1
Introduction to Embedded System
An Embedded System can be defined as a control system or computer system designed to
perform a specific task. Common examples of embedded systems include MP3 players,
navigation systems on aircraft and intruder alarm systems. An embedded system can also be
defined as a single purpose computer.

Embedded systems are considered when the cost of implementing a product designed in
software on a microprocessor and some small amount of hardware, is cheaper, more reliable, or
better for some other reason than a discrete hardware design. It is possible for one small and
relatively cheap microprocessor to replace dozens or even hundreds of hardware logic gates,
timing circuits, input buffers, output drivers, etc. It also happens that one generic embedded
system with a standard input and output configuration can be made to perform in a completely
different manner simply by changing the software.
The uses of embedded systems are virtually limitless, because every day new products are
introduced to the market that utilize 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.
A Real-Time system is defined as a system whose correctness depends on the timeliness of its
response. Examples of such systems are flight control systems of an aircraft, sensor systems in
nuclear reactors and power plants. For these systems, delay in response is a fatal error. A more
relaxed version of Real-Time Systems, is the one where timely response with small delays is
acceptable. Example of such a system would be the Scheduling Display System on the railway
platforms. In technical terminology,
7
Real-Time Systems can be classified as:

i. Hard Real-Time Systems - systems with severe constraints on the timeliness of the
response.
ii. Soft Real-Time Systems - systems which tolerate small variations in response times.
iii. Hybrid Real-Time Systems - systems which exhibit both hardware & software
constraints on its performance
Embedded systems are playing important roles in our lives every day, even though they might
not necessarily be visible. Some of the embedded systems we use every day control the menu
system on television, the timer in a microwave oven, a cellphone, an MP3 player or any other
device with some amount of intelligence built-in. In fact, recent poll data shows that embedded
computer systems currently outnumber humans in the USA. Embedded systems is a rapidly
growing industry where growth opportunities are numerous.

1.1 Real Life Examples of Embedded Systems

Even though often nearly invisible, embedded systems are ubiquitous. Embedded systems are
present in many industries, including industrial automation, defense, transportation, and
aerospace. For example, NASAs Mars Path Finder, Lockheed Martins missile guidance system,
and the Ford automobile all contain numerous embedded systems.

Every day, people throughout the world use embedded systems without even knowing it. In fact,
the embedded systems invisibility is its very beauty: users reap the advantages without having to
understand the intricacies of the technology.

Remarkably adaptable and versatile, embedded systems can be found at home, at work, and even
in recreational devices. Indeed, it is difficult to find a segment of daily life that does not involve
embedded systems in some way. Some of the more visible examples of embedded systems are
provided in the next sections.

1.2 Embedded Systems in the Home Environment

Hidden conveniently within numerous household appliances, embedded systems are found all
over the house. Consumers enjoy the effort-saving advanced features and benefits provided by
these embedded technologies.

Embedded systems in the home assume many forms, including security systems, cable and
satellite boxes for televisions, home theater systems, and telephone answering machines. As
advances in microprocessors continue to improve the functionality of ordinary products,
embedded systems are helping drive the development of additional home-based innovations.

8
Fig1.1 Embedded systems at home

Embedded systems have also changed the way people conduct business. Perhaps the most
significant example is the Internet, which is really just a very large collection of embedded
systems that are interconnected using various networking technologies illustrates what a small
segment of the Internet might look like.

1.3 Embedded systems at work


From various individual network end-points (for example, printers, cable modems, and enterprise
network routers) to the backbone gigabit switches, embedded technology has helped make use of
the Internet necessary to any business model. The network routers and the backbone gigabit
switches are examples of real-time embedded systems. Advancements in real-time embedded
technology are making Internet connectivity both reliable and responsive, despite the enormous
amount of voice and data traffic carried over the network.

1.4 Embedded Systems in Leisure Activities

At home, at work, even at play, embedded systems are flourishing. A childs toy unexpectedly
springs to life with unabashed liveliness. Automobiles equipped with in-car navigation systems
transport people to destinations safely and efficiently. Listening to favorite tunes with anytime-
anywhere freedom is readily achievable, thanks to embedded systems buried deep within
sophisticated portable music players, as shown in Figure1.2

9
Fig 1.2 Navigation system and portable music player

Even the portable computing device, called a web table, is an embedded system.
Embedded systems also have teamed with other technologies to deliver benefits to the
traditionally low-tech world. GPS technology, for example, uses satellites to pinpoint locations
to centimeter-level accuracy, which allows hikers, cyclists, and other outdoor enthusiasts to use
GPS handheld devices to enjoy vast spaces without getting lost. Even fishermen use GPS devices
to store the locations of their favorite fishing holes.

Embedded systems also have taken traditional radio-controlled airplanes, racecars, and boats to
new heights and speeds. As complex embedded systems in disguise, these devices take command
inputs from joysticks and pass them wirelessly to the devices receiver, enabling the model
airplane, racecar, or boat to engage in speedy and complex maneuvers. In fact, the introduction
of embedded technology has rendered these sports safer and more enjoyable for model owners
by virtually eliminating the once-common threat of crashing due to signal interference.

10
Chapter 2
Microcontroller

2.1Microcontroller 8051

The Intel MCS-51 (commonly termed 8051) is an internally Harvard architecture, complex
instruction set computing (CISC) instruction set, single chip microcontroller (C) series
developed by Intel in 1980 for use in embedded systems. Intel's original versions were popular in
the 1980s and early 1990s and enhanced binary compatible derivatives remain popular today.

Intel's original MCS-51 family was developed using N-type metal-oxide-semiconductor (NMOS)
technology like its predecessor Intel MCS-48, but later versions, identified by a letter C in their
name (e.g., 80C51) used complementary metaloxidesemiconductor (CMOS) technology and
consume less power than their NMOS predecessors. This made them more suitable for battery-
powered devices.

The family was continued in 1996 with the enhanced 8-bit MCS-151 and the 8/16/32-bit MCS-
251 family of binary compatible microcontrollers. While Intel no longer manufactures the MCS-
51, MCS-151 and MCS-251 family, enhanced binary compatible derivatives made by numerous
vendors remain popular today. Some derivatives integrate a digital signal processor (DSP).
Beyond these physical devices, several companies also offer MCS-51 derivatives as IP cores for
use in field-programmable gate array (FPGA) or application-specific integrated circuit (ASIC)
designs. ROM of 4KB and RAM of 128 bytes

The 8051 architecture provides many functions (central processing unit (CPU), random access
memory (RAM), read-only memory (ROM), input/output (I/O), interrupt logic, timer, etc.) in
one package:

8-bit arithmetic logic unit (ALU) and accumulator, 8-bit registers (one 16-bit register
with special move instructions), 8-bit data bus and 216-bit address bus/program
counter/data pointer and related 8/11/16-bit operations; hence it is mainly an 8-
bit microcontroller

Boolean processor with 17 instructions, 1-bit accumulator, 32 registers (4 bit-addressable


8-bit) and up to 144 special 1 bit-addressable RAM variables (18 bit-addressable 8-bit)

Multiply, divide and compare instructions

4 fast switchable register banks with 8 registers each (memory mapped)

11
Fast interrupt with optional register bank switching

Interrupts and threads with selectable priority.

Dual 16-bit address bus It can access 2 x 216 memory locations 64 K (65,536
locations) each of RAM and ROM

128 bytes of on-chip RAM (IRAM)

4 Kib of on-chip ROM, with a 16-bit (64 KiB) address space (PMEM). Not included on
803X variants

Four 8-bit bi-directional input/output port, bit addressable

Two 16-bit Counter/timers

Power saving mode (on some derivatives)

Typical applications

8051 chips are used in a wide variety of control systems, telecom applications, robotics as
well as in the automotive industry. By some estimations, 8051 family chips make up over
50% of the embedded chip market.

Basic Pins

PIN 9: PIN 9 is the reset pin which is used to reset the microcontrollers internal registers
and ports upon starting up. (Pin should be held high for 2 machine cycles.)

PINS 18 & 19: The 8051 has a built-in oscillator amplifier hence we need to only connect
a crystal at these pins to provide clock pulses to the circuit.

PIN 40 and 20: Pins 40 and 20 are VCC and ground respectively. The 8051 chip needs
+5V 500mA to function properly, although there are lower powered versions like the
Atmel 2051 which is a scaled down version of the 8051 which runs on +3V.

PINS 29, 30 & 31: As described in the features of the 8051, this chip contains a built-in
flash memory. In order to program this we need to supply a voltage of +12V at pin 31. If
external memory is connected then PIN 31, also called EA/VPP, should be connected to
ground to indicate the presence of external memory. PIN 30 is called ALE (address latch
enable), which is used when multiple memory chips are connected to the controller and
only one of them needs to be selected.We will deal with this in depth in the later chapters.
PIN 29 is called PSEN. This is "program store enable". In order to use the external
memory it is required to provide the low voltage (0) on both PSEN and EA pins.

12
Ports

There are 4 8-bit ports: P0, P1, P2 and P3.

PORT P1 (Pins 1 to 8): The port P1 is a general purpose input/output port which can be
used for a variety of interfacing tasks. The other ports P0, P2 and P3 have dual roles or
additional functions associated with them based upon the context of their usage.The port
1 output buffers can sink/source four TTL inputs. When 1s are written to portn1 pins are
pulled high by the internal pull-ups and can be used as inputs.

Fig 2.1 Pin Diagram of 8051

PORT P3 (Pins 10 to 17): PORT P3 acts as a normal IO port, but Port P3 has additional
functions such as, serial transmit and receive pins, 2 external interrupt pins, 2 external counter
inputs, read and write pins for memory access.

PORT P2 (pins 21 to 28): PORT P2 can also be used as a general purpose 8 bit port when no
external memory is present, but if external memory access is required then PORT P2 will act as

13
an address bus in conjunction with PORT P0 to access external memory. PORT P2 acts as A8-
A15

PORT P0 (pins 32 to 39) PORT P0 can be used as a general purpose 8 bit port when no
external memory is present, but if external memory access is required then PORT P0 acts as a
multiplexed address and data bus that can be used to access external memory in conjunction with
PORT P2. P0 acts as AD0-AD7,

PORT P10: asynchronous communication input or Serial synchronous communication output.

Fig 2.2 Architecture of 8051

14
Chapter 3

Components of the project

3.1 IR Sensor
An infrared sensor is an electronic device, that emits in order to sense some aspects of the
surroundings. An IR sensor can measure the heat of an object as well as detects the motion.
These types of sensors measures only infrared radiation, rather than emitting it that is called as
a passive IR sensor. Usually in the infrared spectrum, all the objects radiate some form of
thermal radiations. These types of radiations are invisible to our eyes, that can be detected by an
infrared sensor. The emitter is simply an IR LED (Light Emitting Diode) and the detector is
simply an IR photodiode which is sensitive to IR light of the same wavelength as that emitted by
the IR LED. When IR light falls on the photodiode, The resistances and these output voltages,
change in proportion to the magnitude of the IR light received.IR sensor consists of two
components . Transmitter and Receiver Transmitter transmits the infrared rays while receiver
receives the infrared rays and provide analog output which is further converted to logic 0 or 1
depending upon the active low or active high by the ADC connected to PORT A. The PCB
containing transmitter and receiver consists of three pins i.e : Vcc , Ground , Output.

IR Sensor Circuit Diagram and Working Principle


An infrared sensor circuit is one of the basic and popular sensor module in an electronics device.
This sensor is analogous to humans visionary senses, which can be used to detect obstacles and
it is one of the common applications in real time.This circuit comprises of the following
components

o LM358 IC 2 IR transmitter and receiver pair

o Resistors of the range of kilo ohms.

o Variable resistors.

15
o LED (Light Emitting Diode).

Fig 3.1 IR Sensor Circuit

In this project, the transmitter section includes an IR sensor, which transmits continuous IR rays
to be received by an IR receiver module. An IR output terminal of the receiver varies depending
upon its receiving of IR rays. Since this variation cannot be analyzed as such, therefore this
output can be fed to a comparator circuit. Here an operational amplifier (op-amp) of LM 339 is
used as comparator circuit.

When the IR receiver does not receive a signal, the potential at the inverting input goes higher
than that non-inverting input of the comparator IC (LM339). Thus the output of the comparator
goes low, but the LED does not glow. When the IR receiver module receives signal to the
potential at the inverting input goes low. Thus the output of the comparator (LM 339) goes high
and the LED starts glowing. Resistor R1 (100 ), R2 (10k ) and R3 (330) are used to ensure that
minimum 10 mA current passes through the IR LED Devices like Photodiode and normal LEDs
respectively. Resistor VR2 (preset=5k ) is used to adjust the output terminals. Resistor VR1
(preset=10k ) is used to set the sensitivity of the circuit Diagram. Read more about IR sensors.

Different Types of IR Sensors and Their Applications

IR sensors are classified into different types depending on the applications. Some of the typical
applications of different types of sensors are

16
The speed sensor is used for synchronizing the speed of multiple motors. The temperature
sensor is used for industrial temperature control. PIR sensor is used for automatic door opening
system and Ultrasonic sensor are used for distance measurement.

IR Sensor Applications

IR sensors are used in various sensor based project and also in various electronic devices which
measures the temperature that are discussed in the below.

Radiation Thermometers

IR sensors are used in radiation thermometers to measure the temperature depend upon the
temperature and the material of the object and these thermometers have some of the following
features

Measurement without direct contact with the object


Faster response
Easy pattern measurements

17
3.2 Seven Segment Display
Seven-segment displays may use a liquid crystal display (LCD), a light-emitting diode (LED) for
each segment, or other light-generating or controlling techniques such as cold cathode gas
discharge, vacuum fluorescent, incandescent filaments, and others. For gasoline price totems and
other large signs, vane displays made up of electromagnetically flipped light-reflecting segments
(or "vanes") are still commonly used. An alternative to the 7-segment display in the 1950s
through the 1970s was the cold-cathode, neon-lamp-like nixie tube. Starting in 1970, RCA sold a
display device known as the Numitron that used incandescent filaments arranged into a seven-
segment display.

In a simple LED package, typically all of the cathodes (negative terminals) or all of the anodes
(positive terminals) of the segment LEDs are connected and brought out to a common pin; this is
referred to as a "common cathode" or "common anode" device. Hence a 7 segment plus decimal
point package will only require nine pins, though commercial products typically contain more
pins, and/or spaces where pins would go, in order to match standard IC sockets. Integrated
displays also exist, with single or multiple digits. Some of these integrated displays incorporate
their own internal decoder, though most do not: each individual LED is brought out to a
connecting pin as described.

A multiplexed 4-digit, seven-segment display with only 12 pins

Multiple-digit LED displays as used in pocket calculators and similar devices used multiplexed
displays to reduce the number of I/O pins required to control the display. For example, all the
anodes of the A segments of each digit position would be connected together and to a driver
circuit pin, while the cathodes of all segments for each digit would be connected. To operate any
particular segment of any digit, the controlling integrated circuit would turn on the cathode
driver for the selected digit, and the anode drivers for the desired segments; then after a short
blanking interval the next digit would be selected and new segments lit, in a sequential fashion.
In this manner an eight digit display with seven segments and a decimal point would require only
8 cathode drivers and 8 anode drivers, instead of sixty-four drivers and IC pins. Often in pocket
calculators the digit drive lines would be used to scan the keyboard as well, providing further
savings; however, pressing multiple keys at once would produce odd results on the multiplexed
display.

A single byte can encode the full state of a 7-segment-display. The most popular bit encodings
are gfedcba and abcdefg, where each letter represents a particular segment in the display. In the
gfedcba representation, a byte value of 0x06 would (in a common-anode circuit) turn on
segments 'c' and 'b', which would display a '1'.
18
When dealing with seven-segment displays, there are two types. Common anode and common
cathode; in common anode all the anodes on the display are tied to a common pin, typically the
power source, and the LED are controlled via the cathodes with ground being on and power
being off. In common cathode all the cathodes are tied to a common pin, in this case generally
ground, and the LED are driven by the state of the anodes where ground is off and power is on.

Fig 3.2 Seven segment display

Hence a seven-segment plus decimal point package will only require nine pins, though
commercial products typically contain more pins in order to match industry standard pinouts.
The seven elements of the display can be lit in different combinations to represent the arabic
numerals. Often the seven segments are arranged in an oblique (slanted) arrangement, which aids
readability. In most applications, the seven segments are of nearly uniform shape and size
(usually elongated hexagons, though trapezoids and rectangles can also be used), though in the
case of adding machines, the vertical segments are longer and more oddly shaped at the ends in
an effort to further enhance readability.

The numerals 6, 7 and 9 may be represented by two or more different glyphs on seven-segment
displays, with or without a 'tail'.

The seven segments are arranged as a rectangle of two vertical segments on each side with one
horizontal segment on the top, middle, and bottom. Additionally, the seventh segment bisects the
rectangle horizontally. There are also fourteen-segment displays and sixteen-segment displays
(for full alphanumerics); however, these have mostly been replaced by dot matrix displays.

The segments of a 7-segment display are referred to by the letters A to G, where the optional
decimal point (an "eighth segment", referred to as DP) is used for the display of non-integer
numbers. In this manner an eight digit display with seven segments and a decimal point would

19
require only 8 cathode drivers and 8 anode drivers, instead of sixty-four drivers and IC pins.
Often in pocket calculators the digit drive lines would be used to scan the keyboard as well,
providing further savings; however, pressing multiple keys at once would produce odd results on
the multiplexed display.A single byte can encode the full state of a 7-segment-display. The most
popular bit encodings are gfedcba and abcdefg, where each letter represents a particular segment
in the display. In the gfedcba representation, a byte value of 0x06 would (in a common-anode
circuit) turn on segments 'c' and 'b', which would display a '1'.

20
3.3 Motor Driver IC
The L293D works on the concept of typical H-bridge, a circuit which allows the high voltage to
be flown in either direction. In a single L293D IC there are two H-bridge circuits which can
rotate two DC motors independently. Due to its size and voltage requirement, it is frequently
used in robotics applications for controlling DC motors, including in Arduino projects. The
L293D is also a key component in larger 'motor driver' boards available premade for hobbyists.
Driver ICs are primarily used in autonomous robotics only. Also most microprocessors operate at
low voltages and require a small amount of current to operate while the motors require a
relatively higher voltages and current . Thus current cannot be supplied to the motors from the
microprocessor. This is the primary need for the motor driver IC.

Working of L293D

There are two drive pins on L293D. Pin 1 (left H-bridge) and pin 9 (right H-bridge). To turn ON
the corresponding motor, pin 1 or 9 need to be set to HIGH. If either pin 1 or pin 9 goes low then
the motor in the corresponding section will go OFF (high impedance). These inputs (1 and 9) are
the ones that should be used to control motor START/STOP and motor speed under PWM, since
there would be high impedance output during low semiperiod of PWM, it would not provoke
overload of the L293D when the motor is turning. Thus, PWM or motor ON/OFF control should
never be input to pins 2, 7, 15, 10, which should only be used to control direction (Clockwise -
CounterClockwise).

The direction-defining four Input pins for the L293D are pin 2 and 7 on the left and pin 15 and
10 on the right as shown on the pin diagram. Left input pins will determine the rotation of motor
connected on the left side and right input for motor on the right hand side. The motors are rotated
on the basis of the inputs provided at the input pins as LOGIC 1 or LOGIC 0.

21
Fig 3.3 Motor Driver IC

A motor driver IC is an integrated circuit chip which is usually used to control motors in
autonomous robots. Motor driver ICs act as an interface between microprocessors in robots and
the motors in the robot. The most commonly used motor driver ICs are from the L293 series
such as L293D, L293NE, etc. These ICs are designed to control 2 DC motors simultaneously.
L293D consist of two H-bridge. H-bridge is the simplest circuit for controlling a low current
rated motor. For this tutorial we will be referring the motor driver IC as L293D only. L293D has
16 pins, they are comprised as follows:

Ground Pins - 4

Input Pins - 4

Output Pins - 4

Enable pins - 2

Voltage Pins - 2

22
Chapter 4
Interfacing with Microcontrollers
4.1 Interfacing of components with Microcontroller 8051

When dealing with real-time software, the value of a variable or the occurrence of an event
depends essentially on the timing of signals to be gathered and then transfer to another
components whole of this idea is first run on softwares and are checked. So that they can work
properly in real world also . There is need of little tweaks which we are able to do after finding
mistakes and learning from it. This process goes on until a perfect running circuit model is
achieved and according to that only the components are laid on PCB.

4.1.1 Interfacing with seven segment display

Fig 4.1 Seven segment interface

23
4.1.2 Interfacing with Motor Driver IC

Fig 4.2 Interface with Motor Driver IC

24
Chapter 5

Programming using embedded C

This project is designed with combination of two latest and more demanding technologies that
are AVR and embedded systems.

The AVR is a modified Harvard architecture 8-bit RISC single-chip microcontroller, which was
developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-
chip flash memory for program storage, as opposed to one-time programmable ROM,
or EEPROM used by other microcontrollers at the time. For In-System Programming, the
programmer is connected to the target using as fewwires as possible. To program any AVR
microcontroller in any target system, a simpleSix-wire interface is used to connect the
programmer to the target PCB.The Serial Peripheral Interface (SPI) consists of three wires:
Serial ClocK (SCK), MasterIn Slave Out (MISO) and Master Out Slave In (MOSI). When
programming theAVR, the In-System Programmer always operate as the Master, and the target
system always operate as the Slave.The In-System Programmer (Master) provides the clock for
the communication on the SCK Line. Each pulse on the SCK Line transfers one bit from the
Programmer (Master) to the Target (Slave) on the Master Out Slave In (MOSI) line.
Simultaneously, each pulse on the SCK Line transfers one bit from the target (Slave) to the
Programmer(Master) on the Master In Slave Out (MISO) line. In-System Programming allows
programming and reprogramming of any AVR microcontrollerpositioned inside the end system.
Using a simple Three-wire SPI interface,the In-System Programmer communicates serially with
the AVR microcontroller,reprogramming all non-volatile memories on the chip. In-System
Programming eliminates the physical removal of chips from the system.This will save time, and
money, both during development in the lab, and when updating the software or parameters in the
field.

This application note shows how to design the system to support In-System Programming.It also
shows how a low-cost In-System Programmer can be made, that will allow the target AVR
microcontroller to be programmed from any PC equipped with a regular 9-pin serial port.
Alternatively, the entire In-System Programmer can be built into the system allowing it to
reprogram itself. All commands have a common format consisting of four bytes. The first byte
contains the command code, selecting operation and target memory. The second and third byte

25
contain the address of the selected memory area. The fourth byte contains the data, going in
either direction.The data returned from the target is usually the data sent in the previous byte. An
example, where two consecutive commands are sent to the target. Notice how all bytes returned
equal the bytes just received. Some commands return one byte from the targets memory. This
byte is always returned in the last byte (byte 4). Data is always sent on MOSI and MISO lines
with most significant bit (MSB) first. In-System Programmer communicates serially with the
AVR microcontroller,reprogramming all non-volatile memories on the chip. In-System
Programming eliminates the physical removal of chips from the system.This will save time, and
money, both during development in the lab, and when updating the software or parameters in the
field.

26
5.1Program for interfacing with 8051

#include<reg51.h>
sbit inbit1=P3^0;
sbit inbit2=P3^1;
sbit i1=P1^0;
sbit i2=P1^1;
sbit i3=P1^2;
sbit i4=P1^3;
sbit e1=P1^4;
sbit e2=P1^5;
sfr seven=0xA0 ;
void MSdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void main()
{
while(1)
{
if(inbit1==0&&inbit2==0)
{
e1=0;
e2=0;
i1=0;
i2=0;
i3=0;
i4=0;
seven=0x5b;
}
MSdelay(50);

if(inbit1==0&&inbit2==1)
{
e1=1;
e2=0;
i1=1;
i2=0;

27
i3=0;
i4=0;
seven=0x8e;
}
MSdelay(50);

if(inbit1==1&&inbit2==0)
{
e1=0;
e2=1;
i1=0;
i2=0;
i3=1;
i4=0;
seven=0x0e;
}
MSdelay(50);

if(inbit1==1&&inbit2==1)
{
e1=1;
e2=1;
i1=1;
i2=0;
i3=1;
i4=0;
seven=0xb8;
}
MSdelay(50);

28
Chapter6
Conclusion

This robot is able to produce the basic walking movements using two motors. we developed the
robot with a very good intelligence which is easily capable to sense the obstacle and by
processing the signal coming from the sensor it is perfectly avoiding the edge coming in between
the path .Robot take the left or right or the forward movement in according to the sensing signal
with the help of the two motor which makes the movement of the robot smooth .In future, the
sensing range can be increased by increasing the sensor quality with the help of ultrasonic sensor
or the IR signal spread all over the provide area.

29
References
Wikipedia
Google
Slideshare.net
Embedded systems design ,Publisher Elsevier India, Author Steve Heath
Embedded systems: concepts ,design and programming, Publisher Pearson,
Author Himanshu Dev & Parag Dev

30

You might also like