You are on page 1of 58

ARDUINO BASED UNDERGROUND CABLE FAULT DETECTOR

Abstract:

The project is intended to detect the location of fault in underground cable lines from the base
station to exact location in kilometers using an Arduino micro controller kit. In the urban areas,
the electrical cable runs in undergrounds instead of overhead lines. Whenever the fault occurs in
underground cable it is difficult to detect the exact location of the fault for process of repairing
that particular cable. The proposed system finds the exact location of the fault. This system uses
an Arduino micro controller kit and a rectified power supply. Here the current sensing circuits
made with a combination of resistors are interfaced to Arduino micro controller kit to help of the
internal ADC device for providing digital data to the microcontroller representing the cable
length in kilometers. The fault creation is made by the set of switches. The relays are controlled
by the relay driver. A 16x2 LCD display connected to the microcontroller to display the
information. In case of short circuit the voltage across series resistors changes accordingly,
which is then fed to an ADC to develop precise digital data to a programmed Arduino micro
controller kit that further displays exact fault location from base station in kilometers. The
project future can be implemented by using capacitor in an AC circuit to measure the impedance
which can even locate the open circuited cable.Whenever a fault occurs in a cable the buzzer
produce the alarm to alert and to take an immediate action by field workers

Block diagram:

Bluetooth 16x2 lcd


module
Relay1
Arduino
switches uno
Relaydriver Relay2
Power
supply Relay3
Circuit diagram:

HC-05

What is Arduino?

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use


hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in
creating interactive objects or environments.

Arduino can sense the environment by receiving input from a variety of sensors and can affect
its surroundings by controlling lights, motors, and other actuators. The microcontroller on the
board is programmed using the Arduino programming language (based on Wiring) and the
Arduino development environment (based on Processing). Arduino projects can be stand-alone
or they can communicate with software on running on a computer (e.g. Flash, Processing,
MaxMSP).

Arduino received an Honory Mention in the Digital Communities section of the 2006 Ars
Electronica Prix. Credits
Arduino Nano overview:

Arduino Nano is a surface mount breadboard embedded version with integrated USB. It is a
smallest, complete, and breadboard friendly. It has everything that Diecimila/Duemilanove has
(electrically) with more analog input pins and onboard +5V AREF jumper. Physically, it is
missing power jack. The Nano is automatically sense and switch to the higher potential source
of power, there is no need for the power select jumper.

Nano’s got the breadboard-ability of the Boarduino and the Mini+USB with smaller footprint
than either, so users have more breadboard space. It’s got a pin layout that works well with the
Mini or the Basic Stamp (TX, RX, ATN, GND on one top, power and ground on the other). This
new version 3.0 comes with ATMEGA328 which offer more programming and data memory
space. It is two layers. That make it easier to hack and more affordable.

You end up paying less with Nano than Mini and USB combined!

Specifications:

Microcontroller Atmel ATmega328


Operating Voltage (logic level) 5 V
Input Voltage (recommended) 7-12 V
Input Voltage (limits) 6-20 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 8
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (of which 2KB used by bootloader)
SRAM 2 KB
EEPROM 1 KB
Clock Speed 16 MHz
Dimensions 0.70” x 1.70”

Features:

• Automatic reset during program download


• Power OK blue LED
• Green (TX), red (RX) and orange (L) LED
• Auto sensing/switching power input
• Small mini-B USB for programming and serial monitor
• ICSP header for direct program download
• Standard 0.1” spacing DIP (breadboard friendly)
• Manual reset switch
Power:

The Arduino Nano can be powered via the mini-B USB connection, 6-20V unregulated external
power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is
automatically selected to the highest voltage source.

POWER SUPPLY:

Block diagram:

Figure: Power Supply

Circuitdiagram:

Description:
Transformer:

A transformer is a device that transfers electrical energy from one circuit to another through
inductively coupled conductors—the transformer's coils. A varying current in the first or
primary winding creates a varying magnetic flux in the transformer's core, and thus a varying
magnetic field through the secondary winding. This varying magnetic field induces a varying
electromotive force (EMF) or "voltage" in the secondary winding. This effect is called mutual
induction.

Figure: Transformer Symbol

(or)

Transformer is a device that converts the one form energy to another form of energy like a
transducer.

Figure: Transformer

Basic Principle :
A transformer makes use of Faraday's law and the ferromagnetic properties of an iron core to
efficiently raise or lower AC voltages. It of course cannot increase power so that if the voltage is
raised, the current is proportionally lowered and vice versa.

Figure: Basic Principle

Transformer Working:

A transformer consists of two coils (often called 'windings') linked by an iron core, as shown in
figure below. There is no electrical connection between the coils, instead they are linked by a
magnetic field created in the core.
Figure: Basic Transformer

Transformers are used to convert electricity from one voltage to another with minimal loss of
power. They only work with AC (alternating current) because they require a changing magnetic
field to be created in their core. Transformers can increase voltage (step-up) as well as reduce
voltage (step-down).

Alternating current flowing in the primary (input) coil creates a continually changing magnetic
field in the iron core. This field also passes through the secondary (output) coil and the changing
strength of the magnetic field induces an alternating voltage in the secondary coil. If the
secondary coil is connected to a load the induced voltage will make an induced current flow.
The correct term for the induced voltage is 'induced electromotive force' which is usually
abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are currents
produced by the alternating magnetic field inducing a small voltage in the core, just like that
induced in the secondary coil. Eddy currents waste power by needlessly heating up the core but
they are reduced to a negligible amount by laminating the iron because this increases the
electrical resistance of the core without affecting its magnetic properties.

Transformers have two great advantages over other methods of changing voltage:

1. They provide total electrical isolation between the input and output, so they can be safely
used to reduce the high voltage of the mains supply.
2. Almost no power is wasted in a transformer. They have a high efficiency (power out /
power in) of 95% or more.

Classification of Transformer:
 Step-Up Transformer
 Step-Down Transformer

Step-Down Transformer:

Step down transformers are designed to reduce electrical voltage. Their primary voltage is
greater than their secondary voltage. This kind of transformer "steps down" the voltage applied
to it. For instance, a step down transformer is needed to use a 110v product in a country with a
220v supply.

Step down transformers convert electrical voltage from one level or phase configuration usually
down to a lower level. They can include features for electrical isolation, power distribution, and
control and instrumentation applications. Step down transformers typically rely on the principle
of magnetic induction between coils to convert voltage and/or current levels.

Step down transformers are made from two or more coils of insulated wire wound around a core
made of iron. When voltage is applied to one coil (frequently called the primary or input) it
magnetizes the iron core, which induces a voltage in the other coil, (frequently called the
secondary or output). The turn’s ratio of the two sets of windings determines the amount of
voltage transformation.

Figure: Step-Down Transformer

An example of this would be: 100 turns on the primary and 50 turns on the secondary, a ratio of
2 to 1.

Step down transformers can be considered nothing more than a voltage ratio device.

With step down transformers the voltage ratio between primary and secondary will mirror the
"turn’s ratio" (except for single phase smaller than 1 kva which have compensated secondary). A
practical application of this 2 to 1 turn’s ratio would be a 480 to 240 voltage step down. Note
that if the input were 440 volts then the output would be 220 volts. The ratio between input and
output voltage will stay constant. Transformers should not be operated at voltages higher than
the nameplate rating, but may be operated at lower voltages than rated. Because of this it is
possible to do some non-standard applications using standard transformers.

Single phase step down transformers 1 kva and larger may also be reverse connected to step-
down or step-up voltages. (Note: single phase step up or step down transformers sized less than
1 KVA should not be reverse connected because the secondary windings have additional turns to
overcome a voltage drop when the load is applied. If reverse connected, the output voltage will
be less than desired.)

Step-Up Transformer:

A step up transformer has more turns of wire on the secondary coil, which makes a larger
induced voltage in the secondary coil. It is called a step up transformer because the voltage
output is larger than the voltage input.

Step-up transformer 110v 220v design is one whose secondary voltage is greater than its
primary voltage. This kind of transformer "steps up" the voltage applied to it. For instance, a
step up transformer is needed to use a 220v product in a country with a 110v supply.

A step up transformer 110v 220v converts alternating current (AC) from one voltage to another
voltage. It has no moving parts and works on a magnetic induction principle; it can be designed
to "step-up" or "step-down" voltage. So a step up transformer increases the voltage and a step
down transformer decreases the voltage.

The primary components for voltage transformation are the step up transformer core and coil.
The insulation is placed between the turns of wire to prevent shorting to one another or to
ground. This is typically comprised of Mylar, nomex, Kraft paper, varnish, or other materials.
As a transformer has no moving parts, it will typically have a life expectancy between 20 and 25
years.
Figure: Step-Up Transformer

Applications

Generally these Step-Up Transformers are used in industries applications only.

Turns Ratio and Voltage

The ratio of the number of turns on the primary and secondary coils determines the ratio of the
voltages...

...where Vp is the primary (input) voltage, Vs is the secondary (output) voltage, Np is the number
of turns on the primary coil, and Ns is the number of turns on the secondary coil.

Diodes:

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol shows
the direction in which the current can flow. Diodes are the electrical version of a valve and
early diodes were actually called valves.

Figure: Diode Symbol


A diode is a device which only allows current to flow through it in one direction. In this
direction, the diode is said to be 'forward-biased' and the only effect on the signal is that there
will be a voltage loss of around 0.7V. In the opposite direction, the diode is said to be 'reverse-
biased' and no current will flow through it.

Rectifier

The purpose of a rectifier is to convert an AC waveform into a DC waveform (OR) Rectifier


converts AC current or voltages into DC current or voltage. There are two different rectification
circuits, known as 'half-wave' and 'full-wave' rectifiers. Both use components called diodes to
convert AC into DC.

The Half-wave Rectifier

The half-wave rectifier is the simplest type of rectifier since it only uses one diode, as shown in
figure .

Figure: Half Wave Rectifier

Figure 2 shows the AC input waveform to this circuit and the resulting output. As you can see,
when the AC input is positive, the diode is forward-biased and lets the current through. When
the AC input is negative, the diode is reverse-biased and the diode does not let any current
through, meaning the output is 0V. Because there is a 0.7V voltage loss across the diode, the
peak output voltage will be 0.7V less than Vs.
Figure: Half-Wave Rectification

While the output of the half-wave rectifier is DC (it is all positive), it would not be suitable as a
power supply for a circuit. Firstly, the output voltage continually varies between 0V and Vs-
0.7V, and secondly, for half the time there is no output at all.

The Full-wave Rectifier

The circuit in figure 3 addresses the second of these problems since at no time is the output
voltage 0V. This time four diodes are arranged so that both the positive and negative parts of
the AC waveform are converted to DC. The resulting waveform is shown in figure 4.

Figure: Full-Wave Rectifier


Figure: Full-Wave Rectification

When the AC input is positive, diodes A and B are forward-biased, while diodes C and D are
reverse-biased. When the AC input is negative, the opposite is true - diodes C and D are
forward-biased, while diodes A and B are reverse-biased.

While the full-wave rectifier is an improvement on the half-wave rectifier, its output still isn't
suitable as a power supply for most circuits since the output voltage still varies between 0V and
Vs-1.4V. So, if you put 12V AC in, you will 10.6V DC out.

Capacitor Filter

The capacitor-input filter, also called "Pi" filter due to its shape that looks like the Greek letter
pi, is a type of electronic filter. Filter circuits are used to remove unwanted or undesired
frequencies from a signal.

Figure: Capacitor Filter


A typical capacitor input filter consists of a filter capacitor C1, connected across the rectifier
output, an inductor L, in series and another filter capacitor connected across the load.

1. The capacitor C1 offers low reactance to the AC component of the rectifier output while
it offers infinite reactance to the DC component. As a result the capacitor shunts an
appreciable amount of the AC component while the DC component continues its journey
to the inductor L
2. The inductor L offers high reactance to the AC component but it offers almost zero
reactance to the DC component. As a result the DC component flows through the
inductor while the AC component is blocked.
3. The capacitor C2 bypasses the AC component which the inductor had failed to block. As
a result only the DC component appears across the load RL.

Figure: Centered Tapped Full-Wave Rectifier with a Capacitor Filter

Voltage Regulator:

A voltage regulator is an electrical regulator designed to automatically maintain a constant


voltage level. It may use an electromechanical mechanism, or passive or active electronic
components. Depending on the design, it may be used to regulate one or more AC or DC
voltages. There are two types of regulator are they.

 Positive Voltage Series (78xx) and


 Negative Voltage Series (79xx)

78xx:’78’ indicate the positive series and ‘xx’indicates the voltage rating. Suppose 7805
produces the maximum 5V.’05’indicates the regulator output is 5V.
79xx:’78’ indicate the negative series and ‘xx’indicates the voltage rating. Suppose 7905
produces the maximum -5V.’05’indicates the regulator output is -5V.

These regulators consists the three pins there are

Pin1: It is used for input pin.

Pin2: This is ground pin for regulator

Pin3: It is used for output pin. Through this pin we get the output.

Figure: Regulator

Relays

A relay is an electrically operated switch. These are remote control electrical


switches that are controlled by another switch, such as a horn switch or a computer
as in a power train control module, devices in industries, home based applications.
Relays allow a small current pin, 4-pin, 5-pin, and 6-pin, single switch or dual
switches. Relays are used throughout the automobile. Relays which come in
assorted sizes, ratings, and applications, are used as remote control switches. A
typical vehicle can have 20 relays or more.
BASICS ON RELAY HANDLING
 To maintain initial performance, care should be taken to avoid dropping or
hitting the relay.
 Under normal use, the relay is designed so that the case will not detach. To
maintain initial performance, the case should not be removed. Relay
characteristics cannot be guaranteed if the case is removed.
 Use of the relay in an atmosphere at standard temperature and humidity with
minimal amounts of dust, SO 2, H 2 S, or organic gases is recommended.
 Please avoid the use of silicon-based resins near the relay, because doing so
may result in contact failure. (This applies to plastic sealed type relays,
too.)
 Care should be taken to observe correct coil polarity (+, –) for polarized
relays.
 Proper usage requires that the rated voltage be impressed on the coil. Use
rectangular waves for DC coils and sine waves for AC coils.
 Be sure the coil impressed voltage does not continuously exceed the
maximum allowable voltage.
 Absolutely avoid using switching voltages and currents that exceed the
designated values.
 The rated switching power and life are given only as guides. The physical
phenomena at the contacts and contact life greatly vary depending on the
type of load and the operating conditions. Therefore, be sure to carefully
check the
 type of load and operating conditions before use.
 Do not exceed the usable ambient temperature values listed in the catalog.
 Use the flux-resistant type or sealed type if automatic soldering is to be
used.
 Use alcohol based cleaning solvents when cleaning is to be performed using
a
sealed type relay.
 Avoid ultrasonic cleaning of all types of relays.
 Avoid bending terminals, because it may cause malfunction.
 As a guide, use a Faston mounting pressure of 40 to 70N {4 to 7kgf}for
relays
with tab terminals.

A relay is used to isolate one electrical circuit from another. It allows a low current
control circuit to make or break an electrically isolated high current circuit path.
The basic relay consists of a coil and a set of contacts. The most common relay
coil is a length of magnet wire wrapped around a metal core. When voltage is
applied to the coil, current passes through the wire and creates a magnetic field.
This magnetic field pulls the contacts together and holds them there until the
current flow in the coil has stopped. The diagram below shows the parts of a
simple relay.

Figure: Relay

Operation:

When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either
makes or breaks a connection with a fixed contact. When the current is switched
off, the armature is usually returned by a spring to its resting position shown in
figure 6.6(b). Latching relays exist that require operation of a second coil to reset
the contact position.

By analogy with the functions of the original electromagnetic device, a solid-state


relay operates a thyristor or other solid-state switching device with a transformer
or light-emitting diode to trigger it.

Pole and throw

Since relays are switches the terminology applied to switches is also applied to
relays. A relay will switch one or more poles, each of whose contacts can be
thrown by energizing the coil in one of three ways:
 Normally-open (NO) contacts connect the circuit when the relay is
activated; the circuit is disconnected when the relay is inactive. It is also
called a Form A contact or "make" contact.
 Normally-closed (NC) contacts disconnect the circuit when the relay is
activated; the circuit is connected when the relay is inactive. It is also called
a Form B contact or "break" contact.
 Change-over (CO), or double-throw (DT), contacts control two circuits: one
normally-open contact and one normally-closed contact with a common
terminal. It is also called a Form C contact or "transfer" contact ("break
before make"). If this type of contact utilizes a "make before break"
functionality, then it is called a Form D contact.

SPST

SPST relay stands for Single Pole Single Throw relay. Current will only flow
through the contacts when the relay coil is energized.

Figure: SPST Relay

SPDT Relay

SPDT Relay stands for Single Pole Double Throw relay. Current will flow
between the movable contact and one fixed contact when the coil is De-energized
and between the movable contact and the alternate fixed contact when the relay
coil is energized. The most commonly used relay in car audio, the Bosch relay, is a
SPDT relay.
Figure: SPDT Relay

DPST Relay

DPST relay stands for Double Pole Single Throw relay. When the relay coil is
energized, two separate and electrically isolated sets of contacts are pulled down to
make contact with their stationary counterparts. There is no complete circuit path
when the relay is De-energized.

Figure: DPST Relay

DPDT Relay

DPDT relay stands for Double Pole Double Throw relay. It operates like the SPDT
relay but has twice as many contacts. There are two completely isolated sets of
contacts.
Figure: DPDT Relay

This is a 4 Pole Double Throw relay. It operates like the SPDT relay but it has 4
sets of isolated contacts.

Figure: 4 Pole Double Throw relay

Types of relay:

1. Latching Relay
2. Reed Relay
3. Mercury Wetted Relay
4. Machine Tool Relay
5. Solid State Relay (SSR)
Latching relay
Latching relay, dust cover removed, showing pawl and ratchet mechanism. The
ratchet operates a cam, which raises and lowers the moving contact arm, seen
edge-on just below it. The moving and fixed contacts are visible at the left side of
the image.

A latching relay has two relaxed states (bi-stable). These are also called
"impulse", "keep", or "stay" relays. When the current is switched off, the relay
remains in its last state. This is achieved with a solenoid operating a ratchet and
cam mechanism, or by having two opposing coils with an over-center spring or
permanent magnet to hold the armature and contacts in position while the coil is
relaxed, or with a remanent core. In the ratchet and cam example, the first pulse to
the coil turns the relay on and the second pulse turns it off. In the two coil
example, a pulse to one coil turns the relay on and a pulse to the opposite coil
turns the relay off. This type of relay has the advantage that it consumes power
only for an instant, while it is being switched, and it retains its last setting across a
power outage. A remanent core latching relay requires a current pulse of opposite
polarity to make it change state.

Figure: Latching relay

Reed relay

A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube,
which protects the contacts against atmospheric corrosion. The contacts are closed
by a magnetic field generated when current passes through a coil around the glass
tube. Reed relays are capable of faster switching speeds than larger types of relays,
but have low switch current and voltage ratings.

Mercury-wetted relay

A mercury-wetted reed relay is a form of reed relay in which the contacts are
wetted with mercury. Such relays are used to switch low-voltage signals (one volt
or less) because of their low contact resistance, or for high-speed counting and
timing applications where the mercury eliminates contact bounce. Mercury wetted
relays are position-sensitive and must be mounted vertically to work properly.
Because of the toxicity and expense of liquid mercury, these relays are rarely
specified for new equipment. See also mercury switch.

Machine tool relay

A machine tool relay is a type standardized for industrial control of machine


tools, transfer machines, and other sequential control. They are characterized by a
large number of contacts (sometimes extendable in the field) which are easily
converted from normally-open to normally-closed status, easily replaceable coils,
and a form factor that allows compactly installing many relays in a control panel.
Although such relays once were the backbone of automation in such industries as
automobile assembly, the programmable logic controller (PLC) mostly displaced
the machine tool relay from sequential control applications.
Solid-state relay

A solid state relay (SSR) is a solid state electronic component that provides a
similar function to an electromechanical relay but does not have any moving
components, increasing long-term reliability. With early SSR's, the tradeoff came
from the fact that every transistor has a small voltage drop across it. This voltage
drop limited the amount of current a given SSR could handle. As transistors
improved, higher current SSR's, able to handle 100 to 1,200 Amperes, have
become commercially available. Compared to electromagnetic relays, they may be
falsely triggered by transients.

Figure: Solid relay, which has no moving parts

Specification

 Number and type of contacts – normally open, normally closed, (double-


throw)
 Contact sequence – "Make before Break" or "Break before Make". For
example, the old style telephone exchanges required Make-before-break so
that the connection didn't get dropped while dialing the number.
 Rating of contacts – small relays switch a few amperes, large contactors are
rated for up to 3000 amperes, alternating or direct current
 Voltage rating of contacts – typical control relays rated 300 VAC or 600
VAC, automotive types to 50 VDC, special high-voltage relays to about 15
000 V
 Coil voltage – machine-tool relays usually 24 VAC, 120 or 250 VAC, relays
for switchgear may have 125 V or 250 VDC coils, "sensitive" relays operate
on a few milli-amperes

Applications:

Relays are used:

 To control a high-voltage circuit with a low-voltage signal, as in some types


of modems,
 To control a high-current circuit with a low-current signal, as in the starter
solenoid of an automobile,
 To detect and isolate faults on transmission and distribution lines by
opening and closing circuit breakers (protection relays),
 To isolate the controlling circuit from the controlled circuit when the two
are at different potentials, for example when controlling a mains-powered
device from a low-voltage switch. The latter is often applied to control
office lighting as the low voltage wires are easily installed in partitions,
which may be often moved as needs change. They may also be controlled
by room occupancy detectors in an effort to conserve energy,
 To perform logic functions. For example, the boolean AND function is
realized by connecting relay contacts in series, the OR function by
connecting contacts in parallel. Due to the failure modes of a relay
compared with a semiconductor, they are widely used in safety critical
logic, such as the control panels of radioactive waste handling machinery.
 As oscillators, also called vibrators. The coil is wired in series with the
normally closed contacts. When a current is passed through the relay coil,
the relay operates and opens the contacts that carry the supply current. This
stops the current and causes the contacts to close again. The cycle repeats
continuously, causing the relay to open and close rapidly. Vibrators are used
to generate pulsed current.
 To generate sound. A vibrator, described above, creates a buzzing sound
because of the rapid oscillation of the armature. This is the basis of the
electric bell, which consists of a vibrator with a hammer attached to the
armature so it can repeatedly strike a bell.
 To perform time delay functions. Relays can be used to act as an mechanical
time delay device by controlling the release time by using the effect of
residual magnetism by means of a inserting copper disk between the
armature and moving blade assembly.

BLUETOOTH:

This module enables you to wireless transmit & receive serial data. It is a drop in
replacement for wired serial connections allowing transparent two way data communication.
You can simply use it for serial port replacement to establish connection between MCU or
embedded project and PC for data transfer. Bluetooth Core V2.0 compliant module with SPP.
The module is designed to be embedded in a host system which requires cable replacement
function. Typically the module could interface with a host through the UART port.

The module could be used in many different applications Example:

• Hand held terminals

• Industrial devices

• Point-of-Sale systems

• PCs

• Personal Digital Assistants (PDAs)

• Computer Accessories

• Access Points
• Automotive Diagnostics Units
We supply module with 9600 baud rate in ready to use with PC. You will need a USB
Bluetooth Adapter at PC side or Bluetooth Enabled Laptop to connect to our Bluetooth module.
Module supplied by us with this setting: 9600 baud rate, Pair Code: 0000

The Bluetooth module works on 3.3V level only. High voltage like 5V will permanently
damage the module, so please take care in using it.

If your application requires to be operated at 5V then use a LM1117-3.3 regulator to


convert the 5V level to 3V3 level as required by module. Also protect the RXD pin against 5V
TXD signal by inserting 1K resistor in series to module RXD pin.

If you wish to connect this module to PC’s Serial port which is at RS232 level, then you
need to add MAX232 circuit as shown above. Status LED flashes at different rates to indicate
different status like searching, config, connected.

Pin name I/O


GND GND Ground
3V3 VDD Power supply
connection
PIO2 I/O Programmable I/O
lines
PIO3 I/O Programmable I/O
lines
NRTS O UART RTS (internal
pull-up, active low)
RXD I UART RX (internal
pull down)
PCMO O Synchronous 8 kbps
data out (internal Pull
down)
USB_D+ A USB data plus
(Internal 22 ohm
serial resistor)
USB_D- A USB data minus
(Internal 22 ohm
serial resistor)
NCTS I UART CTS (internal
pull down, active
low)
PCMI I Synchronous 8 kbps
data in (internal pull-
down)
PCMC I/O Synchronous data
clock (internal pull-
down)
PCMS I/O Synchronous data
strobe (internal pull-
down)
GND GND Ground
GND GND Ground
3V3 VDD Power supply
connection
RES I Reset input (active
low)
PIO6 I/O Programmable I/O
lines
PIO7 I/O Programmable I/O
lines
PIO4 I/O Programmable I/O
lines
NCSB I Chip selection for
SPI (internal pull up,
active low)
SCLK I/O SPI Clock (internal
pull down)
MISO O SPI data output (pull
down)
MOSI I SPI data input (pull
down)
PIO5 I/O Programmable I/O
lines
This module could both act a SPP master and a SPP slave. When in master mode, the module
could search for all the working SPP slave devices around and the host could select which to
connect. When it is in slave mode, it will listen for connection request from another SPP master
device. Bluetooth UART provides the main interface to exchange data with other host system
using the RS232 protocol. An external commands set is provided for the host system to control
and configure AUBTM-20. Four signals are provide for UART function. TXD and RXD
transmit data between AUBTM-20 and the host. NRTS and NCTS provides the RS232 hardware
flow control mechanism. All UART pins are CMOS logic with signal levels of 0V to VDD.
UART is initially configured to work at 9600 bps baud rate, 8-bit, no parity and 1 stop bit. The
host could reconfigure the UART by issuing command.

Keypad (matrix)
INTRODUCTION
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits and other
symbols and usually a complete set of alphabetical letters. If it mostly contains numbers then it can also
be called a numeric keypad.

Keypads are found on many alphanumeric keyboards and on other devices such as calculators,
push-button telephones, combination locks, and digital door locks, which require mainly numeric input.
In keypad we have keys arrays in which keys can be arranged in different combinations and the matrix
keypad in which keys are arrange in a particular rows and columns.
Figure: matrix keypad on PCB board.

CONSTRUCTING A MATRIX KEYPAD


Construction of a keypad is really simple. As per the outline shown in the figure below
we have four rows and four columns. In between each overlapping row and column line there is
a key.

Figure: internal arrangement of the keypad

So keeping this outline we can construct a keypad using simple SPST Switches as shown below:

Figure: internal key connections

Now our keypad is ready, all we have to do is connect the rows and columns to a port of
microcontroller and program the controller to read the input.

SCANNING A MATRIX KEYPAD


There are many methods depending on how you connect your keypad with your
controller, but the basic logic is same. We make the columns as i/p and we drive the rows
making them o/p, this whole procedure of reading the keyboard is called scanning.

In order to detect which key is pressed from the matrix, we make row lines low one by
one and read the columns. Let’s say we first make Row1 low, and then read the columns. If any
of the key in row1 is pressed will make the corresponding column as low i.e. if second key is
pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is
pressed. This is how scanning is done.

So to scan the keypad completely, we need to make rows low one by one and read the
columns. If any of the button is pressed in a row, it will take the corresponding column to a low
state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column
1 will become low, if button 2 then column2 and so on...

SCHEMATIC

Figure: keypad arrangement


The internal arrangement of the keys in a matrix keypad can be seen in the above figure.
We can arrange them in the particular columns and particular rows. Interface of the key pad to
the micro controller is shown the figure below. Depending on the number of keys required for
the application the matrix form is prepared. So for each key has two terminals one for the ground
and one is for the port pins. Each key need port allotment.

Matrix keypad of 4*4 (four rows and four columns) for that one columns ground
terminals are connected commonly and that is given to the one port pin. Input terminal of the
keys according to the one row all are connected commonly and that is given to the one port pins.

Like for 4*4 matrix keypad one port of micro controller totally used. Four pins for the
ground purpose and four pins for the input purpose.
APPLICATION
 Key pad is used for the telephones, mobile phones
 Key pads are used at the bank locker system.
 There used the companies to enter the id numbers of the particular employee.

USES
 The keypad of a calculator contains the digits 0 through 9, from bottom upwards, together with
the four arithmetic operations.
 Keypads are also a feature of some combination locks. This type of lock is often used on doors,
such as that found at the main entrance to some offices.
 Many laptop computers have special function keys which turn part of the alphabetical keyboard
into a numerical keypad as there is insufficient space to allow a separate keypad to be built into
the laptop's chassis. Separate external plug-in keypads can be purchased.

LCD (Liquid Cristal Display):

A liquid crystal display (LCD) is a thin, flat display device made up of any number
of color or monochrome pixels arrayed in front of a light source or reflector. Each
pixel consists of a column of liquid crystal molecules suspended between two
transparent electrodes, and two polarizing filters, the axes of polarity of which are
perpendicular to each other. Without the liquid crystals between them, light
passing through one would be blocked by the other. The liquid crystal twists the
polarization of light entering one filter to allow it to pass through the other.

A program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices
attached to an controller is an LCD display. Some of the most common LCDs
connected to the contollers are 16X1, 16x2 and 20x2 displays. This means 16
characters per line by 1 line 16 characters per line by 2 lines and 20 characters per
line by 2 lines, respectively.

Many microcontroller devices use 'smart LCD' displays to output visual


information. LCD displays designed around LCD NT-C1611 module, are

Shapes and S
inexpensive, easy to use, and it is even possible to produce a readout using the
5X7 dots plus cursor of the display. They have a standard ASCII set of characters
and mathematical symbols. For an 8-bit data bus, the display requires a +5V
supply plus 10 I/O lines (RS RW D7 D6 D5 D4 D3 D2 D1 D0). For a 4-bit data bus it
only requires the supply lines plus 6 extra lines(RS RW D7 D6 D5 D4). When the
LCD display is not enabled, data lines are tri-state and they do not interfere with
the operation of the microcontroller.

Features:

(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM

(3) 80x 8 bits (80 characters).

(4) Character generator ROM

(5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM

(7) 8 different user programmed 5 7 dot-matrix patterns.

(8).Display data RAM and character generator RAM may be

Accessed by the microprocessor.

(9) Numerous instructions

(10) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,


Blink Character, Cursor Shift, Display Shift.

(11). Built-in reset circuit is triggered at power ON.

(12). Built-in oscillator.

Description Of 16x2:

This is the first interfacing example for the Parallel Port. We will start with
something simple. This example doesn't use the Bi-directional feature found on
newer ports, thus it should work with most, if no all Parallel Ports. It however
doesn't show the use of the Status Port as an input. So what are we interfacing? A
16 Character x 2 Line LCD Module to the Parallel Port. These LCD Modules are
very common these days, and are quite simple to work with, as all the logic
required to run them is on board.

Schematic Diagram:
o Above is the quite simple schematic. The LCD
panel's Enable and Register Select is connected to the Control Port.
The Control Port is an open collector / open drain output. While most
Parallel Ports have internal pull-up resistors, there are a few which
don't. Therefore by incorporating the two 10K external pull up
resistors, the circuit is more portable for a wider range of computers,
some of which may have no internal pull up resistors.
o We make no effort to place the Data bus into reverse direction.
Therefore we hard wire the R/W line of the LCD panel, into write
mode. This will cause no bus conflicts on the data lines. As a result
we cannot read back the LCD's internal Busy Flag which tells us if the
LCD has accepted and finished processing the last instruction. This
problem is overcome by inserting known delays into our program.
o The 10k Potentiometer controls the contrast of the LCD panel.
Nothing fancy here. As with all the examples, I've left the power
supply out. You can use a bench power supply set to 5v or use a
onboard +5 regulator. Remember a few de-coupling capacitors,
especially if you have trouble with the circuit working properly.

 The 2 line x 16 character LCD modules are available from a wide


range of manufacturers and should all be compatible with the
HD44780. The one I used to test this circuit was a Power tip PC-1602F
and an old Philips LTN211F-10 which was extracted from a Poker
Machine! The diagram to the right, shows the pin numbers for these
devices. When viewed from the front, the left pin is pin 14 and the
right pin is pin 1
.

16 x 2 Alphanumeric LCD Module Features:

 Intelligent, with built-in Hitachi HD44780 compatible LCD controller and


RAM providing simple interfacing
 61 x 15.8 mm viewing area
 5 x 7 dot matrix format for 2.96 x 5.56 mm characters, plus cursor line
 Can display 224 different symbols
 Low power consumption (1 mA typical)
 Powerful command set and user-produced characters
 TTL and CMOS compatible
 Connector for standard 0.1-pitch pin headers
16 x 2 Alphanumeric LCD Module Specifications:

Symbol Level Function


Pin

1 VSS - Power, GND

2 VDD - Power, 5V

3 Vo - Power, for LCD Drive

Register Select Signal


4 RS H/L H: Data Input
L: Instruction Input

H: Data Read (LCD->MPU)


5 R/W H/L
L: Data Write (MPU->LCD)

6 E H,H->L Enable

7-14 DB0-DB7 H/L Data Bus; Software selectable 4- or 8-bit mode

15 NC - NOT CONNECTED

16 NC - NOT CONNECTED

FEATURES:

• 5 x 8 dots with cursor


• Built-in controller (KS 0066 or Equivalent)

• + 5V power supply (Also available for + 3V)

• 1/16 duty cycle

• B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K (LED)

• N.V. optional for + 3V power supply

Data can be placed at any location on the LCD. For 16×1 LCD, the address
locations are:

Fig :15: Address locations for a 1x16 line LCD

Even limited to character based modules, there is still a wide variety of shapes
and sizes available. Line lengths of 8,16,20,24,32 and 40 characters are all
standard, in one, two and four line versions.

Several different LC technologies exists. “supertwist” types, for example, offer


Improved contrast and viewing angle over the older “twisted nematic” types.
Some modules are available with back lighting, so that they can be viewed in
dimly-lit conditions. The back lighting may be either “electro-luminescent”,
requiring a high voltage inverter circuit, or simple LED illumination.

Electrical Block Diagrm

Power supply for LCD driving:

Fig: 18:power supply for LCD

PIN DESCRIPTION:

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins
(two pins are extra in both for back-light LED connections).
Fig 19: pin diagram of 1x16 lines LCD

Fig 17: Pin specifications

CONTROL LINES:
EN: Line is called "Enable." This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line
is low (0) and then set the other two control lines and/or put data on the data bus.
When the other lines are completely ready, bring EN high (1) and wait for the
minimum amount of time required by the LCD datasheet (this varies from LCD to
LCD), and end by bringing it low (0) again.

RS:

Line is the "Register Select" line. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor,
etc.). When RS is high (1), the data being sent is text data which sould be displayed
on the screen. For example, to display the letter "T" on the screen you would set
RS high.

RW:

Line is the "Read/Write" control line. When RW is low (0), the information
on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("Get LCD
status") is a read command. All others are write commands, so RW will almost
always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of


operation selected by the user). In the case of an 8-bit data bus, the lines are
referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

Logic status on control lines:

• E - 0 Access to LCD disabled


- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instructions

- 1 Character
Writing data to the LCD:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Read data from data lines (if it is reading) on LCD:

1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low


Entering Text:

First, a little tip: it is manually a lot easier to enter characters and commands in
hexadecimal rather than binary (although, of course, you will need to translate
commands from binary couple of sub-miniature hexadecimal rotary switches is a
simple matter, although a little bit into hex so that you know which bits you are
setting). Replacing the d.i.l. switch pack with a of re-wiring is necessary.

SWITCHES:

The switches must be the type where On = 0, so that when they are turned to the
zero position, all four outputs are shorted to the common pin, and in position “F”,
all four outputs are open circuit.

All the available characters that are built into the module are shown in Table 3.
Studying the table, you will see that codes associated with the characters are
quoted in binary and hexadecimal, most significant bits (“left-hand” four bits)
across the top, and least significant bits (“right-hand” four bits) down the left.

Most of the characters conform to the ASCII standard, although the Japanese and
Greek characters (and a few other things) are obvious exceptions. Since these
intelligent modules were designed in the “Land of the Rising Sun,” it seems only
fair that their Katakana phonetic symbols should also be incorporated. The more
extensive Kanji character set, which the Japanese share with the Chinese,
consisting of several thousand different characters, is not included!
Using the switches, of whatever type, and referring to Table 3, enter a few
characters onto the display, both letters and numbers. The RS switch (S10) must
be “up” (logic 1) when sending the characters, and switch E (S9) must be pressed
for each of them. Thus the operational order is: set RS high, enter character,
trigger E, leave RS high, enter another character, trigger E, and so on.

The first 16 codes in Table 3, 00000000 to 00001111, ($00 to $0F) refer to the
CGRAM. This is the Character Generator RAM (random access memory), which can
be used to hold user-defined graphics characters. This is where these modules
really start to show their potential,

offering such capabilities as bar graphs, flashing symbols, even animated


characters. Before the user-defined characters are set up, these codes will just
bring up strange looking symbols.

Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank
characters. ASCII codes “proper” start at 00100000 ($20) and end with 01111111
($7F). Codes 10000000 to 10011111 ($80 to $9F) are not used, and 10100000 to
11011111 ($A0 to $DF) are the Japanese characters.
Fig 20: character details in LCD

Initialization by Instructions:
Fig 21: flow chart of lcd

If the power conditions for the normal operation of the internal reset circuit are
not satisfied, then executing a series of instructions must initialize LCD unit. The
procedure for this initialization process is as above show.
FLOWCHART:

Copy Data in to Accumulator

Wait
Yes
Is LCD Free
No

Set RS Bit

Enable LCD

Send Data

Disable LCD

Is Data
Count Zero
No

STOP
1

Copy Data in to Accumulator

Wait
Yes
Is LCD Free
No

Set RS Bit

Enable LCD

Send Data

Disable LCD

Is Data
Count Zero
No

STOP

Code:

// include the library code:

#include <LiquidCrystal_I2C.h>

#include <SoftwareSerial.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal_I2C lcd(0x27,16,2);

SoftwareSerial ser(2,3);

// define phase control pins

int phase[3] = {8, 9, 10};

int buzzer=7;

//*********************************************************

int distance(int inputVoltage) {


if (inputVoltage >= 850 && inputVoltage < 890) {

return 6;

else if (inputVoltage >= 750 && inputVoltage < 850) {

return 4;

else if (inputVoltage >= 600 && inputVoltage < 750) {

return 2;

else return 0 ;

//*********************************************************

void setup() {

pinMode(buzzer,OUTPUT);

ser.begin(9600);

lcd.begin();

lcd.backlight();

digitalWrite(buzzer,LOW);

// set pin mode for phase relays

for (int j = 0; j < 3; j++) {


pinMode(phase[j], OUTPUT);

void loop()

digitalWrite(phase[0], HIGH);

delay(1000);

int dist1 = distance(analogRead(A0));

if (dist1 == 0) {

digitalWrite(buzzer,LOW);

lcd.setCursor(0, 0);

lcd.print("R: ");

lcd.setCursor(3, 0);

lcd.print("NF ");

ser.println("R :NO FAULT");

else {

digitalWrite(buzzer,HIGH);

lcd.setCursor(0, 0);

lcd.print("R: ");

lcd.setCursor(3, 0);
lcd.print(dist1);

lcd.setCursor(4, 0);

lcd.print(" KM");

ser.print("R :");

ser.print(dist1);

ser.println("KM");

digitalWrite(phase[0], LOW);

//================================================

digitalWrite(phase[1], HIGH);

delay(500);

int dist2 = distance(analogRead(A0));

if (dist2 == 0) {

digitalWrite(buzzer,LOW);

lcd.setCursor(8, 0);

lcd.print("Y: ");

lcd.setCursor(11, 0);

lcd.print("NF ");

ser.println("Y :NO FAULT");

else {

digitalWrite(buzzer,HIGH);

lcd.setCursor(8, 0);

lcd.print("Y: ");

lcd.setCursor(11, 0);
lcd.print(dist2);

lcd.setCursor(12, 0);

lcd.print(" KM");

ser.print("Y :");

ser.print(dist2);

ser.println("KM");

digitalWrite(phase[1], LOW);

//==================================================

digitalWrite(phase[2], HIGH);

delay(500);

int dist3 = distance(analogRead(A0));

if (dist3 == 0) {

digitalWrite(buzzer,LOW);

lcd.setCursor(0, 1);

lcd.print("B: ");

lcd.setCursor(3, 1);

lcd.print("NF ");

ser.println("B :NO FAULT");

else {

digitalWrite(buzzer,HIGH);

lcd.setCursor(0, 1);

lcd.print("B: ");

lcd.setCursor(3, 1);
lcd.print(dist3);

lcd.setCursor(4, 1);

lcd.print(" KM");

ser.print("B :");

ser.print(dist3);

ser.println("KM");

digitalWrite(phase[2], LOW);

ser.println();

CONCLUSION:

APPLICATIONS:

LIMITATIONS:

FUTURE SCOPE:

BIBLOGRAPHY:

 The 8051 Micro controller and Embedded Systems


o MuhammadAliMa
zidi
o JaniceGillispieMa
zidi
 The8051MicrocontrollerArchitecture,Programming&
Applications
o KennethJ.Ayala
 Fundamentals of Micro processors and Micro computers
o B. Ram
 Electronic Components
 D.V.Prasad

References on the Web:

 www.national.com
 www.atmel.com

 www.microsoftsearch.com
 www.geocities.com

You might also like