Sie sind auf Seite 1von 61

Abstract:

INTRODUCTION
This project will design and build a man-machine interface using a video camera to interpret the
American one-handed sign language alphabet and number gestures (plus others for additional keyboard
and mouse control). The keyboard and mouse are currently the main interfaces between man and
computer. In other areas where 3D information is required, such as computer games, robotics and
design, other mechanical devices such as roller-balls, joysticks and data-gloves are used.
Humans communicate mainly by vision and sound, therefore, a man-machine interface would be more
intuitive if it made greater use of vision and audio recognition. Another advantage is that the user not
only can communicate from a distance, but need have no physical contact with the computer. However,
unlike audio commands, a visual system would be preferable in noisy environments or in situations
where sound would cause a disturbance.
The visual system chosen was the recognition of hand gestures. The amount of computation required to
process hand gestures is much greater than that of the mechanical devices, however standard desktop
computers are now quick enough to make this project hand gesture recognition using computer
vision a viable proposition.
A gesture recognition system could be used in any of the following areas:

Man-machine interface: using hand gestures to control the computer mouse and/or keyboard

functions. An example of this, which has been implemented in this project, controls various keyboard
and mouse functions using gestures alone.

3D animation: Rapid and simple conversion of hand movements into 3D computer space for

the purposes of computer animation.

Visualisation: Just as objects can be visually examined by rotating them with the hand, so it

would be advantageous if virtual 3D objects (displayed on the computer screen) could be manipulated
by rotating the hand in.

Computer games: Using the hand to interact with computer games would be more natural for

many applications.

Control of mechanical systems (such as robotics): Using the hand to remotely control a

manipulator.
2.2 Project Summary
In order to detect hand gestures, data about the hand will have to be collected. A decision has to be
made as to the nature and source of the data. Two possible technologies to provide this information are:

A glove with sensors attached that measure the position of the finger joints.

An optical method.

An optical method has been chosen, since this is more practical (many modern computers come with a
camera attached), cost effective and has no moving parts, so is less likely to be damaged through use.
The first step in any recognition system is collection of relevant data. In this case the raw image
information will have to be processed to differentiate the skin of the hand (and various markers) from
the background. Chapter 3 deals with this step.
Once the data has been collected it is then possible to use prior information about the hand (for
example, the fingers are always separated from the wrist by the palm) to refine the data and remove as
much noise as possible. This step is important because as the number of gestures to be distinguished
increases the data collected has to be more and more accurate and noise free in order to permit
recognition. Chapter 4 deals with this step.
The next step will be to take the refined data and determine what gesture it represents. Any recognition
system will have to simplify the data to allow calculation in a reasonable amount of time (the target
recognition time for a set of 36 gestures is 25 frames per second). Obvious ways to simplify the data
include translating, rotating and scaling the hand so that it is always presented with the same position,
orientation and effective hand-camera distance to the recognition system. Chapter 5 deals with this step.
2.3 Existing Systems
A simplification used in this project, which was not found in any recognition methods researched, is the
use of a wrist band to remove several degrees of freedom. This enabled three new recognition methods

to be devised. The recognition frame rate achieved is comparable to most of the systems in existence
(after allowance for processor speed) but the number of different gestures recognised and the
recognition accuracy are amongst the best found. Figure 3 shows several of the existing gesture.
Detection
In order to recognise hand gestures it is first necessary to collect information about the hand from raw
data provided by any sensors used. This section deals with the selection of suitable sensors and
compares various methods of returning only the data that pertains to the hand.
3.1 Choice of sensors
Since the hand is by nature a three dimensional object the first optical data collection method
considered was a stereographic multiple camera system. Alternatively, using prior information about
the anatomy of the hand it would be possible to garner the same gesture information using either a
single camera or multiple two dimensional views provided by several cameras. These three options are
considered below:
Stereographic system: The stereographic system would provide pixellated depth information for any
point in the fields of view of the cameras. This would provide a great deal of information about the
hand. Features that would otherwise be hard to distinguish using a 2D system, such as a finger against a
background of skin, would be differentiable since the finger would be closer to camera than the
background. However the 3D data would require a great deal of processor time to calculate and reliable
real-time stereo algorithms are not easily obtained or implemented.
Multiple two dimensional view system: This system would provide less information than the
stereographic system and if the number of cameras used was not great, would also use less processor
time. With this system two or more 2D views of the same hand, provided by separate cameras, could be
combined after gesture recognition. Although each view would suffer from similar problems to that of
the finger example above, the combined views of enough cameras would reveal sufficient data to
approximate any gesture.
Single camera system: This system would provide considerably less information about the hand. Some
features (such as the finger against a background of skin in the example above) would be very hard to
distinguish since no depth information would be recoverable. Essentially only silhouette information
(see Glossary) could be accurately extracted. The silhouette data would be relatively noise free (given a
background sufficiently distinguishable from the hand) and would require considerably less processor
time to compute than either multiple camera system.
It is possible to detect a large subset of gestures using silhouette information alone and the single

camera system is less noisy, expensive and processor hungry. Although the system exhibits more
ambiguity than either of the other systems, this disadvantage is more than outweighed by the
advantages mentioned above. Therefore, it was decided to use the single camera system.

3.2 Hardware setup


The output of the camera system chosen in Section 3.1 comprises of a 2D array of RGB pixels provided
at regular time intervals. In order to detect silhouette information it will be necessary to differentiate
skin from background pixels. It is also likely that other markers will be needed to provide extra
information about the hand (such as hand yaw- see Glossary) and the marker pixels will also have to be
differentiated from the background (and skin pixels). To make this process as achievable as possible it
is essential that the hardware setup is chosen carefully. The various options are discussed below.
Lighting: The task of differentiating the skin pixels from those of the background and markers is made
considerably easier by a careful choice of lighting. If the lighting is constant across the view of the
camera then the effects of self-shadowing can be reduced to a minimum (see Figure 4). The intensity
should also be set to provide sufficient light for the CCD in the camera.
A

Figure 4 The effect of self shadowing (A) and cast shadowing (B). The top three images were lit by
a single light source situated off to the left. A self-shadowing effect can be seen on all three,

especially marked on the right image where the hand is angled away from the source. The bottom
three images are more uniformly lit, with little self-shadowing. Cast shadows do not affect the
skin for any of the images and therefore should not degrade detection. Note how an increase of
illumination in the bottom three images results in a greater contrast between skin and
background.
However, since this system is intended to be used by the consumer it would be a disadvantage if special
lighting equipment was required. It was decided to attempt to extract the hand and marker information
using standard room lighting (in this case a 100 watt bulb and shade mounted on the ceiling). This
would permit the system to be used in a non-specialist environment.
Camera orientation: It is important to carefully choose the direction in which the camera points to
permit an easy choice of background. The two realistic options are to point the camera towards a wall
or towards the floor (or desktop). However since the lighting was a single overhead bulb, light intensity
would be higher and shadowing effects least if the camera was pointed downwards.
Background: In order to maximise differentiation it is important that the colour of the background
differs as much as possible from that of the skin. The floor colour in the project room was a dull brown.
It was decided that this colour would suffice initially.
3.3 Choice of visual data format
An important trade-off when implementing a computer vision system is to select whether to
differentiate objects using colour or black and white and, if colour, to decide what colour space to use
(red, green, blue or hue, saturation, luminosity). For the purposes of this project, the detection of skin
and marker pixels is required, so the colour space chosen should best facilitate this.
Colour or black and white: The camera and video card available permitted the detection of colour
information. Although using intensity alone (black and white) reduces the amount of data to analyse
and therefore decreases processor load it also makes differentiating skin and markers from the
background much harder (since black and white data exhibits less variation than colour data). Therefore
it was decided to use colour differentiation.
RGB or HSL: The raw data provided by the video card was in the RGB (red, green, blue) format.
However, since the detection system relies on changes in colour (or hue), it could be an advantage to
use HSL (hue, saturation, luminosity- see Glossary) to permit the separation of the hue from luminosity

(light level). To test this the maximum and minimum HSL pixel colour values of a small test area of
skin were manually calculated. These HSL ranges were then used to detect skin pixels in a subsequent
frame (detection was indicated by a change of pixel colour to white). The test was carried out three
times using either hue, saturation or luminosity colour ranges to detect the skin pixels. Next, histograms
were drawn of the number of skin pixels of each value of hue, saturation and luminosity within the test
area. Histograms were also drawn for an equal sized area of non-skin pixels. The results are shown in
Figure 5:

Figure 5 Results of detection using individual ranges of hue (left), saturation (centre) and
luminosity (right) as well as histograms showing the number of pixels detected for each value of
skin (top) and background (bottom). Images and graphs show that hue is a poor variable to use to
detect skin as the range of values for skin hue and background hue demonstrate significant
overlap (although this may have been due to the choice of hue of the background). Saturation is
slightly better and luminosity is the best variable. However, a combination of saturation and
luminosity would provide the best skin detection in this case.
The histogram test was repeated using the RGB colour space. The results are shown in Figure 6.

Figure 6 Histograms showing the number of pixels detected for each value of red (left), green
(centre) and blue (right) colour components for skin pixels (top) and background pixels (bottom).
The ranges for each of the colour components are well separated. This, combined with the fact
that using the RGB colour space is considerably quicker than using HSL suggests that RGB is the
best colour space to use.
Figure 7 shows recognition using red, green and blue colour ranges in combination:

Figure 7 Skin detection using red, green and blue colour ranges in combination. Detection is
adequate and frame rate over twice as fast as the HSL option.
Hue, when compared with saturation and luminosity, is surprisingly bad at skin differentiation (with the
chosen background) and thus HSL shows no significant advantage over RGB. Moreover, since
conversion of the colour data from RGB to HSL took considerable processor time it was decided to use
RGB.
3.4 Colour calibration

It is likely that the detection system will be subjected to varying lighting conditions (for example, due
to time of day or position of camera relative to light sources). Therefore it is likely that an occasional
recalibration will have to be performed. The various calibration techniques are discussed below:
3.4.1

Initial Calibration

The method of skin and marker detection selected above (Section 3.3) involves checking the RGB
values of the pixels to see if they fall within red, green and blue ranges (these ranges are different for
skin and marker). The choice of how to calculate these ranges is an important one. Not only does the
calibration have to result in the detection of all hand and marker pixels at varying light levels, but also
the detection of erroneous background pixels has to be reduced to a minimum.
In order to automatically calculate the colour ranges, an area of the screen was demarcated for
calibration. It was then a simple matter to position the hand or marker (in this case a wrist band) within
this area and then scan it to find the maximum and minimum RGB values of the ranges (see Figure 8).

C (skin ranges)

D (wrist band ranges)

Figure 8 Image A shows the colour calibration areas for wrist band (green) and skin (orange).

Calibration is performed by positioning the wrist band under the green calibration area and the
hand under the orange calibration area (image B shows a partially positioned hand). The
calibration algorithm then reads the colour values of both areas and calculates the ranges by
repeatedly updating maximum and minimum RGB values for each pixel. Images C and D show
the pixel colour values for the skin and wrist band areas. The colour ranges calculated for each
colour component are indicated by double headed arrows.

Figure 9 After calibration of skin and wrist band pixels, colour ranges are used to detect all
subsequent frames. A detected frame is shown here with skin pixel detection indicated in white
and wrist band pixel detection indicated in red.
It was decided to use the calibration routine, discussed in Section 3.4.1, to find the initial values.
However, the ranges returned by this method were less than perfect for the reasons below:

The calibration was carried out using a single frame; hence pixel colour variations over time,

due to camera noise, would not be accounted for.

To ensure that the sampled area only contained skin pixels, by necessity it had to be smaller

than the hand itself. The extremities of the hand (where, due to self-shadowing, the colour variation is
the greatest) were therefore not included in the calibration.

3.4.2

Improving calibration

In order to improve the calibration, four further methods were considered:


1.

Multiple frame calibration: If the calibration was repeated over several frames and the overall

maximum and minimum colour values calculated, then the variation over time due to camera noise
would be included in those ranges and its effect thus negated. The method would require the hand to be
held stationary during the calibration process.
The routine was thus modified to perform the calibration over 10 frames instead of one. Figure 10
shows the results.

Figure 10 Results of multiple frame calibration. Stage A is the result of the initial calibration.
Stage B is the result of calibration over 10 frames. There is no discernable difference in the skin
fit.
Calibration of several frames does little to improve skin detection. Therefore this method was not
retained.
2.

Region-Growing: A second method would be to query pixels close to the detected skin pixels

found using the initial method. If the colour components of these fell just outside the calibration ranges
then the ranges could be increased to include them. This process could then be repeated a number of
times until the skin detection was adequate. Figure 11 shows how the process works (simplified).

Figure 11 A simplified illustration of how region-growing works. Image A shows the initial
captured hand. Image B shows the result of initial calibration, detected pixels are shown in white.
For simplicitys sake the pixels that fall within the initial colour ranges have been drawn as a
square. In practise, all pixels within the ranges will have been identified (these pixels would be
scattered throughout the hand area). Next, any pixels in the neighbourhood of those already
detected are scanned (the area within the black box of image C). If their colour values lie just
outside the current colour ranges, the ranges are increased to include them. The result is shown in
image D (again simplified). Although the pixels between the index and middle fingers fell within
the boundary, their values did not fall close to the ranges, so they were ignored. The process is
then repeated (images E and F) until, in theory, the ranges are such that all skin pixels are
detected.

A program was written to repeat the region-growing process a number of times on a single frame. The
results are shown in Figure 12.

Figure 12 Results of region-growing. Stage A is the result of the initial calibration. Stage B is the
result of 50 repetitions of the region-growing algorithm (the fit is better still but a single
erroneous pixel, circled and arrowed, has been detected in the background). Stage C is the result
of 100 repetitions. The background noise is growing even though the shadowed areas of the hand
are still not detected adequately. Finally, by Stage D with 200 repetitions there is a considerable
amount of background noise.
The results show that performing the region-growing process a small number of times results in slightly
better detection but the process becomes noisy if the number of repetitions is too high (>100). It was

decided to keep this method but restrict its growth to a maximum of 50 repetitions.
3.

Background Subtraction: With this method an image of the background is stored. This

information is then subtracted from any subsequent frames. In theory this would negate the background
leaving only the hand and marker information, making the detection process much easier. However,
although performing background subtraction with a black and white system worked well, doing the
same with colour proved much more difficult as a simple subtraction of the colour components made
the remaining hand and marker colour information uneven over the frame. This method also made the
system considerably slower and was adversely influenced by the automatic aperture adjust of the
camera. As the current system worked adequately it was decided not to proceed with this calibration
step.
4.

Removal of persistent aberrant pixels: Although it is a valid design choice to select a

background that differs greatly in hue both from that of the skin and wrist band colour, it is possible
that imperfections in the background colour or camera function could result in aberrant pixels falling
within the calibrated ranges and therefore be repeatedly misinterpreted as skin or wrist band pixels. It
would be possible to scan the image when the hand is not in the frame and store any (aberrant) pixels
detected. Ignoring these pixels would affect the recognition depending on where the hand was in the
frame. It would therefore be necessary to choose the correct value for the aberrant pixel based on the
value of those surrounding it (if all surrounding pixels are skin then detect as skin, else background).
However, neither the camera nor the background exhibited such pixels when a hand was in frame so it
was decided not to proceed in programming this calibration step.
3.5 Method of colour detection
Until now a simple RGB bounding box has been used in the classification of the skin and marker
pixels. However, if a plot is drawn of the detected skin pixels (see Figure 13) it can be seen that they lie
not within a cuboid (the principle used by the current detection system) but within an ellipsoid.

Figure 13 Plots of different combinations of skin pixel colour values (green) and background pixel
colour values (red). The skin pixels are well separated from the background pixels in all three
colour components but lie within an ellipsoid as opposed to a cuboid. The values are well enough
separated, however, for a cuboid colour range system to work adequately.
In order to improve accuracy it would be necessary to check if the colour components of the skin and
wrist band pixels fell within this ellipsoid. However, this was considered computationally intensive and
given that the current cuboid system works adequately it was not implemented.
3.6 Conclusion
This chapter has described the choice and setup of hardware and the methods of calibration and
detection in order to detect as many of the skin and marker pixels within the frame as possible. The
hardware chosen was a single colour camera pointing down towards a desk (or floor) surface of a
constant colour with no special lighting. Calibration is performed by scanning the RGB colour values
of pixels within a preset area of the frame and improved using a limited amount of region-growing.
Detection is performed by comparing each RGB pixel value with ranges found during calibration.
Figure 12 Stage B shows the successful detection of the majority of the hand area.

Refinement
Using the methods discussed in the previous chapter it is possible to detect the majority of the skin and
band pixels in the frame whilst detecting very few aberrant pixels in the background. However, some
complications were noticed which could reduce the accuracy of recognition at a later stage. These are:
1.

Image distortion: If the cameras visual axis is not perpendicular to the floor plane, a given

gesture would appear different depending on the position and yaw of the hand (a given length in one
area of the frame would appear longer or shorter in another area of the frame). This is termed projective
distortion. Also, if the camera lens is of poor quality then the straight sides of a true square in the frame
would appear curved. This is termed radial distortion.
2.

Skin pixels detected as wrist band pixels: If the wrist band colour ranges are increased

sufficiently for all pixels to be detected then areas of skin that are more reflective (such as the knuckles)
start to be incorrectly identified as band pixels. This is disadvantageous as it leads to inaccurate
recognition information.
3.

Skin pixels of the arm being detected: Any skin pixels above the wrist band will also be

detected as skin. It would be preferable if these pixels could be ignored, as they play no part in the
gesture. Wearing a long sleeve top helps solve the problem but forearm pixels are still detected between
the wrist band and the sleeve (which has a tendency to move up and down the arm as different gestures
are made, leading to variations in the amount of skin detected).
It was decided to reduce the effects of these complications as much as possible.
4.1 Analysis of distortion
Tests were devised to check for the presence of both radial and projective distortion. These are
discussed below.
4.1.1

Radial distortion

In order to assess whether radial distortion was present, a rectangular piece of card was placed in the
frame. It was then a simple matter to check the edges of the frame against the edges of the card (see
Figure 14).

Figure 14 A4 card placed in the frame. If the camera had significant radial distortion, the straight
edges of the paper would appear as curves. This is not the case so radial distortion is not
significant.

The straight sides of the paper are imaged not as curves, but as straight lines, therefore radial distortion
is not present.
4.1.2

Projective distortion

To check for projective distortion a strip of paper was placed in the frame at various positions. By
measuring its length (in pixels) at each location, any vertical or horizontal distortion could be found
(see Figure 15).

A: Strip length 101 pixels

B: Strip length 102 pixels

C: Strip length 99 pixels

D: Strip length 98 pixels

E: Strip length 97 pixels

F: Strip length 95 pixels

Figure 15 Paper strip placed in the frame at different positions (with superimposed lines to aid
measurement). From the measured strip lengths it can be seen that there is only a small amount
of projective distortion present. Overall, there is only 6% deviation in apparent strip length
anywhere in the frame, therefore it was considered unnecessary to correct for projective
distortion.

There is slight image distortion present but its effect is limited to only 6% and therefore was not
considered serious enough to attempt to remove (removal would involve transforming a distorted to
a regular rectangle which would be processor intensive).
4.2 Removal of skin pixels detected as wrist band pixels
Although some skin pixels were incorrectly detected as wrist band pixels when the wrist band
colour ranges were increased, no wrist band pixels were incorrectly detected as skin. It was a simple
matter, therefore, to permit pixels to be detected as wrist band only if they had not previously been
detected as skin. This reduced the number of aberrant wrist band pixels considerably.
4.3 Removal of skin pixels detected from forearm
As there is no difference between the colour ranges of a skin pixel of the hand and a skin pixel of
the forearm, position information will have to be used to remove forearm skin pixels.
4.3.1

Centroid calculation

By averaging the position of the pixels detected it is possible to calculate the centroid of both the
hand and the wrist band.
A formal description of centroid calculation is as follows: From before, the set of all skin
pixel locations was defined as:

Figure 16 Original image before skin and wrist band pixel detection (A) and after (B).
Detected skin pixels are shown in blue and wrist band pixels in red. Centroids are displayed as
black dots.
Notice how even with priority given to skin pixels over wrist band pixels, a number of wrist band
pixels are erroneously detected near the knuckles (where skin has not been detected due to the
higher reflectivity of those areas).
4.3.2

Localising the wrist band

It was considered that if the distance and angle of the edges of the wrist band relative to the hand
centroid could be found, the forearm skin pixels could be removed by comparing their distances and
angles with them.
The edges of the wrist band can be found by scanning lines parallel to the line joining the two
centroids.
Figure 17 shows a number of the lines scanned (reduced for clarity) along with a graph showing the

of wrist band Pixels


detected

thresholds used in the program to detect the band edges.

25
20
15
10

Figure 17 The left image shows the lines scanned to detect the edges of the wrist band. The
number of wrist band pixels detected along each line is counted. The edges have been detected
when the number falls below a certain threshold. The graph on the right shows the number of
pixels detected along each of the lines with the detected edges marked in red.
Using these thresholds it is then possible to utilize only those wrist band pixels that are within the
bands width. This removes any remaining erroneous wrist band pixels detected near the knuckles.
The radius of the band is:
rband max b*left c*band , b*right c*band
Any band pixels further than rband from c*band can then be disqualified.
The wrist band centroid can then be recalculated.
Figure 18 shows the wrist band pixels that have passed this radius test and the recalculated centroid
(passed pixels shown in yellow, radius indicated by black circle).

Figure 18 Radius test applied to wrist band pixels. Any pixels that are further from the wrist
band centroid than the band radius (black circle) previously calculated can be ignored (pixels
that pass shown in yellow, those that fail in red)

4.3.3

Removing skin pixels of the forearm

Finally, using the angle and distance from the hand centroid to the wrist band edges it is possible to
differentiate the skin pixels of the forearm and remove them.
Figure 19 shows the angle and distance criterion being applied, with skin pixels that fail highlighted
in green.

Figure 19 Distance and angle criterion applied to skin pixels. The two straight black lines
show the angle in which the radius criterion is applied. The curved black line shows the
radius beyond which skin pixels are disqualified. In this example failed skin pixels are shown
in green.

HARDWARE REQUIRED

POWER SUPPLY UNIT:


The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V
from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output
obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output
voltage from the rectifier is fed to a filter to remove any a.c components present even mafter
rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.

Circuit Diagram

Transformer:
Usually, DC voltages are required to operate various electronic equipment and these voltages are
5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the
mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a
transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.
Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The
rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because
of its merits like good stability and full wave rectification.

Filter:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and
smoothens the D.C. Output received from this filter is constant until the mains voltage and load is
maintained constant. However, if either of the two is varied, D.C. voltage received at this point
changes. Therefore a regulator is applied at the output stage.

Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical
regulator designed to automatically maintain a constant voltage level. In this project, power supply
of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage
regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12
represent the required output voltage levels.
Notice in the above diagram that a relay uses an electromagnet. This is a device consisting of a coil
of wire wrapped around an iron core. When electricity is applied to the coil of wire it
becomes magnetic, hence the term electromagnet. The A B and C terminals are an SPDT switch
controlled by the electromagnet. When electricity is applied to V1 and V2, the electromagnet acts

upon the SPDT switch so that the B and C terminals are connected. When the electricity is
disconnected, then the A and C terminals are connected. It is important to note that the
electromagnet is magnetically linked to the switch but the two are NOT linked electrically.

AT89S52
5.1 INTRODUCTION
Today, micro controllers have become an integral of all automatic and semi-automatic
machines. Remote controllers, hand-held communication devices, dedicated controllers, have
certainly improved the functional, operational and performance based specifications.
Microcontrollers are single chip microcomputers, more suited for control and automation of
machines and process. Microcontrollers have central processing unit (CPU), memory, I/O units,
timers and counters, analog to digital converters (ADC), digital to analog converters (DAC), serial
ports, interrupt logic, oscillator circuitry and many more functional blocks on chip.
All these functional block on a single Integrated Circuit (IC), result into a reduced size of
control board, low power consumption, more reliability and ease of integration within an
application design. The usage of micro controllers not only reduces the cost of automation, but also
provides more flexibility

5.2 FEATURES
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles

Fully Static Operation: 0 Hz to 24 MHz


Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Two 16-bit Timer/Counters
Six Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes

5.3 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmels high-density non-volatile memory technology and is compatible with
the industry-standard MCS-51 instruction set and pin out.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional
on-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic
chip, the Atmel AT89S52 is a powerful microcomputer which provides highly-flexible and costeffective solution to many embedded control applications

PIN CONFIGURATION

Fig.5.1 Pin configuration

BLOCK DIAGRAM

Fig.5.2. Block diagram

5.6 PIN DESCRIBTION


VCC
Supply voltage.
GND
Ground.

PORT 0
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL
inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0
may also be configured to be the multiplexed low order address/data bus during accesses to external
program and data memory. In this mode P0 has internal pull ups.
Port 0 also receives the code bytes during 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 bi-directional I/O port with internal pull ups. 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 pulledlow will
source current (IIL) because of the internal pull ups. Port 1 also receives the low-order address
bytes during Flash programming and verification.

PORT 2
Port 2 is an 8-bit bi-directional I/O port with internal pull ups. 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 use 16-bit addresses (MOVX @ DPTR). In this application,
it uses strong internal pull ups when emitting 1s. During accesses to external data memory that use
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 bi-directional I/O port with internal pull ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal
pull ups and can be used as inputs.
As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the
pull ups. Port 3 also serves the functions of various special features of the AT89C51 as listed below:

PORT PIN

ALTERNATE FUNCTIONS

P3.0

RXD (serial input port)

P3.1

TXD (serial output port)

P3.2

INT0 (external interrupt 0)

P3.3

INT1 (external interrupt 1)

P3.4

T0 (timer 0 external input)

P3.5

T1 (timer 1 external input)

P3.6

WR (external data memory write strobe)

P3.7

RD (external data memory)

Port 3 also receives some control signals for Flash programming and verification.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device.
ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during accesses to
external memory. This pin is also the program pulse input (PROG) during Flash programming. In
normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used
for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each
access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.

Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.

PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C51 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
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code
from external program memory locations starting at 0000H up to FFFFH. Note, however, that if
lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt
programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.

OSCILLATOR CHARACTERISTICS
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be
configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic
resonator may be used.

To drive the device from an external clock source, XTAL2 should be left unconnected while
XTAL1 is driven as shown in Figure 2. There are no requirements on the duty cycle of the external
clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop,
but minimum and maximum voltage high and low time specifications must be observed.

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 hard ware 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.

Fig.5.3. Oscillator Connections

Note: C1, C2 = 30 pF 10 pF for Crystals


= 40 pF 10 pF for Ceramic Resonators

Fig.5.4.External Clock Drive Configuration


2X16 LCD:

Most LCD programmed in 8 bit configuration. Moreover LCD put on equipment that show
the value of measurement, i.e. temperature, voltage, current, etc. There are a lot of tutorial show
steps how to configure out in order to LCD on. But each LCD has own characteristic
Basic Specifications

Power requirements

4.8 to 5.5Vdc @ 3Ma

User connector

5-pin header; 0.025" posts on 0.10" centers

Connector pinout

+5V GND SERIAL GND +5V

Serial Input

RS-232 or inverted TTL, 2400/9600, N81

Operating Temperature

0 to 50 C

Initialization

switches LCD power; performs soft init

Instruction prefix

ASCII 254 (0FE hex)

LCD type

Supertwist (STN), yellow-green

Optimum viewing direction

6 o'clock

LCD Instructions by Function


Function

ASCII Value

Clear screen

Home cursor

Blank display (retaining data)

Hide cursor

12

Show underline cursor

14

Move cursor 1 character left

16

Move cursor 1 character right

20

Scroll 1 character left

24

Scroll 1 character right

28

Set display address (position the cursor)

128 + location

Move to 1st character of 1st line

128

Move to nth character of 1st line

128 + n

Move to 1st character of 2nd line

192

Move to nth character of 2nd line

192 + n

Set character-generator address

64 + address

SERIAL COMMUNICATION:
DTE and DCE
The terms DTE and DCE are very common in the data communications market. DTE is
short for Data Terminal Equipment and DCE stands for Data Communications Equipment. As the
full DTE name indicates this is a piece of device that ends a communication line, whereas the DCE
provides a path for communication. For example, the PC is a Data Terminal (DTE). The two
modems (yours and that one of your provider) are DCEs, they make the communication between
you and your provider possible.
RS-232
In telecommunications, RS-232 is a standard for serial binary data signals connecting
between a DTE (Data terminal equipment) and a DCE (Data Circuit-terminating Equipment). It is
commonly used in computer serial ports. In RS-232, data is sent as a time-series of bits. Both
synchronous and asynchronous transmissions are supported by the standard. In addition to the data
circuits, the standard defines a number of control circuits used to manage the connection between
the DTE and DCE. Each data or control circuit only operates in one direction that is, signaling from
a DTE to the attached DCE or the reverse. Since transmit data and receive data are separate circuits,
the interface can operate in a full duplex manner, supporting concurrent data flow in both
directions. The standard does not define character framing within the data stream, or character
encoding.
Female 9 pin plug

Functions
Data

Handshake
Common
Other

Signals
TxD
RxD
RTS
CTS
DSR
DCD
STR
Com
RI

PIN
3
2
7
8
6
1
4
5
9

DTE
Output
Input
Output
Input
Input
Input
Output
-Output

DCE
Input
Output
Input
Output
Output
Output
Input
-Input

RS-232 Signals
1.

Transmitted Data (TxD)


Data sent from DTE to DCE.

2.

Received Data (RxD)


Data sent from DCE to DTE.

3.Request To Send (RTS)


Asserted (set to 0) by DTE to prepare DCE to receive data. This may require action on the part
of the DCE, e.g. transmitting a carrier or reversing the direction of a half-duplex line.
4.Clear To Send (CTS)
Asserted by DCE to acknowledge RTS and allow DTE to transmit.
5.

Data Terminal Ready (DTR)


Asserted by DTE to indicate that it is ready to be connected. If the DCE is a modem, it
should go "off hook" when it receives this signal. If this signal is de-asserted, the modem should
respond by immediately hanging up.

6.

Data Set Ready (DSR)


Asserted by DCE to indicate an active connection.If DCE is not a modem (e.g. a null-modem cable
or other equipment), this signal should be permanently asserted (set to 0), possibly by a jumper to
another signal.

7.

Carrier Detect (CD)


Asserted by DCE when a connection has been established with remote equipment.
8. Ring Indicator (RI)
Asserted by DCE when it detects a ring signal from the telephone line.
RTS/CTS Handshaking
The standard RS-232 use of the RTS and CTS lines is asymmetrical. The DTE asserts RTS
to indicate a desire to transmit and the DCE asserts CTS in response to grant permission. This
allows for half-duplex modems that disable their transmitters when not required and must transmit a
synchronization preamble to the receiver when they are re-enabled.
There is no way for the DTE to indicate that it is unable to accept data from the DCE. A nonstandard symmetrical alternative is widely used: CTS indicates permission from the DCE for the
DTE to transmit, and RTS indicates permission from the DTE for the DCE to transmit. The "request
to transmit" is implicit and continuous.
The standard defines RTS/CTS as the signaling protocol for flow control for data transmitted from
DTE to DCE. The standard has no provision for flow control in the other direction. In practice,
most hardware seems to have repurposed the RTS signal for this function.
A minimal 3-wire RS-232 connection consisting only of transmits data, receives data and
Ground, and is commonly used when the full facilities of RS-232 are not required.
When only flow control is required, the RTS and CTS lines are added in a 5-wire version. In our
case it was imperative that we connected the RTS line of the microcontroller (DTE) to ground to
enable receipt of bit streams from the modem.
Specifying Baud Rate, Parity & Stop bits
Serial communication using RS-232 requires that you specify four parameters: the baud rate
of the transmission, the number of data bits encoding a character, the sense of the optional parity
bit, and the number of stop bits. Each transmitted character is packaged in a character frame that
consists of a single start bit followed by the data bits, the optional

parity bit, and the stop bit or bits. A typical character frame encoding the letter "m" is shown
here.

Character Frame Encoding m

We specified the parameters as baud rate 2400 bps, 8 data bits, no parity, and 1 stop bit
(2400-8-N-1). This was set in pre-operational phase while setting up the modem through the hyper
terminal, as per the serial transmission standards in 8051 microcontroller.

ZIGBEE:
ZigBee is the name of a specification for a suite of high level communication protocols
using small, low-power digital radios based on the IEEE 802.15.4 standard for wireless personal
area networks (WPANs), such as wireless headphones connecting with cell phones via short-range
radio. The technology is intended to be simpler and cheaper than other WPANs, such as Bluetooth.
ZigBee is targeted at radio-frequency (RF) applications which require a low data rate, long battery
life, and secure networking.
1.3 OVERVIEW:
ZigBee builds upon the physical layer and medium access control defined in IEEE standard
802.15.4 (2003 version) for low-rate WPAN's. The specification goes on to complete the standard
by adding four main components: network layer, application layer, ZigBee device objects (ZDO's)

and manufacturer-defined application objects which allow for customization and favor total
integration.
Besides adding two high-level network layers to the underlying structure, the most
significant improvement is the introduction of ZDO's. These are responsible for a number of tasks,
which include keeping of device roles, management of requests to join a network, device discovery
and security. At its core, ZigBee is a mesh network architecture. Its network layer natively supports
three types of topologies: both star and tree typical networks and generic mesh networks. Every
network must have one coordinator device, tasked with its creation, the control of its parameters
and basic maintenance. Within star networks, the coordinator must be the central node. Both trees
and meshes allow the use of ZigBee routers to extend communication at the network level (they are
not ZigBee coordinators, but may act as 802.15.4 coordinators within their personal operating
space), but they differ in a few important details: communication within trees is hierarchical and
optionally utilizes frame beacons, whereas meshes allow generic communication structures but no
router beaconing. The relationship between IEEE 802.15.4-2003 and ZigBee is similar to that
between IEEE 802.11 and the Wi-Fi Alliance. The ZigBee 1.0 specification was ratified on
December 14, 2004 and is available to members of the ZigBee Alliance. An entry level membership
called Adopter, in the ZigBee Alliance costs US$3500 annually and provides access to the
specifications and permission to create products for market using the specifications. For noncommercial purposes, the ZigBee specification is available to the general public at the ZigBee
Specification Download Request. Most recently, the ZigBee 2006 specification was posted in
December 2006.3 ZigBee operates in the industrial, scientific and medical (ISM) radio bands; 868
MHz in Europe, 915 MHz in countries such as USA and Australia, and 2.4 GHz in most
jurisdictions worldwide. The technology is intended to be simpler and cheaper than other WPANs
such as Bluetooth. The most capable ZigBee node type is said to require only about 10% of the
software of a typical Bluetooth or Wireless Internet node, while the simplest nodes are about 2%
However, actual code sizes are much higher, closer to 50% of Bluetooth code size ZigBee chip
vendors have announced 128-kilobyte devices. As of 2006, the retail price of a Zigbee-compliant
transceiver is approaching $1, and the price for one radio, processor, and memory package is about
$3. Comparatively, before Bluetooth was launched (1998) it had a projected price, in high volumes,
of $4 - $6; the price of consumer-grade Bluetooth chips is now under $3. First stack release is now
called "Zigbee 2004". The 2nd stack release is called 2006, and mainly replaces the MSG/KVP
structure used in 2004 with a "cluster library". The 2004 stack is now more or less obsolete. The
ZigBee Alliance has started work on ZigBee 2007, looking to extend the ZigBee 2006 specification

capabilities; the main enhancements are optimizing certain network level functionality (such as data
aggregation). There are also some new application profiles like Automatic Meter Reading,
Commercial building automation and home automation based on the "cluster library principle".
Zigbee 2007, now the current stack release, is sometimes called "Pro", but pro is a stack profile,
which defines certain stack settings and mandatory features. ZigBee 2007 at the network level is not
backwards-compatible with ZigBee 2004/2006, although a ZigBee 2004/2006 RFD node can join a
2007 network, and vice-versa. It's not possible to mix 2004/2006 routers with 2007
routers/coordinator.
1.4 NETWORK LAYERS:
The main functions of the network layer are to enable the correct use of the MAC sublayer
and provide a suitable interface for use by the next upper layer, namely 4 the application layer. Its
capabilities and structure are those typically associated to such network layers, including routing.
On the one hand, the data entity creates and manages network layer data units from the payload of
the application layer and performs routing according to the current topology. On the other hand,
there is the layer control, which is used to handle configuration of new devices and establish new
networks: it can determine whether a neighboring device belongs to the network and discovers new
neighbors and routers. The control can also detect the presence of a receiver, which allows direct
communication and MAC synchronization.
1.5 APPLICATION LAYER:
The application layer is the highest-level layer defined by the specification, and is the
effective interface of the ZigBee system to its end users. It comprises the majority of components
added by the ZigBee specification: both ZDO and its management procedures, together with
application objects defined by the manufacturer, are considered part of this layer.

1.5.1 Main Components:


The ZDO is responsible for defining the role of a device as either coordinator or end device,
as mentioned above, but also for the discovery of new (one-hop) devices on the network and the
identification of their offered services. It may then go on to establish secure links with external
devices and reply to binding requests accordingly. The application support sublayer (APS) is the

other main standard component of the layer, and as such it offers a well-defined interface and
control services. It works as a bridge between the network layer and the other components of the
application layer: it keeps up-to-date binding tables in the form of a database, which can be used to
find appropriate devices depending on the services that are needed and those the different devices
offer. As the union between both specified layers, it also routes messages across the layers of the
protocol stack.

SECURITY SERVICES:
As one of its defining features, ZigBee provides facilities for carrying out secure
communications, protecting establishment and transport of cryptographic keys, cyphering frames
and controlling devices. It builds on the basic security framework defined in IEEE 802.15.4. This
part of the architecture relies on the correct management of symmetric keys and the correct
implementation of methods and security policies.
1.6.1 Basic security model:
The basic mechanism to ensure confidentiality is the adequate protection of all keying
material. Trust must be assumed in the initial installation of the keys, as well as in the processing of
security information. In order for an implementation to globally work, its general correctness (e.g.,
conformance to specified behaviors) is assumed. Keys are the cornerstone of the security
architecture; as such their protection is of paramount importance, and keys are never supposed to be
transported through 8 an insecure channel. There is a momentary exception to this rule, which
occurs during the initial phase of the addition to the network of a reviouslyunconfigured device.
The ZigBee network model must take particular care of security considerations, as ad hoc networks
may be physically accessible to xternal devices and the particular working environment cannot be
foretold; likewise, different applications running concurrently and using the same ransceiver to
communicate are supposed to be mutually trustworthy: for cost reasons the model does not assume
a firewall exists between application-level ntities. Within the protocol stack, different network
layers are not cryptographically parated, so access policies are needed and correct design assumed.
The open trust model within a device allows for key sharing, which otably decreases potential cost.
Nevertheless, the layer which creates a frame is responsible for its security. If malicious devices
may exist, every network layer payload must be cyphered, so unauthorized traffic can be
immediately cut off. The exception, again, is the transmission of the network key, which confers a

unified security layer to the network, to a new connecting device. Point-to-point encryption is also
supported.

1.7 PROTOCOLS:
The protocols build on recent algorithmic research (Ad-hoc On-demand Distance Vector,
neuRFon) to automatically construct a low-speed ad-hoc network of nodes. In most large network
instances, the network will be a cluster of clusters. It can also form a mesh or a single cluster. The
current profiles derived from the ZigBee protocols support beacon and non-beacon enabled
networks. In non-beacon-enabled networks (those whose beacon order is 15), an unslotted
CSMA/CA channel access mechanism is used. In this type of network, ZigBee Routers typically
have their receivers continuously active, requiring a more robust power supply. However, this
allows for heterogeneous networks in which some devices receive continuously, while others only
transmit when an external stimulus is detected. The typical example of a heterogeneous network is a
wireless light switch: The ZigBee node at the lamp may receive constantly, since it is connected to
the mains supply, while a battery-powered light switch would remain asleep until the switch is
thrown. The switch then wakes up, sends a command to the lamp, receives an acknowledgment, and
returns to sleep. In such a network the lamp node willbe at least a ZigBee Router, if not the ZigBee
Coordinator; the switch node is typically a ZigBee End Device.
In beacon-enabled networks, the special network nodes called ZigBee Routers transmit
periodic beacons to confirm their presence to other network nodes. Nodes may sleep between
beacons, thus lowering their duty cycle and extending their battery life. Beacon intervals may range
from 15.36 milliseconds to 15.36 ms * 214 = 251.65824 seconds at 250 kbit/s, from 24 milliseconds
to 24 ms * 214 = 393.216 seconds at 40 kbit/s and from 48 milliseconds to 48 ms * 214 = 786.432
seconds at 20 kbit/s. However, low duty cycle operation with long beacon intervals requires precise
timing which can conflict with the need for low product cost.
In general, the ZigBee protocols minimize the time the radio is on so as to reduce power
use. In beaconing networks, nodes only need to be active while a beacon is being transmitted. In
non-beacon-enabled networks, power consumption is decidedly asymmetrical: some devices are
always active, while others spend most of their time sleeping. ZigBee devices are required to
conform to the IEEE 802.15.4-2003 Low-Rate Wireless Personal Area Network (WPAN) standard.
The standard specifies the lower protocol layersthe physical layer (PHY), and the medium access
control (MAC)

portion of the data link layer (DLL). This standard specifies operation in theunlicensed 2.4 GHz,
915 MHz and 868 MHz ISM bands. In the 2.4 GHz band there are 16 ZigBee channels, with each
channel requiring 5 MHz of bandwidth. The center frequency for each channel can be calculated as,
FC = (2405 + 5*(k-11)) MHz, where k = 11, 12, ..., 26.
The radios use direct-sequence spread spectrum coding, which is managed by the digital
stream into the modulator. BPSK is used in the 868 and 915 MHz bands, and orthogonal QPSK that
transmits two bits per symbol is used in the 2.4 GHz band.
The raw, over-the-air data rate is 250 kbit/s per channel in the 2.4 GHz band, 40 kbit/s per
channel in the 915 MHz band, and 20 kbit/s in the 868 MHz band. Transmission range is between
10 and 75 meters (33 and 246 feet), although it is heavily dependent on the particular environment.
The maximum output power of the radios is generally 0 dBm (1 mW).
The basic channel access mode specified by IEEE 802.15.4-2003 is "carrier
sense, multiple access/collision avoidance" (CSMA/CA). That is, the nodes talk in the same way
that people converse; they briefly check to see that no one is talking before they start. There are
three notable exceptions to the use of CSMA. Beacons are sent on a fixed timing schedule, and do
not use CSMA. Message acknowledgements also do not use CSMA. Finally, devices in Beacon
Oriented networks that have low latency real-time requirements may also use Guaranteed Time
Slots (GTS) which by definition does not use CSMA.
1.8 NODE TYPES:
This page describes the types of node that are used in a ZigBee network. Reference will be
made to the toplogies introduced on the previous page (Star, Tree, Mesh), but these topologies will
be described in more detail later in this module. The ZigBee standard has the capacity to address up
to 65535 nodes in a single network. However, there are only three general types of node: These
roles described below exist at the network level a ZigBee node may also be performing tasks at
the application level independent of the role it plays in the network. For instance, a network of
ZigBee devices measuring temperature may have a temperature sensor application in each node,
irrespective of whether they are End Devices, Routers or the Co-ordinator.These node types are
described below.

1.8.1 ZigBeecoordinator(ZC):

The most capable device, the coordinator forms the root of the network tree and might bridge to
other networks. There is exactly one ZigBee coordinator in each network since it is the device that
started the network originally. It is able to store information about the network, including acting as
the Trust Centre & repository for security keys.
All ZigBee networks must have one (and only one) Co-ordinator, irrespective of the network
topology.
In the Star topology, the Co-ordinator is the central node in the network. In the Tree and
Mesh topologies, the Co-ordinator is the top (root) node in the network. This is illustrated below,
where the Co-ordinator is colour-coded in dark black. At the network level, the Co-ordinator is
mainly needed at system initialisation. The tasks of the Co-ordinator at the network layer are:

Selects the frequency channel to be used by the network (usually the one with the least detected
activity)
Starts the network
Allows other devices to connect to it (that is, to join the network)
The Co-ordinator can also provide message routing (for example,
in a Star network), security management and other services.

In some circumstances, the network will be able to operate normally if the Coordinator fails or is
switched off. This will not be the case if the Co-coordinator provides a routing path through the
network (for instance, in a Star topology, where it is needed to relay messages). Similarly the Coordinator provides services at the Application layer and if these services are being used (for
example, Co-coordinator binding), the Co-ordinator must be able to provide them at all times.

1.8.2 ZigBee Router (ZR): As well as running an application function a router can act as an
intermediate router, passing data from other devices.
Networks with Tree or Mesh topologies need at least one Router. The main tasks of a Router are:

Relays messages from one node to another


Allows child nodes to connect to it
In a Star topology, these functions are handled by the Co-ordinator and, therefore, a Star network
does not need Routers. In Tree and Mesh topologies, Routers are located as follows:

In a Tree topology, Routers are normally located in network positions that allow messages to be

passed up and down the tree.


In a Mesh topology, a Router can be located anywhere that a message passing node is required.

However, in all topologies (Star, Tree and Mesh), Router devices can be located at the extremities
of the network, if they run applications that are needed in these locations - in this case, the Router
will not perform its message relay function, unless in a Mesh network (see above). The possible
positions of Routers in the different network topologies are illustrated below, where the Routers are
color-coded in red.
1.10 USES:
ZigBee protocols are intended for use in embedded applications requiring low data rates and
low power consumption. ZigBee's current focus is to define a generalpurpose, inexpensive, selforganizing mesh network that can be used for industrial control, embedded sensing, medical data
collection, smoke and intruder warning, building automation, home automation, etc. The resulting
network will use very small amounts of power so individual devices might run for a year or two
using the originally installed battery.
Typical application areas include:

Home Entertainment and Control - Smart Lighting, Advanced Temperature Control, Safety &
Security and Movies & Music

Home Awareness - Water Sensors, Power Sensors, Smart Appliances and Access sensors
Mobile Services m-payment, m-monitoring and control, m-security and access control, m-

healthcare and tele-assist.


Commercial Building Energy Monitoring, HVAC, Lighting, Access Control.
Industrial Plant Process Control, Asset Management, Environmental management, Energy
Management.

CHAPTER 4: IMPLEMENTATION
The accelerometer records the hand movements in the X and Y directions only and outputs constant
analog voltage levels. These voltages are fed to the comparator IC which compares it with the
references voltages that we have set via variable resistors attached to the IC. The levels that we
have set are 1.7V and 1.4V. Every voltage generated by the accelerometer is compared with these
and an analog 1 or 0 signal is given out by the comparator IC.

Fig 4-1 Input and Output of Comparator IC

This analog signal is the input to the encoder IC. The input to the encoder is parallel while the
output is a serial coded waveform which is suitable for RF transmission. A push button is attached
to pin 14 of this IC which is the Transmission Enable (TE) pin. The coded data will be passed onto
the RF module only when the button is pressed. This button makes sure no data is transmitted
unless we want to.
The RF transmitter modulates the input signal using Amplitude Shift Keying (ASK) modulation. It
is the form of modulation that represents digital data as variations in the amplitude of a carrier
wave.
Page | 21

WIRELESS GESTURE CONTROLLED ROBOT

The following figure shows the modulated output of the RF module:

Fig 4-2 ASK Modulation

The RF modules works on the frequency of 315MHz. It means that the carrier frequency of the RF
module is 315MHz. The RF module enables the user to control the robot wirelessly and with ease.
The schematic of transmitting end can be seen below:

Page | 22

WIRELESS GESTURE CONTROLLED ROBOT

Fig 4-3 Transmitting Circuit

Page | 23

WIRELESS GESTURE CONTROLLED ROBOT

This transmitted signal is received by the RF receiver, demodulated and then passed onto the
decoder IC. The decoder IC decodes the coded waveform and the original data bits are recovered.
The input is a serial coded modulated waveform while the output is parallel. The pin 17 of the
decoder IC is the Valid Transmission (VT) pin. A led can be connected to this pin which will
indicate the status of the transmission. In the case of a successful transmission, the led will blink.
The parallel data from the encoder is fed to the port 1of the microcontroller. This data is in the form
of bits. The microcontroller reads these bits and takes decisions on the basis of these bits. What the
microcontroller does is, it compares the input bits with the coded bits which are burnt into the
program memory of the microcontroller and outputs on the basis of these bits. Port 2 of the
microcontroller is used as the output port. Output bits from this port are forwarded to the motor
driver IC which drives the motors in a special configuration based on the hand movements.
At a dead stop, a motor produces no voltage. If a voltage is applied and the motor begins to spin, it
will act as a generator that will produce a voltage that opposes the external voltage applied to it.
This is called Counter Electromotive Force (CEF) or Back Electromotive Force (Back EMF). If a
load stops the motors from moving then the current may be high enough to burn out the motor coil
windings. To prevent this, flyback diodes are used. They prevent the back emf from increasing and
damaging the motors.
The schematic of receiving end can be seen below:

4.1 SIMULATION
We performed a simulation of our project in PROTEUS and the code was written in C language

using KEIL MICROVISION. We wrote a code for the microcontroller to run DC motors using the
H-Bridge IC (L293D). In the simulation we sent the relevant data to the Microcontroller (AT89C51)
through switches. The Microcontroller processed the data and sent the information to the Actuator
IC (L293D). The Actuator IC upon receiving information showed response by driving the DC
motors. The simulation schematic is as follow:

WIRELESS GESTURE CONTROLLED ROBOT

CHAPTER 5: CONCLUSION, LIMITATIONS AND FUTURE WORK


5.1 CONCLUSION
We achieved our objective without any hurdles i.e. the control of a robot using gestures. The robot
is showing proper responses whenever we move our hand. Different Hand gestures to make the
robot move in specific directions are as follow:

Fig 5-1 Move Forward

Fig 5-2 Move Backward

Fig 5-3 Move Right

Fig 5-4 Move Left

SOFTWARE REQUIRED

INTRODUCTION TO MATLAB
What Is MATLAB?
MATLAB is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation.
Typical uses include: Math and computation,
Algorithm development
Data acquisition
Modeling, simulation, and prototyping
Data analysis, exploration, and visualization
Scientific and engineering graphics

Application development, including graphical user interface building.


MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those with
matrix and vector formulations, in a fraction of the time it would take to write a program in a scalar
non interactive language such as C or FORTRAN.
The name MATLAB stands for matrix laboratory. MATLAB was originally written to
provide easy access to matrix software developed by the LINPACK and EISPACK projects. Today,

MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in
software for matrix computation.
MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses in
mathematics, engineering, and science. In industry, MATLAB is the tool of choice for highproductivity research, development, and analysis.
MATLAB features a family of add-on application-specific solutions called toolboxes. Very
important to most users of MATLAB, toolboxes allow you to learn and apply specialized
technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend
the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are
available include signal processing, control systems, neural networks, fuzzy logic, wavelets,
simulation, and many others.
The MATLAB System:
The MATLAB system consists of five main parts:
Development Environment:
This is the set of tools and facilities that help you use MATLAB functions and files. Many
of these tools are graphical user interfaces. It includes the MATLAB desktop and Command
Window, a command history, an editor and debugger, and browsers for viewing help, the
workspace, files, and the search path.
The MATLAB Mathematical Function:
This is a vast collection of computational algorithms ranging from elementary functions like sum,
sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix
eigen values, Bessel functions, and fast Fourier transforms.
The MATLAB Language:
This is a high-level matrix/array language with control flow statements, functions, data structures,
input/output, and object-oriented programming features. It allows both "programming in the small"
to rapidly create quick and dirty throw-away programs, and "programming in the large" to create
complete large and complex application programs.

Graphics:
MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as
annotating and printing these graphs. It includes high-level functions for two-dimensional and
three-dimensional data visualization, image processing, animation, and presentation graphics. It
also includes low-level functions that allow you to fully customize the appearance of graphics as
well as to build complete graphical user interfaces on your MATLAB applications.
The MATLAB Application Program Interface (API):
This is a library that allows you to write C and Fortran programs that interact with MATLAB. It
includes facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a
computational engine, and for reading and writing MAT-files.

KEIL

The Keil tool chain consists of the following executables located in the c:\c51eval\bin directory:
Vision uvw51e.exe
C Compiler c51.exe
Assembler a51.exe
Linker bL51.exe
dScopedsw51.exe

Vision IDE
Vision is a Windows based front end for the C Compiler and Assembler. It was developed in the
USA as was the printed manual set. Compiler, Assembler and Linker options are set with simple
mouse clicks. Vision runs on Windows 3.1, 95 and NT. The Compiler, Assembler and Linker are
DOS executables. They can be accessed with your favorite batch files if you prefer. This provides
maximum flexibility. This Integrated Development Environment (IDE) has been expressly designed
with the user in mind. A full function editor is included. All IDE functions are intuitive via pull
down menus with prompted selections. An extensive Help utility is included. External executables
can be run from within Vision. This includes emulator software.

C51 C Compiler for the 8051, 8x931Hx and 8x931Ax [USB]


The C51 ANSI compiler along with the A51 assembler is designed specifically for the Intel
MCS8051 microcontroller family, including the 8x931 USB. The C51 is 100% compatible with
existing 8051programs. Extensions provide access to all 8051 hardware components. Sample
USB/931 code is available: www.keil.com/usb. C51 supports code banking. The compiler can be
run in either DOS mode or called from the Windows based front end Vision. run from Vision
which is included with every Assembler and Compiler package.

Evaluation Version of the Keil Tool Set:


The evaluation version of the Keil tool set is restricted to a 2K code size and the code must be
located at 0x4000. Useful object code is produced. Other than these restrictions, the tool set works
exactly as the full version does. This allows you to fully evaluate the features and power of Keil
products. The full version has no restrictions and is fully ANSI compliant.

Das könnte Ihnen auch gefallen