Você está na página 1de 59

DEPLOYMENT OF LOW COST OUTDOOR

SURVEILLANCE SYSTEM

A PROJECT REPORT

Submitted by

GOPALAKANNAN.M 12005106026

JAYAPRAKASH.V 12005106033

SRI RAGHAVAN.N 12005106098

In partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

In

ELECTRONICS AND COMMUNICATION ENGINEERING

VELAMMAL ENGINEERING COLLEGE

ANNA UNIVERSITY::CHENNAI 600 025

MAY 2009
ACKNOWLEDGEMENTS

Any accomplishment requires the effort of many people and this work is
no different.

First of all we would like to express our deep gratitude to our beloved and
respected Thiru M.V.Muthuramalingam,Chairman,Velammal Educational
Trust and Thiru M.V.M.Velmurugan,CEO,Velammal Engineering College
for their kind encouragement and blessings.

Our deepest gratitude and thanks to Dr.J.Shanmugam , Principal who


have always helped us whenever we approached them during the course of our
project.

We wish to express our sincere thanks and gratitude to for our most
respectable and beloved Prof.S.Mary Joans, Professor & Head of the
Department of Electronics and Communication Engineering, who has been
a guiding force and constant source of inspiration to us.

Our sincere gratitude and thanks to our beloved Mr.M.Manigandan,


Lecturer & Internal Guide for having extended her fullest co-operation and
guidance without which this project would not have been possible.

We are also grateful to our Project coordinator Mr.M.Manigandan,


who has contributed great deal of help and support. We also thank our
department staff whose diligent effort made this project possible.
ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “DEPLOYMENT OF LOW COST


OUTDOOR SURVEILLANCE SYSTEM” is the bonafide work of
“ M.GOPALAKANNAN , V.JAYAPRAKASH , N.SRI RAGHAVAN ”

who carried out the project work under my supervision.

SIGNATURE SIGNATURE

SIGNATURE SIGNATURE
Prof. S.MARY JOANS M.E, (Ph.D) Mr M.MANIGANDAN M.E
HEAD OF THE DEPARTMENT SUPERVISOR
LECTURER
ELECTRONICS & ELECTRONICS &
COMMUNICATION ENGG., COMMUNICATION ENGG.,
VELAMMAL ENGINEERING VELAMMAL ENGINEERING
COLLEGE, COLLEGE,
VELAMMAL NAGAR, VELAMMAL NAGAR,
SURAPET, SURAPET,
CHENNAI-66 CHENNAI-66
CERTIFICATE OF EVALUATION

College Name: VELAMMAL ENGINEERING COLLEGE

Department : Electronics and Communication Engineering

Semester : VIII

Title of project Name of Students Name of supervisor with


designation

DEPLOYMENT OF LOW M.Gopalakannan Mrs. Manju Jackin


COST OUTDOOR Asst.Professor,
SURVEILLANCE SYSTEM V.Jayaprakash Department of
Electronics
N.Sri Raghavan And Communication
Engineering

The report of the project work submitted by the above students in partial
fulfillment for the award of Bachelor of Engineering Degree in Electronics and
Communication Engineering of Anna University was evaluated and confirmed
to the report of the work done by the above students.

(Internal Examiner) (External Examiner)


ABSTRACT

we are planning to develop a Low cost Surveillance system under

airborne environment using X-UFO Quad Rotor Aerial Vehicle for

monitoring the outdoor environment. In this project we are going to monitor

the moving human sized objects using wireless Surveillance camera through

PC. The image acquisition is done through Wireless transmission from the

X-UFO Quad Rotor Aerial Vehicle on which the wireless camera is mounted

in it. Meanwhile the aerial vehicle control is done from remote location

through PC in wireless mode. We acquire the real time moving object

images from the wireless Camera. Gyroscope sensor is used in our project

for balancing the aerial vehicle in all directions. We have RF modules for

controlling the Quad Rotor Aerial Vehicle.The control actions of the RF

module is done using DC motor which is interfaced with PC for controlling

it. The image is also acquired at the client side from the server where the

Aerial vehicle control controlling module is being connected to the serial

port of the server side.

The designed system contains accelerometers, gyroscope, wireless

surveillance camera, serial port and Embedded Real-Time Systems. The


information from the camera is read through PCI based TV tuner card for

grabbing the images. This completes our surveillance system with complete

Target matching using Correlation Algorithm using MATLAB


Index

Chapter No Title Page


No

1. Introduction 5

2. Literary Review

2.1.Related Project
2.2.Patent Search
2.3.Project Objective
3. System Overview
3.1.Block Diagram
3.2. System Description
3.2.1.Advantages
3.3. Quadra copter Aerial Vehicle
3.3.1.Digital 4 channel radio
3.4.Circuit Diagram
3.4.1.Hardware Description
3.4.1.1.Power Supply Circuit
3.4.1.2. Transformer
3.4.1.3.Bridge Rectifier
3.4.1.4.Regulator
3.4.1.5.Filter
3.4.1.6.LED
3.4.1.7.Circuit Operation
3.4.2.Microcontroller
5.2.Diode
5.3.Regulator
5.4.Microcontroller
5.4.1.Pin Description
5.5.RS232
5.6.H-Bridge
5.7.DC Gear Motor
6. Parallel Port 22
6.1.Parallel Port –Data Port
6.2.Parallel Port- Status Port
6.3.Parallel Port-control Port
6.4.Parallel port –Gnd Pin
7. Visual Basic 25
8. PCI Based TV tuner Card 26
9. PCI TV Program 27
10. Design Process 30
10.1.Mechanical Design
11. Conclusion 31
CHAPTER 1

INTRODUCTION

At a time of economic recession, the selection of means necessary


for the development of research projects takes high importance because,
among other reasons, the premature end of the project depends on this
selection. The use of existing solutions and the merger among similar
projects allows greater efficiency in the use of existing resources.

The goal of the project is to stabilize the Quadra copter such that it
can be wireless controlled with a serial port based on Server- Client
Architecture and to surveillance the outdoor environment. The X-UFO is a
remote controlled flying toy with four rotors. The output power of X-UFO
the motor is much lower, making it (nearly) harmless.

The helicopter used in the lab project was equipped with some
hardware to control the servos through wireless from remote place. To be
able to use the X-UFO for the lab course the UFO needs a comparable piece
of hardware .The multidisciplinary of this problem is expressed in the
problem statement.
CHAPTER 2

LITERARY REVIEW

2.1.Related Project:

The Project titled, “Quad-rotor Unmanned Aerial Vehicle ” , done by


Carlo Canetta, Mr.Jonathan Chin, Mr.Sevan Mehrabian, Mr.Ludguier
Montejo, Mr.Hendrik Thompson of Columbia university is as follows.

Their objective is to design and build a quad-rotor UAV. Their


proposed design is for a lightweight, nimble craft that can be operated
both indoors and out. The project poses particular challenges in terms of
weight reduction and controllability. Quad-rotor crafts generally support
only a light payload, as they are required to carry the weight of the power
supply, a heavy battery, onboard. Thus, weight reduction of all
components is essential in order to allow for sufficient lift force. The
controls system for such a craft is also complex, as it requires the
synchronization of four individual motors. These motors must be closely
controlled in order to account for variations between the motors (one
motor slightly more powerful than the others will upset the equilibrium
of the craft), and in order to effectively dampen external disturbances.
They succeeded in building a craft structure that was both stiff and
lightweight, using carbon fiber and ABS plastic. They incorporated a
closed loop, proportional control system which measured in-flight
dynamics via a single axis gyro and two dual axis tilt-sensors. A
microcomputer took these sensor inputs and performed proportional
control on the four motors by varying PWM signals sent to each of the
motors. The result of the project is an advanced prototype for
autonomous flight. The controls software is fully operative, though it is
hindered by unreliable operation of the tilt-sensors. Future work will
allow refinements in the control system hardware that will ultimately lead
to stable, untethered flight.

2.2.PATENT SEARCH:

There is a fair amount of published research with regards to quad-rotor


aircraft.Among them are a few “Four Propeller Helicopter” designs
(Dammar, Michael. "Four Propeller Helicopter." US Patent
D465196.November 2002.), some “Quad Tiltrotor” designs (DeTore,
John A., Richard F. Spivey, Malcolm P. Foster, and Tom L. Wood. "Quad
Tiltrotor." US Patent D453317. February 2002.), and various vertical lift
aircrafts (Smart, R.C. "Vertical Lift Aircraft." US Patent 3185410. May
1965.)

In the world of higher education, there are a few members of academia


who have published research on quad-rotor UAVs. Among them are
Joseph F. Horn and Wei Guo of Pennsylvania State University
(“Modeling and Simulation for the Development of a Quad-Rotor UAV
Capable of Indoor Flight”), Ming Chen and Mihai Huzmezan of the
University of British Columbia (“A Simulation Model and H∞ Loop
Shaping Control of a Quad Rotor Unmanned Air Vehicle”), and Eryk
Brian Nice of Cornell University (“Design of a Four Rotor Hovering
Vehicle”).

2.3. Project Objective:

In all the above works the aerial vehicle has been controlled only
through handheld remote using which can only a skilled pilots can
control it. We have come up with a solution to this problem by
controlling the vehicle through PC so that, the aerial vehicle can be
controlled even from remote locations in a smart way.And the same
vehicle can be used for surveillance by having a wireless cam module in
it. Once image has been acquired from the wireless survelliance camera
target image would be located in the test image using correlation
algorithm implemented through MATLAB.
CHAPTER 3

SYSTEMOVERVIEW

3.1 SYSTEM DESCRIPTION

The X-UFO quad rotor aerial vehicle rotors are connected to a bridge
circuit which is used to control its speed which is then connected to a
microcontroller for receiving the control signals from the PC. The control
actions for moving the aerial vehicle like up, down, left, right are done
using remote control circuit. This remote control circuit is connected to
the PC via serial port. The relay driver circuit is used to switch
connections for different control actions of the rotor. The transmitter used
here is of the range 27 MHz. The remote control circuit is interfaced with
PC for controlling the navigation of the aerial vehicle, the interfacing is
done through Visual Basic and the same is used for getting the captured
image / video from the Wireless camera through the PCI TV tuner card.
The user can able to monitor the live videos from the remote location on
a network. Even the control of the AV can be done on the network itself.

The camera module is placed at the center, beneath the X-UFO aerial
vehicle without affecting the hovering and other navigation operation of
the vehicle. The camera which we are going to use here is Wireless
camera. The main reason for choosing this camera is that it features low
size and low power consumption targeting mobile applications. This
complete camera module is ready to connect to camera enabled baseband
processors, back-end IC devices.
The image / video which is captured from the camera is transmitted
using the transmitter which works in the range of 2.4 GHz. The
transmitted image is received at the receiver which is present in the base .
The received image / video at the receiver is monitored in the PC through
the TV receiver module which is being connected at the PCI TV tuner
card through Video in Input of the TV tuner card. For controlling the AV
the Remote control circuit re-modified in such a way that the control of
the AV is done from the PC using serial port. Some of the control
function is lift up, lift down, move straight, move backward without
tilting too much at high altitude of even 100mts.

To acquire the images from the TV receiver module PCI TV tuner


card is used by programming the TV tuner card for capturing the images
from the wireless camera we are using VCAPG2.DLL file created using
VC++ and interfaced with MATLAB for grabbing the images from the
TV receiver module. MATLAB t has the ability to capture the images
from the TV tuner card and which can be processed using Image
Processing Tool Box.

Finally in order to increase the distance of control and monitoring


we are proposing a system in which we can able to grab the image and
transfer the data to a remote location The Aerial Vehicle can be controlled
from the PC side if the modified Remote control which is being
connected to the serial port on the LAPTOP for outdoor unit.
3.2 Block Diagram:

Block Diagram of the Project


3.2.1 ADVANTAGES

The application is typical for many embedded systems, i.e., it


integrates aspects from many different disciplines .The application is
contemporary. Today’s low-cost RC (radio controlled) model-AVs
(such as quad rotors and helicopters) are only rudimentary controlled,
which implies that only highly skilled hobby pilots are capable of
flying these machines (i.e., simultaneously controlling vertical lift,
roll, pitch, and yaw) without crashing within a few seconds after lift-
off. To overcome this we prefer an aerial vehicle which can be
controlled through serial port of PC.

The application is typical for many air, land, and naval vehicles that
require extensive embedded control software to achieve stability
where humans are no longer able to perform this complicated, real-
time task. Professional aerial vehicles such as helicopters, most airline
and fighter jets totally rely on ES for stability. This also applies to
submarines, surface ships, missiles, satellites, and space ships (future
automobiles will also extensively rely on embedded software for
safety-critical tasks such as steering, braking, etc., commonly denoted
“X-by-wire”).

This proposal can also be extend it in TCP/IP LAN network for


monitoring and controlling the Aerial vehicle from remote place based
on Server/Client based architecture.
3.3 Quadra copter Aerial Vehicle
The X-UFO is a remote controlled flying aerial vehicle with four
rotors. This is equipped with some hardware to control the servos and
to communicate with PC. X-UFO uses four powerful electric motors
with driving two pairs of contra- rotating propellers via 1:10 gear
reduction and an innovative electronic gyro for incredible stability.
The motor units are each suspended from a tough carbon fiber rod,
with the gyro and receiver encased in a smoke-tinted clear bubble
mounted centrally in the very durable moulded EPP foam. The
receiver on/off switch is mounted close by. This also has a trainer lead
which can be used to connect to a second 27 MHz transmitter. X-UFO
is operated by a four-channel proportional radio control and has
similar flying characteristics to hovering a R/C helicopter. Each of the
four motors has its own ESC, and these are regulated individually by
the transmitter inputs therefore giving full 4-function control. The
wireless camera used here has active pixels, 1/3 inch optical format.
Integrated digital image processing functions, including defect
correction, lens shading correction, image scaling, demosaicing,
sharpening, gamma correction and color space conversion. It has 8-bit
parallel video interface, horizontal and vertical syncs, 54MHz (max)
clock, two-wire serial control interface with analog inputs from 2.4 to
3 V supply.

RC X-UFO is an extraordinary and unique new flying object. It can


fly up to 100 meters away. It can hover like a helicopter. It can
maneuver around any interior room with amazing precision and agility.
And if it contacts any other object, it simply bounces off and just
keeps on flying.The UFO incorporates the latest miniature technology,
which comes with a unique electronic control system. It utilizes
powerful electric motors with two pairs of counter-rotating propellers
and an innovative gyroscope for incredible stability.

Made of ultra lightweight carbon fiber and EPP foam, it can fly up to
100m indoors, or outside The X-UFO features 4 channels proportional
radio control, with individual trims to finely balance each function for
optimum performance.

3.3.1DIGITAL 4-CHANNEL RADIO:

Control all aspects of flight: throttle, pitch, roll, and yaw! Fantastic radio
range of 100 meters 109 yards means you can fly outdoors on calm days up
to the limits of visibility Gyro Stabilized! To help you fly like a seasoned
pro, the X-UFO has an advanced gyro system.

3.4.CIRCUIT DIAGRAM

REMOTE CONTROL INTERFACING CIRCUIT:


VCC12V DC
T1
- +
7805 . X y
230v AC AXIS
L293D
L293D is H BRIDGE IC To Motor
B R ID G E

1000mf
LED
D3
39 21 1
38 P 0 .0 /A D 0 P 2 .0 /A 8 22 2
37 P 0 .1 /A D 1 P 2 .1 /A 9 23 3
36 P 0 .2 /A D 2 P 2.2/A 1 0 24 4
35 P 0 .3 /A D 3 P 2.3/A 1 1 25
34 P 0 .4 /A D 4 P 2.4/A 1 2 26
33 P 0 .5 /A D 5 P 2.5/A 1 3 27
P 0 .6 /A D 6 P 2.6/A 1 4 5 Volt
32 28
P 0 .7 /A D 7 P 2.7/A 1 5
1 10
2 P 1 .0 P 3 .0 /R XD 11
3 P 1 .1 P 3 .1 /T XD 12
4 P 1 .2 P 3 .2 /IN T O 13
5 P 1 .3 P 3 .3 /IN T 1 14
6 P 1 .4 P 3 .4 /T O 15
l 293 D Motor driver ic
7 P 1 .5 P 3 .5 /T 1 16
8 P 1 .6 P 3.6/W R 17
P 1 .7 P 3.7/R D
19 29
18 XTA L 1 PSEN
9 XTA L 2 30
33Pf R ST A L E /P R O G
31
. E A /V P P .
RESET SW

16
.
A T89C 51 9 12
8 R 1 IN R 1O U T 13

.
33Pf 1 1 R 2 IN R 2O U T 14
TO PC
10 T1out T 1 IN 7
10Mf 10K T2IN T2O U T
1 9
3 C+
4 C 1- 3
5 C 2+
2 C 2- 2
6 V+ M AX232
V- 5
..
15

3.4.1.HARDWARE DESCRIPTION

3.4.1.1 POWER SUPPLY CIRCUIT

D 1
1

VD D
JP2
2 - + 4 1 2
2 V IN VO U T VD D
1 U 2
G N D

7805 R 4
220 VAC C 5 C 6 C 7 220 ohm
470 uF 100 uF 0 .1 u F
3

D 2
3

LED
Circuit of power supply

The power supply consists of ac voltage transformer, diode


rectifier, ripple filter, and voltage regulator. The description of the
components is shown below.

3.4.1.2 TRANSFORMER:

DEFINITION

The transformer is a static electro-magnetic device that


transforms one alternating Voltage (current) into another voltage
(current).However; power remains the same during the
transformation. Transformers play a major role in the transmission and
distribution of ac power.

PRINCIPLE:

Transformer works on the principle of mutual induction. A


transformer consists of laminated magnetic core forming the magnetic
frame. Primary and secondary coils are wound upon the two cores of
the magnetic frame, linked by the common magnetic flux. When an
alternating voltage is applied across the primary coil, a current flows
in the primary coil producing magnetic flux in the transformer core.
This flux induces voltage in secondary coil.
Transformers are classified as:
(a) Based on position of the windings with respect to core i.e.
(1) Core type transformer
(2) Shell type transformer
(b) Transformation ratio:
(1) Step up transformer
(2) Step down transformer

DC power supply exists in every electronic box whether it is a


computer, TV, or equipment in the laboratory. The power supply
consists of ac voltage transformer, diode rectifier, ripple filter, and
voltage regulator. The transformer is an ac device. It has two coil
windings, the primary and the secondary, around a common magnetic
core. The current flowing in the primary winding generates a time
varying electromagnetic field which in turn induces an output voltage
across the secondary winding. The ratio of turns in the two windings
determines the ratio of the input voltage and output voltage. The
power supply that we are building in this experiment is a linear power
supply. In other words, the circuit functions with analog signals.

In our kit, we have a small transformer which can convert 230Vac


from the wall plug to 6-12 V ac.
3.4.1.3 BRIDGE RECTIFIER

When four diodes are connected as shown in figure, the circuit


is called as bridge rectifier. The input to the circuit is applied to the
diagonally opposite corners of the network, and the output is taken
from the remaining two corners. Let us assume that the transformer is
working properly and there is a positive potential, at point A and a
negative potential at point B. the positive potential at point A will
forward bias D3 and reverse bias D4. The negative potential at point B
will forward bias D1 and reverse D2.

At this time D3 and D1 are forward biased and will allow


current flow to pass through them; D4 and D2 are reverse biased and
will block current flow.The path for current flow is from point B
through D1, up through RL, through D3, through the secondary of the
transformer back to point B. this path is indicated by the solid arrows.
Waveforms (1) and (2) can be observed across D1 and D3.

One-half cycle later the polarity across the secondary of the


transformer reverse, forward biasing D2 and D4 and reverse biasing
D1 and D3. Current flow will now be from point A through D4, up
through RL, through D2, through the secondary of T1, and back to
point A. This path is indicated by the broken arrows. Waveforms (3)
and (4) can be observed across D2 and D4. The current flow through
RL is always in the same direction. In flowing through RL this current
develops a voltage corresponding to that shown waveform (5). Since
current flows through the load (RL) during both half cycles of the
applied voltage, this bridge rectifier is a full-wave rectifier.

One advantage of a bridge rectifier over a conventional full-


wave rectifier is that with a given transformer the bridge rectifier
produces a voltage output that is nearly twice that of the conventional
full-wave circuit.

This may be shown by assigning values to some of the


components shown in views A and B. assume that the same
transformer is used in both circuits. The peak voltage developed
between points X and y is 1000 volts in both circuits. In the
conventional full-wave circuit shown—in view A, the peak voltage
from the center tap to either X or Y is 500 volts. Since only one diode
can conduct at any instant, the maximum voltage that can be rectified
at any instant is 500 volts.

The maximum voltage that appears across the load resistor is


nearly-but never exceeds-500 v0lts, as result of the small voltage drop
across the diode. In the bridge rectifier shown in view B, the
maximum voltage that can be rectified is the full secondary voltage,
which is 1000 volts. Therefore, the peak output voltage across the load
resistor is nearly 1000 volts. With both circuits using the same
transformer, the bridge rectifier circuit produces a higher output
voltage than the conventional full-wave rectifier circuit.

3.4.1.4 REGULATOR:

To make the output voltage as constant as possible, one needs a


regulator. The regulator consists of a voltage reference, e.g., a Zener
diode. It can also be an IC component with voltage reference and
feedback control circuit inside.

Finally, you will characterize the performance of the power


supply by measuring its output voltage and ripple as a function of
the load current. The more the current, the higher is the ripple.
Likewise, the more the current, the lower is the voltage. This is
called loading.

Another semiconductor component to be used in this


experiment is a voltage regulator, 7805. “78” indicates that it is a
regulator for positive voltage. There is a corresponding “79” model
for negative voltage. “05” indicates that it has an output of 5 V.
7805 is an integrated circuit. Just like the operational amplifier, the
design engineer of the IC has optimized the circuit. The regulator IC
requires an input voltage at least a couple of V higher than the
output voltage in order to function properly. In a way, it is similar to
the operational amplifier; the output is limited by the power supply
voltage. Your output is always below the input. This voltage
difference keeps all electronic circuits in the IC forwardly biased,
hence, functioning properly in the linear regime.

The lower circuit is a bridge-wave rectifier. There are four


diodes. They are arranged in such a way that the current always
flows in the same direction through the load resistor no matter which
node of the transformer is positive. You can trace the flow of the
current. When the upper node of the transformer is positive, current
flows through the first diode through the load, which is not shown,
then it flows through the last diode to the lower node of the
transformer completing the loop. When the lower node of the
transformer is positive, current flows through the third diode to the
load resistor then it flows through the second diode to the upper
node of the transformer completing the loop. The current flows
through the load resistor along the same direction all the time. The
load resistor must have sufficient power handling capability.
Otherwise, It may burn .The power dissipation is given by voltage
square divided by resistance.

The regulator LM7805 is being used here to provide 5 V supply


to Microcontroller and 12V supply to Motors

IC voltage regulators
Voltage regulators comprise a class of widely used ICs.
Regulator IC units contain the circuitry for reference source,
comparator amplifier, control device, and overload protection all in a
single IC. IC units provide regulation of either a fixed positive
voltage, a fixed negative voltage, or an adjustably set voltage. The
regulators can be selected for operation with load currents from
hundreds of milli amperes to tens of amperes, corresponding to
power ratings from milli watts to tens of watts.

A fixed three-terminal voltage regulator has an unregulated dc input


voltage, Vi, applied to one input terminal, a regulated dc output
voltage, Vo, from a second terminal, with the third terminal
connected to ground.
Circuit Diagram Of Power Supply

The series 78 regulators provide fixed positive regulated voltages


from 5 to 24 volts. Similarly, the series 79 regulators provide fixed
negative regulated voltages from 5 to 24 volts.

• For ICs, microcontroller, LCD --------- 5 volts


• For alarm circuit, op-amp, relay circuits ---------- 12 volts

3.4.1.5. FILTER:

After the rectification process, the voltage signal contains both


an average dc component and a time varying ac component called
the ripple. To reduce or eliminate the ac component, one needs low
pass filter(s). The low pass filter will pass through the dc but
attenuate the ac at 60 Hz or its harmonics, i.e., 120 Hz. It has a
resistor in front and a capacitor across the output and ground. (C-
filter).

3.4.1.6 LED (Light Emitting Diodes):

As its name implies it is a diode, which emits light when


forward biased. Charge carrier recombination takes place when
electrons from the N-side cross the junction and recombine with the
holes on the P side. Electrons are in the higher conduction band on
the N side whereas holes are in the lower valence band on the P side.
During recombination, some of the energy is given up in the form of
heat and light. In the case of semiconductor materials like Gallium
arsenide (GaAs), Gallium phosphate (Gap) and Gallium arsenide
phosphate (GaAsP) a greater percentage of energy is released during
recombination and is given out in the form of light. LED emits no
light when junction is reversed biased.

3.4.1.7 CIRCUIT OPERATION

In circuit operation, when the voltage generated by the


transformer is higher than the capacitor voltage, the current flows
through the diode charging the capacitors. At the same time, the load
resistor drains current from the capacitors. When the amount of
draining matches with the charging current, the voltage is stabilized.
A sudden increase in load current will decrease the voltage across
the capacitor. It will also increase the time period during which the
diodes conduct, hence, the ripple
CHAPTER 4

MICROCONTROLLERS & SERIAL COMMUNICATION

4.1 MICROCONTROLLERS

INTRODUCTION

Circumstances that we find ourselves in today in the field of


microcontrollers had their beginnings in the development of
technology of integrated circuits. This development has made it
possible to store hundreds of thousands of transistors into one chip.
That was a prerequisite for production of microprocessors, and the
first computers were made by adding external peripherals such as
memory, input-output lines, timers and other. Further increasing of the
volume of the package resulted in creation of integrated circuits.
These integrated circuits contained both processor and peripherals.
That is how the first chip containing a microcomputer, or what would
later be known as a microcontroller came about.

4.1.1 DEFINITION OF A MICROCONTROLLER

Microcontroller, as the name suggests, are


small controllers. They are like single chip
computers that are often embedded into other
systems to function as processing/controlling
unit. For example, the remote control you are
using probably has microcontrollers inside that
do decoding and other controlling functions.
They are also used in automobiles, washing
machines, microwave ovens, toys ... etc, where
automation is needed.

The key features of microcontrollers include:

 High Integration of Functionality

 Microcontrollers sometimes are called


single-chip computers because they have
on-chip memory and I/O circuitry and other
circuitries that enable them to function
as small standalone computers without
other supporting circuitry.
 Field Programmability, Flexibility

 Microcontrollers often use EEPROM or EPROM


as their storage device to allow field
programmability so they are flexible to
use. Once the program is tested to be
correct then large quantities of
microcontrollers can be programmed to be
used in embedded systems.
 Easy to Use

Assembly language is often used in


microcontrollers and since they usually
follow RISC architecture, the instruction
set is small. The development package of
microcontrollers often includes an
assembler, a simulator, a programmer to
"burn" the chip and a demonstration board.
Some packages include a high level
language compiler such as a C compiler and
more sophisticated libraries.

Most microcontrollers will also combine other


devices such as:
 A Timer module to allow the
microcontroller to perform tasks for
certain time periods.
 A serial I/O port to allow data to flow
between the microcontroller and other
devices such as a PC or another
microcontroller.
 An ADC to allow the microcontroller to
accept analogue input data for processing.
Figure 2.1: Showing a typical microcontroller
device and its different subunits

4..1.2 PIN CONFIGURATION


Vcc

P1
P0

RESET
RXD EA

TXD PSEN
INT0 ALE
P3 INT1
T0
T1
RD
WR P2
XTAL1
XTAL2
GND

figure 2.2 Pin configuration of Microcontroller


We have 4 ports in 8051 micro controller. They are port0, port1,
port2, port3 which can be accessed as i/o ports. The pins of the micro
controller are explained below.
Reset: It resets total 8051 micro controller.

RXD: It receives data in serial communication.

TXD: It transmits data in serial communication.

INT0: External interrupt for timer 0.

INT1: External interrupt for timer1

T0/1: Timer0/1

RD/WR: To read/Write into external memory.

XTAL1 & XTAL2: To connect the crystal oscillator.

ALE: Address latch enable which is used to access the address


locations from external memory.

PSEN: Program store enable which is used for storing


programming
code into the external memory.

EA: External Access: 64 KB of ROM is the limit for external


4.1.3 RESET CIRCUIT

Reset circuit of microcontroller


Capacitor is storing charge permanently until we use it. Crystal
Oscillator is used to generate a carrier signal with stable frequency.
With the help of this oscillator we will deduce the execution speed in
terms of bytes/ sec.It generates 12 clock pulses /machine cycle.
Capacitors provide charge for crystal oscillator. If we are not
connecting any external memory to micro controller, EA is connected
to Vcc in case of 8051.

RAM ARCHITECTURE

figure 2.4: Ram Architecture

The 8051 has a bank of 128 bytes of Internal RAM. This


Internal RAM is found on-chip on the 8051 so it is the fastest RAM
available, and it is also the most flexible in terms of reading, writing,
and modifying its contents. Internal RAM is volatile, so when the
8051 is reset this memory is cleared. The 128 bytes of internal ram is
subdivided as shown on the memory map. The first 8 bytes (00h -
07h) are "register bank 0". These alternative register banks are located
in internal RAM in addresses 08h through 1Fh.Bit memory actually
resides in internal RAM, from addresses 20h through 2Fh. The 80
bytes remaining of Internal RAM, from addresses 30h through 7Fh,
may be used by user variables that need to be accessed frequently or
at high-speed. This area is also utilized by the microcontroller as a
storage area for the operating stack.

4.2 REGISTER BANKS

The 8051 uses 8 "R" registers which are used in many of its
instructions. These "R" registers are numbered from 0 through 7 (R0,
R1, R2, R3, R4, R5, R6, and R7).These registers are generally used to
assist in manipulating values and moving data from one memory
location to another. The concept of register banks adds a great level of
flexibility to the 8051.

4.2.1 Bit Memory

The 8051, being a communication oriented microcontroller,


gives the user the ability to access a number of bit variables. These
variables may be either 1 or 0. There are 128 bit variables available to
the user, numbered 00h through 7Fh. The user may make use of these
variables with commands such as SETB and CLR. It is important to
note that Bit Memory is really a part of Internal RAM. In fact, the 128
bit variables occupy the 16 bytes of Internal RAM from 20h through
2Fh.

4.2.2 SPECIAL FUNCTION REGISTER (SFR) MEMORY

Special Function Registers (SFRs) are areas of memory that


control specific functionality of the 8051 processor. For example, four
SFRs permit access to the 8051’s 32 input/output lines. Another SFR
allows a program to read or write to the 8051’s serial port .SFR is a
part of Internal Memory. This is not the case. When using this method
of memory access (it’s called direct address), any instruction that has
an address of 00h through 7Fh refers to an Internal RAM memory
address; any instruction with an address of 80h through FFh refers to
an SFR control register.

4.2.3 REGISTERS

The Accumulator
The Accumulator, as its name suggests, is used as a general
register to accumulate the results of a large number of instructions. It
can hold an 8-bit (1-byte) value and is the most versatile register

The "R" registers


The "R" registers are a set of eight registers that are named R0,
R1, etc. up to and including R7. These registers are used as auxiliary
registers in many operations.

The "B" Register


The "B" register is very similar to the Accumulator in the sense
that it may hold an 8-bit (1-byte) value. The "B" register is only used
by two 8051 instructions: MUL AB and DIV AB.

The Data Pointer (DPTR)


The Data Pointer (DPTR) is the 8051’s only user-accessible 16-
bit (2-byte) register. The Accumulator, "R" registers, and "B" register
are all 1-byte values. DPTR, as the name suggests, is used to point to
data. It is used by a number of commands which allow the 8051 to
access external memory.

The Program Counter (PC)


The Program Counter (PC) is a 2-byte address which tells the
8051 where the next instruction to execute is found in memory. When
the 8051 is initialized PC always starts at 0000h and is incremented
each time an instruction is executed.
.
The Stack Pointer (SP)
The Stack Pointer, like all registers except DPTR and PC, may
hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate
where the next value to be removed from the stack should be
4.2.4 ADDRESSING MODES
An "addressing mode" refers to how you are addressing a given
memory location. The addressing modes are as follows,
With an example of each:
Immediate Addressing MOV A, #20h
Direct Addressing MOV A, #30h
Indirect Addressing MOV A, @R0
External Direct MOVX A, @DPTR
Code Indirect MOVC A, @A+DPTR
Each of these addressing modes provides important flexibility.

Interrupts
An interrupt is a special feature which allows the 8051 to
provide the illusion of "multitasking," although in reality the 8051 is
only doing one thing at a time.
.
Timers
Timers are one of the categories of hardware time delays. Time
delays are used to keep a system into halting System or sleepy mode.
We have two timers-timer0, timer1.Hardware time delays are used to
generate exact time delays.

4.2.6 MICROCONTROLLERS VERSUS MICROPROCESSORS


Microcontroller differs from a microprocessor in many ways. First
and the most important is its functionality. In order for a
microprocessor to be used, other components such as memory, or
components for receiving and sending data must be added to it. In
short that means that microprocessor is the very heart of the
computer. On the other hand, microcontroller is designed to be all of
that in one. No other external components are needed for its
application because all necessary peripherals are already built into it.
Thus, we save the time and space needed to construct devices.

Central Processing Unit

Let add 3 more memory locations to a specific block that will have a
built in capability to multiply, divide, subtract, and move its contents
from one memory location onto another. The part we just added in is
called "central processing unit" (CPU). Its memory locations are
called registers.
Figure2.5: Simplified central processing unit with three registers

Registers are therefore memory locations whose role is to help


with performing various mathematical operations or any other
operations with data wherever data can be found. Look at the current
situation. We have two independent entities (memory and CPU) which
are interconnected, and thus any exchange of data is hindered, as well
as its functionality. If, for example, we wish to add the contents of two
memory locations and return the result again back to memory, we
would need a connection between memory and CPU. Simply stated,
we must have some "way" through data goes from one block to
another.

Bus

That "way" is called "bus". Physically, it represents a group of


8, 16, or more wires.There are two types of buses: address and data
bus. The first one consists of as many lines as the amount of memory
we wish to address and the other one is as wide as data, in our case 8
bits or the connection line. First one serves to transmit address from
CPU memory, and the second to connect all blocks inside the
microcontroller.

Figure2.6: Showing connection between memory and central unit


using buses

As far as functionality, the situation has improved, but a new


problem has also appeared: we have a unit that's capable of working
by itself, but which does not have any contact with the outside world,
or with us! In order to remove this deficiency, let's add a block which
contains several memory locations whose one end is connected to the
data bus, and the other has connection with the output lines on the
microcontroller which can be seen as pins on the electronic
component.

Input-output unit

Those locations we've just added are called "ports". There are
several types of ports: input, output or bidirectional ports. When
working with ports, first of all it is necessary to choose which port we
need to work with, and then to send data to, or take it from the port.

Figure2.7: Simplified input-output unit communicating with external


world

When working with it the port acts like a memory location.


Something is simply being written into or read from it, and it could be
noticed on the pins of the microcontroller.

4.3 SERIAL COMMUNICATION


Beside stated above we've added to the already existing unit the
possibility of communication with an outside world. However, this
way of communicating has its drawbacks. One of the basic drawbacks
is the number of lines which need to be used in order to transfer data.
What if it is being transferred to a distance of several kilometers? The
number of lines times’ number of kilometers doesn't promise the
economy of the project. It leaves us having to reduce the number of
lines in such a way that we don't lessen its functionality. Suppose we
are working with three lines only, and that one line is used for sending
data, other for receiving, and the third one is used as a reference line
for both the input and the output side. In order for this to work, we
need to set the rules of exchange of data. These rules are called
protocol For example, if one man is speaking in French, and the other
in English, it is highly unlikely that they will quickly and effectively
understand each other. Let's suppose we have the following protocol.
The logical unit "1" is set up on the transmitting line until transfer
begins. Once the transfer starts, we lower the transmission line to
logical "0" for a period of time (which we will designate as T), so the
receiving side will know that it is receiving data, and so it will activate
its mechanism for reception. Let's go back now to the transmission
side and start putting logic zeros and ones onto the transmitter line in
the order from a bit of the lowest value to a bit of the highest value.
Let each bit stay on line for a time period which is equal to T, and in
the end, or after the 8th bit, let us bring the logical unit "1" back on
the line which will mark the end of the transmission of one data. The
protocol we've just described is called in professional literature NRZ
(Non-Return to Zero).
Figure2.8: Serial unit sending data through three lines only

As we have separate lines for receiving and sending, it is


possible to receive and send data (info.) at the same time. So called
full-duplex mode block which enables this way of communication is
called a serial communication block. Unlike the parallel transmission,
data moves here bit by bit, or in a series of bits what defines the term
serial communication comes from. After the reception of data we need
to read it from the receiving location and store it in memory as
opposed to sending where the process is reversed. Data goes from
memory through the bus to the sending location, and then to the
receiving unit according to the protocol.

Timer unit

Since we have the serial communication explained, we can


receive, send and process data.
Figure2.9: Timer unit generating signals in regular time intervals

However, in order to utilize it in industry we need a few


additionally blocks. One of those is the timer block which is
significant to us because it can give us information about time,
duration, protocol etc. The basic unit of the timer is a free-run counter
which is in fact a register whose numeric value increments by one in
even intervals, so that by taking its value during periods T1 and T2
and on the basis of their difference we can determine how much time
has elapsed. This is a very important part of the microcontroller whose
understanding requires most of our time.

Figure2.10: Physical configuration of the interior of a


microcontroller
Figure2.11: Microcontroller outline with basic elements and internal
connections

For a real application, a microcontroller alone is not enough.


Beside a microcontroller, we need a program that would be executed,
and a few more elements which make up interface logic towards the
elements of regulation (which will be discussed next).

3.4.3.Coding For AT89C51

#include<reg51.h>

sbit out10 = P2^0 ;


sbit out11 = P2^1 ;
sbit out20 = P2^2 ;
sbit out21 = P2^3 ;

void main()
{
int x = 0 ;
TMOD = 0x20;
TH1 = 0xf4;
SCON = 0x50;
TR1 = '1'; //start timer

while(1)

{
while(!RI) ;
RI = 0 ;
x = SBUF ;

if ( x == '1' )
{
out10 = 1 ;
out11 = 0 ;
}

if ( x == '2' )
{
out10 = 0 ;
out11 = 1 ;
}

if ( x == '3' )
{
out10 = 0;
out11 = 0;
}

if ( x == '4' )
{
out20 = 1 ;
out21 = 0 ;
}

if ( x == '5' )
{
out20 = 0 ;
out21 = 1 ;
}

if ( x == '6' )
{
out20 = 0;
out21 = 0;
}
}

4.5 SERIAL COMMUNICATION

Serial communication is basically the transmission or reception


of data one bit at a time. Today's computers generally address data in
bytes or some multiple thereof. A byte contains 8 bits. A bit is
basically either a logical 1 or zero. Every character on this page is
actually expressed internally as one byte. The serial port is used to
convert each byte to a stream of ones and zeroes as well as to convert
a streams of ones and zeroes to bytes. The serial port contains a
electronic chip called a Universal Asynchronous Receiver/Transmitter
(UART) that actually does the conversion.

The serial port has many pins. We will discuss the transmit and
receive pin first. Electrically speaking, whenever the serial port sends
a logical one (1) a negative voltage is effected on the transmit pin.
Whenever the serial port sends a logical zero (0) a positive voltage is
effected. When no data is being sent, the serial port's transmit pin's
voltage is negative (1) and is said to be in a MARK state. Note that
the serial port can also be forced to keep the transmit pin at a positive
voltage (0) and is said to be the SPACE or BREAK state. (The terms
MARK and SPACE are also used to simply denote a negative voltage
(1) or a positive voltage(0) at the transmit pin respectively).

When transmitting a byte, the UART (serial port) first sends a


START BIT which is a positive voltage (0), followed by the data
(general 8 bits, but could be 5, 6, 7, or 8 bits) followed by one or two
STOP BITs which is a negative(1) voltage. The sequence is repeated
for each byte sent. Figure 1 shows a diagram of a what a byte
transmission would look like.

At this point you may want to know what is the duration of a


bit. In other words, how long does the signal stay in a particular state
to define a bit. The answer is simple. It is dependent on the baud rate.
The baud rate is the number of times the signal can switch states in
one second. Therefore, if the line is operating at 9600 baud, the line
can switch states 9,600 times per second. This means each bit has the
duration of 1/9600 of a second or about 100 µsec.

When transmitting a character there are other characteristics


other than the baud rate that must be known or that must be setup.
These characteristics define the entire interpretation of the data
stream. The first characteristic is the length of the byte that will
be transmitted. This length in general can be anywhere from 5 to 8
bits.

The second characteristic is parity. The parity characteristic can


be even, odd, mark, space, or none. If even parity, then the last data bit
transmitted will be a logical 1 if the data transmitted had an even
amount of 0 bits. If odd parity, then the last data bit transmitted will be
a logical 1 if the data transmitted had an odd amount of 0 bits. If
MARK parity, then the last transmitted data bit will always be a
logical 1. If SPACE parity, then the last transmitted data bit will
always be a logical 0. If no parity then there is no parity bit
transmitted.

Assume we want to send the letter 'A' over the serial port. The
binary representation of the letter 'A' is 01000001. Remembering that
bits are transmitted from least significant bit (LSB) to most significant
bit (MSB), the bit stream transmitted would be as follows for the line
characteristics 8 bits, no parity, 1 stop bit, 9600 baud.

LSB (0 1 0 0 0 0 0 1 0 1) MSB

The above represents (Start Bit) (Data Bits) (Stop Bit)

To calculate the actual byte transfer rate simply divide the baud rate
by the number of bits that must be transferred for each byte of data. In
the case of the above example, each character requires 10 bits to be
transmitted for each character. As such, at 9600 baud, up to 960 bytes
can be transferred in one second.
The above discussion was concerned with the
"electrical/logical" characteristics of the data stream. We will expand
the discussion to line protocol.

Serial communication can be half duplex or full duplex. Full


duplex communication means that a device can receive and transmit
data at the same time. Half duplex means that the device cannot send
and receive at the same time. It can do them both, but not at the same
time. Half duplex communication is all but outdated except for a very
small focused set of applications.

Half duplex serial communication needs at a minimum two


wires, signal ground and the data line. Full duplex serial
communication needs at a minimum three wires, signal ground,
transmit data line, and receive data line. The RS232 specification
governs the physical and electrical characteristics of serial
communications. This specification defines several additional signals
that are asserted (set to logical 1) for information and control beyond
the data signals and signal ground.

These signals are the Carrier Detect Signal (CD), asserted by


modems to signal a successful connection to another modem, Ring
Indicator (RI), asserted by modems to signal the phone ringing, Data
Set Ready (DSR), asserted by modems to show their presence, Clear
To Send (CTS), asserted by modems if they can receive data, Data
Terminal Ready (DTR), asserted by terminals to show their presence,
Request To Send (RTS), asserted by terminals if they can receive data.
The section RS232 Cabling describes these signals and how they are
connected.

The above paragraph eluded to hardware flow control.


Hardware flow control is a method that two connected devices use to
tell each other electronically when to send or when not to send data. A
modem in general drops (logical 0) its CTS line when it can no longer
receive characters. It re-asserts it when it can receive again. A terminal
does the same thing instead with the RTS signal. Another method of
hardware flow control in practice is to perform the same procedure in
the previous paragraph except that the DSR and DTR signals are used
for the handshake.

Note that hardware flow control requires the use of additional


wires. The benefit to this however is crisp and reliable flow control.
Another method of flow control used is known as software flow
control. This method requires a simple 3 wire serial communication
link, transmit data, receive data, and signal ground. If using this
method, when a device can no longer receive, it will transmit a
character that the two devices agreed on. This character is known as
the XOFF character. This character is generally a hexadecimal 13.
When a device can receive again it transmits an XON character that
both devices agreed to. This character is generally a hexadecimal

115.5

4.5.1 RS – 232
In telecommunications, RS-232 (Recommended Standard 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.

RS-232 devices may be classified as Data Terminal Equipment


(DTE) or Data Communications Equipment (DCE); this defines at
each device which wires will be sending and receiving each signal.
The standard recommended but did not make mandatory the D-
subminiature 25 pin connector. In general and according to the
standard, terminals and computers have male connectors with DTE
pin functions, and modems have female connectors with DCE pin
functions. Other devices may have any combination of connector
gender and pin definitions. Many terminals were manufactured with
female terminals but were sold with a cable with male connectors at
each end; the terminal with its cable satisfied the recommendations in
the standard. Presence of a 25 pin D-sub connector does not
necessarily indicate an RS-232-C compliant interface.

4.6 H – BRIDGE

An H-bridge is an electronic circuit which enables a voltage to


be applied across a load in either direction. These circuits are often
used in robotics and other applications to allow DC motors to run
forwards and backwards. H-bridges are available as integrated
circuits, or can be built from discrete components.
A "double pole double throw" relay can generally achieve the
same electrical functionality as an H-bridge (considering the usual
function of the device). Though an H-bridge would be preferable
where a smaller physical size is needed, high speed switching, low
driving voltage, or where the wearing out of mechanical parts is
undesirable.

The term "H-bridge" is derived from the typical graphical


representation of such a circuit. An H-bridge is built with four
switches (solid-state or mechanical). When the switches S1 and S4
(according to the first figure) are closed (and S2 and S3 are open) a
positive voltage will be applied across the motor. By opening S1 and
S4 switches and closing S2 and S3 switches, this voltage is reversed,
allowing reverse operation of the motor.

Using the nomenclature above, the switches S1 and S2 should


never be closed at the same time, as this would cause a short circuit on
the input voltage source. The same applies to the switches S3 and S4.
This condition is known as shoot-through.
Circuit of H-Bridge

Você também pode gostar