You are on page 1of 61

ACKNOWLEDGMENT

We cant achieve worthwhile in the field of the technical education without testing
the theoretical knowledge acquired in classroom as it is effectively linked to the
practical approach. We all experienced the same, while working for the project.
We would like to express a deep sense of gratitude and thanks profusely to
. (Head of department, E.C.E.) for allowing us to carry out the project
named Fist controlled wireless robot and for providing us the excellent facilities
and atmosphere under his leadership, during the entire duration of work.
Our very special thanks to .. for being our project guide, whose
excellent guidance, constant encouragement and motivation has inspired us a
lot at all phases of our work, without whom we would not be able to complete
our project.
We are also extremely thankful to our lab technicians for guiding and helping us
during the entire course of our project.
Finally, we also express our gratitude to other faculty members of E.C.E
department for their intellectual support throughout the course of work.
It has been a wonderful experience and we are deeply indebted to all those who
made it possible.

Wireless Fist Controlled Robot


Its a wireless fist controlled robot. In this we are utilizing the concept of RF
communication and a MEMS (Micro Electro Mechanical System) based
accelerometer. Accelerometers are used to read the first axis across x, y and z axis.
RF means Radio Frequency. We use the radio waves to communicate the
transmitter with receiver end. We are using a RF transmitter and receiver module,
So that transmitter can communicate with receiver end. An encoded data from
accelerometer is attached with the RF transmitter which acts as a Controlling unit.
RF receiver is mounted with robot, which continuously receives the transmitted
data. According to received data microcontroller take decision and move the robot
in some particular direction. In this transmitter send data, which is received by RF
receiver and processed by microcontroller and finally microcontroller take decision
according to received data

Block Diagram

Schematic Diagrams

MATERIAL USED
1. Transformer
2. Diodes 1N4007
3. Capacitor (470uF,1000uf,22pf)
4. Voltage Regulator (7805 & 7812)
5. Resistors
6. LED
7. Microcontroller
8. LM358
9. LM324
10.IC bases
11.Crystal
12.Switches
13.Accelerometer
14.DC Motors
15.Opto coupler
16.Wheels
17.Casted Wheel
18.Ht12D
19.Ht12E
20.RF modules
21.IC bases
22.Ribbon wire
23.Jumper wire
24.Soldering Iron
25.Soldering Wire
26.Multimeter
27.PCB

28.Cutter
29.Screw & Nuts
WORKING
In this .wireless robot, we use the RF band to control our robot. To perform this
action first of all we set up a wireless link between our robot and remote by the use
of 433MHz modules, which consist of a RF TX along with encoder and RF RX
along with the decoder circuit. Encoder and decoder circuit are used to encode and
decode the data because many signal are being communicating on RF bands. By
using these encoder and decoder we confirm our security First and fore most task
of this project is to read the axis of fist. It is accomplished by the accelerometer.
Accelerometer is a device, which gives a change in the output voltage as the axis
of the object changes. It has three axis X, Y and Z. Accelerometer works on +5V
DC. Output of accelerometer is fed to the op-amp comparator circuits. We need 6
op-amp comparators so that we can figure out all the 6 axis of fist. We tune the opamp to provide the output only if accelerometer moves beyond the particular limit.
Output of these op-amps drives the decimal to binary converter IC. Now the digital
data is ready for transmission but is advice able to raise the power of signal so that
communication distance can be increased. To achieve this we are using opto
couplers. After the opto coupler we are using HT12E to encode the signal and
finally this encoded signal is fed to the RF module, which transmit the data with
address line so that receiver could avoid the noise, because we using 433MHz
radio frequency, which is a general purpose frequency band.
At the receiver end RF rx receives the RF signal then it sends it to the decoder
circuit, which confirms the only transmitted data at the output. Output of RF rx are
fed to the microcontroller at the P1.0, P1.1, P1.2 and P1.3 and according to the
these inputs we control three motors.

As we know motors operate at 9V and microcontroller operates at 5V, so we need a


voltage level shifter and a isolator circuit so that we can control our motors from
the microcontroller. Same action is achieved by the PC817 Opto coupler, which
consists of a LED at the first two pins and a photo transistor at the 3rd and 4th pin of
opto coupler. At the 4th pin we get 9V correspond to 5V at the pin of
microcontroller.

Components Description

RESISTORS
The flow of charge (or current) through any material, encounters an opposing force
similar in many respect to mechanical friction. This opposing force is called
resistance of the material. It is measured in ohms.

In some electric circuits

resistance is deliberately introduced in the form of the resistor.


Resistors are of following types:
1. Wire wound resistors.
2. Carbon resistors.
3. Metal film resistors.

Wire Wound Resistors:


Wire wound resistors are made from a long (usually Ni-Chromium) wound on a
ceramic core. Longer the length of the wire, higher is the resistance. So depending
on the value of resistor required in a circuit, the wire is cut and wound on a
ceramic core. This entire assembly is coated with a ceramic metal. Such resistors
are generally available in power of 2 watts to several hundred watts and resistance

values from 1ohm to 100k ohms. Thus wire wound resistors are used for high
currents.

Carbon Resistors:
Carbon resistors are divided into three types:
a.

Carbon composition resistors are made by mixing carbon grains with


binding material (glue) and moduled in the form of rods. Wire leads are inserted
at the two ends. After this an insulating material seals the resistor. Resistors are
available in power ratings of 1/10, 1/8, 1/4 , 1/2 , 1.2 watts and values from 1
ohm to 20 ohms.
b. Carbon film resistors are made by deposition carbon film on a ceramic rod.

c.

They are cheaper than carbon composition resistors.


Cement film resistors are made of thin carbon coating fired onto a

solid

ceramic substrate. The main purpose is to have more precise resistance values
and greater stability with heat. They are made in a small square with leads.

Metal Film Resistors:

They are also called thin film resistors. They are made of a thin metal

coating

deposited on a cylindrical insulating support. The high resistance values are not
precise in value; however, such resistors are free of inductance effect that is
common in wire wound resistors at high frequency.
Variable Resistors:
Potentiometer is a resistor where values can be set depending on the requirement.
Potentiometer is widely used in electronics systems. Examples are volume control,
tons control, brightness and contrast control of radio or T.V. sets.

RESISTOR COLOR CODE


1st
Color ban
d

2nd

3rd

band 4th

band (multiplier)

band Temp.

(tolerance)

Coefficient

Black 0

100

Brown 1

101

1% (F)

100 ppm

Red

102

2% (G)

50 ppm

Orang

103

15 ppm

Yellow 4

104

25 ppm

Green 5

105

0.5% (D)

Blue

106

0.25% (C)

Violet 7

107

0.1% (B)

Gray

108

0.05% (A)

White 9

109

Gold

101

5% (J)

Silver

102

10% (K)

None

Example: 1k or 1000 ohms

20% (M)

Band1

Band 2

Band 3

Band 4

CAPACITORS
A capacitor can store charge, and its capacity to store charge is called capacitance.
Capacitors consist of two conducting plates, separated by an insulating material
(known as dielectric). The two plates are joined with two leads. The dielectric
could be air, mica, paper, ceramic, polyester, polystyrene, etc. This dielectric gives
name to the capacitor. Like paper capacitor, mica capacitor etc.
Types of Capacitors:- Capacitors are of two Types Fixed and variable capacitor.
Fixed types of capacitor are further of two types:Polar Capacitor:- Those capacitor have polarity are known as polar capacitor.
Electrolytic capacitor are the example of polar capacitors.

Non Polar Capacitor:- Those capacitor have no polarity are known as NON- polar
capacitor. Ceramic capacitor are the example of non polar capacitors

Electrolytic Capacitor: Electrolytic capacitors have an electrolyte as a dielectric.


When such an electrolyte is charged, chemical changes takes place in the
electrolyte. If its one plate is charged positively, same plate must be charged
positively in future. We call such capacitors as polarized. Normally we see
electrolytic capacitor as polarized capacitors and the leads are marked with positive
or negative on the can. Non-electrolyte capacitors have dielectric material such as
paper, mica or ceramic. Therefore, depending upon the dielectric, these capacitors
are classified.

Ceramic Capacitor: Such capacitors have disc or hollow tabular shaped dielectric
made of ceramic material such as titanium dioxide and barium titanate. Thin
coating of silver compounds is deposited on both sides of dielectric disc, which
acts as capacitor plates. Leads are attached to each sides of the dielectric disc and
whole unit is encapsulated in a moisture proof coating. Disc type capacitors have
very high value up to 0.001uf. Their working voltages range from 3V to 60000V.
These capacitors have very low leakage current. Breakdown voltage is very high.

Diode:Diodes are semiconductor devices which might be described as passing current in


one direction only. Diodes have two terminal, an anode and a cathode. The cathode
is always identified by a dot, ring or some other mark. Diode is a unidirectional
device. In this current flows in only one direction.

Diodes can be used as voltage regulators, tuning devices in rf tuned circuits,


frequency multiplying devices in rf circuits, mixing devices in rf circuits, switching
applications or can be used to make logic decisions in digital circuits. There are
also diodes which emit "light", of course these are known as light-emitting-diodes
or LED's.
a rectifying diode of the 1N4001-07 ( 1A) type or even one of the high power, high
current stud mounting types. You will notice the straight bar end has the letter "k",

this denotes the "cathode" while the "a" denotes anode. Current can only flow from
anode to cathode and not in the reverse direction, hence the "arrow" appearance.
This is one very important property of diodes.
The principal early application of diodes was in rectifying 50 / 60 Hz AC mains to
raw DC which was later smoothed by choke transformers and / or capacitors. This
procedure is still carried out today and a number of rectifying schemes for diodes
have evolved, half wave, full wave and bridge, full wave and bridge rectifiers.

As examples in these applications the half wave rectifier passes only the positive
half of successive cycles to the output filter through D1. During the negative part
of the cycle D1 does not conduct and no current flows to the load. In the full wave
application it essentially is two half wave rectifiers combined and because the
transformer secondary is centre tapped, D1 conducts on the positive half of the
cycle while D2 conducts on the negative part of the cycle. Both add together. This
is more efficient. The full wave bridge rectifier operates essentially the same as the
full wave rectifier but does not require a cetre tapped transformer. Further
discussion may be seen on the topic power supplies

1N400X series Diode:Features


Diffused Junction
High Current Capability and Low Forward Voltage Drop
Low Reverse Leakage Current
Lead Free Finish

IC
IC (Integrated Circuit) means that all the components of the circuit are fabricated
on same chip. Digital ICs are a collection of resistors, diodes, and transistors
fabricated on a single piece of semiconductor, usually silicon called a substrate,

which is commonly referred to as wafer. The chip is enclosed in a protective


plastic or ceramic package from which pins extend out connecting the IC to other
device. Suffix N or P stands for dual-in-line (plastic package (DIP) while suffix J
or I stands for dual-in-lime ceramic package. Also the suffix for W stands for flat
ceramic package.
The pins are numbered counter clockwise when viewed from the top of the
package with respect to an identity notch or dot at one end of the chip.The
manufacturers name can usually be guessed from its logo that is printed on the IC.
The IC type number also indicates the manufacturers code. For e.g. DM 408 N SN
7404 indicates National Semiconductor and Texas Instruments.

Other examples are:


Fair Child

: UA, UAF

National Semiconductor : DM, LM, LH, LF, and TA.


Motorola

: MC, MFC.

Sprague

: UKN, ULS, ULX.

Signetic

: N/s, NE/SE, and SU.

Burr-Brown

: BB.

Texas Instruments

: SN.

The middle portion i.e. the IC type number tells about the IC function and also the
family, which the particular IC belongs to.ICs that belongs to standard TTL series
have an identification number that starts with 74; for e.g. 7402, 74LS04, 74S04 etc.

ICs that belongs to standard CMOS family their number starts with 4, like 4000,
451B, 4724B, 1400. The 74C, 74HC, 74AC & 74ACT series are newer CMOS
series.
Various series with TTL logic family are:Standard TTL 74.
Schottky TTL 74s.
Low power Schottky 74LS.
Advance Schottky 74AS.
Advanced Low Power Schottky 74ALs.

Also there are various series with CMOS logic family as metal state CMOS 40 or
140.
Transistor:The schematic representation of a transistor is shown. Note the arrow pointing
down towards the emitter. This signifies it's an NPN transistor A transistor is
basically a current amplifier. Say we let 1mA flow into the base. We may get
100mA flowing into the collector. Note: The currents flowing into the base and
collector exit through the emitter (sum off all currents entering or leaving a node
must equal zero). The gain of the transistor will be listed in the datasheet as either
DC or Hfe. The gain won't be identical even in transistors with the same part
number. The gain also varies with the collector current and temperature.

Signals from switches


When a switch is used to provide an input to a circuit, pressing the switch usually
generates a voltage signal. It is the voltage signal which triggers the circuit into

action. What do you need to get the switch to generate a voltage signal? . . . You
need a voltage divider. The circuit can be built in either of two ways:

The pull down resistor in the first circuit forces Vout to become LOW except when
the push button switch is operated. This circuit delivers a HIGH voltage when the
switch is pressed. A resistor value of 10

is often used.

In the second circuit, the pull up resistor forces Vout to become HIGH except when
the switch is operated. Pressing the switch connects Vout directly to 0 V. In other
words, this circuit delivers a LOW voltage when the switch is pressed.
In circuits which process logic signals, a LOW voltage is called 'logic 0' or just '0',
while a HIGH voltage is called 'logic1' or '1'. These voltage divider circuits are
perfect for providing input signals for logic systems.
What kinds of switches could you use. One variety of push button switch is called
a miniature tactile switch. These are small switches which work well with
prototype board:

LED:- LED means light emitting diode. Its function is similar to the diode. But
these are not made up from silicon or germanium. These are generally used as a
indicating device. There are variety of LEDs are available in market depending
upon their size and colour.

Polarity of LED:- LED have polarity. We can judge its polarity by watching
flags in its structure. Bigger flag is known as cathode and smaller flag is known as
anode as shown below.

Voltage Regulator The LM78XX 3-terminal positive voltage regulators employ


internal current-limiting, thermal shutdown and safe-area compensation, making
them essentially indestructible. Heat sinking is provided; they can deliver over
1.0A output current. They are intended as fixed voltage regulators in a wide range
of applications including local (on-card) regulation for elimination of noise and
distribution problems associated with single-point regulation. In addition to use as
fixed voltage regulators.

Features
Output current up to 1 A
Output voltages of 5; 6; 8; 9; 12; 15; 18; 24 V
Thermal overload protection
Short circuit protection

Crystal: - Its a 2 terminal component. This component has no polarity. Its basic
function to generate a Square Wave of some fixes frequency. Its value is measure
in MHz.

Accelerometer
An accelerometer Sensor is an electromechanical device that measures acceleration
forces. These forces may be static or dynamic which is caused by moving or
vibrating the accelerometer. By measuring the amount of static acceleration due to
gravity, you can find out the angle the device is tilted at with respect to the earth.
By sensing the amount of dynamic acceleration, you can analyse the way the
device is moving.

We are using ADXL335 accelerometer. The ADXL335 is a small, thin, low power,
complete 3-axis accelerometer with signal conditioned voltage outputs. The
product measures acceleration with a minimum full-scale range of 3 g. It can
measure the static acceleration of gravity in tilt-sensing applications, as well as
dynamic acceleration resulting from motion, shock, or vibration.

Pinout:1.
2.
3.
4.
5.

Vcc
X-out
Y-out
Z-out
GND

OP-AMP Comparator Circuit Working


A comparator circuit compares two voltages and outputs either a 1 (the voltage at
the plus side; VDD in the illustration) or a 0 (the voltage at the negative side) to
indicate which is larger. Comparators are often used, for example, to check
whether an input has reached some predetermined value. In most cases a
comparator is implemented using a dedicated comparator IC, but op-amps may be

used as an alternative. Comparator diagrams and op-amp diagrams use the same
symbols.
Figure 4 shows a comparator circuit. Note first that the circuit does not use
feedback. The circuit amplifies the voltage difference between Vin and VREF, and
outputs the result at Vout. If Vin is greater than VREF, then voltage at Vout will rise
to its positive saturation level; that is, to the voltage at the positive side. If Vin is
lower than VREF, then Vout, will fall to its negative saturation level, equal to the
voltage at the negative side.
In practice, this circuit can be improved by incorporating a hysteresis voltage range
to reduce its sensitivity to noise. The circuit shown in Fig. 5, for example, will
provide stable operation even when the Vin signal is somewhat noisy.

ISOLATORS
Opto coupler (PC-817)
An isolator device to electrically insulate and isolate a separate component in a
circuit board arrangement to allow for relatively fast and convenient diagnostic
inspection of a circuit to locate failed components

In electronics, an opto-isolator, also called an optocoupler, photocoupler, or optical


isolator, is "an electronic device designed to transfer electrical signals by utilizing
light waves to provide coupling with electrical isolation between its input and
output. The main purpose of an opto-isolator is "to prevent high voltages or rapidly
changing voltages on one side of the circuit from damaging components or
distorting transmissions on the other side
An opto-isolator contains a source (emitter) of light, almost always a near infrared
light-emitting diode (LED), that converts electrical input signal into light, a closed
optical channel (also called dielectrically channel[5]), and a photo sensor, which
detects incoming light and either generates electric energy directly, or modulates
electric current flowing from an external power supply. The sensor can be a photo
resistor, a photodiode, a phototransistor. Pin diagram of PC 817 is shown below.

PC 817 is a 4 pin opto coupler as shown above. A series resistance of 470


ohm is used to limit the voltage across the diode. +5V power supply is connected
to the first pin of IC, which is the anode pin diode. 2nd pin is connected to the port
of microcontroller. When the second pin is low then we get low output, when the
input to 2nd pin high we get high voltage the output. Thus we isolate the voltage
having the same logic level.

RF MODULE
RF module comes in the transmitter and receiver pair. Varity of RF modules are
available in the market. These RF modules operate at some particular frequency
like 433 MHz and 315 MHz. HT 12 D and HT 12 E ICs are used with the RF

modules to encode and decode the data and channels. RF modules send data
serially by air as shown below:-

HT 12 E is an encoder IC which is used to encode the channel and data. Its a 18


pin IC. 4 pins are used for the data and 8 pins are used for addressing. 17th pin is
the output pin, which is further connected to the RF module of some particular
frequency. Pin diagram and circuit is shown below : -

HT 12 D is an decoder IC which is used to decode the channel and data. Its a 18


pin IC. 4 pins are used for the data and 8 pins are used for addressing. 14th pin is
the input pin, which is connected to the RF receiver. Pin diagram and circuit is
shown below : -

PIC MICROCONTROLLERS (MCU)


The

situation

we

find

ourselves

today

in

the

field

of

microcontrollers has its beginnings in the development of


technology of integrated circuits. It enabled us to store hundreds
of

thousands

of

transistors

into

one

chip,

which

was

precondition for the manufacture of microprocessors. The first


computers were made by adding external
peripherals, such as memory, input/output lines, timers and other
circuits, to it. Further increasing of package density resulted in
designing an integrated circuit which contained both processor
and peripherals.
microcomputer

This is how
later

known

the first chip containing


as

the

microcontroller

was

developed.

INTRODUCTION
The PIC16F887 is a well known product by Microchip. It features
all the components which modern microcontrollers normally have.
For its low price, wide range of application, high quality and easy

availability, it is an ideal solution in applications such as the


control of different processes in industry, machine control
devices, measurement of different values etc. Some of its main
features are listed below. Commonly in electronics usually think
that the microcontroller is the same as the microprocessor. Thats
not true. They differ from each other in many ways. The first and
most important difference in favor of the microcontroller is its
functionality. In order that the microprocessor may be used, other
components, memory comes first, must be added to it. Even
though it is considered a powerful computing machine, it is not
adjusted to communicating to peripheral environment. In order to
enable the microprocessor to communicate with peripheral
environment, special circuits must be used. This is how it was in
the beginning and remains the same .

BASIC CIRCUIT OF PIC MICROCONTROLLER

FIG 2:BLOCK DIAGRAM OF A PIC MICROCONTROLLER


PINOUT DESCRIPTION
Most pins of the PIC16F887 microcontroller are multi-functional as
seen

in

figure

above.

For

example,

designator

RA3/AN3/Vref+/C1IN+ for the fifth pin of the microcontroller


indicates
that it has the following functions:
RA3 Port A third digital input/output
AN3 Third analog input
Vref+ Positive voltage reference
C1IN+ Comparator C1 positive input

Such

pin

functionality

is

very

useful

as

it

makes

the

microcontroller package more compact without affecting its


operation.

These

various

pin

functions

cannot

be

used

simultaneously, but can be changed at any point during


operation.
MEMORY
The PIC16F887 has three types of memory ROM, RAM and
EEPROM. All of them will be
separately discussed since each has specific functions, features
and organization.
ROM MEMORY
ROM memory is used to permanently save the program being
executed. This is why it is often called program memory. The
PIC16F887 has 8Kb of ROM (in total of 8192 locations). Since
the ROM memory is made with FLASH technology, its contents
can be changed by providing a special programming voltage
(13V). of a special program on the PC and a simple electronic
device called the programmer.

THE PIC16F887 BASIC FEATURES


RISC architecture
Only 35 instructions to learn
All single-cycle instructions except branches
Operating frequency 0-20 MHz
Precision internal oscillator
Factory calibrated
Software selectable frequency range of 8MHz to 31KHz
Power supply voltage 2.0-5.5V
Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA
(stand-by mode)
Power-Saving Sleep Mode
Brown-out Reset (BOR) with software control option
35 input/output pins
High current source/sink for direct LED drive
software and individually programmable pull-upresistor
Interrupt-on-Change pin
8K ROM memory in FLASH technology
Chip can be reprogrammed up to 100.000 times

In-Circuit Serial Programming Option


Chip can be programmed even embedded in the target device
256 bytes EEPROM memory
Data can be written more than 1.000.000 times
368 bytes RAM memory
A/D converter:
14-channels
10-bit resolution
3 independent timers/counters
Watch-dog timer
Analogue comparator module with
Two analogue comparators
Fixed voltage reference (0.6V)
Programmable on-chip voltage reference
PWM output steering control
Enhanced USART module
Supports RS-485, RS-232 and LIN2.0
Auto-Baud Detect
Master Synchronous Serial Port (MSSP)
supports SPI and I2C mode

PIN CONFIGURATION OF 8051 MICROCONTROLLER


POWER SUPPLY
Evan through the PIC16F887 can operate at different supply
voltages, why to test 'Murphy's low'?! A 5V DC power supply is the
most suitable. The circuit, shown on the previous page,

uses a cheap integrated three-terminal positive regulator LM7805


and provides high-quality voltage stability and quite enough
current to enable the microcontroller and peripheral
electronics to operate normally (enough here means 1A).

RESET SIGNAL
In order that the microcontroller can operate properly, a logic one
(VCC) must be applied on the reset pin. The push button
connecting the reset pin MCLR to GND is not necessary.
However, it is almost always provided because it enables the
microcontroller to return safely to normal operating conditions if
something goes wrong. By pushing this button, 0V is brought
to the pin, the microcontroller is reset and the program execution
starts from the beginning. A10K resistor is used to allow 0V to be
applied to the MCLR pin, via the push button, without shorting the
5VDCrail to earth.
CLOCK SIGNAL
Even though the microcontroller has a built-in oscillator, it cannot
operate without external components which stabilize its operation
and determine its frequency (operating speed of the
microcontroller). Depending on elements in use as well as their
frequencies, the oscillator can be run in four different modes:
LP - Low Power Crystal;
XT - Crystal / Resonator;

HS - High speed Crystal / Resonator; and


RC - Resistor / Capacitor.

Quartz Crystal
When the quartz crystal is used for frequency stabilization, a builtin oscillator operates at a precise frequency which is not affected
by changes in temperature and power supply voltage.
This frequency is usually labeled on the crysal casing.
Apart from the crystal, capacitors C1 and C2 must also be
connected as per schematic below. Their capacitance is not of
great importance. Therefore, the values provided in the

table

Ceramic Resonator
CERAMIC resonator is cheaper, but very similar to quartz by its
function and the way of operation. This is why schematics
illustrating their connection to the microcontroller are identical.
However, the capacitor value is slightly different due to different
electric features. Refer to the table below

Such resonators are usually connected to oscillators when it is not


necessary to provide extremely precise frequency
SFR REGISTERS
In addition to registers which do not have any special and
predetermined function, every microcontroller has a number of
registers

(SFR)

whose

function

is

predetermined

by

the

manufacturer. Their bits are connected (literally) to internal

circuits of the microcontroller such as timers, A/D converter,


oscillator.
INPUT / OUTPUT PORTS
In order to make the microcontroller useful, it has to be connected
to additional electronics, i.e. peripherals. Each
microcontroller has one or more registers (called ports) connected
to the microcontroller pins. Why input/output?
Because you can change a pin function as you wish. For example,
suppose you want your device to turn on/off three
signal LEDs and simultaneously monitor the logic state of five
sensors or push buttons. Some of the ports need to be configured
so that there are three outputs (connected to LEDs) and five
inputs (connected to sensors). It is simply
performed by software, which means that a pin function can be
changed during operation which control the operation of a small
circuit within the microcontroller- Special Function Registers do
exactly that.
MEMORY UNIT
Memory is part of the microcontroller used for data storage. The
easiest way to explain it is to compare it with a
filing cabinet with many drawers. Suppose, the drawers are
clearly marked so that their contents can be easily found
out by reading the label on the front of the drawer.

READ ONLY MEMORY (ROM)


Read Only Memory (ROM) is used to permanently save the
program being executed. The size of program that can be
written

depends

on

the

size

of

this

memory.

Todays

microcontrollers commonly use 16-bit addressing, which means


that they are able to address up to 64 Kb of memory, i.e. 65535
locations. As a novice, your program will rarely exceed the limit of
several hundred instructions. There are several types of ROM.
Masked ROM (MROM)
Masked ROM is a kind of ROM the content of which I is
programmed by the manufacturer. The term masked comes
from the manufacturing process, where regions of the chip are
masked off before the process of photolithography. In case of a
large-scale production, the price is very low. Forget it...
One Time Programmable ROM (OTP ROM)
One time programmable ROM enables you to download a program
into it, but, as its name states, one time only. If an
error is detected after downloading, the only thing you can do is
to download the correct program to another chip.
Flash Memory
This type of memory was invented in the 80s in the laboratories
of INTEL and was represented as the successor to the

UV EPROM. Since the content of this memory can be written and


cleared

practically

microcontrollers

with

an
Flash

unlimited
ROM

are

number
ideal

of
for

timer
learning,

experimentation and small-scale production. Because of its


great popularity, most microcontrollers are manufactured in flash
technology today. So, if you are going to buy a
microcontroller, the type to look for is definitely Flash!
RANDOM ACCESS MEMORY (RAM)
Once the power supply is off the contents of RAM is cleared. It is
used for temporary storing data and intermediate results created
and used during the operation of the microcontroller. For example,
if the program performs an addition (of whatever), it is necessary
to have a register representing what in everyday life is called the
sum. For this reason, one of the registers of RAM is called the
sum and used for storing results of addition.

ELECTRICALLY ERASABLE PROGRAMMABLE ROM (EEPROM)


The contents of EEPROM may be changed during operation
(similar to RAM), but remains permanently saved even after the
loss of power (similar to ROM). Accordingly, EEPROM is often used
to store values, created during operation, which must be
permanently saved. For example, if you design an electronic lock
or an alarm, it would be great to enable the user to create and

enter the password, but its useless if lost every time the power
supply goes off. The ideal solution is a microcontroller with an
embedded EEPROM.
INTERRUPT
Most programs use interrupts in their regular execution. The
purpose of the microcontroller is mainly to respond to changes in
its surrounding. In other words, when an event takes place, the
microcontroller does something... For example, when you push a
button on a remote controller, the microcontroller will register it
and respond by changing a channel, turn the volume up or down
etc. If the microcontroller spent most of its time endlessly
checking a few buttons for hours or days, it would not be practical
at all.
This is why the microcontroller has learnt a trick during its
evolution. Instead of checking each pin or bit constantly,
the microcontroller delegates the wait issue to a specialist
which will respond only when something attention worthy
happens. The signal which informs the central processor unit
about such an event is called an INTERRUPT BUS A bus consists of
8, 16 or more wires. There are two types of buses: the address
bus and the data bus. The address bus consists of as many lines
as necessary for memory addressing. It is used to transmit
address from the CPU to the memory. The data bus is as wide as
the data, in our case it is 8 bits or wires wide. It is used to connect
all the circuits within the microcontroller

SERIAL COMMUNICATION
Parallel connection between the microcontroller and peripherals
via input/output ports is the ideal solution on shorter distances up
to several meters. However, in other cases when it is necessary to
establish communication

between two devices on longer

distances it is not possible to use parallel connection. Instead,


serial communication is used. Today, most microcontrollers have
built in several different systems for serial communication as a
standard equipment. Which of these systems will be used
depends on many factors of which the most important are:
How many devices the microcontroller has to exchange data
with?
How fast the data exchange has to be?
What is the distance between devices?
Is it necessary to send and receive data simultaneously?
One
BAUD RATE
The term baud rate is used to denote the number of bits
transferred per second [bps]. Note that it refers to bits, not
bytes. It is usually required by the protocol that each byte is
transferred along with several control bits. It means
that one byte in serial data stream may consist of 11 bits. For
example, if the baud rate is 300 bps then maximum 37 and
minimum 27 bytes may be transferred per second.

UART (UNIVERSAL ASYNCHRONOUS RECEIVER/TRANSMITTER)


This sort of communication is asynchronous, which means that a
special line for transferring clock signal is not used. In some
applications, such as radio connection or infrared waves remote
control, this feature is crucial. Since only one communication line
is used, both receiver and transmitter operate at the same
predefined rate in order to maintain necessary synchronization.
This is a very simple way of transferring data since it basically
represents the conversion of 8-bit data from parallel to serial
format. Baud rate is not high, up to 1 Mbit/sec.
TIMERS/COUNTERS
The microcontroller oscillator uses quartz crystal for its operation.
Even though it is not the simplest solution, there
are many reasons to use it. The frequency of such oscillator is
precisely defined and very stable, so that pulses it generates are
always of the same width, which makes them ideal for time
measurement. Such oscillators are also used in quartz watches. If
it is necessary to measure time between two events, it is
sufficient to count up pulses generated by this oscillator. This is
exactly what the timer does.

WATCHDOG TIMER
A watchdog timer is a timer connected to a completely separate
RC oscillator within the microcontroller. If the watchdog timer is
enabled, every time it counts up to the maximum value, the
microcontroller reset occurs and the program execution starts
from the first instruction. The point is to prevent this from
happening by using a specific command. Anyway, the whole idea
is based on the fact that every program is executed in several
longer or shorter loops. If instructions which reset the watchdog
timer are set at the appropriate program locations, besides
commands being regularly executed, then the operation of the
watchdog timer will not affect the program execution. If for any
reason, usually electrical noise in industry, the program counter
gets stuck at some memory location from which there is no
return, the watchdog timer will not be cleared, so the registers
value being constantly incremented will reach the maximum et
voila! Reset occurs!

INSTRUCTION SET
All instructions understandable to the microcontroller are called
together the Instruction Set. When you write a program in
assembly language, you actually specify instructions in such an
order they should be executed. The main restriction here is a

number of available instructions. The manufacturers usually adopt


either approach described below:
RISC (REDUCED INSTRUCTION SET COMPUTER)
In this case, the microcontroller recognizes and executes only
basic operations (addition, subtraction, copying etc.). Other, more
complicated operations are performed by combining them. For
example, multiplication is performed by performing successive
addition. Its the same as if you try to explain to someone, using
only a few different words, how to reach the airport in a new city.
However, its not as black as its painted. First of all, this language
is easy to learn. The microcontroller is very fast so that it is not
possible to see all the arithmetic acrobatics it performs. The user
can only see the final results. At last, it is not so difficult to explain
where the airport is if you use the right words such as left, right,
kilometers etc.

CISC (COMPLEX INSTRUCTION SET COMPUTER)


CISC is the opposite to RISC! Microcontrollers designed to
recognize more than 200 different instructions can do a lot
of things at high speed. However, one needs to understand how
to take all that such a rich language offers, which is not at all easy

DC MOTOR

PRINCIPLE OF OPERATION

In any electric motor, operation is based on simple electromagnetism. A currentcarrying conductor generates a magnetic field; when this is then placed in an
external magnetic field, it will experience a force proportional to the current in the
conductor, and to the strength of the external magnetic field. As you are well aware
of from playing with magnets as a kid, opposite (North and South) polarities
attract, while like polarities (North and North, South and South) repel. The internal
configuration of a DC motor is designed to harness the magnetic interaction
between a current-carrying conductor and an external magnetic field to generate
rotational motion.
ISOLATORS
Opto coupler (PC-817)
An isolator device to electrically insulate and isolate a separate component in a
circuit board arrangement to allow for relatively fast and convenient diagnostic
inspection of a circuit to locate failed components
In electronics, an opto-isolator, also called an optocoupler, photocoupler, or optical
isolator, is "an electronic device designed to transfer electrical signals by utilizing
light waves to provide coupling with electrical isolation between its input and
output. The main purpose of an opto-isolator is "to prevent high voltages or rapidly
changing voltages on one side of the circuit from damaging components or
distorting transmissions on the other side
An opto-isolator contains a source (emitter) of light, almost always a near infrared
light-emitting diode (LED), that converts electrical input signal into light, a closed
optical channel (also called dielectrical channel[5]), and a photosensor, which
detects incoming light and either generates electric energy directly, or modulates

electric current flowing from an external power supply. The sensor can be a
photoresistor, a photodiode, a phototransistor. Pin diagram of PC 817 is shown
below.

Working: - PC 817 is a 4 pin opto coupler as shown above. A series resistance of


470 ohm is used to limit the voltage across the diode. +5V power supply is

connected to the first pin of IC, which is the anode pin diode. 2nd pin is connected
to the port of microcontroller. When the second pin is low then we get low output,
when the input to 2nd pin high we get high voltage the output. Thus we isolate the
voltage having the same logic level.

H-BRIDGE CIRCUIT

Working: - 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.
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 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.

The two basic states of an H bridge


The H-bridge arrangement is generally used to reverse the polarity of the motor,
but can also be used to 'brake' the motor, where the motor comes to a sudden stop,
as the motor's terminals are shorted, or to let the motor 'free run' to a stop, as the
motor is effectively disconnected from the circuit.

Program void main()


{ TRISD=0;
PORTD=255;

TRISD = 255; //Configure 1st bit of PORTD as input

TRISB = 0; //Configure 1st bit of PORTB as output


PORTB = 255; //LED OFF
do
{
if(PORTD.F4 == 0) //forward
{

PORTB.F0 = 0; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED ON
PORTB.F3 = 0; //LED OFF
}
else if(PORTD.F1 == 0) //reverse
{

PORTB.F0 = 0; //LED ON
PORTB.F1 = 1; //LED OFF

PORTB.F2 = 0; //LED ON
PORTB.F3 = 1; //LED OFF
}
else if(PORTD.F2 == 0) //left
{

PORTB.F0 = 1; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED ON
PORTB.F3 = 0; //LED OFF
}
else if(PORTD.F3 == 0) //right
{

PORTB.F0 = 0; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 1; //LED ON
PORTB.F3 = 0; //LED OFF
}

else if(PORTD.F0 == 0) //stop


{

PORTB.F0 = 1; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 1; //LED ON
PORTB.F3 = 0; //LED OFF
}
else
{

PORTB.F0 = 0; //LED ON
PORTB.F1 = 0; //LED OFF
PORTB.F2 = 0; //LED ON
PORTB.F3 = 0; //LED OFF
}

} while(1);
}

You might also like