Professional Documents
Culture Documents
BACHELOR OF ENGINEERING
In
ELECTRICAL AND ELECTRONICS ENGINEERING
By
SHAIK JUNAID
1604-12-734-014
1604-12-734-037
1604-12-734-052
INDEX
TOPICS
1. Certificates
2. Acknowledgement
CHAPTER 1: INTRODUCTION
1.1
1.2
Project overview
1.3
Thesis
REFERENCES
CHAPTER 1: INTRODUCTION
1.1Introduction:
The aim of this project is to construct a three phase fault
monitor and prevention system using 8-bit microcontroller. The three
phasing fault analysis to prevent faults the system automatically
resets are required for critical loads and circuits. These are required
because the normal overload protection doesn't trip on time. For large
air-conditioning compressors, irrigation pumps these are sometimes,
included.
The purpose of this project is to develop an intelligent system that
continuously monitors all the three phase voltages (High voltage AC)
and if any of these three phases is disconnected then this system
takes
the
preventive
action.
The
4
preventive
action
could
be
the
preventive
action.
The
preventive
action
could
be
Chapter 1
diagram of the project and explains the purpose of each block. In the
same chapter the explanation of microcontrollers, power supplies,
relay, LCD, voltage sensor, optocoupler are considered.
Chapter 4
of the project.
Chapter 7
project.
which
power
them,
but
they
allow
different
2.1.3 Resources:
To save costs, embedded systems frequently have the
cheapest processors that can do the job. This means your programs
need to be written as efficiently as possible. When dealing with large
data sets, issues like memory cache misses that never matter in PC
programming can hurt you. Luckily, this won't happen too often- use
reasonably efficient algorithms to start, and optimize only when
necessary. Of course, normal profilers won't work well, due to the
same reason debuggers don't work well.
11
12
it's wiser to just buy the generic chip and write your own custom
software for it. Producing a custom-made chip to handle a particular
task or set of tasks costs far more time and money. Many embedded
computers even come with extensive libraries, so that "writing your
own software"
becomes
a very
From an
2.2.1 Debugging:
Embedded debugging may be performed at different
levels, depending on the facilities available. From simplest to most
sophisticate they can be roughly grouped into the following areas:
processor
core.
common
problem
with
multi-core
2.2.2 Reliability:
Embedded systems often reside in machines that are
expected to run continuously for years without errors and in some
cases recover by them if an error occurs. Therefore the software is
usually developed and tested more carefully than that for personal
computers, and unreliable mechanical moving parts such as disk
drives, switches or buttons are avoided.
14
to
repair.
Examples
include
space
systems,
s is selected by an
The system will lose large amounts of money when shut down:
Telephone switches, factory controls, bridge and elevator
controls, funds transfer and market making, automated sales
and service.
A variety of techniques are used, sometimes in combination, to
recover from errorsboth software bugs such as memory leaks, and also soft
errors in the hardware:
An
Embedded
encapsulation
Hypervisor
for
any
is
able
subsystem
to
provide
component,
so
secure
that
or
privileged-level
keeps
faults
15
from
system
software.
propagating
from
This
one
In this design, the software simply has a loop. The loop calls
subroutines, each of which manages a part of the hardware or
software.
16
tasks are executed by the main loop. This method brings the system
close to a multitasking kernel with discrete processes.
Cooperative Multitasking:
Primitive Multitasking:
17
time period i.e.., if the tasking is not done in a particular time period
then there is a cause of damage to the entire equipment.
Eg: consider a system in which we have to open a valve within
30 milliseconds. If this valve is not opened in 30 ms this may cause
damage to the entire equipment. So in such cases we use embedded
systems for doing automatic operations.
19
20
21
Fig2.5:Printing machine
Fig2.6: Robot
22
23
24
26
28
29
CISC, RISC
It has already been said that PIC16F72 has RISC architecture. This
term is often found in computer literature, and it needs to be
explained here in more detail. Harvard architecture is a newer concept
than von-Neumann. It rose out of the need to speed up the work of a
microcontroller. In Harvard architecture, data bus and address bus
are separate. Thus a greater flow of data is possible through the
central processing unit, and of course, a greater speed of work.
Separating a program from data memory makes it further possible for
instructions not to have to be 8-bit words. PIC16F72 uses 14 bits for
instructions, which allows for all instructions to be one-word
instructions. It is also typical for Harvard architecture to have fewer
instructions than von-Neumann's, and to have instructions usually
executed in one cycle.
30
31
Clock from the oscillator enters a microcontroller via OSC1 pin where
internal circuit of a microcontroller divides the clock into four even
clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks
make up one instruction cycle (also called machine cycle) during
which one instruction is executed.
32
Pipelining
Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of
calling and executing instructions are connected in such a way that in
order to make a call, one instruction cycle is needed, and one more is
needed for decoding and execution. However, due to pipelining, each
instruction is effectively executed in one cycle. If instruction causes a
change on program counter, and PC doesn't point to the following but
to some other address (which can be the case with jumps or with
calling subprograms), two cycles are needed for executing an
instruction. This is so because instruction must be processed again,
but this time from the right address. Cycle of calling begins with Q1
33
Pin description
PIC16F72 has a total of 28 pins. It is most frequently found in a DIP28
type of case but can also be found in SMD case which is smaller from
a DIP. DIP is an abbreviation for Dual In Package. SMD is an
abbreviation for Surface Mount Devices suggesting that holes for pins
to go through when mounting aren't necessary in soldering this type
of a component.
34
By utilizing all of this pin so many application can be done such as:
1. LCD connect to Port B pin.
2. LED connect to any pin declared as output.
3. Relay and Motor - connect to any pin declared as output.
4. External EEPROM connect to I2C interface pin RC3 and RC4
(SCL and SDA)
5. LDR, Potentiometer and sensor connect to analogue input pin
such as RA0.
6. GSM modem dial up modem connect to RC6 and RC7 the serial
communication interface using RS232 protocol.
36
For more detail function for each specific pin please refer to the device
datasheet from Microchip.
Ports
Term "port" refers to a group of pins on a microcontroller which can be
accessed simultaneously, or on which we can set the desired
combination of zeros and ones, or read from them an existing status.
Physically, port is a register inside a microcontroller which is
connected by wires to the pins of a microcontroller. Ports represent
physical connection of Central Processing Unit with an outside world.
Microcontroller uses them in order to monitor or control other
components or devices. Due to functionality, some pins have twofold
roles like PA4/TOCKI for instance, which is in the same time the
fourth bit of port A and an external input for free-run counter.
Selection of one of these two pin functions is done in one of the
configuration registers. An illustration of this is the fifth bit T0CS in
OPTION register. By selecting one of the functions the other one is
disabled.
All port pins can be designated as input or output, according to the
needs of a device that's being developed. In order to define a pin as
input or output pin, the right combination of zeros and ones must be
written in TRIS register. If the appropriate bit of TRIS register contains
logical "1", then that pin is an input pin, and if the opposite is true,
it's an output pin. Every port has its proper TRIS register. Thus, port
A has TRISA, and port B has TRISB. Pin direction can be changed
during the course of work which is particularly fitting for one-line
communication where data flow constantly changes direction. PORTA
37
and PORTB state registers are located in bank 0, while TRISA and
TRISB pin direction registers are located in bank 1.
Each PORTB pin has a weak internal pull-up resistor (resistor which
defines a line to logic one) which can be activated by resetting the
seventh bit RBPU in OPTION register. These 'pull-up' resistors are
automatically being turned off when port pin is configured as an
output. When a microcontroller is started, pull-ups are disabled.
38
Memory organization
PIC16F72 has two separate memory blocks, one for data and the other
for program. EEPROM memory with GPR and SFR registers in RAM
memory make up the data block, while FLASH memory makes up the
program block.
Program memory
Data memory
40
Batteries.
Solar power.
Generators or alternators.
42
230V AC MAINS
TRANSFORMER
BRIDGE RECTIFIER(DIODES)
CAPACITOR
RESISTOR
43
Transformers:
A transformer is
energy from
device
one circuit to
coupled conductors
without
varying current in
the
first
varying magnetic
flux in
the
that
transfers electrical
another
changing
or
through inductively
its
frequency.
primary winding
transformer's
core,
creates
and
thus
A
a
a
44
45
induce power, called EDDY CURRENTS, into this core, the core is
LAMINATED. This means that it is made up from metal sheets
insulated from each other. Transformers to work at higher frequencies
have an iron dust core or no core at all.
Note that the transformer only works on AC, which has a
constantly changing current and moving field. DC has a steady
current and therefore a steady field and there would be no induction.
Some transformers have an electrostatic screen between
primary and secondary. This is to prevent some types of interference
being fed from the equipment down into the mains supply, or in the
other direction. Transformers are sometimes used for IMPEDANCE
MATCHING.
We can use the transformers as step up or step down.
Step Up transformer:
In case of step up transformer, primary windings are
every less compared to secondary winding. Because of having more
turns secondary winding accepts more energy, and it releases more
voltage at the output side.
Step down transformer:
Incase of step down transformer, Primary winding induces
more flux than the secondary winding, and secondary winding is
having less number of turns because of that it accepts less number of
flux, and releases less amount of voltage.
Battery power supply:
46
and
reliability.
battery
consists
of
multiple
48
diodes,
vacuum
tube
diodes,
mercury
arc
valves,
and
other
components.
A device that it can perform the opposite function
(converting DC to AC) is known as an inverter.
When only one diode is used to rectify AC (by blocking the
negative or positive portion of the waveform), the difference between
the term diode and the term rectifier is merely one of usage, i.e., the
term rectifier describes a diode that is being used to convert AC to DC.
Almost all rectifiers comprise a number of diodes in a specific
arrangement for more efficiently converting AC to DC than is possible
with only one diode. Before the development of silicon semiconductor
rectifiers, vacuum tube diodes and copper (I) oxide or selenium
rectifier stacks were used.
Bridge full wave rectifier:
The Bridge rectifier circuit is shown in fig:3.8, which
converts an ac voltage to dc voltage using both half cycles of the input
ac voltage. The Bridge rectifier circuit is shown in the figure. The
circuit has four diodes connected to form a bridge. The ac input
voltage is applied to the diagonally opposite ends of the bridge. The
load resistance is connected between the other two ends of the bridge.
For the positive half cycle of the input ac voltage,
diodes D1 and D3 conduct, whereas diodes D2 and D4 remain in the
OFF state. The conducting diodes will be in series with the load
resistance RL and hence the load current flows through RL.
49
Output
50
functions,
specifically
to
remove
unwanted
51
52
53
Fig
Operation of Capacitor:
Think of water flowing through a pipe. If we imagine a
capacitor as being a storage tank with an inlet and an outlet pipe, it is
possible to show approximately how an electronic capacitor works.
First, let's consider the case of a "coupling capacitor"
where the capacitor is used to connect a signal from one part of a
circuit to another but without allowing any direct current to flow.
Step 4: Regulation
The process of converting a varying voltage to a constant
regulated voltage is called as regulation. For the process of regulation
we use voltage regulators.
Voltage Regulator:
A voltage regulator (also called a regulator) with only
three terminals appears to be a simple device, but it is in fact a very
complex integrated circuit. It converts a varying input voltage into a
constant regulated output voltage. Voltage Regulators are available in
a variety of outputs like 5V, 6V, 9V, 12V and 15V. The LM78XX series
of voltage regulators are designed for positive input. For applications
requiring negative input, the LM79XX series is used. Using a pair of
voltage-divider resistors can increase the output voltage of a regulator
circuit.
It is not possible to obtain a voltage lower than the stated
rating. You cannot use a 12V regulator to make a 5V power supply.
Voltage regulators are very robust. These can withstand over-current
55
draw due to short circuits and also over-heating. In both cases, the
regulator will cut off before any damage occurs. The only way to
destroy a regulator is to apply reverse voltage to its input. Reverse
polarity destroys the regulator almost instantly. Fig: 3.3.11 shows
voltage regulator.
57
Fig 3.3.13:
3.4. LED:
A light-emitting diode (LED) is a semiconductor light
source. LEDs are used as indicator lamps in many devices, and are
increasingly used for lighting. Introduced as a practical electronic
component in 1962, early LEDs emitted low-intensity red light, but
58
The internal
Working:
59
Fig
The
light-emitting
semiconductor
material
is
what
60
High-efficiency
No UV Rays
61
primary
of
the
transformer
must
be
connected
to
the
63
64
The standards
Regulatory agencies such as UL in the United States,
CENELEC in Europe, CSA in Canada, and TIIS in Japan, set the
power level needed to make circuitry intrinsically safe. In essence, the
standards set the requirements for the galvanic isolation barrier
between the safe circuitry and the outside world. For best results,
choose optocouplers with additional reinforced insulation as suggested
by IEC EN-60747- 5-2. Reinforced insulation ensures protection from
electric shock as well as provides a failsafe mode. Fail-safe techniques
terminate
system
operation
and
leaves
system
processes
and
65
use
for
controlling
up
to
lines
via
the
parallel
port.
Applications
1. Computer terminals
2. System appliances, measuring instruments
3. Registers, copiers, automatic vending machines
4. Electric home appliances, such as fan heaters, etc.
5. Signal transmission between circuits of different potentials and
impedances
66
3.7 Relay:
A relay is an electrically operated switch. Many relays use an
electromagnet to operate a switching mechanism, but other operating
principles are also used. Relays find applications where it is necessary
to control a circuit by a low-power signal, or where several circuits
must be controlled by one signal. The first relays were used in long
distance telegraph circuits, repeating the signal coming in from one
circuit and re-transmitting it to another. Relays found extensive use in
telephone
exchanges
and
early
computers
to
perform
logical
operations. A type of relay that can handle the high power required to
directly drive an electric motor is called a contactor. Solid-state relays
control power circuits with no moving parts, instead using a
semiconductor device triggered by light to perform switching. Relays
with calibrated operating characteristics and sometimes multiple
operating coils are used to protect electrical circuits from overload or
faults; in modern electric power systems these functions are
performed by digital instruments still called "protection relays".
3.8.1 Basic design and operation:
67
with a fixed contact. If the set of contacts was closed when the relay
was De-energized, then the movement opens the contacts and breaks
the connection, and vice versa if the contacts were open. When the
current to the coil is switched off, the armature is returned by a force,
approximately half as strong as the magnetic force, to its relaxed
position. Usually this force is provided by a spring, but gravity is also
used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low voltage application, this is
to reduce noise. In a high voltage or high current application, this is to
reduce arcing.
If the coil is energized with DC, a diode is frequently installed across
the coil, to dissipate the energy from the collapsing magnetic field at
deactivation,
which
would
otherwise
generate
voltage
spike
69
70
3. 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.
4. 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 lowvoltage 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.
5. Polarized relay
A polarized relay placed the armature between the poles of a
permanent magnet to increase sensitivity. Polarized relays were used
in middle 20th Century telephone exchanges to detect faint pulses and
71
characterized
by
large
number
of
contacts
(sometimes
auxiliary contacts are in series with the coil. If the overload senses
excess current in the load, the coil is de-energized. Contactor relays
can be extremely loud to operate, making them unfit for use where
noise is a chief concern.
8. Solid-state relay
73
forced-guided
contacts
relay
has relay
contacts
that
are
76
77
A large relay with two coils and many sets of contacts, used in an old
telephone switching system
79
Coil current
Package/enclosure
open,
touch-safe,
double-voltage
for
Aerospace
or
radiation-resistant
testing,
special
quality
assurance
Regulatory approvals
Advantages of relays:
Relays can switch AC and DC, transistors can only switch DC.
Relays are a better choice for switching large currents (> 5A).
Disadvantages of relays:
81
Relays use more power due to the current flowing through their
coil.
3.8: LCD
82
Pin description:
Pin No.
Name
Description
Pin no. 1
VSS
Pin no. 2
VCC
Pin no. 3
VEE
Contrast adjust
Pin no. 4
RS
Instruction
input
1 = Data input
0 = Write to LCD module
Pin no. 5
R/W
Read
from
LCD
module
Pin no. 6
EN
Enable signal
Pin no. 7
D0
Pin no. 8
D1
Pin no. 9
D2
Pin no. 10
D3
Pin no. 11
D4
Pin no. 12
D5
Pin no. 13
D6
Pin no. 14
D7
84
Circuit Description:
85
instruction.
In
short,
we
must
always
manipulate
EN
when
87
Applications:
Medical equipment
Serial terminal
Advertising system
EPOS
88
Gaming box
Security systems
Climatizing units
PLC Interface
Simulators
Environmental monitoring
Lab development
Student projects
Home automation
PC external display
89
90
Fig: 4.1 show the toolbar in which the each button has the
following functions:
The select tool: It is fairly obvious what this does. It allows you
to move
top toolbar will show buttons to move traces to the top / bottom
copper layer, and rotate buttons.
The place pad: button allows you to place small soldier pads
which are useful for board connections or if a part is not in the
part library but the part dimensions are available. When this
tool is selected the top toolbar will give you a large selection of
round holes, square holes and surface mount pads.
The place trace: tool allows you to place a solid trace on the
board of varying thicknesses. The top toolbar allows you to
select the top or bottom layer to place the trace on.
92
The remove a trace button is not very important since the delete
key will achieve the same result.
93
Large capacitors, relays, and similar parts which dont have axial
leads can NOT have traces on top unless boards are plated
professionally.
Ground-plane or other special purposes for one side:
When using a double sided board you must consider
which traces should be on what side of the board. Generally, put
power traces on the top of the board, jumping only to the bottom if a
part cannot be soldiered onto the top plane (like a relay), and viceversa.
Some projects like power supplies or amps can benefit
from having a solid plane to use for ground. In power supplies this
can reduce noise, and in amps it minimizes the distance between
parts and their ground connections, and keeps the ground signal as
simple as possible. However, care must be taken with stubborn chips
such as the TPA6120 amplifier from TI. The TPA6120 datasheet
specifies not to run a ground plane under the pins or signal traces of
this chip as the capacitance generated could effect performance
negatively.
4.2 PIC Compiler:
PIC compiler is software used where the machine
language code is written and compiled. After compilation, the machine
source code is converted into hex code which is to be dumped into the
microcontroller for further processing. PIC compiler also supports C
language code.
Its important that you know C language for
microcontroller which is commonly known as Embedded C. As we are
94
going to use PIC Compiler, hence we also call it PIC C. The PCB, PCM,
and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for
14-bitopcodes, and PCH is for 16-bit opcode PIC microcontrollers. Due
to many similarities, all three compilers are covered in this reference
manual. Features and limitations that apply to only specific
microcontrollers are indicated within. These compilers are specifically
designed to meet the unique needs of the PIC microcontroller. This
allows developers to quickly design applications software in a more
readable, high-level language. When compared to a more traditional C
compiler, PCB, PCM, and PCH have some limitations. As an example
of the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to
push variables onto, and also because of the way the compilers
optimize the code. The compilers can efficiently implement normal C
constructs, input/output operations, and bit twiddling operations. All
normal C data types are supported along with pointers to constant
arrays, fixed point decimal, and arrays of bits.
PIC C is not much different from a normal C program.
If you know assembly, writing a C program is not a crisis. In PIC, we
will have a main function, in which all your application specific work
will be defined. In case of embedded C, you do not have any operating
system running in there. So you have to make sure that your program
or main file should never exit. This can be done with the help of
simple while (1) or for (;;) loop as they are going to run infinitely.
We have to add header file for controller you are
using, otherwise you will not be able to access registers related to
peripherals.
95
Now you have to click 'File, Save as' and choose a file name for
your source code ending with the letter '.c'. You can name as
'project.c' for example and click save. Then you have to add this
file to your project work.
97
98
You can then start to write the source code in the window titled
'project.c' then before testing your source code; you have to
compile your source code, and correct eventual syntax errors.
By
clicking
on
compile
option
automatically.
99
.hex
file
is
generated
Now
it
displays
PCB
where
circuit
is
designed
using
100
10. Now click on letter p, then under that select PIC16F72 ,other
components related to the project and click OK. The PIC 16F72 will be
called your 'Target device, which is the final destination of your
source code.
101
102
104
106
107
5. Import the program which is .hex file from the saved location by
selecting File option and clicking on Import Hex as shown in below
window.
108
109
110
111
112
113
Advantages:
1. Faster protection of critical electrical equipment.
2. Heavy-duty irrigation water pumps.
3. Industrial drive motors.
4. Any three phase driven industrial loads.
5. Conservation of energy.
6. Efficient and low cost design.
7. Low power consumption.
8. Easy to install.
9. Fast response.
Disadvantages:
Interfacing High voltage sensor to the Micro Controller is
sensitive.
Applications:
1. Rural installations.
2. Heavy industrial loads.
3. Public lighting
4. Irrigation water pumps
115
CHAPTER 7: RESULTS
7.1 Result:
116
117
REFERENCES
Books referred:
1. Raj
kamal
Microcontrollers
Architecture,
118
Programming,
6. Embedded C Michael.J.Pont.
APPENDIX
Program Code:
The program code which is dumped in the microcontroller of our
project is shown below.
#include <16F72.h>
#include <string.h>
#include <sensor.h>
#include <ADC.h>
#fuses
HS,NOWDT,PROTECT,brownout,put
#use
delay
(clock=20000000)
void main()
{
int i = 0;
void main()
{
lcd_init();
lcd_putc('\f');
// Clear LCD
lcd_gotoxy(1,1);
// row-1, column-1
printf(lcd_putc," AC induction ");
lcd_gotoxy(1,2);
// row-1, column-2
printf(lcd_putc," protection ");
delay_ms(2000);
//Microcontroller Health Check Start
output_high(PIN_C3);
119
delay_ms(1000);
output_low(PIN_C3);
delay_ms(1000);
output_high(PIN_C3);
delay_ms(1000);
output_low(PIN_C3);
output_high(PIN_C4);
delay_ms(1000);
output_low(PIN_C4);
delay_ms(1000);
while(1)
{
if(!(input(PIN_A0) && input(PIN_A2) && input(PIN_A5)))
{
output_low(PIN_C7);
}
if(!input(PIN_A0))
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"R-Phase Fault");
output_high(PIN_C3);
output_high(PIN_C7);
delay_ms(100);
}
if(!input(PIN_A2))
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"Y-Phase Fault");
output_high(PIN_C3);
output_high(PIN_C7);
output_low(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C3);
delay_ms(100);
}
if(!input(PIN_A5))
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"B-Phase Fault");
output_high(PIN_C3);
output_high(PIN_C7);
output_low(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
delay_ms(100);
120
}
}
}
121