Anda di halaman 1dari 53

UNIVERSITY OF NAIROBI

DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING

FINAL YEAR PROJECT REPORT


TITLE: AUTOMATED ELECTRIC FENCE
PROJECT NO.: 12

SUBMITTED BY

SAID BREK SAID


F17/23247/2008

SUPERVISOR: DR. G.N KAMUCHA


EXAMINER: DR. DHARMADHIKARY

Project report submitted in partial fulfillment of the requirements for the award of the degree of
Bachelor of Science in Electrical & Electronic Engineering of the University of Nairobi.

Date of Submission: 27/04/2014


DECLARATION OF ORIGINALITY

NAME OF STUDENT: Said Brek Said

REGISTRATION NUMBER: F17/23247/2008

COLLEGE: Architecture And Engineering

FACULTY/ SCHOOL/ INSTITUTE: Engineering

DEPARTMENT: Electrical And Information Engineering

COURSE NAME: Bachelor Of Science In Electrical & Electronic Engineering

TITLE OF WORK: AUTOMATED ELECTRIC FENCE

1) I understand what plagiarism is and I am aware of the university policy in this regard.
2) I declare that this final year project report is my original work and has not been submitted
elsewhere for examination, award of a degree or publication.
Where other peoples work or my own work has been used, this has properly been
acknowledged and referenced in accordance with the University of Nairobis requirements.
3) I have not sought or used the services of any professional agencies to produce this work.
4) I have not allowed, and shall not allow anyone to copy my work with the intention of
passing it off as his/her own work.
5) I understand that any false claim in respect of this work shall result in disciplinary action,
in accordance with University anti-plagiarism policy.

Signature:

ii
Date: ..

DEDICATION

I dedicate this work to my parents and my family in general, colleagues and friends who played a
significant role in the success I have accomplished in the completion of this project.

ii
ACKNOWLEDGEMENT

First and foremost I wish to thank the God Almighty who has seen me through my studies at the
university.

Secondly I greatly appreciate the guidance of my supervisor Dr. G. N. Kamucha, the Dean-
Faculty of Engineering, Chairman-Department of Electrical and Information Engineering and all
my lecturers and support staff at the University of Nairobi for their support which contributed
greatly to the provision of knowledge as well as the completion of this project.

Lastly, I extend special thanks to my parents, Mr. and Mrs. Brek for their mutual, emotional and
financial support throughout my education.

iii
TABLE OF CONTENTS
DECLARATION OF ORIGINALITY ..................................................................................................... ii
DEDICATION............................................................................................................................................. ii
ACKNOWLEDGEMENT......................................................................................................................... iii
CHAPTER 1: INTRODUCTION.............................................................................................................. 1
1.1 BACKGROUND ............................................................................................................................... 1
1.2 PROBLEM STATEMENT .............................................................................................................. 2
1.3 OBJECTIVES ................................................................................................................................... 2
1.4 PROJECT SCOPE............................................................................................................................ 2
1.5 PROJECT JUSTIFICATION.......................................................................................................... 2
CHAPTER 2: LITERATURE REVIEW.................................................................................................. 3
2.1 INTRODUCTION............................................................................................................................. 3
2.2 THE 555 TIMER IC ......................................................................................................................... 5
2.2.1 Description.................................................................................................................................. 5
2.2.2 Timer Circuitry .......................................................................................................................... 8
2.2.3 Reset Function ............................................................................................................................ 9
2.2.4 Trigger Requirements................................................................................................................ 9
2.2.5 Control Voltage ........................................................................................................................10
2.2.6 Modes of operation...................................................................................................................11
2.3 MICROCONTROLLER ................................................................................................................13
2.3.1 Types of Microcontrollers ....................................................................................................... 14
2.3.2 Atmega based microcontrollers ..............................................................................................16
2.4 ARDUINO ....................................................................................................................................... 17
2.4.1 Arduino Software.....................................................................................................................17
2.4.2 Arduino Hardware...................................................................................................................18
2.4.2 Pulse Width Modulation.......................................................................................................... 19
2.5 ELECTRIC FENCE ENERGIZER ..............................................................................................19
2.5.1 Types of Energizers ...................................................................................................................20
2.6 IGNITION COIL ............................................................................................................................22
2.6.1 Principle of Operation ............................................................................................................. 23
2.6.2 Types of ignition coils .............................................................................................................. 24

iv
2.7 RELAY SWITCH ...........................................................................................................................25
2.7.1 Functions of a Relay Switch .................................................................................................... 26
2.7.2 Applications of Relay ...............................................................................................................26
2.8 OP-AMP........................................................................................................................................... 26
2.8.1 Circuit Notation........................................................................................................................27
2.8.2 Principle of operation .............................................................................................................. 28
2.9 COMPARATOR .............................................................................................................................29
2.9.1 Principle of operation .............................................................................................................. 30
2.9.2 Key Specifications ....................................................................................................................30
CHAPTER 3: DESIGN AND IMPLEMENTATION............................................................................ 30
3.1 DESIGN OF 555 SIREN GENERATOR......................................................................................31
3.2 DESIGN OF FENCE ENERGISER..............................................................................................32
3.2.1 Generation of PWM pulses using Arduino Uno.................................................................... 32
3.2.2 Generation of shock .................................................................................................................34
3.2.3 Voltage sensing comparator.................................................................................................... 37
3.2.4 The complete system circuit .................................................................................................... 38
CHAPTER 4: RESULTS AND ANALYSIS...........................................................................................39
4.1 Alarm circuit results .......................................................................................................................39
4.2 Shock generation circuit results..................................................................................................... 40
CONCLUSION ......................................................................................................................................... 42
APPENDIX................................................................................................................................................42
ARDUINO SKETCH USED TO GENERATE PWM....................................................................... 42
REFERENCES.......................................................................................................................................... 43

v
TABLE OF FIGURES
Figure 2.1 NE555 Timer ................................................................................................................. 5
Figure 2.2 555 Timer Functional Block Diagram........................................................................... 6
Figure 2.3 Pin-out diagram ............................................................................................................. 6
Figure 2.5 Schematic of 555 Dual Timer........................................................................................ 8
Figure 2.6 AC coupling of the Trigger Pulse................................................................................ 10
Figure 2.7 Schematic of a 555 in monostable mode ..................................................................... 11
Figure 2.8 Standard 555 astable circuit......................................................................................... 12
Figure 2.9 Schematic of a 555 in Bistable Mode.......................................................................... 13
Figure 2.1.0 Arduino Pin Mapping ............................................................................................... 16
Figure 2.11 Basic Board: Arduino Uno ........................................................................................ 18
Figure 2.12 Arduino PWM signals ............................................................................................... 19
Figure 2.13 Mains Energizer......................................................................................................... 20
Figure 2.14 Battery Energizer....................................................................................................... 21
Figure 2.15 Solar Energizer .......................................................................................................... 21
Figure 2.16 Spark plug.................................................................................................................. 22
Fig 2.17 Ignition coil constituents ................................................................................................ 23
Figure 2.18 Types of ignition coils ............................................................................................... 25
Figure 2.19 Electromagnetic or mechanical relay ........................................................................ 25
Figure 2.20 Ua741 op-amp ........................................................................................................... 27
Figure 2.21 Circuit diagram symbol for op-amp .......................................................................... 27
Fig 2.22 An op-amp without negative feedback (a comparator) .................................................. 28
Figure 2.23 An op-amp with negative feedback (a non-inverting amplifier) ............................... 28
Figure 2.24 A simple op-amp comparator .................................................................................... 29
Figure 3.1 555 Siren generator circuit .......................................................................................... 31
Figure 3.2 Flow chart of the Arduino sketch execution process................................................... 33
Figure 3.3 Generating PWM pulses and amplifying them to 12V ............................................... 34
Figure 3.4 Flow chart showing the generation of shock pulses .................................................... 36
Figure 3.5 Voltage comparator sensing circuit ............................................................................. 37
Figure 3.6 The complete system circuit ........................................................................................ 38
Figure 4.1 High frequency waveforms ......................................................................................... 39
Figure 4.2 Low frequency waveforms .......................................................................................... 40
Figure 4.3 Arduino Uno pin 13 PWM generated pulses............................................................... 41
Figure4.4 Transformer secondary side voltage............................................................................. 42

vi
ABSTRACT

Electric fences are the most popular means of fencing since not only do they provide a physical
barrier, they are extra effective in that they provide more security since the shock that is
delivered from the fence tends to keep both people and animal away. Over the decades, as
technology keeps on growing so as the different type of electric fences keep on emerging. So as
to make my contribution in this field, this paper will cover the scope of building an automated
electric fence which is unique in that the generation of shock and the control of an alarm system
are controlled by a micro-controller.
Currently in Kenya, it is only the top security agencies that have ventured into this kind of
electric fencing, but their systems are more complex hence that comes at a price. What this paper
will cover is an implementation that will be affordable to all.

vii
CHAPTER 1: INTRODUCTION

1.1 BACKGROUND

Electric fences began to be implemented ever since the early 1930s and they were used to control
livestock in the United States of America and New Zealand. An ignition coil of a car was used to
build the first electric fence in the year 1936-1937 by an inventor called Bill Gallagher. [1]The
electric fence is very versatile and one of its functions was in providing effective security
solutions implemented in many applications. Some of the typical installations are as listed below

a) Military bases, borders and high security installations.


b) Industrial sites and factories.
c) Remote warehouses and builders yards.
d) Cellular phone antenna sites.
e) Electricity transformer, sub-stations and electricity pylons.
f) Housing Estates.
g) Private Houses.
h) Car lots.
i) Rental storage facilities [2]

Electric fences are mostly used in agriculture. Whereas standard fences are constructed to just
form a physical barrier, electric fences are constructed to form both psychological and mental
barriers. The mental barrier is accomplished by introducing an electric shock through the fence
wire that both repels the animals and makes them less likely to contact the fence again. [3]
However in security systems, the electric shock is meant to keep intruders out and is usually
accompanied by an alarm system which is triggered when an intruder is detected and has been
shocked already. And this is what this project is aiming to achieve.

1
1.2 PROBLEM STATEMENT

Security is very essential in each home especially in these times where cases of burglary and
theft have risen off the charts. Though it is the duty of the police in our country to ensure the
safety of all citizens, it is also ones duty to cater and make sure that his/her home is safe for the
family. This project will guide users through building a security system that isnt complex as
such but will do the job.

1.3 OBJECTIVES

The objectives of this project is to build an automated electric fence where the generation of
shock and the alarm system are controlled by a micro-controller.

1.4 PROJECT SCOPE

This project entails the following

i. Designing an electric fence charger that is essentially a high voltage pulse generator and
linking it to the fence.
ii. Designing a 555 timer siren generator that will serve as the alarm system.
iii. Interfacing the micro-controller with the alarm system together with the necessary
arduino microcontroller program that will enable the micro-controller to execute its
function.

1.5 PROJECT JUSTIFICATION

The readily available security systems solutions in the market are very expensive. Besides the
security group of companies, the likes of G4S, KK security and Wells Fargo have completely
taken over the market and hence they tend to offer home security systems but at a ridiculously
high price. This project is hence aimed at providing a cheaper alternative of a self-built security
systems that I still as efficient as the others.

2
CHAPTER 2: LITERATURE REVIEW

2.1 INTRODUCTION

An electric fence is made up of an open electrical circuit comprising of two arms as shown
below:
a) The first arm is the fence connected to the fence energizer. This section is usually
insulated from any other conductive material like the ground, leaves, grass and trees by
plastic insulators or an air gap of at least 3cm.
b) The second arm is the ground itself that is connected to the Earth terminal of the
energizer by way of a metal rod or earth stake/post.
This forms OPEN electrical circuit as shown below waiting for a person or animal to close the
circuit.

Taking an example of a horse, the electrical circuit is then CLOSED when the horse comes into
contact with both the live fence and the ground at the same time. This forms a short circuit
allowing the electricity to flow from the animal and back to the energizer via the earth metal rod
giving the animal an electrical shock as it touches the wire.

3
The voltage being sent through the wires is usually very high but the current or amperage is low.
Electric fence energizers output high voltages of around 8kV but very low amperage around
120mA. Also the output is made safe in that the electrical energy is released in pulses once every
1/300th second. The reason for the pulsating current is that if the wires are touched and deliver
shock, then whatever touches it has a chance to withdraw or remove itself. [4]The person or
animal has to be in direct contact with the ground to feel the shocking sensation. This is why a
bird resting on the wire will not receive a shock since it is not touching the ground so the circuit
isnt completed. Another case is when a person wearing insulated footwear will only receive a
very small shock because all the current cannot pass through the insulated soles as shown below:
[5]

There are two types of fences:

4
I. Permanent electric fences: Permanent electric fences are preferred since they provide a
long-term fencing solution. Compared to other fences like barbed wire, woven wire and
rail fence, permanent power fence systems are economical, easy to install and operate,
and require less maintenance, due to minimal physical contact with animals.
II. Temporary/Portable electric fences: Portable electric fences provide flexibility in pasture
management and are ideal for short-term animal control or rotational grazing. Easily
transported, constructed and maintained, portable fences are an effective temporary
fencing solution for a range of animals and situations. [5]

2.2 THE 555 TIMER IC

Philips Semiconductors introduced the 555 IC timer that was a unique functional building block
that enjoyed unprecedented popularity. The timers success is mainly to several inherent
characteristics foremost of which are; versatility, stability and low cost. The simplicity of the
timer, in conjunction with its ability to produce long time delays in a variety of applications, has
lured many designers from mechanical timers, op amps, and various discrete circuits into the
ever increasing ranks of timer users. [7]
The 555 timer IC is an integrated circuit (chip) used in a variety of timer, pulse generation,
and oscillator applications. The 555 can be also be used to provide time delays, as an oscillator,
and as a flip-flop element Derivatives provide up to four timing circuits in one package. [8] The
image below shows the NE555 timer:

Figure 2.1 NE555 Timer

2.2.1 Description

The 555 timer consists of two voltage comparators, a bistable flip-flop(R-S flip-flop), a
discharge transistor, and a resistor divider network. To understand the basic concept of the timer
lets first examine the timer in block form in Figure 1.

5
Figure 2.2 555 Timer Functional Block Diagram

The resistive divider network is used to set the comparator levels. Since the three resistors are
equal in value, the threshold comparator is referenced internally at 2/3 of supply voltage level
and the trigger comparator is referenced at 1/3 of supply voltage. The outputs of the comparators
are tied to the bistable flip-flop. When the trigger voltage is dropped below 1/3 of the supply, the
comparator changes its state and sets the flip-flop driving the output to a high state. The
threshold pin normally monitors the voltage of the capacitor in the RC timing network, When the
capacitor voltage exceeds 2/3 of the supply, the threshold comparator resets the flip-flop which
in turn drives the output to a comparator resets the flip-flop which in turn drives the output to a
low state. When the output is in a low state, the discharge transistor is on, thereby discharging
the external timing capacitor. Once the capacitor is discharged, the timer will await another
trigger pulse, the timing cycle having been completed. [7]
Here is the pin-out diagram for the 555 timer

Figure 2.3 Pin-out diagram

6
Pin 1: Grounded Terminal: All the voltages are measured with respect to the Ground terminal.
Pin 2: Trigger Terminal: The trigger pin is used to feed the trigger input, then the 555 IC is set up
as a monostablemultivibrator. This pin is an inverting input of a comparator and is responsible
for the transition of flip-flop from set to reset. The output of the timer depends on the amplitude
of the external trigger pulse applied to this pin. A negative pulse with a dc level greater than
Vcc/3 is applied to this terminal. In the negative edge, as the trigger passes through Vcc/3, the
output of the lower comparator becomes high and the complimentary of Q becomes zero. Thus
the 555 IC output gets a high voltage, and thus a quasi-stable state.
Pin 3: Output Terminal: Output of the timer is available at this pin. There are two ways in which
a load can be connected to the output terminal. One way is to connect between output pin (pin 3)
and ground pin (pin 1) or between pin 3 and supply pin (pin 8). The load connected between
output and ground supply pin is called the normally on load and that connected between output
and ground pin is called the normally off load.
Pin 4: Reset Terminal: Whenever the timer IC is to be reset or disabled, a negative pulse is
applied to pin 4, and thus is named as reset terminal. The output is reset irrespective of the input
condition. When this pin is not to be used for reset purpose, it should be connected to + VCC to
avoid any possibility of false triggering.
Pin 5: Control Voltage Terminal: The threshold and trigger levels are controlled using this pin.
The pulse width of the output waveform is determined by connecting a POT or bringing in an
external voltage to this pin. The external voltage applied to this pin can also be used to modulate
the output waveform. Thus, the amount of voltage applied in this terminal will decide when the
comparator is to be switched, and thus changes the pulse width of the output. When this pin is
not used, it should be bypassed to ground through a 0.01 micro Farad to avoid any noise
problem.
Pin 6: Threshold Terminal: This is the non-inverting input terminal of comparator 1, which
compares the voltage applied to the terminal with a reference voltage of 2/3 VCC. The amplitude
of voltage applied to this terminal is responsible for the set state of flip-flop. When the voltage
applied in this terminal is greater than 2/3Vcc, the upper comparator switches to +Vsat and the
output gets reset.
Pin 7: Discharge Terminal: This pin is connected internally to the collector of transistor and
mostly a capacitor is connected between this terminal and ground. It is called discharge terminal
because when transistor saturates, capacitor discharges through the transistor. When the
transistor is cut-off, the capacitor charges at a rate determined by the external resistor and
capacitor.
Pin 8: Supply Terminal: A supply voltage of + 5 V to + 18 V is applied to this terminal with
respect to ground (pin 1) [9].

7
2.2.2 Timer Circuitry

Figure 2.5 Schematic of 555 Dual Timer

The timer is composed of five distinct circuits: two voltage comparators; a resistive voltage
divider reference; a bistable flip-flop; a discharge transistor; and an output stage that is the
totem-pole design for sink or source capability. Q10-Q13 comprise a Darlington differential
pair which serves as a trigger comparator. Starting with a positive voltage on the trigger, Q10
and Q11 turn on when the voltage at Pin 2 is moved below one third of the supply voltage. The
voltage level is derived from a resistive divider chain consisting of R7, R8 and R9. All three
resistors are of equal value (5kW). At 15V supply, the triggering level would be 5V. When Q10
and Q11 turn on, they provide a base drive for Q15, turning it on. Q16 and Q17 form a bistable
flip-flop. When Q15 is saturated, Q16 is off and Q17 is saturated. Q16 and Q17 will remain in
these states even if the trigger is removed and Q15 is turned off. While Q17 is saturated, Q20
and Q14 are turned off.
The output structure of the timer is a totem-pole design, with Q22 and Q24 being large
geometry transistors capable of providing 200mA with a 15V supply. While Q20 is off, base
drive is provided for Q22 by Q21, thus providing a high output. For the duration that the output
is in a high state, the discharge transistor is off. Since the collector of Q14 is typically
connected to the external timing capacitor, C, while Q14 is off, the timing capacitor now can
charge through the timing resistor, RA.

8
The capacitor voltage is monitored by the threshold comparator (Q1-Q4) which is a Darlington
differential pair. When the capacitor voltage reaches two thirds of the supply voltage, the current
is directed from Q3 and Q4 thru Q1 and Q2. Amplification of the current change is provided by
Q5 and Q6. Q5-Q6 and Q7-Q8 comprise a diode-biased amplifier. The amplified current change
from Q6 now provides a base drive for Q16 which is part of the bistable flip-flop, to change
states. In doing so, the output is driven low, and Q14, the discharge transistor, is turned on,
shorting the timing capacitor to ground.

2.2.3 Reset Function

Regressing to the trigger mode, it should be noted that once the device has triggered and the
bistable flip-flop is set, continued triggering will not interfere with the timing cycle. However,
there may come a time when it is necessary to interrupt or halt a timing cycle. This is the
function that the reset accomplishes. In the normal operating mode the reset transistor, Q25, is
off with its base held high. When the base of Q25 is grounded, it turns on, providing base drive
to Q14, turning it on. This discharges the timing capacitor, resets the flip-flop at Q17, and drives
the output low. The reset overrides all other functions within the timer.

2.2.4 Trigger Requirements

Due to the nature of the trigger circuitry, the timer will trigger on the negative-going edge of the
input pulse. For the device to time-out properly, it is necessary that the trigger voltage level be
returned to some voltage greater than one third of the supply before the timeout period. This can
be achieved by making either the trigger pulse sufficiently short or by AC coupling into the
trigger. By AC coupling the trigger (see Figure 2.4), a short negative-going pulse is achieved
when the trigger signal goes to ground. AC coupling is most frequently used in conjunction with
a switch or a signal that goes to ground which initiates the timing cycle. Should the trigger be
held low, without AC coupling, for a longer duration than the timing cycle the output will remain
in a high state for the duration of the low trigger signal, without regard to the threshold
comparator state.This is due to the predominance of Q15 on the base of Q16, controlling the state
of the bistable flip-flop. When the trigger signal then returns to a high level, the output will fall
immediately. Thus, the output signal will follow the trigger signal in this case.

9
Figure 2.6 AC coupling of the Trigger Pulse

2.2.5 Control Voltage

One important thing, the control voltage, is brought out on the timer. As mentioned before, both
the trigger comparator, Q10-Q13, and the threshold comparator, Q1-Q4, are referenced to an
internal resistor divider network, R7, R8, and R9. This network establishes the nominal two
thirds of supply voltage (VCC) trip point for the threshold comparator and one third of VCC for
the trigger comparator. The two thirds point at the junction of R7, R8 and the base of Q4 is
brought out. By imposing a voltage at this point, the comparator reference levels may be shifted
either higher or lower than the nominal levels of one third and two thirds of the supply voltage.
Varying the voltage at this point will vary the timing. This feature of the timer opens a multitude
of application possibilities such as using the timer as a voltage-controlled oscillator, pulse-width
modulator, etc. For applications where the control voltage function is not used, it is strongly
recommended that a bypass capacitor (0.01mF) be placed across the control voltage pin and

10
ground. This will increase the noise immunity of the timer to high frequency trash which may
monitor the threshold levels causing timing error.
2.2.6 Modes of operation

The timer lends itself to three basic operating modes


a) Monostable (one-shot)
This is one of the simplest and most widely used operating modes of the timer is the monostable
(one-shot). This configuration requires only two external components for operation (see Figure
2.5). The sequence of events starts when a voltage below one third VCC is sensed by the trigger
comparator. The trigger is normally applied in the form of a short negative-going pulse. On the
negative-going edge of the pulse, the device triggers, the output goes high and the discharge
transistor turns off. Note that prior to the input pulse, the discharge transistor is on, shorting the
timing capacitor to ground. At this point the timing capacitor, C, starts charging through the
timing resistor, R. The voltage on the capacitor increases exponentially with a time constant
T=RC. Ignoring capacitor leakage, the capacitor will reach the two thirds VCC level in 1.1 time
constants or
t = 1.1 RC
Where T is in seconds, R is in ohms, and C is in Farads.

Figure 2.7 Schematic of a 555 in monostable mode

This voltage level trips the threshold comparator, which in turn drives the output low and turns
on the discharge transistor. The transistor discharges the capacitor, C, rapidly. The timer has
completed its cycle and will now await another trigger pulse. [7]

11
b) Astable (oscillatory)
Here pins 2 and 6 are connected so the circuit will trigger itself each timing cycle, thereby
functioning as an oscillator. Capacitor C charges through R1 and R2 but discharges through R2.
The charge on C ranges from V to V . [10]

Figure 2.8 Standard 555 astable circuit


The oscillator frequency is given by:
.
f=( )

The high time from each pulse is given by:


t1=0.693(R1+R2)C
And the low time from each pulse is given by
t2=0.693.R2.C
c) Bistable
In bistable mode, the 555 timer acts as a basic flip-flop. The trigger and reset inputs (pins 2 and 4
respectively on a 555) are held high via Pull-up resistors while the threshold input (pin 6) is
simply floating. Thus configured, pulling the trigger momentarily to ground acts as a 'set' and
transitions the output pin (pin 3) to Vcc (high state). Pulling the reset input to ground acts as a
'reset' and transitions the output pin to ground (low state). No capacitors are required in a bistable
configuration. Pin 5 (control) is connected to ground via a small-value capacitor (usually 0.01 to
0.1 uF); pin 7 (discharge) is left floating. [11]

12
Figure 2.9 Schematic of a 555 in Bistable Mode

2.3 MICROCONTROLLER

A microcontroller is a computer-on-a-chip, or, if you prefer, a single-chip computer.


Microsuggests that the device is small, and controller tells you that the device might be used to
control objects, processes, or events. Another term to describe a microcontroller is embedded
controller, because the microcontroller and its support circuits are often built into, or embedded
in, the devices they control.
You can find microcontrollers in all kinds of things these days. Any device that measures, stores,
controls, calculates, or displays information is a candidate for putting a microcontroller inside.
The largest single use for microcontrollers is in automobilesjust about every car manufactured
today includes at least one microcontroller for engine control, and often more to control
additional systems in the car. In desktop computers, you can find microcontrollers inside
keyboards, modems, printers, and other peripherals. In test equipment, microcontrollers make it
easy to add features such as the ability to store measurements, to create and store user routines,
and to display messages and waveforms. Consumer products that use microcontrollers include
cameras, video recorders, compact-disk players, and ovens. And these are just a few examples.

A microcontroller is similar to the microprocessor inside a personal computer. Examples of


microprocessors include Intels 8086, Motorolas 68000, and Zilogs Z80. Both microprocessors
and microcontrollers contain a central processing unit, or CPU. The CPU executes instructions
that perform the basic logic, math, and data-moving functions of a computer. To make a
complete computer, a microprocessor requires memory for storing data and programs, and
input/output (I/O) interfaces for connecting external devices like keyboards and displays.

In contrast, a microcontroller is a single-chip computer because it contains memory and I/O


interfaces in addition to the CPU. Because the amount of memory and interfaces that can fit on a
single chip is limited, microcontrollers tend to be used in smaller systems that require little more
than the microcontroller and a few support components. Examples of popular microcontrollers
are Intels 8052 (including the 8052-BASIC, which is the focus of this book), Motorolas
68HC11, and Zilogs Z8. [12]

13
2.3.1 Types of Microcontrollers

Microcontrollers can be classified according to the following


a) Number of Bits

The bits in microcontroller are 8-bits, 16-bits and 32-bits microcontroller.

In 8-bit microcontroller, the point when the internal bus is 8-bit then the ALU is performs the
arithmetic and logic operations. The examples of 8-bit microcontrollers are Intel 8031/8051,
PIC1x and Motorola MC68HC11 families.

The 16-bit microcontroller performs greater precision and performance as compared to 8-bit. For
example 8 bit microcontrollers can only use 8 bits, resulting in a final range of 000 0xFF (0-
255) for every cycle. In contrast, 16 bit microcontrollers with its 16 bit data width has a range of
00000 0xFFFF (0-65535) for every cycle. A longer timer most extreme worth can likely
prove to be useful in certain applications and circuits. It can automatically operate on two 16 bit
numbers. Some examples of 16-bit microcontroller are 16-bit MCUs are extended 8051XA,
PIC2x, Intel 8096 and Motorola MC68HC12 families.

The 32-bit microcontroller uses the 32-bit instructions to perform the arithmetic and logic
operations. These are used in automatically controlled devices including implantable medical
devices, engine control systems, office machines, appliances and other types of embedded
systems. Some examples are Intel/Atmel 251 family, PIC3x.

b) Memory Devices

The memory devices are divided into two types, they are

o Embedded memory microcontroller


o External memory microcontroller
o Embedded memory microcontroller: When an embedded system has a microcontroller
unit that has all the functional blocks available on a chip is called an embedded
microcontroller. For example, 8051 having program & data memory, I/O ports, serial
communication, counters and timers and interrupts on the chip is an embedded
microcontroller.

o External Memory Microcontroller: When an embedded system has a microcontroller unit


that has not all the functional blocks available on a chip is called an external memory
microcontroller. For example, 8031 has no program memory on the chip is an external
memory microcontroller.

14
c) Instruction set

ISC: CISC is a Complex Instruction Set Computer. It allows the programmer to use one
instruction in place of many simpler instructions.

RISC: The RISC is stands for Reduced Instruction set Computer, this type of instruction sets
reduces the design of microprocessor for industry standards. It allows each instruction to operate
on any register or use any addressing mode and simultaneous access of program and data.

Example for CISC and RISC:

CISC: Mov AX, 4 RISC: Mov AX, 0

Mov BX, 2 Mov BX, 4

ADD BX, AX Mov CX, 2

Begin ADD AX, BX

Loop Begin

From above example, RISC systems shorten execution time by reducing the clock cycles per
instruction and CISC systems shorten execution time by reducing the number of instructions per
program. The RISC gives a better execution than the CISC.

d) Memory Architecture

Memory architecture of microcontroller are two types, they are namely:

o Harvard memory architecture microcontroller


o Princeton memory architecture microcontroller

Harvard Memory Architecture Microcontroller: The point when a microcontroller unit has a
dissimilar memory address space for the program and data memory, the microcontroller has
Harvard memory architecture in the processor.

15
Princeton Memory Architecture Microcontroller: The point when a microcontroller has a
common memory address for the program memory and data memory, the microcontroller has
Princeton memory architecture in the processor. [13]

2.3.2 Atmega based microcontrollers

They include the atmega 8, 16, 32, 64 and 128 microcontrollers. Atmega 8 is normally a low
power complementary metal oxide semiconductor (CMOS) 8-bit microcontroller based on the
AVR enhanced RISC architecture. It is a powerful microcontroller that provides a highly flexible
and cost effective solution to many embedded control applications. The Atmega 8 AVR is
supported with a full suite of program and system development tools. Furthermore, this
microcontroller has an in-built 10-bit successive approximation ADC. Atmega 16, 32, 64 and
128 microcontrollers have similar features to atmega 8 only that atmega 16, 32, 64 and 128 have
16, 32, 64 and 128 bits respectively.
The AtmelAVR ATmega8 is a low-power CMOS 8-bit microcontroller based on the AVR
RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8
achieves throughputs approaching 1MIPS per MHz, allowing the system designer to optimize
power consumption versus processing speed. [14]

Figure 2.1.0 Arduino Pin Mapping

16
2.4 ARDUINO

Arduino is a tool for making computers that can detect and control more of the physical world
than compared to a desktop computer. It's an open-source physical computing platform based on
a simple microcontroller board, and a development environment for writing software for the
board. Arduino can be used to develop interactive objects, taking inputs from a variety of
switches and sensors, and controlling a variety of lights, motors etc. Arduino projects can be
stand-alone, or they can communicate with software running on your computer (e.g. Flash,
Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled; the
open-source IDE can be downloaded for free. The Arduino programming language is an
implementation of Wiring, a similar physical computing platform, which is based on the
Processing multimedia programming environment. [15]
The Arduino environment has been designed to be easy to use for beginners who have no
software or electronics experience. With Arduino, you can build objects that can respond to
and/or control light, sound, touch, and movement. Arduino has been used to create an amazing
variety of things, including musical instruments, robots, light sculptures, games, interactive
furniture, and even interactive clothing.
Arduino is famously known for its hardware, but you also need software to program that
hardware. Both the hardware and the software are called Arduino. The combination enables
you to create projects that sense and control the physical world. The software is free, open
source, and cross-platform. The boards are inexpensive to buy, or you can build your own (the
hardware designs are also open source). In addition, there is an active and supportive Arduino
community that is accessible worldwide through the Arduino forums and the wiki (known as the
Arduino Playground)

2.4.1 Arduino Software

Software programs, called sketches, are created on a computer using the Arduino integrated
development environment (IDE). The IDE enables you to write and edit code and convert this

17
code into instructions that Arduino hardware understands. The IDE also transfers those
instructions to the Arduino board (a process called uploading).

2.4.2 Arduino Hardware

The Arduino board is where the code you write is executed. The board can only control and
respond to electricity, so specific components are attached to it to enable it to interact with the
real world. These components can be sensors, which convert some aspect of the physical world
to electricity so that the board can sense it, or actuators, which get electricity from the board and
convert it into something that changes the world. Examples of sensors include switches,
accelerometers, and ultrasound distance sensors. Actuators are things like lights and LEDs,
speakers, motors, and displays. There are a variety of official boards that you can use with
Arduino software and a wide range of Arduino-compatible boards produced by members of the
community. The most popular boards contain a USB connector that is used to provide power and
connectivity for uploading your software onto the board. The figure 2.9 shows a basic a basic
board, the Arduino Uno [16]

Figure 2.11 Basic Board: Arduino Uno

18
2.4.2 Pulse Width Modulation

The Arduino Uno ON/HIGH/5V and OFF/LOW/0V digital outputs are termed as a square wave.
The duration of the ON time is what is known as pulse-width and when the width pulse is varied
rapidly to generate an effect of what seems as an analog voltage signal, then the output is termed
a PWM signal. The signal looks somewhat as what is shown below: [17]

Figure 2.12 Arduino PWM signals

2.5 ELECTRIC FENCE ENERGIZER

The source of the shock in an electrical fence is the energizer. The energizer provides regular
pulses of electricity to your fence. These intermittent high voltage pulses flow from the
energizer, along connection cable to the fence, and then along the length of the fence. The live
wires of your fence should not come into contact with fence posts or corner posts, and this
achieved by the use of insulators. [17]

19
2.5.1 Types of Energizers

Electric fence energizers are categorized according to their source of power and their ratings.
A. Source of power

i. Mains Energizers This is the most recommended as mains power is reliable and it is
cheaper to run and less hassle than battery powered systems. It is very simple to use as
one plugs the energizer into the mains, the energizer converts the power to pulses and the
pulses are taken out to your fence through lead out cable. Lead out cable comes in 25m,
50m and 100m lengths and can also be joined to cover longer distances.

Figure 2.13 Mains Energizer

ii. Battery Energizers This type of energizer is comes in handy when the fence is far away
from the mains supply. Energizers can be powered by different batteries:

(a) D-Cell battery (a size of dry cell) powered energizer for small distances, strip
grazing, small gardens and pond protection (up to approx. 400m).
(b) 6 or 9 Volt battery energizers which are very portable, light-weight. These
energizers have excellent battery life and are normally housed within the
energizer making it compact and easy to transport. These batteries are non-
rechargeable hence disposable
(c) 12 Volt battery energizers which are the most powerful of the battery category.
Re-chargeable batteries are used to make sure one has a replacement when
charging is taking place. A leisure battery (a lead-acid battery meant to be
regularly discharged) is used as opposed to car batteries which are designed to
release power quickly and so need charging every couple of days. Leisure

20
batteries are slow release and last up to 4-6 weeks.

Figure 2.14 Battery Energizer

iii. Solar Solar powered energizers are helpful when charging batteries becomes
cumbersome since it can be tiring too. The panels will extend the life of your battery
according to how powerful the energizer is since the more the energizer is powerful, the
higher watts solar panels you will require.A solar energizer has an integral solar panel
that is permanently fitted onto the energizer these energizers still require a 12v leisure
battery.A Solar Assist System is a solar panel that has a stand and directly connected onto
a 12v battery and can be fitted to almost all energizers that are powered by battery.

Figure 2.15 Solar Energizer

B. Energizer ratings

Energizers can be compared according to the following ratings:


i. Stored Energy The energizer takes power from a power source (mains or battery) and
through its storage capacitors, the energizer accumulates this power and it is this

21
energythat gives the energizer the power it creates. The amount of energy that can be
stored is proportional to the length of the fence that the energizer can power.
ii. Output Energy The energy stored in the energizer is usually discharged through an
output transformer going to the fence lines. It is inevitable that some energy is lost in this
process and hence the output energy is always lower than what was stored. This output
energy is the energy that goes down the fence and is measured in joules.

iii. Power Consumption Depending on how powerful the energizer is, the power source
will be used accordingly. The length and type of fence is hence taken into consideration
carefully.

iv. Distance This is estimated maximum distance the energizer will power and assumes a
suitable earth system and perfect conditions of the fence.[18]

2.6 IGNITION COIL

An ignition coil, also known as a spark coil, is an induction coil in a cars ignition system that
steps up the batterys low voltage of 12V to kilovolts necessary to create an electric spark in the
cars spark plugs to ignite the fuel. It consists of a laminated iron core enclosed by two copper
wire coils but unlike a power transformer, an ignition coil has an open magnetic circuit. This
means that around the windings, the iron core doesnt for a closed loop and hence the energy
stored in the core magnetic field is the energy that is transferred to the spark plug. [19]

Figure 2.16 Spark plug

22
The diagram below illustrates the ignitions coil set up:

Fig 2.17 Ignition coil constituents

2.6.1 Principle of Operation

The coil is usually inserted inside a plastic or metal can with insulated terminals for the high
voltage and low voltage connections. The primary winding is made of several hundred turns of
heavy wire and just inside it, the secondary winding is situated consisting of several thousand
turns of fine wire. These are wrapped around an iron core in the center. When current from the
battery is conducted through the primary winding, a strong magnetic field builds up around the
iron core. When the current flowing is interrupted by the breaker points or by a solid-state device
in an electronic ignition, the magnetic field drops across the secondary winding. Since the
secondary winding has more turns than the primary, high voltage is then induced into the
secondary winding. And it is this high voltage then shoots out of the center terminal of the
distributor, which is attached to the iron core. [20] The voltage output is very high but with a low
amperage hence non-lethal when comes to contact with someone touching the fence.

23
2.6.2 Types of ignition coils

Over the last few decades, car ignition technology has developed significantly and therefore,
several new ignition coil types have been developed. Depending on how old a vehicle is, the
engine design and the ignition system, any of the following designs of ignition coils might be
used:
1. Can-type ignition coils:
In older vehicles and antique cars, this type of ignition coil is what may be found to be
used. Some older versions of this type are filled with oil which is to act as a coolant and
also as an insulator but most have a more modern dry insulation design.
2. Distributor coils:
For this type, the induced high voltage reaches the individual spark plugs Through a
distributor mechanism that is. This type is an evolution of the can-type coil and were
widely used until the 1990s.
3. Ignition blocks:
Ignition blocks contain several ignition coils, which are connected by high tension cables
to each plug each. This type of ignition coil is available in single or dual spark
technology. In single-spark ignition blocks, each of the ignition cable supplies the high
voltage pulse to one cylinder while in dual-spark blocks, the high voltage pulse is fed
simultaneously to two cylinders.
4. Pencil or coil on plug ignition coils:
This ignition coil type is located directly on top of the spark plug. The high voltage pulse
is taken straight to the spark plug, reducing power loss. Since pencil ignition coils are
found in the spark plug tunnel, they dont occupy a lot of space in the engine
compartment. Pencil ignition coils are used in cars with electronic ignition systems and
they are also available as single-spark or dual-spark coils.
5. Ignition coil pack systems:
So called coil packs combine a number of pencil ignition coils mounted within a single
component known as a rail. This rail is then placed across a bank of several spark plugs.
[21]

The diagram below shows all of the above 5 types of ignition coils:

24
Figure 2.18 Types of ignition coils

2.7 RELAY SWITCH

Relays switches that are electro magnetically operated where an actuating current on isolated
load circuits or contacts. It is hence an electrically operated switch that makes it possible for one
circuit to be switched on by another circuit that is separate.
Galvanic isolation is where functional parts of an electrical system are isolated to prevent flow of
current prohibiting any conduction path. [23]
Current flowing through the coil of the relay generates a magnetic field that attracts and pulls
lever and changes the switch contacts. Since the current in the coil can be on or off, relays have
two switch positions and they are double throw.

Figure 2.19 Electromagnetic or mechanical relay

The connections on the relay are usually labeled COM (POLE), NC and NO as shown in the
diagram above.

25
COM/POLE= Common, NC and NO always connect to this, it is the moving part of the switch.
NC = Normally Closed, COM/POLE is connected to this when the relay coil is not magnetized.
NO = Normally Open, COM/POLE is connected to this when the relay coil is MAGNETIZED
and vice versa.

2.7.1 Functions of a Relay Switch

The primary functions of a relay are as follows:


a) Separating different load circuits for multi-pole relays.
b) Interfacing power circuits and electronic circuits.
c) It performs several switching functions e.g. delay, signal conditioning.
d) Separating DC circuits from AC circuits.

2.7.2 Applications of Relay

Relays have got so many applications. The following are some of the applications:
i. Computer interfaces.
ii. Air conditioning and heating.
iii. Automotive electrics.
iv. Control of motors and solenoids.
v. Electric power control.
vi. Production and test equipment.
vii. Lighting control.

2.8 OP-AMP

An operational amplifier (op-amp) is a DC-coupled high gain electronic voltage amplifier with a
differential input and usually a single-ended output. The op-amp is a high performance linear
amplifier that has a variety of uses. The op-amp has two inputs; the inverting input (-) and the
non-inverting input (+) and one output. The polarity of a signal applied to the inverting input is
hence reversed at the output while when the same signal is applied to the non-inverting input
retains its polarity at the output.

26
Figure 2.20 Ua741 op-amp

2.8.1 Circuit Notation


Below are the op-amp circuit symbols where:
V+: non-inverting input
V: inverting input
Vout: output
VS+: positive power supply
VS: negative power supply

Figure 2.21 Circuit diagram symbol for op-amp

27
2.8.2 Principle of operation

The amplifier's differential inputs are the non-inverting input (+) with voltage V+ and an
inverting input () with voltage V as described earlier. Ideally, the op-amp usually amplifies
only the difference in voltage between the two input voltages, which is called the differential
input voltage. And hence, the output voltage of the op-amp Vout is given by the equation:

WhereAOLis known as the open-loop gain of the amplifier. The term open-loop means that the
feedback loop is absent from the output to the input.
A. Open loop
The AOL value most of the times is usually very large (in the ranges of 100,000 or more) for any
IC op-amp. Thus, a small difference in the values of V+ and V drives the output of the amplifier
to near the supply voltage.

Fig 2.22 An op-amp without negative feedback (a comparator)

B. Closed loop

Figure 2.23 An op-amp with negative feedback (a non-inverting amplifier)

28
Negative feedback is used when a predictable operation is required. It is done by applying a
portion of the output voltage back to the inverting input and the closed loop feedback greatly
reduces the circuits gain. Hence, when using a negative feedback the overall gain and response
of the circuit is mostly determined by the feedback network.The op-amp circuits response with
its input, output and feedback circuits to an input is related mathematically using a transfer
function which is very important in many op-amps like in analog computers. High input
impedance at the input terminals and the low output impedance at the output terminal are very
useful op-amp features.
In the non-inverting amplifier given in the figure above, the presence of negative feedback via
the voltage divider Rf,Rg determines the closed loop-gain ACL = Vout / Vin. When Voutis enough to
pull the inverting input to equal Vin equilibrium will be. The voltage gain of the entire circuit is
thus 1 + Rf/Rg. Taking for example, if Vin = 1 V and Rf = Rg, Vout will be 2 V, exactly the amount
required to keep V at 1 V. Because of the feedback provided by the Rf, Rg network, this is circuit
is a closed loop one.
The closed-loop gain ACL is given by:

[24]

2.9 COMPARATOR

A comparator is a circuit that compares an input voltage to a given reference voltage and changes
the state of its output when the input has been exceeded. The decision-making ability is very
important and has many applications.
An op-amp without a feedback resistor is used to make a simple analog comparator. [25]

Figure 2.24 A simple op-amp comparator

29
2.9.1 Principle of operation

Given that the non-inverting input (V+) is at a higher voltage than the inverting input (V-), the
high gain of the op-amp will cause the output to saturate at the highest positive voltage that it can
output. And when the non-inverting input (V+) drops below the inverting input (V-), the output
then saturates at the most negative voltage it can output. The op-amp's output voltage is limited
by the supply voltage. An op-amp that is operating in a linear mode with negative feedback,
using a balanced, split-voltage power supply, (powered by VS) has its transfer function
typically written as:

However, this equation may not be applicable to a comparator circuit which is non-linear and
operates open-loop (no negative feedback).

2.9.2 Key Specifications

Several parameters must be considered while selecting a suitable comparator:


a) Speed and power.
b) Hysteresis.
c) Output type.
d) Internal reference. [26]

CHAPTER 3: DESIGN AND IMPLEMENTATION

The electric fence energizer to be designed is unique in that generation of shock is to be


controlled using a microcontroller where it generates PWM pulses of 5V magnitude and sends
them to an ignition coil that steps the pulses to around 12KV. This method of generating pulses
is advantageous in that the micro-controller generates accurate pulses.
The system consists of three parts namely:

30
i. Alarm system(555 siren generator).
ii. Generation of shock.
iii. Voltage sensing comparator.
3.1 DESIGN OF 555 SIREN GENERATOR

Figure 3.1 555 Siren generator circuit

The above circuit shows the circuit model of a typical 555 timer IC siren generator. The two
NE555 timers used are both connected in their astable mode of operation and a speaker is
connected at the output of IC2 to create a police siren tone. The circuit above is powered by a
12V dc power supply but the circuit can be powered from anything between 6 to 15V DC and is
fairly loud.

IC1 is connected as a slow astablemultivibrator and the frequency at which it is operating at can
be calculated as follows:
.
f=( )
=0.7059 Hz

31
The diode between pins 6 and 7 of IC1 functions to allow current only in its forward direction
hence this makes the current to flow only in one direction so that the pulse generated will be
reduced to half. This is to say that the duty cycle will be set to 50%.
IC2 is then connected as a fast astablemultivibrators operating at high frequencies of:
.
f= ( )
=480 Hz

The output of IC1 is then connected to the control voltage pin (pin 5) of IC2 and in doing so, the
output of IC2 is modulated by the frequency of IC1. It is this modulating effect that gives the
siren effect.
A speaker is then connected out of IC2 pin 3so as to produce the siren sound. The loudness of the
siren can be further increased by connecting a power amplifier then to the speaker.

3.2 DESIGN OF FENCE ENERGISER

The fence energizer consists of an Arduino board whose microcontroller generates PWM pulses
and an ignition coil that will step up the generated pulses to kilovolts. These pulses are then
output from the positive terminal of the secondary side of the ignition coil and to the fence which
will give a painful but non-lethal sensation when touched by either a person or an animal.

3.2.1 Generation of PWM pulses using Arduino Uno

The advantage of the Arduinos programming language is that it makes PWM very easy to
implement by simply calling analogWrite (pin, dutyCycle), where dutyCycle is usually a value
from 0 to 255 since the Atmega328 is an 8 bit microcontroller. Pin is one of the PWM pins (3, 5,
6, 10, 11). The analogWrite gives a simple interface to the hardware PWM but it is
disadvantageous in that it doesnt provide any control frequency.
It is due to this that I will proceed to generate PWM pulses using the bit-banging method. What
this means is that you can manually implement PWM on any pin repeatedly by turning the pin
ON and OFF for the desired times.
Choosing pins 10 and 13 on the Arduino board to output the required PWM pulses, a sketch of
the program will be provided at the end of this report specifically in the Appendix section. Pins
generated from pin 10 serve as signals to the inverting input of a comparator for voltage
comparison functionality as will be discussed late or while pulses from pin 13 will be taken to
the ignition coil for stepping up. However, the following is a flow chart illustrating how it goes
about to generate the pulses:

32
Start

Take Pin 13
to HIGH
(5V)

Wait for 2
milliseconds

Set pin 13 to Wait for 18


LOW (0V) process milliseconds
Figure 3.2 Flow chart of the Arduino sketch execution

The generated PWM pulses will be of 5V value, they will have to be amplified to near values of
12V before going to the ignition coil for stepping up purposes. Operational amplifiers, op-amps,
were implemented to amplify these pulses.

33
3.2.2 Generation of shock

Figure 3.3 Generating PWM pulses and amplifying them to 12V

Pulses from the digital pin 13 of the Arduino are at 5V and passing them through the first op-
amp U1 amplifies it. Since the op-amp is connected as an inverting amplifier, the gain supplied is
a negative gain. The voltage output is calculated as follows:

2.4 10
= 5 = 12
1 10

34
Since the gain was negative, the output too is negative so we pass these -12V signals through
another op-amp with a gain of -1 and hence the calculation of the U2 op-amp out is as follows:

1 10
= 12 = 12
1 10

The output of U2 then taken to the primary terminal of ignition coil. The ignition coil was
simulated in Proteus Simulation Software as a step-up with a turn ratio of 1:1000. The turn ration
was set in the properties of the Proteus simple transformer using the fokkowing relationship
between turns ratio with the inductance of the transformers primary and secondary sides:

= =

Where N1=number of turns of primary winding


N2 =number of turns of secondary winding
V1 =voltage applied on the primary side of the transformer
V2 =voltage induced on the secondary side of the transformer
L1 =inductance on the primary winding
L2 =inductance on the secondary winding

Therefore, to give the simple transformer a turns ratio = , we set 1 = 1 and 2 =


1000 .

Start

35
Pass the
pulses
through U1

Pass the
pulses
through U2

Take the
amplified pulses
to positive
terminal of coil

Output the
stepped up
pulses to the
fence line

Figure 3.4 Flow chart showing the generation of shock pulses

36
3.2.3 Voltage sensing comparator

Figure 3.5 Voltage comparator sensing circuit

As seen from above, it is the same circuit used to generate shock but with the addition of another
pair of op-amps that are fed from the same Arduino digital output 13 and function the same way
as the op-amps discussed in the previous article outputting another set of 11.8V pulses. This
pulses are then directed to the non-inverting input of the comparator where it will be used as a
reference voltage. The inverting input of the comparator is then connected at the input of the coil
where it will monitor the primary side voltage. When no one is touching the fence, V->V+ the
comparator wont be outputting any voltage since the output will be a 0.
When a load is connected across the secondary coil of the transformer, the load current flowing
through the secondary coil will produce a magnetic field which will act to neutralize the
magnetic field that is produced by the primary current. This will reduce the self-induced
(opposition) voltage in the primary coil and in turn allow more primary current to flow. The
primary current increases as the secondary load current increases, and decreases as the secondary
load current decreases. When the secondary load is removed, the primary current is again
reduced to the small exciting current that is enough for purposes of magnetizing the iron core of
the transformer.

37
Using the above knowledge and knowing that a human being has a resistance of nearly 100k,
when someone now touches the fence line that is connected to the positive terminal of the
secondary coil that person will create a short circuit. This means that current flowing on the
secondary side increases hence decreasing the voltage decreases. This affects the primary side in
that the applied voltage will in turn reduce and more primary current will flow. This drop of
about 0.5V will be seen at V- which will now be at 11.5V and since now V-<V+, the comparator
will output a 1 that is a 5V that will magnetize the coil on the relay switching the alarm circuit.
When the person gets the sting of the shock and breaking contact with the line fence, the initial
conditions would be reset and the system return in its default state and the alarm tone will stop.

3.2.4 The complete system circuit

The following is a circuit showing the complete system designed:

Figure 3.6 The complete system circuit

38
CHAPTER 4: RESULTS AND ANALYSIS

4.1 Alarm circuit results

The following waveforms were obtained from the output of the second 555 timer in the alarm
circuit:

Figure 4.1 High frequency waveforms

Period=1 millisecond
1 1
= = = 1000
1 10
Vpeak = 2V

39
Figure 4.2 Low frequency waveforms

Period = 2 millisecond
1
= = 500
2 10

The above two waveforms of high and low frequencies from the second and first ICs
respectively indicate the siren like sound output at the speaker for the alarm.

4.2 Shock generation circuit results

The Arduino digital pin 13 output of PWM pulses were captured in the simulation software:

40
Figure 4.3 Arduino Uno pin 13 PWM generated pulses

The total time period is 5 4 = 20 but the pulses are on for only 2ms hence the duty
cycle 100% = 10%

The figure below shows the ignition coil out in the Proteus simulation

41
Figure 4.4 Transformer secondary side voltage
The generated output observed is 11,538V from the Proteus software.

CONCLUSION

From the results obtained, pulses were generated and stepped up to produce shock of magnitude
11,538V. This was noted to be lower than the expected 12,000V due to power losses that occur
within a transformer. Also the results obtained were from a simulation, because the measuring
instruments from the department high voltage lab were analog instruments and would not be
capable to measure pulses of such high voltages. Time was also a major limitation faced, hence
simulation results were opted for. With this, a system was successfully constructed that would
accurately produce pulses and generate them to high voltages that were of low amperage to
deliver a painful but non-lethal shock.

APPENDIX

ARDUINO SKETCH USED TO GENERATE PWM

void setup()
{
pinMode(13, OUTPUT);
}

42
void loop()
{
digitalWrite(13, HIGH);
delayMicroseconds(2000); // Approximately 10% duty cycle @ 50Hz
digitalWrite(13, LOW);
delayMicroseconds(20000 - 2000);
}

REFERENCES

[1] P. Goldsmith, Legend: From Electric Fences to Global Success: The Sir William Gallagher
Story, Random House New Zealand, 2013.

[2] G. A. F. a. S. T. Limited, Introduction to Electric Security Fencing, Kfar Saba: G.M


Advanced Fencing and Security Technologies Limited, 2013.

[3] L. Brown, Introduction to Electric Fencing, Abbotsford: British Columbia, 1996.

[4] A. Store, "Agrisellex Electric Fencing," 2011. [Online]. Available:


http://www.agrisellex.co.uk/information/how-a-fence-works.html. [Accessed Saturday
March 2014].

[5] G. A. M. Systems, "Gallagher," 2008-2014. [Online]. Available:


http://www.gallagherusa.com/electric-fencing/electricfence101.aspx. [Accessed March
2014].

[6] G. A. M. Systems, "Gallagher," [Online]. Available: http://www.gallagherusa.com/electric-


fencing/types/. [Accessed March 2014].

[7] P. Semiconductors, NE555 and NE556 applications, Amsterdam: PHILIPS, 1988.

[8] W. Jack, The 555 Timer IC-An Interview with Hans Camenzind, The Semiconductor
Museum, 2010.

[9] Circuitstoday.com, "Circuits Today," 2007-2011. [Online]. Available:


http://www.circuitstoday.com/555-timer. [Accessed March 2014].

43
[10] F. Mimms, Forrest Mims-engineer's mini-notebook 555 timer circuits (radio shack
electronics), Forrest Mimms.

[11] W. Foundation, "Wikipedia," 05th March 2014. [Online]. Available:


http://en.wikipedia.org/wiki/555_timer_IC. [Accessed 23rd March 2014].

[12] J. Axelson, The Microcontroller Idea Book, Madison: Lakeview Research, 1997.

[13] Pyrite Technologies, "ELPROCUS," 2013. [Online]. Available:


http://www.elprocus.com/microcontrollers-types-and-applications/. [Accessed March 2014].

[14] ATMEL, Atmega8, San Jose: Atmel Corporation, 2013.

[15] Arduino, "ARDUINO," 2014. [Online]. Available:


http://arduino.cc/en/Guide/Introduction#.Uy9AU_mSwTg. [Accessed March 2014].

[16] M. Margolis, Arduino Cookbook, Sebstopol: Michael Margolis and Nicholas Weldin, 2011.

[17] Asian Insitute of Technology, Arduino Tutorial \Pulse Width Modulation & Analog Input",
2012.

[18] Dakenag, Electric Fencing Manual, Asquith: Clark Equipment, 2009.

[19] F. C. Ltd, "About EFD," 2013. [Online]. Available:


http://www.electricfencing.co.uk/electric-fencing-energiser/. [Accessed April 2014].

[20] WikiMedia Foundation, "WIKIPEDIA The Free Encyclopedia," 18 April 2014. [Online].
Available: http://en.wikipedia.org/wiki/Ignition_coil.

[21] INTERNATIONAL auto parts, [Online]. Available: http://www.international-auto.com/fiat-


lancia-electrical-system/ignition-basics-the-coil.cfm.

[22] EQTwo, "NGK Spark plugs," 2010. [Online]. Available:


http://ngkntk.co.uk/index.php/technical-centre/ignition-coils-tec/ignition-coils-types/.
[Accessed 2014].

[23] OEN India Limited, RELAY BASICS, OEN India Limited.

[24] Wikimedia Foundation, "WIKIPEDIA The Free Encyclopedia," 21 April 2014. [Online].
Available: http://en.wikipedia.org/wiki/Operational_amplifier#Applications.

[25] F. Mims, "THE FORREST MIMS CIRCUIT SCRAPBOOK VOLUME I," 2010, p. 10.

[26] Wikimedia Foundation, "WIKIPEDIA The Free Encyclopedia," 19 April 2014. [Online].
Available: http://en.wikipedia.org/wiki/Comparator.

44
45

Anda mungkin juga menyukai