Arduino Cable Fault Detection Guide
Arduino Cable Fault Detection Guide
Bachelor of Technology
in
Submitted by
K.JAGAN - 14361A0201
R.PAVAN - 14361A0208
G.PRANAY - 14361A0211
Y.SHEKAR - 14361A0215
G.C.ARUN - 15365A0205
Mr.Mahesh
(Asst.prof.)
June 2018
Phones: 08542-275313,275587
Bachelor of Technology
in
Submitted by
K.JAGAN - 14361A0201
R.PAVAN - 14361A0208
G.PRANAY - 14361A0211
Y.SHEKAR - 14361A0215
G.C.ARUN - 15365A0205
Mr.Mahesh
(Asst.prof.)
June 2018
Phones: 08542-275313,275587
Phones: 08542-275313,275587
CERTIFICATE
K.JAGAN(14361A0201),R.PAVAN(14361A0208),G.PRANAY(14361A211),
Y.SHEKAR(14361A0215),G.C.ARUN(15365A0205)Bachelor of Engineering in Electronics &
Communication Engineering of the Jawaharlal Nehru Technological University, Hyderabad
during the year 2017-18. It is certified that all corrections / suggestions indicated for Internal
assessment have been incorporated in the Report deposited in the department library. The
project report has been approved as it satisfies the academic requirements in respect of
Project work prescribed for the said Degree.
External Viva
1.
2.
ACKNOWLEDGEMENT
There are many people instrumental for the successful completion of this dissertation work.
First, I owe my parents my deepest gratitude, as nothing would have been really possible
without their constant support and encouragement.
The heights reached by the great men did not come in a single fight, but they, on their way
stepped on successes crossing all the stones of failures. Accordingly I now take up this
privilege of remembering with gratitude those people behind the success of my project,
which really pushed me across the stones of failure.
As Noble Laureate Sir Rabindranath Tagore said, “A good teacher explains, a better teacher
demonstrates but the best teacher inspires”, this is how my guide Dr.Susant Kumar Panigrahi
guided me through my project work. I would like to thank him for permitting me to
undertake the dissertation work under his able guidance, and Prof. for his / her very useful
suggestions, support and guidance. They have been pillars of strength, and their presence
has inspired me to do all the better and there aren’t enough words to describe it.
I would be failing in my duty if I don’t thank our beloved H.O.D Dr.Susant Kumar Panigrahi and
our Principal, Dr. LinganGouda Kulakarni for their constant encouragement and resolve.
I also take this opportunity in expressing my gratitude and respect to all those who have
directly and indirectly helped and encouraged me during the course of this project.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
1. ABSTRACT 10
4. HARDWARE REQUIREMENTS
4.1 TRANSFORMERS 17
4.3 RECTIFIER
4.4 FILTER
22
4.8 ULN2003
4.9 RELAYS
4.10 1N4007
4.11 RESISTORS
4.12 CAPACITORS
5. SOFTWARE REQUIREMENTS 56
6. SCHEMATIC DIAGRAM 66
6.1 DESCRIPTION 67
7. LAYOUT DIAGRAM 71
8. BILL OF MATERIALS 72
11. RESULTS 69
12. CONCLUSION 93
13. BIBLIOGRAPHY 94
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
OF VOLTAGE REGULATOR 22
6. SCHEMATIC
7. LAYOUT
1. ABSTRACT
The project uses the standard concept of Ohms law i.e., when a low DC voltage is applied at the
feeder end through a series resistor (Cable lines), then current would vary depending upon the
location of fault in the cable. In case there is a short circuit (Line to Ground), the voltage across
series resistors changes accordingly, which is then fed to inbuilt ADC of Arduino board to
The project is assembled with a set of resistors representing cable length in KM’s and fault
creation is made by a set of switches at every known KM to cross check the accuracy of the
same. The fault occurring at a particular distance and the respective phase is displayed on a LCD
CLASSIFICATION
Real Time Systems.
A right answer after the dead line is a wrong answer.
11
4. HARDWARE REQUIREMENTS
1. TRANSFORMER (230 – 12 V AC)
3. RECTIFIER
4. FILTER
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
5. MICROCONTROLLER (AT89S52/AT89C51)
7. ADC0804
8. ULN2003
9. RELAYS
10. IN4007
11. RESISTORS
12. CAPACITORS
4.1 TRANSFORMER
Transformers convert AC electricity from one voltage to another with a little loss of power.
Step-up transformers increase voltage, step-down transformers reduce voltage. Most power
supplies use a step-down transformer to reduce the dangerously high voltage to a safer low
voltage.
The input coil is called the primary and the output coil is called the secondary. There is no
electrical connection between the two coils; instead they are linked by an alternating magnetic
field created in the soft-iron core of the transformer. The two lines in the middle of the circuit
symbol represent the core. Transformers waste very little power so the power out is (almost)
equal to the power in. Note that as voltage is stepped down and current is stepped up.
13
Where,
Vp = primary (input) voltage.
Vs = secondary (output) voltage
Np = number of turns on primary coil
Ns = number of turns on secondary coil
Ip = primary (input) current
Is = secondary (output) current.
If the secondary coil is attached to a load that allows current to flow, electrical power is
transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly
efficient; all the incoming energy is transformed from the primary circuit to the magnetic field
and into the secondary circuit. If this condition is met, the incoming electric power must equal
the outgoing power:
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
If the voltage is increased, then the current is decreased by the same factor. The impedance in
one circuit is transformed by the square of the turns ratio. For example, if an impedance Zs is
attached across the terminals of the secondary coil, it appears to the primary circuit to have an
impedance of (Np/Ns)2Zs. This relationship is reciprocal, so that the impedance Zp of the primary
circuit appears to the secondary to be (Ns/Np)2Zp.
15
Description
The LM78XX/LM78XXA series of three-terminal positive regulators are available in the
TO-220/D-PAK package and with several fixed output voltages, making them useful in a Wide
range of applications. Each type employs internal current limiting, thermal shutdown and safe
operating area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1A output Current. Although designed primarily as fixed voltage
regulators, these devices can be used with external components to obtain adjustable voltages and
currents.
4.3 RECTIFIER
A rectifier is an electrical device that converts alternating current (AC), which periodically
reverses direction, to direct current (DC), current that flows in only one direction, a process
known as rectification. Rectifiers have many uses including as components of power supplies
and as detectors of radio signals. Rectifiers may be made of solid state diodes, vacuum tube
diodes, mercury arc valves, and other components. The output from the transformer is fed to the
rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave
rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full
17
wave rectification. In positive half cycle only two diodes( 1 set of parallel diodes) will conduct,
in negative half cycle remaining two diodes will conduct and they will conduct only in forward
bias only.
4.4 FILTER
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and
smoothens the D.C. Output received from this filter is constant until the mains voltage and load
is maintained constant. However, if either of the two is varied, D.C. voltage received at this point
changes. Therefore a regulator is applied at the output stage.
The simple capacitor filter is the most basic type of power supply filter. The use of this filter is
very limited. It is sometimes used on extremely high-voltage, low-current power supplies for
cathode-ray and similar electron tubes that require very little load current from the supply. This
filter is also used in circuits where the power-supply ripple frequency is not critical and can be
relatively high. Below figure can show how the capacitor changes and discharges.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
4.5 LCD
Description:
This is the example for the Parallel Port. This example doesn't use the Bi-directional feature
found on newer ports, thus it should work with most, if not all Parallel Ports. It however doesn't
show the use of the Status Port as an input for 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 running them is on board.
Pros:
No geometric distortion
19
LCD Background:
Frequently, an 8051 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
8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and
20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines,
respectively.
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The
user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit
data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for
the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control
lines plus the 8 lines for the data bus).
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
4.8 ULN2003
RELAY DRIVER:
ULN2003 is a high voltage and high current Darlington transistor array.
DESCRIPTION:
The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It
consists of seven NPN Darlington pairs that feature high-voltage outputs with common-cathode
Clamp diode for switching inductive loads. The collector-current rating of a single Darlington
pair is 500mA. The Darlington pairs may be paralleled for higher current capability.
Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED gas
discharge), line drivers, and logic buffers.
The ULN2003 has a 2.7kW series base resistor for each Darlington pair for operation directly
with TTL or 5V CMOS devices.
21
FEATURES:
Pin no.:16
Case Style:DIP-16
Base Number:2003
Device Marking:ULN2003A
IC Generic Number:2003
23
PIN Diagram:
Darlington pairs are back to back connection of two transistors with some source resistors and
when they are arranged as shown in the circuit they are used to amplify weak signals. The
amount by which the weak signal is amplified is called the ‘GAIN’. .
FEATURES OF DRIVER:
Seven Darlington’s per package
Simplified layout
25
Figure shows the Darlington pair connection of transistor. The circuit above is a ‘Darlington
Pair’ driver. The first transistor’s emitter feeds into the second transistor’s base and as a result
the input signal is amplified by the time it reaches the output. The important point to remember
is that the Darlington Pair is made up of two transistors
FEATURES
* 500mA rated collector current (Single output).
* High-voltage outputs: 50V.
* Inputs compatible with various types of logic.
* Relay driver application.
4.9 RELAY
A relay is an electrically operated switch. Many relays use an electromagnet to operate a
switching mechanism mechanically, but other operating principles are also used. Relays are used
where it is necessary to control a circuit by a low-power signal (with complete electrical
isolation between control and controlled circuits), or where several circuits must be controlled by
one signal.
A relay is an electrically operated switch. Current flowing through the coil of the relay creates a
magnetic field which attracts a lever and changes the switch contacts.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
Relays allow one circuit to switch a second circuit which can be completely separate from the
first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains
circuit. There is no electrical connection inside the relay between the two circuits; the link is
magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be
as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot
provide this current and a transistor is usually used to amplify the small IC current to the larger
value required for the relay coil. The maximum output current for the popular 555 timer IC is
200mA so these devices can supply relay coils directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for
example relays with 4 sets of changeover contacts are readily available. For further information
about switch contacts and the terms used to describe them please see the page on switches.
Applications of relays
Relays are used to and for:
27
4.10 IN4007
Diodes are used to convert AC into DC these are used as half wave rectifier or full
wave rectifier. Three points must he kept in mind while using any type of diode
1.Maximum forward current capacity
2.Maximum reverse voltage capacity
3.Maximum forward voltage capacity
PN JUNCTION OPERATION
Now that you are familiar with P- and N-type materials, how these materials are joined together
to form a diode, and the function of the diode, let us continue our discussion with the operation
of the PN junction. But before we can understand how the PN junction works, we must first
consider current flow in the materials that make up the junction and what happens initially
within the junction when these two materials are joined together.
29
the majority current carriers in the N-type material (electrons) are repelled by the negative side of
the battery and move through the crystal toward the positive side of the battery.
Current flow through the P-type material is illustrated. Conduction in the P material is by
positive holes, instead of negative electrons. A hole moves from the positive terminal of the P
material to the negative terminal. Electrons from the external circuit enter the negative terminal
of the material and fill holes in the vicinity of this terminal. At the positive terminal, electrons
are removed from the covalent bonds, thus creating new holes. This process continues as the
steady stream of holes (hole current) moves toward the negative terminal
4.11 RESISTORS
A resistor is a two-terminal electronic component designed to oppose an electric current by
producing a voltage drop between its terminals in proportion to the current, that is, in accordance
with Ohm's law:
V = IR
Resistors are used as part of electrical networks and electronic circuits. They are extremely
commonplace in most electronic equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as
nickel/chrome).
The primary characteristics of resistors are their resistance and the power they can dissipate.
Other characteristics include temperature coefficient, noise, and inductance. Less well-known is
critical resistance, the value below which power dissipation limits the maximum permitted
current flow, and above which the limit is applied voltage. Critical resistance depends upon the
materials constituting the resistor as well as its physical dimensions; it's determined by design.
Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits. Size,
and position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
Resistors are common elements of electrical networks and electronic circuits and are ubiquitous
in most electronic equipment. Practical resistors can be made of various compounds and films,
as well as resistance wire (wire made of a high-resistivity alloy, such as nickel-chrome).
Resistors are also implemented within integrated circuits, particularly analog devices, and can
also be integrated into hybrid and printed circuits.
The electrical functionality of a resistor is specified by its resistance: common commercial
resistors are manufactured over a range of more than 9 orders of magnitude. When specifying
that resistance in an electronic design, the required precision of the resistance may require
attention to the manufacturing tolerance of the chosen resistor, according to its specific
application. The temperature coefficient of the resistance may also be of concern in some
precision applications. Practical resistors are also specified as having a maximum power rating
31
which must exceed the anticipated power dissipation of that resistor in a particular circuit: this is
mainly of concern in power electronics applications. Resistors with higher power ratings are
physically larger and may require heat sinking. In a high voltage circuit, attention must
sometimes be paid to the rated maximum working voltage of the resistor.
Units
The ohm (symbol: Ω) is the SI unit of electrical resistance, named after Georg Simon Ohm. An
ohm is equivalent to a volt per ampere. Since resistors are specified and manufactured over a
very large range of values, the derived units of milliohm (1 mΩ = 10−3 Ω), kilohm (1 kΩ = 103
Ω), and megohm (1 MΩ = 106 Ω) are also in common usage.
The reciprocal of resistance R is called conductance G = 1/R and is measured in Siemens (SI
−1
unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of an ohm: S = Ω .
Although the concept of conductance is often used in circuit analysis, practical resistors are
always specified in terms of their resistance (ohms) rather than conductance.
4.12 CAPACITORS
The properties of capacitors in a circuit may determine the resonant frequency and quality factor
of a resonant circuit, power dissipation and operating frequency in a digital logic circuit, energy
capacity in a high-power system, and many other important aspects.
A capacitor (formerly known as condenser) is a device for storing electric charge. The forms of
practical capacitors vary widely, but all contain at least two conductors separated by a
non-conductor. Capacitors used as parts of electrical systems, for example, consist of metal foils
separated by a layer of insulating film.
Capacitors are widely used in electronic circuits for blocking direct current while allowing
alternating current to pass, in filter networks, for smoothing the output of power supplies, in the
resonant circuits that tune radios to particular frequencies and for many other purposes.
A capacitor is a passive electronic component consisting of a pair of conductors separated by a
dielectric (insulator). When there is a potential difference (voltage) across the conductors, a
static electric field develops in the dielectric that stores energy and produces a mechanical force
33
terms, the dielectric is just an electrical insulator. Examples of dielectric mediums are glass, air,
paper, vacuum, and even a semiconductor depletion region chemically identical to the
conductors. A capacitor is assumed to be self-contained and isolated, with no net electric charge
and no influence from any external electric field. The conductors thus hold equal and opposite
charges on their facing surfaces, and the dielectric develops an electric field. In SI units, a
capacitance of one farad means that one coulomb of charge on each conductor causes a voltage
of one volt across the device.
The capacitor is a reasonably general model for electric fields within electric circuits. An ideal
capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge ±Q
on each conductor to the voltage V between them:
Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to vary. In
this case, capacitance is defined in terms of incremental changes:
Energy storage
Work must be done by an external influence to "move" charge between the conductors in a
capacitor. When the external influence is removed the charge separation persists in the electric
field and energy is stored to be released when the charge is allowed to return to its equilibrium
position. The work done in establishing the electric field, and hence the amount of energy stored,
is given by:
Current-voltage relation
The current i(t) through any component in an electric circuit is defined as the rate of flow of a
charge q(t) passing through it, but actual charges, electrons, cannot pass through the dielectric
layer of a capacitor, rather an electron accumulates on the negative plate for each one that leaves
35
the positive plate, resulting in an electron depletion and consequent positive charge on one
electrode that is equal and opposite to the accumulated negative charge on the other. Thus the
charge on the electrodes is equal to the integral of the current as well as proportional to the
voltage as discussed above. As with any antiderivative, a constant of integration is added to
represent the initial voltage v (t0). This is the integral form of the capacitor equation,
.
Taking the derivative of this, and multiplying by C, yields the derivative form,
.
The dual of the capacitor is the inductor, which stores energy in the magnetic field rather than
the electric field. Its current-voltage relation is obtained by exchanging current and voltage in the
capacitor equations and replacing C with the inductance L.
5. SOFTWARE REQUIREMENTS
5.1 ARDUINO PROGRAMMING LANGUAGE
The Arduino microcontroller is an easy to use yet powerful single board computer that has
gained considerable traction in the hobby and professional market . The Arduino is
open-source, which means hardware is reasonably priced and development software .
An important feature of the Arduino is that you can create a control program on the host PC,
download it to the Arduino and it will run automatically. Remove the USB cable connection to
the PC, and the program will still run from the top each time you push the reset button. Remove
the battery and put the Arduino board in a closet for six months. When you reconnect the battery,
the last program you stored will run. This means that you connect the board to the host PC to
develop and debug your program, but once that is done, you no longer need the PC to run the
program.
37
http://arduino.cc/en/Guide/HomePage. Go all the way through the steps to where you see the
pin 13 LED blinking. This is the indication that you have all software and drivers successfully
installed and can start exploring with your own programs.
Congratulations; you have created and run your first Arduino program.Push the Arduino reset
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
1.6 Troubleshooting
If there is a syntax error in the program caused by a mistake in typing, an error message will
appear in the bottom of the program window. Generally, staring at the error will reveal the
problem. If you continue to have problems, try these ideas
Run the Arduino program again
Check that the USB cable is secure at both ends.
Reboot your PC because sometimes the serial port can lock up
If a “Serial port…already in use” error appears when uploading
Ask a friend for help
2 Flashing an LED
Light emitting diodes (LED's) are handy for checking out what the Arduino can do.. For this
task, you need an LED, a 330 ohm resistor, and some short .
Connect the notched or flat side of the LED (the notch or flat is on the rim that surrounds the
LED base; look carefully because it can be hard to find) to the Gnd bus and the other side to a
39
free hole in main area of the breadboard Place the resistor so that one end is in the same column
as the LED and the other end is in a free column. From that column, connect a wire to digital pin
2 on the Arduino board. Your setup will look something like this
PIN 2 330
Gnd
Did the LED light up for one second? Push the Arduino reset button to run the program again.
The pinMode command sets the LED pin to be an output. The first digitalWrite command says
to set pin 2 of the Arduino to HIGH, or +5 volts. This sends current from the pin, through the
resistor, through the LED (which lights it) and to ground. The delay(500) command waits for
500 msec. The second digitalWrite command sets pin 2 to LOW or 0 V stopping the current
thereby turning the LED off. Code within the brackets defining the loop() function is repeated
forever, which is why the LED blinks.
This exercise shows how the Arduino can control the outside world. With proper interface
circuitry the same code can turn on and off motors, relays, solenoids, electromagnets,
pneumatic valves or any other on-off type device.
3.Reading switch
Open the Serial Monitor window. When the switch is open, you should see a train of 1's on the
screen. When closed, the 1's change to 0's. On the hardware side, when the switch is open, no
current flows through the resistor. When no current flows through a resistor, there is no voltage
drop across the resistor, which means the voltage on each side is the same. In your circuit, when
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
the switch is open, pin 3 is at 5 volts which the computer reads as a 1 state. When the switch is
closed, pin 3 is directly connected to ground, which is at 0 volts. The computer reads this as a 0
state.
Now try this program which is an example of how you can have the computer sit and wait for a
sensor to change state.
4.Controlling a Small DC Motor
The Arduino can control a small DC motor through a transistor switch. You will need a TIP120
transistor, a 1K resistor a 9V battery with battery snap and a motor.
pin 2 can be any digital I/O pin on your Arduino. Connect the minus of the battery to the emitter
of the transistor (E pin) and also connect the emitter of the transistor to Gnd on the Arduino
board.
To check if things are working, take a jumper wire and short the collector to the emitter pins of
the transistor. The motor should turn on. Next, disconnect the 1K resistor from pin 2 and jumper
it to +5V. The motor should turn on. Put the resistor back into pin 2 and run the following test
program:
5. Arduino Hardware
41
The power of the Arduino is not its ability to crunch code, but rather its ability to interact with the
outside world through its input-output (I/O) pins. The Arduino has 14 digital I/O pins labeled 0 to 13
that can be used to turn motors and lights on and off and read the state of switches.
Each digital pin can sink or source about 40 mA of current. This is more than adequate for
interfacing to most devices, but does mean that interface circuits are needed to control devices
other than simple LED's. In other words, you cannot run a motor directly using the current
available from an Arduino pin, but rather must have the pin drive an interface circuit that in turn
drives the motor. A later section of this document shows how to interface to a small motor.
To interact with the outside world, the program sets digital pins to a high or low value using C
code instructions, which corresponds to +5 V or 0 V at the pin. The pin is connected to external
interface electronics and then to the device being switched on and off. The sequence of events is
shown in this figure.
+5V
0V
Board pin
set to +5V/0V
+12 V
Interface
electronics use
signal voltages and
1K
PIN 4
power supply to TIP120
switch motor
on/off
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
To determine the state of switches and other sensors, the Arduino is able to read the voltage
value applied to its pins as a binary number. The interface circuitry translates the sensor signal
into a 0 or +5 V signal applied to the digital I/O pin. Through a program command, the Ardiomp
interrogates the state of the pin. If the pin is at 0 V, the program will read it as a 0 or LOW. If it
is at +5 V, the program will read it as a 1 or HIGH. If more than +5 V is applied, you may blow
out your board, so be careful. The sequence of events to read a pin is shown in this figure.
The set of valid instructions comes from the particular programming language used. There are
many languages, including C, C++, Java, Ada, Lisp, Fortran, Basic, Pascal, Perl, and a thousand
others. The Arduino uses a simplified variation of the C programming language.
For any programming language, the instructions must be entered in a specific syntax in order for
the computer to interpret them properly. Typically, the interpretation is a two step process. A
compiler takes the language specific text you enter for the program and converts it into a
machine readable form that is downloaded into the processor. When the program executes, the
processor executes the machine code line by line.
All sequential programming languages have four categories of instructions. First are operation
43
commands that evaluate an expression, perform arithmetic, toggle states of I/O lines, and many
other operations. Second are jump commands that cause the program to jump immediately to
another part of the program that is tagged with a label. Jumps are one way to break out of the
normal line-by-line processing mode. For example, if you want a program to repeat over and
over without stopping, have the last line of the program be a jump command that takes the
program back to its first line. Third are branch commands that evaluate a condition and jump if
the condition is true. For example, you might want to jump only if a number is greater than zero.
Or, you might want to jump only if the state of an i/o line is low. Fourth are loop commands that
repeat a section of code a specified number of times. For example, with a loop you can have a
light flash on and off exactly six times.
Most programming languages contain a relatively small number of commands. The complexity
of computers comes from combining and repeating the instructions several million times a
second.
The computer will execute this line by line. The art of programming is simply a matter of
translating your intent into a sequence of instructions that match.
Here is an example of a for loop command followed by a branch command that uses an IF
statement
The commands inside the loop will be repeated six times. Following this, if the value of
the variable j is greater than 4, the program will skip to the instruction tagged with the
specified label, and if not, the line following the if statement will be executed.
In addition to the basic commands, languages have the ability to call functions which are
independent sections of code that perform a specific task. Functions are a way of calling a
section of code from a number of different places in the program and then returning from that
section to the line that follows the calling line. Here's an example
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
The function apples is everything between the set of braces that follows “apples()”. When
the function completes, the program jumps back to the line following the line that called the
function.
b7 b6 b5 b4 b3 b2 b1 b0
Thus, in the binary number 011, bits 0 and 1 are 1 while bit 2 is 0. In the binary number
1000001, bits 0 and 7 are 1 and the rest are zero.
Here are a few binary to decimal conversions for byte size numbers.
Binary Decimal
00000011 3
00000111 7
11111111 255
In a computer, variables are used to store numbers. A bit variable can take on two values, 0 and
1, and is typically used as a true/false flag in a program. A byte variable can take on integer
45
values 0-255 decimal while a 16-bit word variable can take on integer values 0-65,535. Variables
can be either signed (positive and negative values) or unsigned (positive only).
Constants are fixed numbers and can be entered as ordinary decimal numbers (integer only) or
in hexadecimal (base 16) or in binary (base 2) as shown in the table below
Labels are used to reference locations in your program. They can be any combination of letters,
numbers and underscore (_), but the first character must be a letter. When used to mark a
location, follow the label with a colon. When referring to an address label in an instruction line,
don't use the colon. Here's an example
Use labels sparingly as they can actually make a program difficult to follow and
Here is the same using a symbol to define "LED"
void setup()
{
pinMode(LED,OUTPUT);
void loop()
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
Note how the use of symbols reduces the need for comments. Symbols are extremely useful to
define for devices connected to pins because if you have to change the pin that the device
connects to, you only have to change the single symbol definition rather than going through the
whole program looking for references to that pin.
47
startup() function are executed once when the program begins and are used to initialize. Use it to
set directions of pins or to initialize variables. The instructions placed in loop are executed
repeatedly and form the main tasks of the program. Therefore every program has this structure
The program performs no function, but is useful for clearing out any old program. Note that the
compiler does not care about line returns, which is why this program works if typed all on one
line.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
7.4 Math
The Arduino can do standard mathematical operations. While floating point (e.g. 23.2) numbers
are allowed if declared as floats, operations on floats are very slow so integer variables and
integer math is recommended. If you have byte variables, no number, nor the result of any math
operation can fall outside the range of 0 to 255. You can divide numbers, but the result will be
truncated (not rounded) to the nearest integer. Thus in integer arithmetic, 17/3 = 5, and not 5.666
and not 6. Math operations are performed strictly in a left-to-right order. You can add parenthesis
to group operations.
The table below shows some of the valid math operators. Full details of their use can be found
in the Arduino Language Reference.
Symbol Description
+ addition
- subtraction
* multiplication
/ division
% modulus (division remainder)
<< left bit shift
>> right bit shift
& bitwise AND
| bitwise OR
This section covers the small set of commands you need to make the Arduino do something
useful. These commands appear in order of priority. You can make a great machine using only
digital read, digital write and delay commands. Learning all the commands here will take you
to the next level.
PIN MODE
This command, which goes in the setup() function, is used to set the direction of a digital I/O
pin. Set the pin to OUTPUT if the pin is driving and LED, motor or other device. Set the pin to
INPUT if the pin is reading a switch or other sensor. On power up or reset, all pins default to
inputs. This example sets pin 2 to an output and pin 3 to an input.
49
Serial.print
The Serial.print command lets you see what's going on inside te Arduino from your computer.
For example, you can see the result of a math operation to determine if you are getting the right
number. Or, you can see the state of a digital input pin to see if the Arduino is a sensor or switch
properly. When your interface circuits or program does not seem to be working, use the
Serial.print command to shed a little light on the situation. For this command to show anything,
you need to have the Arduino connected to the host computer with the USB cable.
You may have noticed when trying this out that if you leave one of the pins disconnected, its
state follows the other. This is because a pin left floating has an undefined value and will wander
from high to low. So, use two jumper wires when trying out this example.
Here's one that checks the value of a variable after an addition. Because the calculation is done
just once, all the code is in the setup() function. The Serial.flush()
int i,j,k;
void setup()
{
Serial.begin(9600);
i=21;
j=20;
k=i+j;
Serial.flush();
Serial.print(k);
}
void loop() {}
DIGITAL WRITE
This command sets an I/O pin high (+5V) or low (0V) and is the workhorse for commanding the
outside world of lights, motors, and anything else interfaced to your board. Use the pinMode()
command in the setup() function to set the pin to an output.
DELAY
Delay pauses the program for a specified number of milliseconds. Since most interactions with
the world involve timing, this is an essential instruction. The delay can be for 0 to 4,294,967,295
m sec. This code snippet turn on pin 2 for 1 second.
void setup()
{
Serial.begin(9600);
void loop()
{
if (digitalRead(3) == LOW) {
Serial.println("Somebody closed the switch!");
}
}
The if line reads the state of pin 3. If it is high, which it will be for this circuit when the switch is
open, the code jumps over the Serial.println command and will repeat the loop. When you close
51
the switch, 0V is applied to pin 3 and its state is now LOW. This means the if condition is true so
this time around the code between the braces is executed and the message is printed
if (condition) {
//commands
If the condition is true, the program will execute the commands between the braces. If the
condition is not true, the program will skip to the statement following the braces.
The condition compares one thing to another. In the example above, the state of pin 1 was compared
to LOW with ==, the equality condition. Other conditional operators are != (not equal to), > (greater
than), < (less than), >= (greater than or equal to), and <= (less than or equal to).
You can have the program branch depending on the value of a variable. For example, this
program will print the value of i only when it is less than 30.
int i;
void setup()
{
Serial.begin(9600);
i=0;
}
void loop()
{
i=i+1;
if (i<30) {
Serial.println(i);
}
}
The for statement is used to create program loops. Loops are useful when you want a chunk of
code to be repeated a specified number of times. A variable is used to count the number of times
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
the code is repeated. Here is an example that flashes an LED attached to pin 2 five times
int i;
void setup()
{
pinMode(2,OUTPUT);
for (i=0;i<5;i++) {
digitalWrite(2,HIGH);
delay(250);
digitalWrite(2,LOW);
delay(250);
}
void loop() {}
The variable i is the loop counter. The for() statement has three parts: the initialization, the check
and the increment. Variable i is initialized to zero. The check is to see if i is less then 5. If so, the
commands between the braces are executed. If not, those commands are skipped. After the
check, i is incremented by 1 (the i++ command). While the for statement could read for
(i=1;i==5;i++), it is convention to start the counter variable at zero and use less than for the
condition check.
You can have the loop counter increment by two or by three or by any increment you want. For
example, try this code fragment.
int i;
void setup()
53
Serial.begin(9600);
for (i=0;i<15;i=i+3) {
Serial.println(i);
}
}
void loop() {}
Loops can be nested within loops. This example will flash the LED 10 times because for each of
the five outer loops counted by i, the program goes twice through the inner loop counted by j.
int i,j;
void setup()
pinMode(2,OUTPUT);
for (i=0;i<5;i++) {
for(j=0;j<2;j++) {
digitalWrite(2,HIGH);
delay(250);
digitalWrite(2,LOW);
delay(250);
}
}
WHILE
The while statement is another branch command that does continuous looping. If the condition
following the while is true, the commands within the braces are executed continuously. Here is
an example that continuously reads a switch on pin 3, and then when the switch is pressed, the
condition is no longer true so the code escapes the while command and prints.
void setup()
Serial.begin(9600);
while(digitalRead(3) == HIGH) {
}
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
}
void loop() {}
GOTO
The goto statement commands the computer to jump immediately to another part of the program
marked by an address label. The goto should be used sparingly because it makes the program
hard to follow, but is handy for breaking out of nested loops or other complex control structures.
Here is an example
void setup()
{
Serial.begin(9600);
while(true) {
if (digitalRead(3) == LOW) {
goto wrapup;
}
}
wrapup:
The while(true) statement runs continuously, checking the state of pin 3 each time. When pin 3 is
low (pressed), the if condition is true and the goto statement executed, breaking out of the while
loop.
55
functions
Functions are a powerful programming feature that are used when you want to set up an action
that can be called from several places in the program. For example, let's say you wanted an LED
connected to pin 2 to flash 3 times as an alert, but that you needed to execute the alert at three
different places in the program. One solution would be to type in the flashing code at the three
separate program locations. This uses up precious code space and also means that if you change
the flash function, for example changing from 3 flashes to 4, you have to change the code in
three places. A better solution is to write the flash function as a subroutine and to call it from the
main body of the code.
int i;
void setup()
{
pinMode(2,OUTPUT);
Serial.begin(9600);
Serial.println("Welcome to my program");
delay(1000);
flasher();
}
void loop() {}
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
void flasher()
for(i=0;i<3;i++) {
digitalWrite(2,HIGH);
delay(250);
digitalWrite(2,LOW);
delay(250);
}
}
Several things should be noted here. The function flasher() is defined outside the setup() and
loop() functions. When the main program encounters a flasher(); command, the program
immediately jumps to the function and starts executing the code there. When it reaches the end
of the function, the program returns to execute the command that immediately follows the
flasher(); command. It is this feature that allows you to call the subroutine from several different
places in the code. Parameters can be passed to and returned from functions, but that feature is
for the advanced programmer.
This concludes the section on basic program commands. You can write some awesome programs
using just what was described here. There is much more that the Arduino can do and you are
urged to read through the complete Arduino Language Reference page on-line
9 Coding Style
Style refers to your own particular style for creating code and includes layout, conventions for
using case, headers, and use of comments. All code must follow correct syntax, but there are
57
many different styles you can use. Here are some suggestions:
Start every program with a comment header that has the program name and perhaps a brief
description of what the program does.
Use indentation to line things up. Function name and braces are in column one, then use
indents in multiples of 2 or 4 to mark code chunks, things inside loops and so on. Mark
major sections or functions with a comment header line or two
Have just the right number of comments, not too few and not too many. Assume the reader
knows the programming language so have the comment be instructive. Here is an example of
an instructive comment
digitalWrite(4,HIGH) // turn on motor
You need not comment every line. In fact, commenting every line is generally bad practice.
Add the comments when you create the code. If you tell yourself, "Oh, I'll add the comments
when the code is finished", you will never do it.
*//
For more commands see the ME2011 “Arduino Microcontroller Guide” and the Language
Reference section of the arduino web site.
Instructions in the setup() function are executed once. Those in the loop() function are
executed indefinitely.
Examples {}
1. Turn on LED connected to Pin 2 for 1 s. 2. Flash LED connected to Pin 2 at 1 Hz forever.
pinMode(2,OUTPUT); pinMode(2,OUTPUT);
digitalWrite(2,HIGH);
delay(1000); }
digitalWrite(2,LOW);
void loop()
6.SCHEMATIC DIAGRAM
59
6.1 OPERATION
POWER SUPPLY
The circuit uses standard power supply comprising of a step-down transformer from 230Vto
12V and 4 diodes forming a bridge rectifier that delivers pulsating dc which is then filtered by
an electrolytic capacitor of about 470µF to 1000µF. The filtered dc being unregulated, IC
LM7805 is used to get 5V DC constant at its pin no 3 irrespective of input DC varying from 7V
to 15V. The input dc shall be varying in the event of input ac at 230volts section varies from
160V to 270V in the ratio of the transformer primary voltage V1 to secondary voltage V2
governed by the formula V1/V2=N1/N2. As N1/N2 i.e. no. of turns in the primary to the no. of
turns in the secondary remains unchanged V2 is directly proportional to V1.Thus if the
transformer delivers 12V at 220V input it will give 8.72V at 160V.Similarly at 270V it will give
14.72V.Thus the dc voltage at the input of the regulator changes from about 8V to 15V because
of A.C voltage variation from 160V to 270V the regulator output will remain constant at 5V.
The regulated 5V DC is further filtered by a small electrolytic capacitor of 10µF for any noise so
generated by the circuit. One LED is connected of this 5V point in series with a current limiting
resistor of 330Ω to the ground i.e., negative voltage to indicate 5V power supply availability.
The unregulated 12V point is used for other applications as and when required.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
All standard items like power supply, accessories to the Arduino board like LCD, the relay driver
IC –U2 ,ULN 2003 the blue square bordered on the diagram as seen, a set of resistors
representing the underground cable are used as per the circuit .
61
OPERATION EXPLANATION
CONNECTIONS
The output of the power supply which is 5v is given to the respective pin of Arduino board and
GND is connected accordingly. Relay’s 1, 2, &3 are given to pins 1B, 2B&3B of ULN2003A
and Arduino board.
WORKING
The project uses four sets of resistances in series representing cables i.e. R4 to7; 8 to 11; 12 to 15
and 16 to 19 as shown in the circuit diagram, one set for each phase and one for ground. Each
series resistors represents the resistance of the underground cable for a specific distance thus 4
such resistances in series represent 1-4kms. 3 relays are used to common point of their contacts
are grounded while the NO points are connected to the input of the R11, R15,R19 being the 3
phase cable input. R4 is fed with a series resistor R20 to 5v supply. The common point of which
is given to input pin of inbuilt ADC of Arduino board duly wired as explained above.
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
While any of the 12switches (representing as fault switches) are operated they impose conditions
like LG, LL, 3L fault as per the switch operation. The program while executed continuously
scans by operating the 3relays in sequence of 1sec interval. Thus any NO point while driven to
GND through the common contact point of the relay develops a current flow through R20 & any
of the cable by the fault switch and all the resistors in that branch ,depending on the created
fault. Thus the voltage drop at the ADC pin varies depending on the current flow which is
inversely proportional to the resistance value representing the length of cable in kilometres. This
varying voltage is fed to the inbuilt ADC of the Arduino board and program while executed
63
displays an output in the LCD display upon the distance of the fault occurring in kms. In a fault
situation it display’s R=3km if the 3km’s switch is made ON. Accordingly all other faults are
indicated.
OPERATING PROCEDURE
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
7. LAYOUT DIAGRAM
8. BILL OF MATERIALS
65
9.CODING
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
67
This test is performed to check whether the voltage at different terminals is according to the
requirement or not. We take a multi meter and put it in voltage mode. Remember that this test is
performed without microcontroller. Firstly, we check the output of the transformer, whether we
get the required 12 v AC voltage.
Then we apply this voltage to the power supply circuit. Note that we do this test without
microcontroller because if there is any excessive voltage, this may lead to damaging the
controller. We check for the input to the voltage regulator i.e., are we getting an input of 12v and
an output of 5v. This 5v output is given to the microcontrollers’ 40th pin. Hence we check for the
voltage level at 40th pin. Similarly, we check for the other terminals for the required voltage. In
this way we can assure that the voltage at all the terminals is as per the requirement.
11. RESULTS
12. CONCLUSION
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
13. BIBLIOGRAPHY
1. “The 8051 Microcontroller and Embedded systems” by Muhammad Ali Mazidi and Janice
WEBSITES
www.atmel.com
www.arduino forum.com
www.beyondlogic.org
www.wikipedia.org
www.howstuffworks.com
www.alldatasheets.com
69