Professional Documents
Culture Documents
We hereby declare that this is our work and that it has not been submitted before anywhere
for the purpose of awarding a degree to the best of our knowledge.
JUDE CHINOSO VIOLET DATE
..
AJAYI TEMITOPE RACHEAL DATE
WALKER ENAEFE HILARY DATE
..
GONU SHOLA DATE
i
CERTIFICATION
This is to certify that the DESIGN AND CONSTRUCTION OF A 3KVA
MICROCONTROLLER BASED INVERTER WITH CONTROLLED OUTPUT was carried
out by JUDE CHINOSO VIOLET, WALKER ENAEFE HILARY, AJAYI TEMITOPE
RACHAEL and GONU SHOLA under the guidance of Engr. C. K. Igbinoba and has been
duly approved for acceptance by the department of Electrical and Electronic Engineering,
College of Technology Federal University of Petroleum Resources Effurun Delta State,
Nigeria for the award of the Bachelor of Engineering Degree(B.Eng) in Electrical and
Electronics Engineering.
ENGR. C. K. IGBINOBA DATE
(Project Supervisor)
..
ENGR. DR. J. E. OKIAIFOH DATE
(Head of Department)
ii
DEDICATION
We dedicate this project to all the lovers of Engineering in the world.
iii
ACKNOWLEDGMENTS
First, we are grateful to Almighty God for His wisdom, and the grace to learn as quickly as
possible on this project, and that He has seen us through to the end.
We grateful to our supervisor Mr. C. K. Igbinoba for his guidance up to know and through
the length of the project.
And to Engr. Dr. G. Ofualagba for his support through the project, to Mr. Josiah for his
expert advice during the length of the project.
Lastly, to all the lecturers of the department for the way they have equipped us with things we
should know about till now.
iv
ABSTRACT
The aim of this project is to design and construct a 3 KVA microcontroller based pure sine
wave inverter with controlled output. A system that will convert the DC voltage from a
battery source to 230 VAC at a frequency of 50Hz. The controlled output will be used to shut
down heavy loads when the battery voltage reaches 22 VDC.
The system was constructed and tested by connecting a 24 VDC battery to the inverter input,
and the inverter gave 230 VAC at the output. A load of 1 KVA was connected to the
controlled output and the output was cut-off when the battery level dropped to 22 VDC
leaving the other output ON. The entire system was cut-off when the battery voltage dropped
to 20 VDC.
v
TABLE OF CONTENTS
DECLARATION ........................................................................................................................ i
CERTIFICATION .....................................................................................................................ii
ACKNOWLEDGMENTS ........................................................................................................ iv
ABSTRACT ............................................................................................................................... v
ABBREVIATIONS .................................................................................................................. xi
INTRODUCTION ..................................................................................................................... 1
vi
2.3.2 Micro-controller....................................................................................................... 8
CHAPTER 3 ............................................................................................................................ 15
CHAPTER 4 ............................................................................................................................ 35
vii
4.1 IMPLEMENTATION ................................................................................................... 35
4.3 RESULTS...................................................................................................................... 40
CHAPTER 5 ............................................................................................................................ 44
REFERENCES ........................................................................................................................ 45
APPENDIX .............................................................................................................................. 47
viii
LIST OF FIGURES
Figure 2.2: H-Bridge Configuration using N-Channel MOSFETs ............................................ 5
Figure 2.3: MOSFET symbol .................................................................................................... 7
Figure 2.5: A simple electromechanical relay ........................................................................ 11
Figure 2.6: cross section of a power MOSFET........................................................................ 12
Figure 2.7: MOSFET characteristics ....................................................................................... 13
Figure 2.8: Schematic diagram of an opto-isolator .................................................................. 13
Figure 3.1: Block diagram of pure sine wave inverter............................................................. 15
Figure 3.2: graph of sinewave against duty cycle .................................................................... 16
Figure 3.3: internal structure of the PIC18F2550 chip ............................................................ 20
Figure 3.4: internal structure of the PIC16F873A chip ........................................................... 21
Figure 3.5: Series Gate Resistance vs. Amplitude of Negative Voltage Spike and Turn-off
time .......................................................................................................................................... 24
Figure 3.6: PWM ripple current flow ...................................................................................... 25
Figure 3.7: IR2110 connection ............................................................................................... 27
Figure 3.8: H-bridge and MOSFET circuit .............................................................................. 29
Figure 3.9: LC filter ................................................................................................................. 30
Figure 3.10: program flowchart ............................................................................................... 31
Figure 3.11: complete circuit diagram ..................................................................................... 32
Figure 4.1: Bobbing cuttings.................................................................................................... 35
Figure 4.2: bobbing after cutting and gluing pieces together .................................................. 36
Figure 4.3: transformer while wearing in the laminations ....................................................... 36
Figure 4.4: MOSFETs and transformer connection with casing ............................................. 37
Figure 4.5: PCB diagram of inverter work .............................................................................. 38
Figure 4.6: Proteus simulation diagram for inverter oscillation .............................................. 40
Figure 4.7: Proteus simulation for charging oscillation ........................................................... 40
Figure 4.8: The inverter when on ............................................................................................. 41
Figure 4.9: The inverter when on ............................................................................................. 41
Figure 4.10: The output sinewave ............................................................................................ 42
ix
LIST OF TABLES
Table 2.1: Valid H-Bridge Switch State .................................................................................... 6
Table 3.1: duty cycles for PWM .............................................................................................. 17
Table 3.2: duty cycle in terms on of time on ........................................................................... 18
Table 4.1 Results table ............................................................................................................. 42
Table 4.2: Bill of Engineering measurement and evaluation ................................................... 43
x
ABBREVIATIONS
MCU Microcontroller unit
ADC Analog to digital converter
IC Integrated circuit
KB Kilobyte
VDD Microcontroller supply voltage
VSS Microcontroller ground
CPU Central processing unit
ROM Read only memory
RAM Random access memory
AC Alternating current
DC Direct current
VDC Direct current voltage
VAC Alternating current voltage
LCD Liquid crystal display
GND Ground
CPU Central processing unit
NO Normally open
NC Normally closed
AVR Automatic voltage regulator
KVA Kilo Volt Ampere
Qg Gate charge of high-side FET
f frequency
ICbs (leak) bootstrap capacitor leakage current
Iqbs (max) Maximum VBS quiescent current
VCC Logic section voltage source
Vf Forward voltage drop across the bootstrap diode
VLS Voltage drop across the low-side FET
VMin Minimum voltage between VB and VS
Qls level shift charge required per
xi
CHAPTER ONE
INTRODUCTION
Power instability in our environment pushes us to generate our own power. Developing
countries which form a majority in African continent have the problem of unstable power
supply, the Nigerian power grid also faces this problem. Nigeria has some major challenges
in its power system: these include Insufficient power generation, overloading of distribution
transformers, vandalism, power infrastructure problems, and so on. Which brings us to the
importance of generating power on the sides to compliment the power supply. Of the several
methods that can be employed in generating self-power, Renewable energy sources form the
largest part.
In renewable energy literature, the words alternative and sustainable are being used to
emphasize the possibility of using sources other than the fossil ones which will never finish.
Whatever they are called, renewable, alternative and sustainable, these energy systems
are planned as the parts of the solution to the energy problem by substituting the fossil
sources with the replenished ones.
Renewable energy is the energy obtained from the continuous or repetitive currents of energy
recurring in the natural environment. To assume any energy flow as renewable it should be
replenished at least at the same rate as it is used. A renewable energy system is an
alternative one, if it is able to provide some or whole part of the energy needs which is met
by the fossil ones. Such a system is also sustainable because the energy supply will sustain
continuously, as the sun continues to shine, gravity applies on objects and the earth rotates.
Fossil fuels, on the other hand, like coal, petroleum and gas are the conventional ones having
no sustainability.
Although problem arise from the type of power generated from renewable energy sources; in
the form of its inconsistency and its output form (direct current) hence the need of an inverter
to be able to convert the DC energy formed to a steady constant frequency Alternating
current form needed for home and industrial applications.
Power inverters are used to convert direct current (DC), such as that from a battery, to
alternating current (AC), such as what can be drawn from a standard wall outlet. These
devices are used in a large number of applications, including conditioning energy derived
1
from solar cells into usable power and supplying electricity to household appliances during
power outages.
Due to the unstable nature of the electricity supply received by consumers of electricity in
Nigeria, many consumers depend on the use of motor generating set as an alternative source
of electricity supply which is noisy, expensive to maintain and causes a lot of pollution.
This research work propose the use of Inverter which is preferred to motor generating sets
because it is noiseless, relatively small in size, maintenance free and pollution-free.
The aim of this project is to design and implement a pure sinewave single phase 3kva inverter
with controlled output which can produce AC power outputs at high efficiency.
The objectives of this project is to design an inverter that will produce an output up to 3 KVA
with input from a 24 V battery and can be used to power AC loads.
The Objectives of the system are
Generation of a pure sine wave output.
Use of microcontroller as the main circuit control component hence reducing the
complexity of the circuit.
Having a controlled output.
To design a system that will make electric power available for 24 hours.
To design a system that will automatically switch of heavy loads when the back-up
battery drops to a certain level.
To design a system that is noiseless.
To design a system that is maintenance free.
To design a system that is pollution free.
This project work focuses on the design of a single phase inverter which can deliver a
maximum power of 3 KVA including the losses by converting the 24 VDC voltage from a
battery bank to an output voltage of 230 (30V).
2
1.5 APPLICATIONS OF PROJECT
This design is suitable for domestic applications, for inductive loads like air conditioners,
refrigerators, air conditioners, pumps, etc. for loads which are very sensitive.
This Project has five (5) chapters, each having its own importance.
Chapter 1: Introduction - Justifies the need for the project and states the
requirements/specifications of the project.
Chapter 2: Literature review - Reviews some existing Inverter systems and the principles
behind the design implemented in this project.
Chapter 3: Methodology and system design - Gives a detailed account of the design process.
Chapter 4: Construction, Tests and Results Discusses the hardware implementation of the
design, the results and problems encountered. The Bill of Measurement/Evaluation is also
given in this chapter.
Chapter 5: Conclusion and Recommendations - Summarizes the observations and inferences
made in the course of the project. Recommendations for further work is also given in this
chapter.
3
CHAPTER TWO
LITERATURE REVIEW
The design of a dc to ac voltage source inverters can be done using several energy conversion
topologies. Suryawanshi et al. (2006); Abolarinwa and Gana (2010), Sekar and
Baladhandapani (2013) designed and inverter circuit using Push pull, half-bridge and full
bridge converters. Push-pull converters are restricted to low DC supply voltage applications
because of their tendency to develop magnetic flux walking problems that can lead to failure.
They are however commonly employed because of their rather simple structure compared to
that of full-bridge converter circuits. Wuidart (1999) in his work reported that Full-bridge
converters are used in high power applications where their higher component count and the
associated cost are of secondary importance. Voltage source inverter systems can also be
classified based on their output waveform type. The earliest power inverters produce square
wave output waveforms. Square waveforms are easily and efficiently produced at high power
levels. However, the high harmonic content implies that they cannot be used to power
harmonic sensitive loads. A version of square wave inverters is the modified sinewave
inverters. Inspite of the term, a modified sinewave inverter produces a waveform that looks
more like a square wave than a sinewave. Pure sinewave inverters are by far the best, because
their output waveforms have very little harmonic content, though they are somewhat more
complex to design compared to square wave and modified squarewave inverters.
Consequently, they are much more costly. Kolla et al. (2013) provides a detailed explanation
on the performances and characteristics of the various inverter types.
Pulse width modulation (PWM) is a powerful technique for controlling analogue with a
processors digital outputs. It is also known as pulse duration modulation (PDM). The leading
edge of the carrier pulse remains fixed and the occurrence of the trailing of the pulses varies.
PWM signals find a wide application in modern electronics. Some of these reasons are:
Easy to Generate PWM signals are quite easy to generate. Many modern
microcontrollers include PWM hardware within the chip; using this hardware often
takes very little attention from the microprocessor and it can run in the background
4
without interfering with executing code. PWM signals are also quite easy to create
directly from a comparator only requiring the carrier and the modulating signals input
into the comparator.
Digital to Analogue Conversion pulse width modulation can function effectively, as
a digital to analogue converter, particularly combined with appropriate filtering. The
fact that the duty cycle of a PWM signal can be accurately controlled by simple
counting procedures is one of the reasons why PWM signals can be used to
accomplish digital-to-analogue conversion.
A digital microcontroller PWM requires a reference signal, sometimes called a modulating or
control signal, which is a sinusoidal in this case; and a carrier signal, which is a triangular
wave that controls the switching frequency. Microcontroller modules are used to compare the
two to give a PWM signal.
The applications of PWM are wide variety used like ranging from measurement and
communications to power control and conversion. In PWM inverter harmonics will be much
higher frequencies than for a square wave, making filtering easier.
In PWM, the amplitude of the output voltage can be controlled with the modulating
waveforms. Reduced filter requirements to decrease harmonics and the control of the output
voltage amplitude are two distinct advantages of PWM. Disadvantages include more complex
control circuits for the switches and increased losses due to more frequent switching.
5
As shown the H-Bridge circuit consists of four switches corresponding to high side left, high
side right, low side left, and low side right. There are four possible switch positions that can
be used to obtain voltages across the load. These positions are outlined in Table 1. Note that
all other possibilities are omitted, as they would short circuit power to ground, potentially
causing damage to the device or rapidly depleting the power supply.
The switches used to implement an H-Bridge can be mechanical or built from solid state
transistors. Selection of the proper switches varies greatly. The use of P-Channel MOSFETs
on the high side and N-Channel MOSFETs on the low side is easier, but using all N-Channel
MOSFETs and a FET driver, lower on resistance can be obtained resulting in reduced
power loss. The use of all N-Channel MOSFETs requires a driver, since in order to turn on a
high-side
N-Channel MOSFET, there must be a voltage higher than the switching voltage. This
difficulty is often overcome by driver circuits capable of charging an external capacitor to
create additional potential.
Analogue signals are usually fundamentally different from those the microcontroller
understands (ones and zeros) and have to be converted therefore into values understandable
for the microcontroller. An analogue to digital converter is an electronic circuit which
converts continuous signals to discrete digital numbers i.e. into a binary number and passes it
to the CPU for further processing (Verle, 2009). Similarly, the outputs are always in digital
form, thus when a digital system such as the microcontroller is used to monitor and/or control
a physical process as in the case of this project, where it monitors the input voltage and
controls the switching of relays connected to taps of an autotransformer, we must bridge the
6
gap between the analogue and digital nature of the system variables using Analog-to-digital
converters (ADC) and digital-to-analogue converters (DAC) to create an interface.
When utilizing N-Channel MOSFETs to switch a DC voltage across a load, the drain
terminals of the high side MOSFETs are often connected to the highest voltage in the system.
This creates a difficulty, as the gate terminal must be approximately 10V higher than the
drain terminal for the MOSFET to conduct. Often, integrated circuit devices known as
MOSFET drivers are utilized to achieve this difference through charge pumps or
bootstrapping techniques. These chips are capable of quickly charging the input capacitance
of the MOSFET (Cgiss) quickly before the potential difference is reached, causing the gate to
source voltage to be the highest system voltage plus the capacitor voltage, allowing it to
conduct. A diagram of an N- channel MOSFET with gate, drain, and source terminals is
shown in Figure 3.
7
There are many MOSFET drivers available to power N-Channel MOSFETs through level
translation of low voltage control signals into voltages capable of supplying sufficient gate
voltage. Advanced drivers contain circuitry for powering high and low side devices as well as
N and P-Channel MOSFETs. In this design, all MOSFETs are N-Channel due to their
increased current handling capabilities. To overcome the difficulties of driving high side N-
Channel MOSFETs, the driver devices use an external source to charge a bootstrapping
capacitor connected between Vcc and source terminals. The bootstrap capacitor provides gate
charge to the high side MOSFET. As the switch begins to conduct, the capacitor maintains a
potential difference, rapidly causing the MOSFET to further conduct, until it is fully on. The
name bootstrap component refers to this process and how the MOSFET acts as if it is
pulling itself up by its own boot strap.
2.3.2 MICRO-CONTROLLER
8
It would be simpler to adapt. With an analogue system, it would be difficult to make
changes for the desired output. In many cases, this is a desired trait, as it would be
designed for a single purpose and therefore a single output. However, as this is
something that is designed to be available all over the world, it needs to be adjustable
to different standards of frequency and voltage. With an analogue circuit, this would
require a different circuit that it would have to switch over to, while with a micro-
controller, it merely requires a change in the programs code.
It can allow for easy feedback to control the power flowing through the load. One of
the problems that can occur with systems like this is that the variances in load can
cause variances in the supplied current and voltage. With a microcontroller, it is
possible to have it look at the power output and change the duty cycle based on
whether or not the load requires additional power or is being oversupplied.
2.3.3 TRANSFORMER
A transformer is an electrical device that transfers energy between two circuits through
electromagnetic induction. A transformer may be used as a safe and efficient voltage
converter to change the AC voltage at its input to a higher or lower voltage at its output.
Other uses include current conversion, isolation with or without changing voltage and
impedance conversion. A transformer consists of two windings of wire that are wound around
a common core to provide tight electromagnetic coupling between the windings. The core
material is often a laminated iron core. The coil that receives the electrical input energy is
referred to as the primary winding, the output coil is the secondary winding.
The ideal transformer induces secondary voltage VS as a proportion of the primary voltage
VP and respective winding turns as given by the equation
= = =a 2.1
Where,
a is the winding turns ratio,
Vp is the primary/source voltage,
Vs is the secondary voltage,
Ns is the number of secondary turns
Np is the number of primary turns
9
Figure 2.4: Equivalent circuit of a transformer
2.3.5 RELAY
10
Relays are used where it is necessary to control a circuit by a separate low-power signal, or
where several circuits must be controlled by one signal. Magnetic latching relays require one
pulse of coil power to move their contacts in one direction, and another, redirected pulse to
move them back. Repeated pulses from the same input have no effect. Magnetic latching
relays are useful in applications where interrupted power should not be able to transition the
contacts.
Magnetic latching relays can have either single or dual coils. On a single coil device, the
relay will operate in one direction when power is applied with one polarity, and will reset
when the polarity is reversed.
electromagnetic relay consists of a coil of wire wrapped around a soft iron core, an iron yoke
which provides a low reluctance path for magnetic flux, a movable iron armature, and one or
more sets of contacts (there are two contacts in the relay pictured). The armature is hinged to
the yoke and mechanically linked to one or more sets of moving contacts. It is held in place
by a spring so that when the relay is de-energized there is an air gap in the magnetic circuit.
In this condition, one of the two sets of contacts in the relay pictured is closed, and the other
set is open. Other relays may have more or fewer sets of contacts depending on their function.
The relay in the figure 5 above also has a wire connecting the armature to the yoke. This
ensures continuity of the circuit between the moving contacts on the armature.
When an electric current is passed through the coil it generates a magnetic field that activates
the armature, and the consequent movement of the movable contact(s) either makes or breaks
(depending upon construction) a connection 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
11
switched off, the armature is returned by a force, approximately half as strong as the
magnetic force, to its relaxed position. Most relays are manufactured to operate quickly. In a
low-voltage application this reduces noise; in a high voltage or current application it reduces
arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to semiconductor circuit components.
2.3.6 MOSFETS
Power MOSFETs have a different structure from the lateral MOSFET: as with most power
devices, their structure is vertical and not planar. In a planar structure, the current and
breakdown voltage ratings are both functions of the channel dimensions (respectively width
and length of the channel). With a vertical structure, the voltage rating of the transistor is a
function of the doping and thickness of the N epitaxial layer, while the current rating is a
function of the channel width. This makes it possible for the transistor to sustain both high
blocking voltage and high current within a compact piece of silicon.
12
Figure 2.7: MOSFET characteristics
For the MOSFET to carry drain current Id (on state) a channel between the drain and source
must be created. This occurs when drain to source Vgs voltage exceeds the device threshold
(Vgs>Vth). Once the channel is induced the MOSFET can operate in either triode region
(drain current proportional to channel resistance) or the saturation region for the MOSFET to
carry drain current Id (on state) a channel between the drain and source must be created. This
occurs when drain to source Vgs voltage exceeds the device threshold (Vgs>Vth). Once the
channel is induced the MOSFET can operate in either triode region (drain current
proportional to channel resistance) or the saturation region
2.3.7 OCTO-COUPLER
14
CHAPTER 3
3.1 METHODOLOGY
The method employed for the design of the pure sine wave inverter involves converting the
DC input voltage to AC through the use of PWM generated by the microcontroller, then the
output AC is stepped up to the desired output. This project can be complex when looked at as
a whole, but can be much easier to analyse when broken into smaller divisions. As will be
done in the following sections.
15
From the block diagram, the various circuits needed for the design are shown, the whole
circuit can be divided into two parts as a whole: namely the control circuit and the oscillator
circuit. While the oscillator circuit is responsible for the generation of the pure sine wave, the
control circuit act as the brain behind the automation of the rest of the circuit. The ensuing
sections show the individual circuit design and how every part is pieced together.
The PWM signal to be used in the circuit is produced by a microcontroller, most powerful
microcontrollers have the ability to produce up to 4 PWMs, for instance the PIC18F2550 chip
from pic has this ability. The PORT C of this microcontroller has 2 outputs that produces
PWM, while another PORT could be used to produce the complimentary signal.
For the production of the PWM 32 were picked for this project, for calculating the value of
the duty cycle for the samples we use the formula
;
The corresponding angles are gotten by dividing the angle for one half cycle by total number
of samples.
16
Assuming our maximum duty cycle is given as 250 then the first 16 samples are:
Table 3.1: duty cycles for PWM
The 16 samples are then repeated to give a total of 32 samples, to form a half wave at 50 Hz.
The microcontroller is set to produce the PWM at a chosen frequency of 3kHz and also 2
other sine waves at 50 Hz each, for the PIC16F873A chip for instance:
The CCP modules in built in the microcontroller were not used in this project, but a software
PWM was written in other to have full control. This would mean that more than 4 PWM can
be produced and the output pins could be any of the controller pins rather than from the
designated CCP output pins. The advantage of this would be in charging the batteries, since
only the low side MOSFETs need to be switched to give appropriate charging current. This
will be explained in the ensuing sections.
17
3.2.1A PWM GENERATION TECHNIQUE AND REGULATION
The software PWM created uses the delay function in the microC compiler, to get a
frequency of 50Hz each duty cycle has to last for 625s.
T (period of sine wave) = = = 0.02s 3.10
.
For a half cycle = = 0.01s 3.11
.
Tp (period of PWM) = = = 312s 3.12
A duty cycle is in simple terms the ratio of the time on to period of the PWM; so each of the
duty cycles previously calculated show how long the pins should stay high relative to how
long they should stay low. Hence any pin of the microcontroller could be made to stay high
for that period of time as calculated for each duty cycle value, and stay off for the rest of the
period.
Time period on is calculated by percentage time on
Table 3.2: duty cycle in terms on of time on
Duty cycle Percentage time on Time period on
0o 0 0
25 0.10 30
49 0.196 60
73 0.292 90
96 0.384 119
118 0.472 147
139 0.556 173
159 0.636 198
177 0.708 220
193 0.772 240
208 0.832 259
220 0.88 274
231 0.924 288
239 0.956 298
245 0.98 305
249 0.996 310
250 0.98 312
18
The designated PWM are then varied to be on at the following times as calculated in the table
above and be, low for the rest of the period.
The PWM signal generated is regulated by a feedback technique which is one of the most
critical aspects of the PWM generation without the regulation the output voltage becomes
excessively high at start and may fall to be very low when load is applied else the need for
the regulation, the regulation is done by a feedback circuit whose function is to detect the
output voltage and make adjustments to the duty cycles: if they should be increased or
decreased. The circuit configuration for the feedback is shown in ensuing sections.
19
3.2.1 B WHY PIC MICROCONTROLLER
PIC18F2550 and PIC18f877a have the Harvard architecture. 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.
It is also typical for Harvard architecture to have fewer instructions than von-Neumann's, and
to have instructions usually executed in one cycle. Microcontrollers with Harvard architecture
20
are also called "RISC microcontrollers". Figure 7 presents the internal block of the
PIC18F2550.
And Figure 8 represents the Internal block of the PIC16F873A
21
For this design two chips are chosen, one for the LCD display and the other for the oscillation
and the control of the entire circuit.
PIC chips are readily available in the market so there will be no need to incur extra
cost of shipping.
The relative ease of programming with the PIC compiler which uses the C language
which we are familiar with.
The PIC18F2550 has a stable internal oscillator up to 8MHz, and has a large memory
space of 64KBs
3.2.2 H-BRIDGE
In other to generate a sine wave with both the positive voltage half and the negative voltage
half with a centre zero volt from a single source require the use of a four switches arranged in
an H configuration. The switches chosen in this case is the MOSFET.
In designing this circuit, a choice had to be made on with switch would be more suitable for
use. One is the power MOSFET the other is the insulated gate bipolar transistor (IGBT). Each
has its advantages, and there is a high degree of overlap in the specifications of the two.
IGBTs tend to be used in very high voltage applications, nearly always above 200V, and
generally above 600W. They do not have the high frequency switching capability of
MOSFETs, and tend to be used at frequencies lower than 29 kHz. They can handle high
currents, are able to output greater than 5kW, and have very good thermal operating ability,
being able to operate properly above 100 Celsius. One of the major disadvantages of IGBTs
is their unavoidable current tail when they turn off. Essentially, when the IGBT turns off, the
current of the gate transistor cannot dissipate immediately, which causes a loss of power each
time this occurs. This tail is due to the very design of the IGBT and cannot be remedied.
IGBTs also have no body diode, which can be good or bad depending on the application.
IGBTs tend to be used in high power applications, such as uninterruptible power supplies of
power higher than 5kW, welding, or low power lighting.
Power MOSFETS have a much higher switching frequency capability than do IGBTs, and
can be switched at frequencies higher than 200 kHz. They do not have as much capability for
high voltage and high current applications, and tend to be used at voltages lower than 250V
and less than 500W. MOSFETs do not have current tail power losses, which makes them
more efficient than IGBTs. Both MOSFETs and IGBTs have power losses due to the ramp up
22
and ramp down of the voltage when turning on and off (dV/dt losses). Unlike IGBTs,
MOSFETs have body diode.
Generally, IGBTs are the sure bet for high voltage, low frequency (>1000V, <20 kHz) uses
and MOSFETs are ideal for low voltage, high frequency applications (<250V, >200 kHz). In
between these two extremes is a large grey area. In this area, other considerations such as
power, percent duty cycle, availability and cost tend to be the deciding factors. Since this
project is about design of a 600W inverter, with a 24DC bus, and a switching frequency of 3
kHz MOSFET is the ideal choice, in spite of MOSFET switches having high ON state
resistance and conduction losses. Also MOSFET being a voltage controlled device, it can be
driven directly from CMOS or TTL logic and the same gate signal can be applied to
diagonally opposite switches since the gate drive current required is very low.
The use of P-Channel MOSFETs on the high side and N-Channel MOSFETs on the low side
is easier, but using all N-Channel MOSFETs and a FET driver, lower on resistance can be
obtained resulting in reduced power loss. This requires a more complex circuit since the gate
of the high side MOSFETs must be driven positive with respect to Vs bus voltage to turn on
the MOSFETs.
a. MOSFET selection
In the H-bridge design 4 MOSFETs are used on each side of the bridge therefore bringing it
all to a total of 16 MOSFETs. The Maximum input current is given by:
I= = = 125A. 3.13
So each side of the bridge should be able to carry a maximum current of 125A, for this design
the MOSFET Irfp260n was chosen, having a maximum rating of 40A. four of the MOSFETs
where paralleled together on each side, so that the input capacity is now 160A. This is enough
to handle the current sufficiently.
23
good trade-off between the spike amplitude and the turn-off speed the di/dt may have to be
reduced by reducing the switching speed by means of the gate resistor. A graph of the
negative spike and the turn-off time versus series gate resistance is shown in Figure 13 The
layout should also minimize the stray inductance in the charge/discharge loops of the gate
drive to reduce oscillations and to improve switching speed and noise immunity, particularly
the dV/dt induced turn-on. For this design resistor values of 100 ohms were chosen.
Figure 3.5: Series Gate Resistance vs. Amplitude of Negative Voltage Spike and Turn-off time
24
applications has been the amount of ripple current that the electrolytic capacitor can sustain.
This limits the design criteria of the designer to figuring out how many individual capacitors
are required for a given design rather than the total amount of capacitance that is required.
To calculate the ripple current:
The source inductance is usually large enough to limit the high frequency ripple current.
Therefore, the ripple current in the bus link capacitor is essentially the same as the ripple
current in the phase leg as illustrated in Figure 14. When the top left and bottom right
switches are turned on the current flows from the bus link capacitor through the load via top
left and bottom right switches and returns to the bus link capacitor. Similarly, the current
flows from the bus link capacitor through the load when the bottom left and top right
switches are turned on. The bus link capacitance selection is based on the maximum bus
ripple voltage desired.
The maximum ripple voltage is when the duty cycle is at 50%, so that
maximum peak to peak ripple voltage is given as
Choosing an allowable 1% for the ripple voltage we can calculate the DC link capacitor
value; 1% of the bus voltage is 0.2.
Re-arranging
C= 3.15
.
The primary inductance Is calculated as
25
Transformer core area a = 0.00063m2
From the core used B = 1.3T 3.16
So that flux linkage = 3.17
= 1.3 0.00063 = 0.00819
The secondary winding inductance L = N 3.18
Then C = = 441F
0.00000943 .
The maximum ripple current is given as
I 0.5t = 0.25 ( )
3.19
For this project a capacitance 4, 4700F capacitors were used in parallel to efficiently handle
the ripple current and the ripple voltage.
For the MOSFET switch to be turned on the voltage at the gate terminal must be 10V higher
than the drain terminal voltage. the drain of the high side device is connected to 24V DC
power which is to be inverted into the 230V AC power. This is a problem because the 24V is
the highest voltage in the system therefore, to drive MOSFETs in the H-Bridge MOSFET
driver IC is used with a bootstrap capacitor specifically designed for driving a half-bridge.
For this design the IR2110 MOSFET driver was chosen, it is rated at 600V, with a gate
driving current of 2A and a gate driving voltage of 10-20V. The turn on and turn off times are
120ns and 94ns respectively. The MOSFET driver operates from a signal input given from
the microcontroller and takes its power from the battery voltage supply that the system uses.
The driver is capable of operating both the high side and low side devices, but in order to get
the extra 10V for the high side device, an external bootstrap capacitor is charged through a
diode from the 18V power supply when the device is off. Because the power for the driver is
supplied from the low voltage source, the power consumed to drive the gate is small. When
the driver is given the signal to turn on the high side device, the gate of the MOSFET has an
extra boost in charge from the bootstrap capacitor, surpassing the needed 10V to activate the
device and turning the switch on.
26
Figure 3.7: IR2110 connection
The bootstrap diode and capacitor are the only external components strictly required for
operation in a standard PWM application. Local decoupling capacitors on the VCC (and
digital) supply are useful in practice to compensate for the inductance of the supply lines.
The voltage seen by the bootstrap capacitor is the VCC supply only. Its capacitance is
determined by the following constraints:
1. Gate voltage required to enhance MGT
2. IQBS - quiescent current for the high-side driver circuitry
3. Currents within the level shifter of the control IC
4. MGT gate-source forward leakage current
5. Bootstrap capacitor leakage current
Factor 5 is only relevant if the bootstrap capacitor is an electrolytic capacitor, and can be
ignored if other types of capacitor are used. Therefore, it was ignored since only non-
electrolytic capacitors were used.
The minimum bootstrap capacitor value was calculated from the following equation:
[
qbs(max) cbs(leak)
C 3.20
min
Where:
Qg = Gate charge of high-side FET = 63nC
f = frequency of operation = 3000Hz
ICbs (leak) = bootstrap capacitor leakage current = 250A
Iqbs (max) = Maximum VBS quiescent current = 230A
VCC = Logic section voltage source = 24V
Vf = Forward voltage drop across the bootstrap diode = 0.4V
27
VLS = Voltage drop across the low-side FET = 1.8V
VMin = Minimum voltage between VB and VS = 10V
Qls = level shift charge required per cycle (typically 5nC for 500 V/600 V MGDs and 20nC
for 1200 V MGDs)
The values substituted into this equation were found either in driver datasheet for IR2110 IC
or IRFP260N MOSFET datasheet. Using these numbers minimum bootstrap capacitance
value was calculated as
[
. .
0.025
The capacitor value obtained from the above equation is the absolute minimum required,
however due to nature the bootstrap circuit operation, a low value of capacitor can lead to
overcharging which could in turn damage the IC. Therefore, to minimize the risk of
overcharging and further reduce ripple on the Vds voltage the capacitor value obtained is
multiplied by a factor of 15 to get a capacitor value of 0.3F, but the design a capacitor value
of 47 f was used.
The bootstrap diode must be able to block the full voltage seen in the specific circuit and is
about equal to the voltage across the power rail. The current rating of the diode is the product
of gate charge times switching frequency. The high temperature reverse leakage characteristic
of this diode can be an important parameter in those applications where the capacitor has to
hold the charge for a prolonged period of time. For the same reason it is important that this
diode have an ultra-fast recovery to reduce the amount of charge that is fed back from the
bootstrap capacitor into the supply.
In order to improve decoupling a decoupling capacitors has to be connected directly across
the VCC and COM pins as shown in figure 12. The diode chosen for this design is the In4148
diode which meets the specifications given above.
28
Figure 3.8: H-bridge and MOSFET circuit
The following calculations were followed in designing the transformer, for a 3KVA design:
The calculations were based on the following formulas:
Primary winding calculations
1) Core area = 1.152 ( ) 3.21
2) Calculating turns per volt (tpv)
TPV = 1 (4.44 10 ) 3.22
( )
3) Primary winding current = ( . )
3.23
29
6. Secondary winding current = .
= 14.49 A
The final component necessary to output a pure sine wave signal is an output filter. For our
circuit we need a basic LC low pass filter with the following setup below in Figure
This will filter out all the excess noise above the critical frequency. The goal for this is to
bring the critical frequency as close as possible to the desired frequency of 50 Hz, removing
other harmonics that crop up within the system. The lower the cut-off frequency, the greater
the capacitance and inductance required to properly create the filter. The output of the H-
bridge was ideally a 50Hz sine wave. Because it was encoded using a 3 kHz PWM signal it
was to be filtered. Due to the high current expected to be sourced by the load of our output,
the only option is a passive low pass filter, which is an inductor and capacitor in series, with
the load connected across the capacitor designed for passing all signals under 50Hz.
Fc = 3.28
Since the secondary side of the transformer has an inductance all that was needed was just a
shunt capacitor. From the earlier calculations
Transformer core area a = 0.00063m2
From the core used B = 1.3T
So that flux linkage =
= 1.3 0.00063 = 0.00819
The secondary winding inductance L = N
.
L = 478 .
= 0.27H
Hence the capacitor value needed from the formula above is calculated from the formula
C= = .
= 3.7 10 = 3.7F
30
For the design the available 4.7F capacitor was used
The program written for the microcontroller functions by executing instructions in a specified
order, thus the program instructions must be organized in the desired order to avoid improper
co-ordination of events during operation. While the source code of the program is given in
Appendix I of this report the flowchart given below shows the core instructions in the
program and the order in which they will be executed by the microcontroller.
31
Figure 3.11: complete circuit diagram
32
3.3 MODE OF OPERATION
In free running mode (when the inverter is not on or when there is no mains), the battery
voltage is used to power the circuit. It is connected through a 10 choke resistor which acts
as a fuse for circuit protection. Voltage is supplied to the circuit through the 5 V and 12 V
voltage regulators. The 5 VDC is fed to the microcontroller and to the MOSFET driver and to
the LCD. The 12V regulator is used to power the relays and also act as a bias voltage for the
MOSFET driver.
In inverter mode, the microcontroller senses the battery voltage through the voltage divider
circuit made up of 100 K and 1 K resistor. If the battery voltage is above the low battery
value of 21 V, the microcontroller sends the oscillations to the H-bridge which in turn uses
the oscillations to convert the battery DC voltage to an AC voltage, the AC voltage is then
stepped-up by the transformer TR2 to a nominal voltage of 230 V. The output of the
transformer TR2 is then passed through a filter capacitor to reduce the high harmonic
component of the AC wave. The output from the filter is then stepped-down through another
transformer TR1 to provide feedback to the microcontroller. The output of the step down
transformer is rectified and then passed through a voltage divider circuit made up of 100 K
and 10 K resistor. The function of the feedback is to ensure that the output voltage is
relatively fixed at 230 VAC with 30 VAC variation. The microcontroller switches the
controlled output relay to ensure that the load powered by the controlled output is ON as long
as the battery voltage is above 23 VDC. Once the battery voltage falls below 23 VDC, the
controlled output is disconnected and only the main output is allowed to be powered. Under
the condition where with the battery falls below 21 VDC which is the stated low battery, the
main output is cut off. The maximum current drawn is calculated as the total power divide by
the input voltage, which is 3 KVA divided by 24 VDC, which gives a total of 125 AMPS.
Therefore the overload current is set at 110 AMPS to allow for inaccuracy. Under the
condition that the input current rises above 110 AMPS, the oscillation is cut off and the
condition could either be read as an overload or a short circuit.
In mains mode, the microcontroller senses the presence of a mains input through the help of
an optocoupler U1. The 230 VAC rectified passes through a voltage divider so that a proper
voltage could be used to bias the optocoupler U1. When theres mains, 5 VDC is sent to the
designated mains pin of a microcontroller through the optocoupler. This way the
microcontroller is aware of the presence of mains and switches the outputs to be powered
directly from mains while also switching mains into the transformer TR2, hence the
33
transformer acts as a step down transformer in this case and steps down the 230 VAC to the
appropriate 24 VAC needed to charge the battery. In this mode the H-bridge is configured as
a buck converter using the lower side MOSFET as a switch, the higher side MOSFET as a
diode then using the transformer as both a source and an inductor while using the DC link
capacitor as ripple capacitors. The low side MOSFET are switched at the same time with a
frequency of above 7 KHz. The microcontroller monitors the input current through the
current transformer TR3 to ensure that the charging current is always within 9 AMPS to
10 AMPS during normal charge. When the battery voltage rises up to 27 VDC, the
microcontroller switches the low side MOSFET in the buck converter configuration to ensure
that the charging current is within 0.7 AMPS to 1 AMP. Charging continues as long as the
battery voltage is less than the fully charge threshold and stops once the battery voltage is
equal to the fully charge value of 30 VDC.
34
CHAPTER 4
4.1 IMPLEMENTATION
The materials used in constructing the transformer for this project are
Laminations sheet of steel
The Winding bobbing made of forma
Copper wire gauge 8 and gauge 17
Insulation paper made of Mica
Masking tape
Bracket and screws
Sandpaper
Epoxy glue
The constructional procedure is sequenced below:
1. We cut the bobbing according to the shape of the E and I of the lamination so that the
windings fit into the lamination winding window.
2. We glued the bobbing sides together with Epoxy glue and allowed it to set.
35
Figure 4.2: bobbing after cutting and gluing pieces together
3. We then insulated the bobbing with Mica paper and started the winding. We started at
the low voltage side, and wound the precise number of turns as calculated in our
specifications. After which we wound the high voltage side, we made sure to insulate
the low voltage side with the Mica paper first, and then we wound the number of turns
as calculated in our specifications.
4. After all the winding were completed, we then insulated the whole with the mica
paper to ensure that there was no fracture to the windings. Then we started to wear in
the laminations, after which we locked the lamination in place with the bracket and
screws to reduce vibration during the transformer operation.
36
4.1.2 H-BRIDGE CONSTRUCTION
37
4.1.3 CIRCUIT CONSTRUCTION
The electronic circuit was constructed on a printed circuit. All components on the hardware
were connected as shown in the circuit diagram and permanently soldered to the board
38
4.2 TESTS
During and after the construction of the 3kVA microcontroller based pure sine wave inverter
some of the following tests were conducted, these tests were conducted with a working
digital multi-meter and also and an analogue meter to ensure correctness in the values
measured.
This test is done to check the validity of an electrical path; this test was carried out a lot
during the assembling of the project components, particularly on the PCB.
The test is performed by simply selecting continuity test using the multi-meter dial, and
placing the probes on the points being tested. If connected the multi-meter buzzes a high
pitched sound and reads a value, if not connected 1 which signifies infinity is displayed on
the screen.
Voltage tests were carried out severally to ascertain the voltages at different points in the
network. A multi-meter was also used in carrying out this test. To carry out this test, the
voltage type to be measured (AC or DC) is selected and the range of the multi-meter was set
to match the expected voltage to be measured. The red probe was place on the positive
terminal and the black probe on the negative terminal.
After the wounding of the transformer, no-load test was carried out. The purpose of this test
is to determine no-load or core loss. Which in turn can be used in calculating the core loss
and the iron loss. One of the winding; in our case the High voltage side is connected to a
supply and the other side is left open, then the voltages and current is measured. The value of
the no-load current we got was 0.3A, which was within reasonable limits, since the no-load
current is within 2 10% of the rated current value.
39
4.3 RESULTS
40
Figure 4.8: The inverter when on
41
Figure 4.10: The output sinewave
42
4.4 BILL OF ENGINEERING MEASUREMENT AND EVALUATION
43
CHAPTER 5
5.1 CONCLUSION
The objectives of this project is to design an inverter that will produce an output up to 3 KVA
with input from a 24 V battery and can be used to power AC loads. Within the limit of
correctness, the project worked as proposed in the objectives and according to the results
gotten in the preceding chapter. This proposed pure Sine Wave inverter has various
applications because of its key advantages such as operation with very low harmonic
distortion and clean power like utility-supplied electricity, reduction in audible and electrical
noise in Fans, fluorescent lights and so on, faster, quieter and cooler running of Inductive
loads like microwaves and motors.
5.2 RECOMMENDATIONS
An extra improvement could be made to allow for short circuit protection, so that if there is a
condition for a bridge in both the phase and neutral lines, the microcontroller produces no
oscillations. This would be important as a short circuit conditions can lead to permanent
damage to circuit components. Secondly the board could be a printed circuit board that would
ensure the validity of connected links.
44
REFERENCES
Abolarinwa, J. and Gana, P. (2010). Design and Development of Inverter with AVR Using
Switch Mode Square Wave switching scheme. Assumption University Journal, 13(4).
Kolla, J., Devakumar, V. S., and Babu, B. K. (2013). A Comparison on Power Electronic
Inverter Topologies. International Journal of Innovative research and development, Vol. 2,
Issue 5.
Leung, I. F. (2011). PWM Techniques: A Pure Sine Wave Inverter. Worcester Polytechnic
Institute.
https://en.wikipedia.org/wiki/Power_inverter
Sanjay Dixit, A. T. (n.d.). 800VA Pure Sine Wave Inverters Reference Design. Texas
Instruments Application Report.
Suryawanshi, H. M., Borghate, B. B., Ramteke, M. R., and Thakre, K. L. (2006). Electronic
45
Ballast using a Symmetrical Half-Bridge Inverter Operating at Unity-Power-Factor and High
Efficiency. Journal of Power Electronics, Vol 6.
https://en.wikipedia.org/wiki/Voltage_regulator
46
APPENDIX
const short max_count = 16; // the maximum time period of oscillation for pwm charger
const short maxi_count = 31;//31; //maximum time period of oscillation
const short keep_time = 3;//this should be 20us but due to the external oscillator its 3// keeps
the track of time for oscillator
const short keeping_time = 2;// should be 10us dut keeps track of time for charger
const short signal_regulator = 32; //varies the different duty cycles in other to regulate the
output voltage
const short low_batt_level = 20;
const short full_batt_level = 29;
const short float_charge_level = 27;
unsigned short duty_cycle, ascending, descending, count, adder, mode, delay;/* ascending
keeps track of high part of
duty cycle, descending keeps track of low part*/
int
output_voltage_collect,input_current_collect,output_voltage,input_current,battery_collect,bat
tery_voltage,i,j,k;
47
float AC_VOLT,BAT_VOLT,IN_CURRENT;
char sum,sum1;
0,1,1,2,3,4,4,5,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6,5,4,4,3,2,1,1,0,
//24% duty cycle
0,1,2,3,4,5,5,6,7,8,8,8,9,9,9,9,9,9,9,9,8,8,8,7,6,5,5,4,3,2,1,0,
//30% duty cycle
0,1,2,4,5,6,7,8,9,10,10,11,12,12,12,12,12,12,12,12,11,10,10,9,8,7,6,5,4,2,1,0,
//40% duty cycle
0,2,4,5,7,9,11,12,14,15,16,17,17,18,19,19,19,19,18,17,17,16,15,14,12,11,9,7,5,4,2,0,
//60% duty cycle
0,2,4,6,8,10,13,14,16,17,18,20,20,21,22,22,22,22,21,20,20,18,17,16,14,13,10,8,6,4,2,0,
//70% duty cycle
0,3,6,9,12,15,18,20,23,25,26,28,29,30,31,31,31,31,30,29,28,26,25,23,20,18,15,12,9,6,3,0
//100% duty cycle
}; //pwm duty cycles
void turn_off();
void check_battery_level();
void check_input_current();
void check_output_voltage();
void AVR();
void charging_algorithm();
void oscillator();
48
void main() {
adc_init();
mode = 1;
osccon = 0b01100111; // initialize the chip frequency to 8MHz
OSCCON2 = 0B00000011;
OSCTUNE.PLLEN = 0;
cm1con0 = 0; // turn off comparators
cm2con1 = 0;
cm2con0 = 0;
ansele.f2=ansele.f3=ansele.f4 = 1; //configure port e as analogue
anselb=anselc=anseld= 0 ;//configure the other ports as digital
duty_cycle = 0;
trisb0_bit = 0;
trisb1_bit = 0;
trisb3_bit = 1;
trisc1_bit = 0;
trisc2_bit = 0;
trisc7_bit = 1;
trisd5_bit = 0;
trisc6_bit = 0;
trisd0_bit = trisd1_bit = 0;
portb.f0 = 0;
portb.f1 = 0;
portb.f3 = 1;
portc.f1 = 0;
portc.f2 = 0;
portc.f7 = 1;
portd.f0 = portd.f1 = 0;
main_relay = controlled_relay = 0;
adder = 32;
i,j,k,sum,sum1 = 0;
TRISA = 0xFF;
while(1)
49
{
check_battery_level();
check_input_current();
if((turn_on == 0) && (mains_sense == 0))
{
if(((int)BAT_VOLT < 20) || ((int)IN_CURRENT > 80))
{
turn_off();
}else if(((int)BAT_VOLT > 20) && ((int)IN_CURRENT < 80))
{
oscillator();
}
if((int)BAT_VOLT < 20)
{
bet3 = 1;
bet4 = 0;
}
if((int)(IN_CURRENT > 80))
{
bet3 = 0;
bet4 = 1;
}
}
else if((turn_on == 0) || (mains_sense == 1))
{
if((int)BAT_VOLT >= 30)
{
turn_off();
bet3 = 1;
bet4 = 0;
}else if((int)BAT_VOLT < 30)
{
bet3 = 0;
bet4 = 1;
50
charging_algorithm();
}
}if (mains_sense == 1)
{
main_relay = 1;
}else if(mains_sense == 0)
{
main_relay = 0;
}
if((mains_sense == 0) || ((int)BAT_VOLT <= 22))
{
controlled_relay = 1;
}else if((mains_sense == 1) || (int)(BAT_VOLT > 22))
{
controlled_relay = 0;
}
}
}
void oscillator()
{
output_voltage_collect = ADC_get_sample(1);
output_voltage = output_voltage_collect * 4.888;
AC_VOLT = (output_voltage*203.74);
AC_VOLT = AC_VOLT/1000;
if(j++>5)
{j = 0;
if((int)AC_VOLT < 140)
{
adder = adder + 32;
}
else if((int)AC_VOLT > 260)
{
51
adder = adder - 32;
}
if (adder > 192)
{
adder = 192;
}
if (adder <32)
{
adder = 32;
}
}
if (mode == 1)
{
count = 0;
for(count = 0;count < 31; count++)
{
sum = count + adder;
for(ascending = sample_number[sum];ascending > 0; --ascending)
{
Ho1 = 1; Lo2 = 1;
Ho2 = 0; Lo1 = 0;
delay_us(keep_time);
}
for(descending = ((sample_number[sum]) + 1);descending <=
maxi_count;descending++)
{
Ho1 = 0; Lo2 = 0;
Ho2 = 0; Lo1 = 0;
delay_us(keep_time);
}
mode = 0;
}
}
if (mode == 0)
52
{
count = 0;
for(count = 0;count < 31; count++)
{
sum1 = count +adder;
for(ascending = sample_number[sum1];ascending > 0; ascending--)
{
Ho1 = 0; Lo2 = 0;
Ho2 = 1; Lo1 = 1;
delay_us(keep_time);
}
for(descending = (sample_number[sum1]) + 1;descending <=
maxi_count;descending++)
{
Ho1 = 0; Lo2 = 0;
Ho2 = 0; Lo1 = 0;// same goes here for low 1
delay_us(keep_time);
}
mode = 1;
}
}
}
void charging_algorithm()
{
if((int)BAT_VOLT > 28 && (int)BAT_VOLT<30)
{
duty_cycle = 2;
bet3 = 1;
bet4 = 1;
}
else if((int)BAT_VOLT < 28)
{
53
duty_cycle = 8;
}
//count = 0;
for(count = 0;count < 64; count++)
{
for(ascending = duty_cycle ;ascending > 0; --ascending)
{
Ho1 = 0; Lo2 = 1;
Ho2 = 0; Lo1 = 1;
delay_us(keeping_time);
}
for(descending = duty_cycle + 1;descending <= max_count;descending++)
{
Ho1 = 0; Lo2 = 0;
Ho2 = 0; Lo1 = 0;
delay_us(keeping_time);
}
}
void check_input_current()
{
input_current_collect = adc_get_sample(0);
input_current = input_current_collect * 4.888;
IN_CURRENT = (input_current*100.0);
IN_CURRENT = IN_CURRENT/1000;
}
void check_battery_level()
{
battery_collect = adc_get_sample(2);
battery_voltage = battery_collect * 4.888;
BAT_VOLT = (battery_voltage*100.0);
BAT_VOLT = BAT_VOLT/1000;
54
}
void turn_off()
{
Ho1 = 0; Lo2 = 0;
Ho2 = 0; Lo1 = 0;
}
int
output_voltage_collect,input_current_collect,output_voltage,input_current,battery_collect,bat
tery_voltage,k;
float AC_VOLT,BAT_VOLT,IN_CURRENT;
55
void show_oss();
void show_mains();
void display_bat();
void display_volt();
void check_battery_level();
void check_output_voltage();
void main() {
ADC_Init();
lcd_init();
cmcon = 0x07;
adcon1 = 0x80;
lcd_cmd(_lcd_clear);
lcd_cmd(_lcd_cursor_off);
trisa = 0xff;
trisc.f5 = 1;
trisc.f7 = 1;
trisd.f0 = 1;
trisd.f1 = 1;
while(1)
{
if(((oscillator == 0) && (mains_sense == 0))||((oscillator == 0) && (mains_sense ==
0)))
{
show_oss();
}
else if((oscillator == 0) || (mains_sense == 1))
{
show_mains();
}
}
}
void show_oss()
{
56
check_output_voltage();
check_battery_level();
lcd_out(1,2, "Walker,Tope,Jude,Shola Inverter");
for(k=0; k<15; k++) {
Lcd_Cmd(_LCD_SHIFT_LEFT);
Delay_ms(500);
}
lcd_cmd(_lcd_clear);
lcd_out(1,1, "Inverter mode");
display_volt();
if(bet3 ==1 && bet4 ==0)
{
delay_ms(500);
lcd_out(2,1,"Low battery");
delay_ms(3000);
}
else if(bet3 ==0 && bet4 == 1)
{
delay_ms(500);
lcd_out(2,1,"Over load");
delay_ms(3000);
lcd_cmd(_lcd_clear);
}
else if(bet3 ==1 && bet4 == 1)
{
delay_ms(500);
lcd_out(2,1,"Over load");
delay_ms(3000);
lcd_cmd(_lcd_clear);
}
}
void show_mains()
{
57
lcd_cmd(_lcd_clear);
check_battery_level();
lcd_out(1,2, "Walker,Tope,Jude,Shola Inverter");
for(k=0; k<15; k++) {
Lcd_Cmd(_LCD_SHIFT_LEFT);
Delay_ms(500);
}
lcd_cmd(_lcd_clear);
lcd_out(1,1, "Mains mode");
display_bat();
if(bet3 ==1 && bet4 ==0)
{
delay_ms(300);
lcd_out(2,1,"Fully charged");
delay_ms(4000);
}
else if(bet3 ==0 && bet4 == 1)
{
lcd_out(2,1,"Charging");
delay_ms(1000);
}
else if(bet3 ==1 && bet4 == 1)
{
delay_ms(300);
lcd_out(2,1,"Float charging");
delay_ms(3000);
lcd_cmd(_lcd_clear);
}
}
void check_output_voltage()
{
output_voltage_collect = ADC_get_sample(1);
output_voltage = output_voltage_collect * 4.888;
58
AC_VOLT = (output_voltage*403.67);
AC_VOLT = AC_VOLT/1000;
}
void check_battery_level()
{
battery_collect = adc_get_sample(2);
battery_voltage = battery_collect * 4.888;
BAT_VOLT = (battery_voltage*100.0);
BAT_VOLT = BAT_VOLT/1000;
}
void display_bat(){
lcd_out(2,1, "battery : ");
lcd_chr(2,11,((BAT_VOLT * 10)/ 100) + 48);
lcd_chr(2,12,((int)BAT_VOLT) %10+ 48);
lcd_out(2,13,".");
lcd_chr(2,14,((int)(BAT_VOLT * 10))%10+ 48);
lcd_out(2,15,"V");
}
void display_volt(){
lcd_out(2,1, "voltage = ");
lcd_chr(2,11, (int)(AC_VOLT/100)+48);
lcd_chr(2,12, ((((int)(AC_VOLT))%100)/10)+48);
lcd_chr(2,13, ((int)(AC_VOLT))%10+48);
lcd_out(2,14, ".");
lcd_chr(2,15, ((int)(AC_VOLT*10))%10+48);
lcd_out(2,16, "V");
}
59