Real Project
Real Project
INTRODUCTION
1.1 Background of Study
A 5kVA inverter system is a critical component in a photovoltaic solar power system. It converts the
direct current (DC) output of a photovoltaic solar panel into a utility frequency alternating current
(AC) that can be fed into a commercial electrical grid or used by a local, off-grid electrical network
[1]. The system is designed to provide a clean sinusoidal 50 or 60 Hz AC current that can be applied
directly to the commercial electrical grid or to a local, off-grid electrical network [1].
Electricity is the main source of power for domestic consumption, industrial development, and
medical centers.However, power failure has resulted in people buying fuel generators for their own
daily activity. Other businesses are also not functioning due to absence of constant power supply.
These are the reasons that necessitate the designing and the construction of a solar powered inverter
and other standby system that can deliver maximum output power to the load[2]. As society grows
from simple to complex, the need for power grew with this complexity and so it becomes necessary
to generate another type of power using inverter[2].
2
1.2 Problem Statement
Nigeria is a country that has been buoyant in the production of crude oil and carbon by-products.
However, despite this, the country remains underdeveloped, and one of the reasons for this is the
lack of electricity. The country is unable to provide constant electricity, which has led to problems
for citizens, especially business owners. In addition, the use of carbon by-products has left the
country dirty and polluted. Therefore, there is a need for the construction of a 5kVA inverter system,
which would provide less pollution and noise, and help to address the country's energy needs in a
more sustainable way.
3
condition, refrigerator, telecommunication and broadcast equipment, public address systems,
rechargeable lambs etc. is a major segment of an uninterrupted power supply unit(UPS).
Efficiency and reliability in power conversion are paramount, and this project offers the opportunity
to improve both. Achieving a high efficiency rating in an inverter can reduce energy wastage and
operational costs, making it not only an environmentally friendly solution but also a cost-effective
one.
The inverter is in high demand because of the advantage it offers against other alternative ways of
power generation, such as generators [3].
1.5 Scope and limitation of the project
The scope of this project is to design and construct an inverter with an output power rating of 5KVA,
from a 12V dc input. The design and construction of a 5KVA inverter is justified by the fact that it
converts 12V dc from a battery to 220V ac, 5KVA output which can be used to power essential
circuits such as computers, electric bulb, refrigerator, air conditions etc.
Despite the benefit of constructing an inverter and its pollution and noise free nature unlike other
alternative sources of power generation, there is need to charge the battery so as to supply power in a
cloudy day or in the night.
Chapter one contains introduction which dives into the background of the work, problem statement,
aim and objectives of the project.
The second chapter discussed the theory of the inverter system, it features a review of current
literature on inverter system, a summary of the review and literature gaps.
The third chapter is the method used to execute the project also mentions the design analysis of the
work, circuit diagram explanation and preliminary design assumption. It discusses the design and the
construction process, principle operation of an inverter, design principle of transformer.
The chapter four explains the different tests taking before the project commence and after the
completion of the project with result analysis.
The last chapter is the conclusion, recommendation and references of the project.
4
CHAPTER TWO
LITERATURE REVIEW
2.1 Theory of the Inverter System:
2.1.1 Introduction
An inverter is a device that converts direct current (DC) to alternating current (AC) [4]. It serves the
opposite purpose of a rectifier, which transforms alternating current to direct current. The oscillator,
amplifier, switching, and transformer stages of the inverter system all work together to provide the
appropriate alternating current output. These inverter system stages are designed to create output
with the desired frequency, phase, and voltage that is compatible with that required in domestic
appliances and industries [4].
The power inverter was invented in the late 1800s as a result of significant research into current
electricity[5]. Early inverters were electromechanical devices that looked like generators and
operated via a rotating-coil mechanism. David Prince coined the name "inverter" when he published
an essay on inverters in the GE Review in 1925[5].
Inverters were developed throughout the middle of the twentieth century, and we would not have
them now without Tesla's work and inventions1. Inverters switched from mechanical vibrations to
solid-state transistors (which control the flow of signals through a circuit) in the 1960s to oscillate
DC and generate square wave AC[6].
Vanner Inc introduced a 1000 watt inverter for use in ambulances in 1979[6]. The company's
technology was celebrated for its incredible 87% efficiency and a rising product range that
influenced the future[6]. Having already merged with Weldon, it purchased the rights to the pure sine
wave inverter in 1994[6].
Power inverters as we know them today first appeared on the market about 1995[6]. Statpower Tech
Corp of Canada, along with Vanner-Weldon, developed the pure sine wave inverter/charger on the
back of its high-frequency modern sine wave inverters[6]. Using high-frequency switching
techniques, it was able to deliver more output with less distortion in both charger and inverter
modes[6].
5
2.1.3 Classification of Inverters
a. Mode of Operation:
I. Stand-alone inverters: These supply stable voltage and frequency to the load[7].
II. Grid-connected inverters: These are the most commonly used option.
III. Bimodal inverters: These are usually more expensive and are used less often[7].
b. Type of Output:
II. Modified square wave inverters: These are used for resistive, capacitive, and inductive loads[8].
III. Square wave inverters: These are used for some resistive loads[8].
c. Source of Inverter:
III. Variable DC-link inverters: Their input voltage is controllable by adjusting the values of
inductor and capacitor used for DC link[9].
I. Square Wave inverter: The square wave inverter converts DC input into square wave AC
output[9].
II. Quasi Square Wave inverter: Quasi square wave came as modification of square wave
inverter[9].
6
f. Communication Base Classification:
I. Serial Communication (e.g., RS-232, RS-485): This is reliable and easy to implement but can be
slow and limited in terms of data transfer rates[10].
II. Parallel Communication (e.g., Centronics, SCSI): This offers high speed and throughput but
requires a large number of cables and pins, and can be difficult to synchronize[10].
III. Ethernet Communication (e.g., Ethernet, Modbus TCP): This also offers high speed and
throughput, and long-distance capability. However, it requires additional equipment such as
switches and routers, and can be susceptible to network congestion and packet loss[10].
IV. Bluetooth Communication (e.g., Bluetooth Classic, Bluetooth Low Energy): This has low power
consumption and is easy to use and implement. However, it has a limited range and data transfer
rates, and can be susceptible to interference from other wireless devices[10].
V. Zigbee Communication (e.g., Zigbee, Thread): This also has low power consumption, offers
mesh networking, and is secure. However, it has limited bandwidth, range, and the number of
devices that can be connected to a single network[10].
VI. Wi-Fi Communication (e.g., Wi-Fi, Modbus TCP/IP): This offers high speed and throughput,
wide range, and is easy to use. However, it requires additional equipment such as routers and
access points, and can be susceptible to interference from other wireless devices[10].
7
2.1.4 Diagram of an Inverter
Fig 2.1 shows a typical inverter, and it’s various components. These components work hand in hand
to aid proper function of the inverter. The functions of these components are as follows:
a. Battery(s):
The battery is a crucial component of an inverter. It provides the initial electrical energy in the form
of direct current (DC) which the inverter then converts into alternating current (AC) for use in
appliances[12]. The DC is drawn from the batteries and converted to AC Sby the inverter for use in
appliances[12]. Conversely, the batteries are charged by being plugged into a power source.
There are several battery chemistries used in inverter batteries, including lead-acid, lithium-ion, and
nickel-cadmium[12]. Lead-acid batteries are the most common type of inverter batteries and are
available in two variants: flooded lead-acid batteries and sealed lead-acid batteries[13]. The capacity
of a battery is the amount of wattage in run time that is to be expected from a battery. It is calculated
in Ah (Ampere hours). For instance, purchasing a battery that provides a run time of 3hrs and
assuming the standard battery voltage is 12V will require a battery with a capacity of (400 * 3) / 12 =
100 Ah[13]. Most inverter batteries are rated at 12 volts, but some larger systems may use 24-volt
batteries[13]. Another important thing to consider is the depth of discharge, which is the capacity to
which the lead-acid battery is discharged before it is charged again. The recommended depth of
discharge for lead-acid batteries is often 50%[13]. Except for locally made and non-branded
inverters, all inverters have battery protection technologies which protect the batteries from damage,
overheating, overcharging, deep discharge, and misplacement of the battery terminals. They also
have displays, LED lights, and alarms that show and inform the user of the state of the battery[13].
b. Oscillator:
The oscillator is a crucial component of an inverter. It generates a periodic signal, often a sine wave
or a square wave, which is used to switch the inverter’s output between positive and negative
8
states[14]. This switching action is what converts the DC input from the battery into AC
output[14].There are several types of oscillators that can be used in inverters, including relaxation
oscillators, ring oscillators, and crystal oscillators. The choice of oscillator depends on the specific
requirements of the inverter, such as the desired frequency and stability of the output[14]. An
oscillator circuit typically consists of an amplifier and a feedback loop. The amplifier provides gain,
while the feedback loop determines the frequency of the oscillation[14]. In many inverter designs,
the amplifier is implemented using a CMOS unbuffered inverter, which has high input impedance,
high gain, and high bandwidth[14]. The feedback loop often includes passive components such as
resistors and capacitors, which determine the frequency of the oscillation[14]. The performance of
the oscillator is critical to the overall performance of the inverter. A stable and accurate oscillator can
produce a high-quality AC output with low distortion[14]. On the other hand, an unstable or
inaccurate oscillator can result in a poor-quality output with high distortion[14]. In some inverter
designs, the oscillator is controlled by a microcontroller or DSP processor. These processors generate
the required pulses with the desired frequency[15]. This allows for precise control of the inverter’s
output[15].
c. Current Driver:
The current driver is a crucial component of an inverter. It amplifies the AC from the oscillator to
increase its power. This is necessary because the oscillator usually generates signals with low
power[16]. The current driver circuit typically consists of a network of power transistors[16]. These
transistors are responsible for turning the DC into three phases for the motor. This network of power
transistors in a small inverter drive is often one ‘Intelligent Power Module’ (known as an IPM) and
includes its own protection and basic control circuits[16]. The performance of the current driver is
critical to the overall performance of the inverter. A stable and accurate current driver can produce a
high-quality AC output with low distortion. On the other hand, an unstable or inaccurate current
driver can result in a poor-quality output with high distortion[16]. In some inverter designs, the
current driver is controlled by a microcontroller or DSP processor. These processors generate the
required pulses with the desired frequency. This allows for precise control of the inverter’s output.
d. Step-up Transformer:
A step-up transformer is a type of transformer that increases the voltage from its primary (input) side
to its secondary (output) side. It’s called a “step-up” because it elevates the voltage level.
In the context of an inverter, the step-up transformer comes into play after the DC power has been
converted into AC. Here’s the basic process:
I. DC to AC Conversion: The inverter first converts the low-voltage DC power into AC power.
This is typically done using electronic switches that rapidly turn the DC power on and off,
creating a square wave or sine wave pattern that mimics AC power[17].
II. Voltage Elevation: The AC power is then fed into the step-up transformer. Because the
transformer is designed with more turns of wire on the secondary coil than on the primary coil, it
increases (or “steps up”) the voltage of the AC power[18].
III. Power Output: The high-voltage AC power from the secondary side of the transformer can then
be used to power AC devices or fed into the electrical grid.
9
e. Control Unit:
This is the brain of the inverter. It manages and regulates the operation of all other components to
ensure efficient performance and safety. It controls the switching of signals according to the
requirement. The control unit of an inverter is responsible for controlling the frequency of power
supplied to an AC motor to control the rotation speed of the motor[19]. Without an inverter, the AC
motor would operate at full speed as soon as the power supply was turned ON[19]. The use of an
inverter to adjust the speed and acceleration of an AC motor increases the range of applications of
the motor compared with a motor that operates at a constant speed[19].
f. Output:
This is where the converted AC power is delivered to external devices or systems[20].
g. AC Power Supply:
This represents an alternative source of power, indicating that this inverter can also be powered by an
external AC source[21].
2.2 Review of Related Literatures:
“Design and Construction of 5KVA Solar Power Inverter System”[22]: This paper presents the
design and construction of a 5kVA solar power inverter system. The solar panels were installed free
from trees/building shade aligned to receive maximum sun rays at 450 North-East. The panels were
then connected to the charge controller and the circuit was wired to the battery. It was observed that
7.8% of the total output power was lost during the testing and measurements which resulted from
components used. The output voltage (VOUT) for both expected and achieved values of the solar
cell is 100V, the output current (IOUTPUT) for the inverter is 10A for expected value and 9.7A for
the achieved value[22].
“Design and Construction of 5KVA Inverter”[23]: This document discusses the use of inverters as an
alternative for un-interruptible power supply due to their greater environmental compatibility. The
major challenge remains local production of sufficiently high powered inverters for big loads and
longer periods of time. In this study, effort is made to produce a robust KVA inverter. The
construction is divided into four units consisting of oscillator unit, MOSFET assembly unit,
Transformer unit and battery charger monitor unit. Each constructed unit was independently tested
for proper functionality before the composite coupling[23].
“Multilevel Inverters for High-Power Applications”[24]: This study, published in 2023, reviews and
compares different topologies of Multilevel Inverters (MLIs) used in high-power applications. The
authors found that MLIs present better control and a good range of system parameters than two-level
inverters. They suggest that MLIs are more suitable for high-power applications[24]. The paper aims
to review and compare the different topologies of MLI used in high-power applications. Single and
10
multisource MLI’s working principal and switching states for each topology are demonstrated and
compared. A Simulink model system integrated using detailed circuit simulations in developed in
MATLAB Simulink program[24].
“Comparative Review of Three Different Power Inverters for DC–AC Applications”[25]: This paper,
published in 2023, presents a comparative review of three different widely used power inverters: the
conventional six-switch inverter, the reduced switch count four-switch inverter, and the eight-switch
inverter. The authors discuss each inverter with respect to cost, complexity, losses, common mode
voltage, and control techniques[25]. The paper is intended to serve as a guide regarding selecting the
appropriate inverter for each specific application[25].
“A General Review of Multilevel Inverters Based on Main Submodules”[27]: This review provides a
comparative study between different topologies of multilevel inverters. The MLIs are categorized
and investigated from different perspectives such as the number of components, the ability to create
inherent negative voltage, working in regeneration mode and using single dc source[27].
“Best Solar Inverters 2023”[28]: This review provides a guide to the best grid-tie solar inverters. The
hype around home batteries is also growing, but battery systems still require a solar inverter to
enable charging from solar[28].
“The Best Power Inverters of 2024”[29]: This review provides a guide to the best power inverters of
2024. The best power inverters should have high wattage, plenty of outlets, resistance to overloads,
short circuits, and high temperatures to keep your devices safe[29].
[27], The authors present the background and motivation for studying multilevel inverters (MLIs),
which are DC-to-AC converters that offer more output levels and lower harmonic distortion than
traditional two-level inverters.
[26],The authors review and compare five types of MLI topologies based on the number and
configuration of voltage sources, switches, capacitors, and diodes. They discuss the advantages and
disadvantages of each topology in terms of complexity, cost, efficiency, and performance.
11
[24],The authors develop a MATLAB-Simulink model to simulate the behavior of different MLI
topologies under varying speed and torque conditions. They measure the total harmonic distortion
(THD) of the output voltage and current waveforms and compare the results among the topologies.
The authors conclude that MLIs are more suitable for high-power applications than two-level
inverters, and that cascade-five-level and NPC-five-level MLIs have shown the lowest current
harmonics. They also suggest some possible improvements and extensions for future research.
a. Advanced Control Techniques: While the literature discusses various control methods for single-
and three-phase inverters, there is a lack of research on advanced control techniques that can improve
the efficiency and reliability of power inverters.
b. Integration with Renewable Energy Sources: As the world moves towards renewable energy, there
is a need for research on how power inverters can be better integrated with renewable energy sources
like solar and wind.
c. Inverter Design for Specific Applications: Most of the literature focuses on general-purpose
inverters. There is a gap in the research on inverters designed for specific applications, such as
electric vehicles or industrial machinery.
d. Efficiency Improvement: While the efficiency of power inverters has improved over the years,
there is still room for research on how to further improve this aspect, especially for high-power
applications.
e. Cost Reduction: The cost of power inverters is a significant barrier to their widespread adoption.
Research on how to reduce the cost of these devices, either through improved manufacturing
techniques or innovative design, is needed.
f. Reliability and Durability: Power inverters are often used in harsh environments and under
demanding conditions. Research on how to improve their reliability and durability is another
potential gap in the literature.
12
CHAPTER THREE
The First step in this project is to determine the exact requirements of the individual parts of the
system, this in general enables the system designer to have a concrete idea on what the system is
required to achieve at the end putting into consideration also, a standard of measurement of how
much of the specified qualities of the system is to be achieved at the end of the system design. As
applied to this project, the design specifications will be analyzed under the following headings -
functional, power and physical structure specification.
Considering the computing requirements of the system, the central component of the design
hardware is chosen to be a microcontroller with high enough internal flash memory to contain the
program code. For this project, the dsPIC30F2010 microcontroller was chosen due to its faster
processor which uses a 16-bit for signal processing, and the ease to be interfaced with other
components such as NTC 10K heat sensor and CT5A/5mA current sensor, low power consumption,
and easily availability of development tools and libraries.
13
The display unit chosen for the project is a 16x2 LCD, the choice is made due to its portability and
low power consumption. It has backlight and potentiometer adjustable contrast for visibility
adjustment. It can display 16 characters per line and there are two of such lines. Each of the character
is created by 7 by 5-pixel matrix.
The conditions to be monitored by this system are the heat / temperature, current overloading and
battery voltage, which are sensed by NTC 10k sensor, CT 5A/5mA sensor and by the use of potential
divider circuit with comparator respectively. These are in general low cost and low power
consumption sensors which are easily interfaced with the microcontroller. More on these sensors will
be discussed in the proceeding chapter when we discuss the circuit design.
14
3.4 Analysis of the System
This section provides a detailed analysis of the circuit diagram and explains the concept behind each
section of the entire circuit diagram. The system operates in two modes, inverting mode and
charging mode. At inverting mode, the system converts the D.C source to A.C signal to power A.C
loads while in the charging mode; the system uses the Mains A.C signal as a source to charge the
battery. This it accomplishes by the use of a rectification technique to convert the A.C signal to
suitable D.C signal for charging of the battery.
R/W gives you the choice between writing and reading. If set (R/W=1) reading is enabled. R/W=0
when writing.
Enable pins is used by the LCD to latch information presented to its data pins. When data is supplied
to data pins, a high to low pulse must be applied to this pin in-order for the LCD to latch in the data
15
present at the data pins. D0-D7 The 8-bit data pins, D0-D7, are used to send information to the LCD
or read the contents of LCD's internal register.
In the interfacing of the LCD to the dsPIC30F2010, the data pin D4- D7 were used to send
information to the LCD from the controller. These data pins are connected to the RB3, RB3, RB5,
RB6 of the controller respectively. The RS and E pin are connected to the RB0 and RB1 pin of the
controller respectively.
16
Figure 3.3: Pin Layout of dsPIC30F2010 Microcontroller
17
17 PGD/EMUD/U1TX/SDO1/SCL/RF3 F
18 PGC/EMUC/U1RX/SDI1/SDA/RF2 F
19 Vss Ground
20 VDD Positive Power Supply for analogue module
21 PWM3H/RE5 E
22 PWM3L/RE4 E
23 PWM2H/RE3 E
24 PWM2L/RE2 E
25 PWM1H/RE1 E
26 PWM1L/RE0 E
27 AVSS Analogue Ground
28 AVDD Analogue Power Supply
CT 5A/5mA (current transformer) is a sensor that measure alternating current (AC). They are
particularly useful for measuring whole building electricity consumption or generation. It is a device
that detects and converts current to an easily measured output voltage which is proportional to the
current through the path. CT was used in this work to check for current over-loading in the inverter.
The two terminals of the CT are used to connect to ground and to the microcontroller. The line to
measure for the current is allowed to pass through the hollow of the CT.
18
Figure 3.5: Current transformer used as current sensor
For example, if the voltage input is 52v, then the voltage appearing in the microcontroller will be:
R1
V R2 = x V¿ (1)
R 1+ R 2
12 k
V R 2= x 52 v
100 k +12 k
19
12
x 52=0.107 x 52=5.57 V
112
In mains mode the inverter is expected to charge the batteries; in this mode, the low side MOSFETs
are switched to ensure charging. Power from the mains is stepped down by series of resistors and
then rectified to DC, the output is connected to pin 2 of ADC module of the dsPIC30F2010
microcontroller. The output voltage sense is achieved by using series of resistors to lower the output
voltage to a safe working voltage for the microcontroller pin 3 after passing through a rectification
diode.
The relay circuit is controlled by dsPIC30F2010. Whenever there is mains, the microcontroller sends
signal to the relay circuit to switch mains into the inverter circuit for charging, and also to supply the
load. Figure 3.3 shows the relay circuit for the power inverter.
20
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 MOSFET, 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.
H-Bridge is rather simple circuit, containing four switching element, with the load at the center, in an
H-like configuration. The switching elements are usually bi-polar or FET transistors, but for this
project, the switching element is MOSFET (IRF4110). MOSFET was used because of its fast
switching response and because of its ability to handle higher voltages.
The top end of the bridge is connected to a power supply (battery) and the bottom-end is grounded.
In general, all four switching elements can be turned on and off independently, though there are
some obvious restrictions. The load in this aspect is the step-up transformer.
21
Figure 3.9: The Switch Section
S/N Q1 Q2 Q3 Q4 RESULT
1. ON OFF OFF ON +VE
2. OFF ON ON OFF -VE
3. ON ON OFF OFF ZERO
4. OFF OFF ON ON ZERO
The number of MOSFET in each side of the H-bridge required for the inverter is calculated by
computing the maximum current Imax required which is given by
And then dividing the maximum current of the inverter by maximum current capacity of each
MOSFET.
22
104.167
Number of MOSFET = =0.58
180
wℎere 180 is tℎe maximum drain current I D of MOSFET IR 4110, gotten ¿ tℎe datasℎeet
In the design of the 5KVA inverter transformer, the size of the lamination was obtained from the
following formulas listed from equations 3 to equation 7 so that it can provide enough magnetic flux
for stepping 48V AC to 220V AC at the required power rating.
The following calculations were made in designing the transformer, for a 5KVA:
1
TPV = −4
− −−− −−(4)
(4.44 x 10 x CA x flux density x AC frequency)
1
turns per volt= =0.425
( 4.44 x 10 x 81.5 x 1.3 x 50 )
−4
(5000)
primary winding current= =130 A
(48 x 0.8)
23
(5000)
secondary winding current= =28.4 A
220 x 0.8
1
F c= −− −−(8)
2 π √ LC
Where
F c – cut-off frequency
C – Shunt capacitor
Since the secondary side of the transformer has an inductance all that was needed was just a shunt
capacitor.
Φ
Tℎe secondary windinginductance L= −− −−(9)
¿
0.000 10595 −8
L= =5.69 x 10 H
93.5 x 19.9
Hence the minimum capacitor value needed for the low pass filter is given by;
24
1
C= 2 2
−−−(10)
4π xf L
1
C= 2 2 −7
=25.5 F
4 π x 50 x 3.97 x 10
25
Figure 3.10: flow diagram of the inverter
Step 2: Initialize ADC and LCD Libraries: This imports the libraries to be used for the program, port
declaration and clearing.
Step 3: IS MAINS ON? : A decision is made here, if YES, the charging algorithm is implemented to
charge the battery. When the battery is greater than 55V, the charging stops, but if the battery is less
than 55V, the battery charging continues. If MAINS ON IS NO, then PWM is initialized. This
initialization occurs only if battery voltage is greater than 42V; otherwise the battery charging
algorithm is implemented. After initializing PWM, the system checks the output voltage if it is
greater than 220V. If greater than 220V, the duty cycle of the PWM is reduced, if lesser than 220V,
the duty cycles of the PWM is increased.
26
Figure 3.11: Flow Chart of current sensor
27
CHAPTER FOUR
The third chapter explained that the inverter is separated into two parts: the control stage and the
power stage. These components were developed and tested independently, and once all of them had
produced the expected results, they were combined to form the inverter system.
a. Soldering iron
b. Soldering lead
c. Multi-meter
d. PCB
e. Cutter
f. Pliers.
As explained in chapter three, the control stage consists of four sections: oscillating, signaling,
switching, and sensing. The connection of these sections to the microcontroller was addressed in
Chapter three. In order to implement these sections, the various interface devices were tested to
ensure they were in good working order.
The LCD was tested by giving power to its anode and cathode pins. When this connection was made,
the LCD's backlight lit up. In addition, a variable resistor was connected to the VSS pin to control
the backlight's contrast. After establishing the LCD's viability, it was connected to the
microcontroller. The same procedure was carried out the buzzer, but this time electricity was
supplied to the buzzer's positive and negative terminals to see if it beeped. The various sensors used
were also tested.
The CT current sensor and the NTC heat sensor were employed to measure AC current overload and
temperature, respectively. Before connecting these devices to the microcontroller, the CT was tested
to measure the current in an AC line. This was accomplished by attaching an AC line to the CT's
sensing terminal and reading the output with a digital meter. After confirming that the CT was in
good working order, it was connected to the microcontroller.
28
The NTC heat sensor, which is a variable resistor, was tested by simply measuring the resistance
value of the NTC with a meter. It read a good value, indicating that it is in good operating order.
The relay, which is a crucial component of the switching section, was also tested prior to connecting
with the controller. A multi-meter was used to carry out the test, which includes measuring the
resistance value of the relay's pins. For a 12v relay utilized in this project, the coil resistance value
stated by the manufacturer should be around 320 ohms. When the test was completed, the coil
resistance measured 280 ohms. This is a high value, indicating that the relay coil is good. The relay's
other terminals were also tested (COM, NO, and NC). The test was carried out by measuring the
resistance between the COM, NO, and NC terminals. For a NO terminal, the resistance value should
read high indicating an open circuit while for NC terminal, the resistance value should read
approximately zero; indicating a closed circuit. Following confirmation, it was connected to the
controller.
All of the control sections of the inverter were implemented on a separate PCB from the power part.
This control portion requires a voltage source of 12v and 5v for the relay and LCD, respectively.
Hence, a supply of 12V was tapped from the power part of the inverter to the controller part.
LM324N voltage regulator was used to supply a stable 5v to the LCD. The circuit of the control part
was implemented such that it was placed at the front end of the inverter system. This is because it
comprises of the LCD. The LCD shows the status of the inverter, hence more reasonable to be placed
at the front.
29
Figure 4.1: Image of the Control Part of the Inverter
From chapter three, the sections of this power stage include the driving section, the switching
section, transforming section, filtering section and power supply section. The interfacing of these
30
sections to the controller has been discussed in chapter three. A test for the workability of the
components used in these sections was carried out.
For the switching section, a test of the MOSFET working condition was carried out. A test for the
MOSFET pins was done by the use of multi-meter to test for the Gate, Source and Drain pin. This
was done by setting the multi-meter to the diode mode. Firstly, the internal capacitance in the
MOSFET is discharged by touching the gate and drain pins of the MOSFET with a conductor
material. Then the meter black probe is connected to the source and the red probe to the drain of the
device. An open circuit indication on the meter confirms that the MOSFET is in good working
condition. To compensate for the heat generated by MOSFETs when in operation, a heat sink was
attached to all MOSFETs. In the configuration of the H-Bridge circuit, two MOSFETs were used at
each side of the h-bridge instead of one MOSFET as seen from the calculation in chapter three. The
reason is to increase the current handling capacity of the MOSFETs in case of current surge. In the
H-bridge circuit connection, the drain of all the MOSFETs were linked to another, hence, in the
implementation, the body of the MOSFET to the drain was used to join all the drains of the
MOSFETs through the heat sink (heat sink being an aluminum is a good conductor).
The iron-core transformer being a low frequency transformer is always large in size and very heavy.
These necessitated that the transformer be positioned at the center of the inverter circuit. This was
done to prevent a case whereby the mass of the inverter system is being shifted to just one end of the
body. By so doing, being at the center will make the weight of the inverter system to be balanced.
The iron cores of the transformer were tightened firmly with a screw and nut. This is to ensure close-
packing of these cores in order to reduce excess noise that results from vibration of these cores if
loosely packed.
The driving section and the switching section were implemented on same PCB; separated from the
other sections. It is in this board that DC supply battery goes to for inversion. It is positioned at the
back of the inverter, very close to the fan. The essence of the fan is to reduce the heat temperature of
the MOSFETs.
31
Figure 4.2: Image Showing the Power Stage Input
The power supply section of 12v switch mode was implemented using a ferrite core transformer and
rectification circuit. This section was implemented on a separate PCB placed in between the control
stage and switching/driving section. It is from this section that the control stage taps a 12v supply.
32
Figure 4.3: Image of the 12v Power Supply Unit
After the sections of the systems were integrated into a whole, few tests were carried out before the
packaging of the system. The tests were majorly on the control stage and the power stage of the
inverter.
In the control stage, emphasis was placed on the LCD display. When the inverter was operated in the
inverting mode, the LCD display was able to display that it is in the inverting mode, it was able to
tell the present voltage value of the battery. In the case of charging mode, the LCD display was able
to tell the difference.
33
Figure 4.4: LCD Display of the Inverter
In the power stage, a test was carried out on the switching section using multi-meter. A test of DC
voltage reading showed the voltage of the battery. Then a test of the voltage reading at the secondary
side of the transformer showed an AC reading of 220v.
The 48V battery of 200Ah was used to power electrical loads. These loads include a television,
ceiling fan, light bulbs, Music player, refrigerator and laptops. The combined wattage of these loads
is about 1600 watts. There was no long delay for the refrigerator to start producing ice, the light
bulbs were very bright and there were no fuzzy images on the television screen. This confirms that
the output signal produced had minimum distortion.
An analysis of different load characteristics applied to the inverter was carried out. This analysis
involved an evaluation of loads and power consumption. It was carried out with the battery fully
charged. Four cases will be examined and a load-time graph will be plotted to see how long the
battery lasts before discharging all its power.
34
PB
duration of battery , BL = −−− − ( 11)
PL
10560
¿ =2.6 ℎours=2 ℎr 60 minutes
4000
PB
duration of battery , BL =
PL
10560
¿ =5.3 ℎours=5 ℎr 30 minutes
2000
PB
duration of battery , BL =
PL
10560
¿ =10.6 ℎours=10 ℎr 60 minutes
1000
35
battery power∈ watt − ℎour , P B=I B V B =220 Aℎ x 48 V =10560 wℎ
PB
duration of battery , BL =
PL
10560
¿ =14.1 ℎours =14 ℎr 10 minutes
750
PB
duration of battery , BL =
PL
10560
¿ =21.1 ℎours =21 ℎr 1minutes
500
Table 4 shows the evaluation of the different battery duration at different loads
36
Figure 4.5. Graph Showing Battery Variation with Load.
4.4 Packaging
The constructed project was packaged to create a visually appealing device. Several aspects were
considered for packaging, including the longevity of the material utilized (wood, plastic, or metal).
Metal sheet was chosen for this project. This is to ensure that heat is easily dissipated into the
surroundings.
To avoid short-circuiting, all conducting components were appropriately insulated from the case, and
suitable connections were earthed.
The package's portability was considered in order to restrict the amount of space it will take up and
to reduce the strain associated with device relocation.
The ventilation of the package was also studied; this is to aid in the temperature regulation of the
gadget, as the majority of the components in the construction generate heat.
37
Figure 4.6: Packaged Inverter
38
4.5 Bill of Engineering Measurement and Evaluation (BEME)
Microcontroller
1 DSPIC30F2010 1 ₦10000 ₦10000
39
12 Temperature sensor 1 ₦3,000 ₦3,000
TOTAL 367,700
40
CHAPTER FIVE
Also, this inverter is a general-purpose inverter. It would be advisable for more research to be carried
out on inverters designed for specific applications, such as electric vehicles or industrial machinery.
41
REFERENCES
[1] Samphina, “Design and Construction of a 5KVA Solar Power Inverter”, Samphina Academy, 25
April 2018. [Online]. Available:https://shorturl.at/gEOR1[Accessed 30 January 2024].
[2] RC Research, “Design and Construction of a 5KVA Inverter,” RC Research Clue, 8 th January
2017[Online]. Available: https://shorturl.at/aiUY1[Accessed 30 January 2024].
[3] “How to choose a power inverter for your RV or road trip vehicle”, 9 th July,2014
[online].Available:https://shorturl.at/mqCUV [accessed 9th November, 2023].
[4] Fuji, “What Does an Inverter Do ?”Fuj Electronic Global. [Online]. Available:
https://shorturl.at/vFXY2[accessed 9th November, 2023].
[5] C.E.Mebunii, “Power Inverter Definition, History, Working Principle, and Types,” Felsics, April
2022.[Online]. Available:https://shorturl.at/jqFHP[Accessed 9
November 2023].
[6] Micheal Johns,“History of Power Inverters,”Wattalot.
[Online].Available:https://shorturl.at/BMOR9[Accessed 30 January 2024]
[7] Pennstate, “Inverter Types and Classifications,” Commercial Solar Electric Systems.[Online].
Available: https://shorturl.at/cfjY3[Accessed 30 January 2024].
[8] Rashikagupta1985, “Classification of Inverters,” Quick Learn, 21 June 2021.[Online]. Available:
https://shorturl.at/bvAQ3 [Accessed 9 November 2023].
[9] Muhammad Umair, “Inverter Basics, Classifications, and App;ications,” EE Power School, 3
January 2021. [Online]. Available: https://shorturl.at/fGKX1 [Accessed 9 November 2023].
[10] Scholartech,“Inverter Communications: Types, Applications, and Future
Trends,”Scholartechadvisor,11 April 2022.[Online].Available:https://shorturl.at/fq459
[Accessed 9 November 2023].
[11] Elprocus, “Inverter: Types, Circuit Diagram and Its Applications,” Elprocus,
[Online].Available:https://shorturl.at/loKQ6 [Accessed 9 November 2023].
[12] David watson, “Major Components of Inverters,” The Engineering Projects, 4 November 2012.
[Online]. Available: https://shorturl.at/gsNX0 [Accessed 9 November 2023].
[13] Solar Kobo, “Inverter Batteries: All You Need To Know,” Solarkobo, 11 August 2019.
[Online]. Available:https://shorturl.at/pNR68 [Accessed 9 November 2023].
[14] “How an Inverter Works,”CircuitsToday.[Online].Available: https://shorturl.at/tyJTU[Accessed
9 November 2023].
[15] James Irvine,“what is the function of an oscillator within an inverter circuit?” Electrotechonline,
29 May 2008.[Online]. Available: https://shorturl.at/dpN26 [Accessed 9 November 2023].
[16] Inverter Drive, “How an Inverter Drive Works and Controls the Speed of an AC Induction
Motor,”InverterDrive.[Online].Available:https://shorturl.at/hvwI2 [Accessed 9 November
2023].
42
[17] Paul Evans, “How Inverters Work,” The Engineering Mindset, 15 December 2017.[Online].
Available:https://shorturl.at/eyF67[Accessed 9 November 2023].
[18] IDS, “WHAT IS AN INVERTER?” www IDS.[Online]. Available:
https://shorturl.at/kluMR[Accessed 9 November 2023].
[19] THS, “Inverters 101: What is an Inverter and How do They Help?” THS Supply,15 March
2022. [Online]. Available:https://shorturl.at/bhFHV[Accessed 9 November 2023].
[20] Paul Evans, “Power Inverters Explained” The Engineering Mindset, 25 April 2020.[Online].
Available:https://shorturl.at/fpHJ3 [Accessed 9 November 2023].
[21] Powmr, “The Ultimate Guide to Choose Batteries for Inverter,”Powmr, 24 August 2023.
[Online]. Available: https://shorturl.at/puyN9[Accessed 9 November 2023].
[22] Ibrahim Aminu;Samuel Shaka;Yahaya Yunisa; Jangfa Timothy Zihmwang, “Design and
Construction of 5KVA Solar Power Inverter System” International Journal of Advances in
Engineering and Management (IJAEM),Vol 4, No. 2, pp: 1355-1358, February 2022.
[23] Osama B A L A Odeni,“DESIGN AND CONSTRUCTION OF 5KVA INVERTER,”
Academia, [Online]. Available:https://shorturl.at/jxyJ0[Accessed 9 November 2023].
[24] Chukwuka Anene,“Design and Implementation of a 5 kVA Inverter,” Research Gate, October
2016. [Online]. Available: https://shorturl.at/bftU8 [Accessed 9 November 2023].
[25] Abdulwasa B. Barnawi, Abdull Rahman A. Alfifi, Z.M.S. Elbarbary, Saad Fahed Alqahtani,
Irshad Mohammad Shaik, “Review of multilevel inverter for high-power applications,” Emerald
Insight, 11 October 2023. [Online]. Available: https://shorturl.at/lCWX1 [Accessed 9 November
2023].
[26] Md. Faruk Kibria, Ahmed Elsanabary, Kok SoonTey, Marizan Mubin, and SaadMekhilef, “A
Comparative Review on Single Phase Transformerless
Inverter Topologies for Grid-Connected Photovoltaic Systems,” Energies, p. 16, 1363.
[27] Ali Abdel-Aziz, Mohamed A. Elgenedy, and Barry Williams, “A Comparative Review of Three
Different Power Inverters for DC–AC Applications,” Energies,P. 16, 1363.
[28] Short Publishing Works, “Inverter battery capacity: What you need to know,” Inverter Guides, 4
April 2023.[Online]. Available:https://shorturl.at/gDSZ1[Accessed 9 November 2023].
[29] David Beren, “The Best Power Inverters of 2024,” Life Wire Tech for Humans, 7 February
2024.[Online]. Available:https://shorturl.at/sINY1[Accessed 8 February 2024].
43
APPENDIX
Code for the Microcontroller
#include <p30f2010.h>
#include <libpic30.h>
#include "DataEEPROM.h"
#define stbyinv 1
#define upsmode 2
#define invmode 3
#define modekey 4
#define upkey 5
#define downkey 6
#define stbyups 7
#define fanheat 640
///////////////////////////////////////////////////////////////////////////////////////////
const signed int
sine_table[91]={0,174,348,523,697,871,1045,1218,1391,1564,1736,1908,2079,2249,2419,2
588,2756,2923,3090,
3255,3420,3583,3746,3907,4067,4226,4383,4539,4694,4848,5000,5150,5299,5446,
5591,5735,5877,6018,6156,6293,6427,6560,6691,6819,6946,7071,7193,7313,7431,7547,76
60,7771,
7880,7986,8090,8191,8290,8386,8480,8571,8660,8746,8829,8910,8987,9063,9135,9205,92
71,9335,
9396,9455,9510,9563,9612,9659,9702,9743,9781,9616,9848,9876,9902,9925,9945,9961,99
75,9986,
9993,10000,10000};
44
struct
{
unsigned int frstdisp:1;
unsigned int setup:1;
unsigned int gravity:1;
unsigned int onflag:1;
unsigned int vcorrect:1;
unsigned int chrcorrect:1;
unsigned int chon:1;
unsigned int swon:1;
unsigned int nofeed:1;
unsigned int shorttrip:1;
unsigned int zincfail:1;
unsigned int mainsok:1;
unsigned int lbwarn:1;
unsigned int olwarn:1;
unsigned int olcut:1;
unsigned int lbcut:1;
unsigned int fault:1;
unsigned int hiload:1;
unsigned int msgrtn:1;
unsigned int chrmsgrtn:1;
unsigned int firston:1;
}flags;
int chshoot;
int chshootdly=0;
int flicker=0;
int *adjust;
int *ptr;
int adj;
int *value;
int chadj;
int champs1;
signed int duty_cycle_1;
signed int p=0,flag=1,rising=1;
int pb,qb,cth,ctl;
////////////////////////////////
unsigned int setdly;
unsigned int menudelay;
unsigned int lcdtmr;
unsigned int counter;
unsigned int resumedelay;
45
unsigned int buzzcount;
unsigned int buzzdelay;
unsigned int buzzoftme;
unsigned int buzzontme;
unsigned int peakfail;
unsigned int oldelay;
unsigned int tripdly;
unsigned int round;
unsigned int chrdly;
unsigned int slowdly;
unsigned int fbdly;
unsigned int ctfaildly;
unsigned int deadshortdly;
unsigned int lbdly;
unsigned int acdly;
unsigned int keydly;
unsigned int msgrtndly;
unsigned int gravitydly;
unsigned int fltdly;
unsigned int blinkdly;
unsigned int startdly;
////////////////////////////////
unsigned long endtimer;
unsigned long controlavg;
unsigned long mainsavg;
unsigned long outavg;
unsigned long wattsavg;
unsigned long batavg;
unsigned long keyavg;
unsigned long heatavg;
unsigned int modeavg;
/////////////////////////////////
unsigned int indummy;
unsigned int outdummy;
unsigned int ctdummy;
unsigned int keys;
unsigned int ntcvalue;
unsigned int batts;
unsigned int batrecharge;
//////////////////////////////////
unsigned int loaddisp;
unsigned int acoutdisp;
unsigned int mainsdisp;
unsigned int battdisp;
unsigned int battvolts;
unsigned int batrestart;
46
unsigned int loadpercent;
unsigned int champs;
unsigned int chdisp;
unsigned int mainsvolt;
unsigned int acout;
unsigned int keyvalue;
unsigned int key;
unsigned int heat;
unsigned int post;
unsigned int err;
unsigned int cherr;
unsigned int prect;
///////////////////////////////////
signed int upspeak;
signed int acpeak;
signed int ctpeak;
signed int batclb;
signed int mainsclb;
unsigned int chrclb;
unsigned int loadclb;
unsigned int pdctemp;
////////////////////////////////////
unsigned int deadshort;
unsigned int controlvolt;
unsigned int setvout;
unsigned int setchramp;
unsigned int setoverload;
unsigned int setupshi;
unsigned int setupslo;
unsigned int setinvhi;
unsigned int setinvlo;
unsigned int setbatful;
unsigned int setbatwrn;
unsigned int setbatlo;
unsigned int setbatres;
unsigned int defaults;
/////////////////////////////////////
47
extern unsigned short Eeprom_ReadWord(unsigned short pushAddressOffset);
void delay_ms(unsigned int gs);
void delay_us(unsigned int gs);
///////////////////////////////////////////////
const char str0[17]= "CALIBRATION MENU";
const char str20[17]="BATTERY V: V";
const char str21[17]="INVERTER MODE ON";
const char str22[17]=" U.P.S MODE ON ";
const char str23[17]=" SBY SWITCH OFF ";
const char str24[17]=" SBY SWITCH ON ";
const char str25[17]="MAINS VOLT: V";
const char str26[17]="INVERTER V: V";
const char str27[17]="TOTAL LOAD: %";
//////////////////////////////////////////
//const char str28[17]=" TRIP:C-T FAULT ";
const char str29[17]="TRIP:LOW-BATTERY";
const char str30[17]=" TRIP:OVERLOAD ";
const char str31[17]="SHORT CKT FAULT";
const char str32[17]="WARN:LOW-BATTERY";
const char str33[17]=" WARN:OVERLOAD ";
const char str34[17]=" TRIP:F-B FAULT ";
const char str35[17]="TRIP:SYNC FAULT ";
const char str36[17]="AC CHARGR: A";
const char str38[17]=" DSP SINEWAVE ";
#include "lcdsoft.h"
#include "functions.h"
void clear_flag();
void trip(int s);
int getvalue(int ch);
void chargeron();
void chroff();
void invon();
void invoff();
void stabilise();
void Modulate();
void find_key();
int findpeak(int ct);
void mains_stat_check();
void find_mainsvolt();
void find_batvolt();
void find_champs();
void find_upsvolt();
void find_load();
void overload_check();
void lobat_check();
48
void chr_stabilize();
////////////////////////////////////
void feed_buzz(int a,int b,int c)
{
buzzdelay=0;
buzzoftme=b;
buzzontme=a;
buzzcount=c;
}
//////////////////////////////////////////////////////
void __attribute__((__interrupt__,no_auto_psv)) _FLTAInterrupt(void)
{
_FLTAIF = 0;
}
//////////////////////////////////////////////////////////
void __attribute__((__interrupt__, __auto_psv__)) _T1Interrupt(void)
{
_T1IF = 0; // Clear interrupt flag
if(PORTEbits.RE8==0)
{
fltdly++;
if(fltdly>3000)
{
flags.olcut=1;
__asm__ volatile ("reset");
}
}
counter++;
acpeak=getvalue(0); //4.4 us
indummy=acpeak;
acpeak=indummy-508;
if(acpeak<0)
{
acpeak=508-indummy;
if(!flags.onflag)
{
rising=0;
flag=0;
}
}
mainsavg+=acpeak;
if(flags.setup)
{
49
OVDCON= 0X0000;
change=0;
buzzer=0;
}
if(!flags.setup)
{
if((indummy<600)&&(indummy>400)&&(flags.swon))
{
if(peakfail<150)
{
peakfail++;
}
if(peakfail==149)
{
if(flags.vcorrect)
{
invon(150);
}
}
}
else
{
peakfail=0;
}
if(flags.onflag)
{
Modulate(); //4.4 us
upspeak=getvalue(1); //4.4 us
outdummy=upspeak;
upspeak=outdummy-508;
if(upspeak<0)
upspeak=508-outdummy;
outavg+=upspeak;
if(upspeak<150)
{
fbdly++;
if(fbdly>30000)
{
flags.fault=1;
trip(5);
}
}
else
fbdly=0;
}
50
else
{
rising=1;
flag=1;
loadpercent=0;
acout=0;
}
ctpeak=getvalue(2);
if(flags.onflag)
{
if((ctpeak>750)||(ctpeak<250))
{
deadshortdly++;
if(deadshortdly>1500)
{
deadshort=1;
OVDCON= 0X0000;
trip(1);
}
}
}
else
{
if(flags.chon==1)
{
if((ctpeak<508)||(ctpeak>512))
ctfaildly=0;
else
{
ctfaildly++;
if(ctfaildly>10000)
{
chroff();
}
}
}
if(ctpeak>506)
{
51
pb=ctpeak-506;
if(cth<pb)
cth=pb;
}
if(ctpeak<506)
{
qb=506-ctpeak;
if(ctl<qb)
ctl=qb;
}
wattsavg+=cth+ctl;
ctl=cth=0;
heat=getvalue(3);
}
batavg+=getvalue(5);
lcdtmr++;
if(counter==359)////////////////////// 20 milli sec
{
mainsvolt=__builtin_divud(mainsavg,288)+mainsclb; //2.2 microseconds
mainsavg=0;
if(mainsvolt<90)
{
mainsvolt=0;
mainsdisp=0;
}
else
{
if((indummy>180)&&(indummy<900))
{
if(mainsdisp==0)
{
mainsdisp=mainsvolt-80;
}
if(mainsdisp<mainsvolt-2)
{
mainsdisp++;
}
if(mainsdisp>mainsvolt+2)
{
mainsdisp--;
}
}
}
52
find_batvolt();
keyavg+=getvalue(4);
keydly++;
if(keydly==10)
find_key();
if(!flags.setup)
{
mains_stat_check();
if(flags.onflag==1)
{
acout=__builtin_divud(outavg,285);
outavg=0;
if(acoutdisp<acout-2)
acoutdisp++;
if(acoutdisp>acout+2)
acoutdisp--;
find_load();
overload_check();
lobat_check();
}
}
wattsavg=0;
if(buzzcount>0)
{
buzzdelay++;
if(buzzdelay<=buzzontme)
buzzer=1;
else
{
buzzer=0;
if(buzzdelay>=buzzoftme)
{
buzzdelay=0;
buzzcount--;
fltdly=0;
}
}
}
else
{
53
FLTACON=0x0001;
IEC2bits.FLTAIE = 1;
if(round>0)
{
if((!flags.onflag)&&(flags.swon)&&(round<4))
{
if(mainsvolt<110)
{
clear_flag();
invon(0);
}
}
}
if(round==4)
change=0;
}
if(!flags.setup)
{
if((resumedelay==200)||(flags.mainsok==1))
{
LCD_DB6=1;
if(flags.swon==1)
{
blinkdly++;
if(blinkdly<30)
LCD_DB7=1;
else
LCD_DB7=0;
if(blinkdly>60)
blinkdly=0;
}
else
LCD_DB7=0;
}
else
{
LCD_DB6=0;
if(flags.onflag==1)
LCD_DB7=1;
else
LCD_DB7=0;
}
}
counter=0;
54
if((key==modekey)&&(flags.setup==0))
{
menudelay++;
if(menudelay>124)
flags.setup=1;
}
else
menudelay=0;
if(flags.setup==1)
{
setdly++;
if(setdly>3000)
__asm__ volatile ("reset");
}
}
cherr=mainsvolt;
}
//////////////////////////////////////
void init_PWM()
{
PTCON= 0XE003;
PTMR = 0x0000;
PTPER = PDC1=PDC2= 1230;
SEVTCMP = 0x0000;
PWMCON1 = 0x0033;
PWMCON2 = 0x0000;
DTCON1= 0X0059;
FLTACON = 0x0000;
OVDCON= 0X0000;
PTCONbits.PTEN = 1;
IEC2bits.PWMIE = 0; // disable PWM interrupts
T1CON = 0XE000;
TMR1 = 0;
PR1 = 1355;
_T1IF = 0;
_T1IE = 1;
}
/////////////////////////////////////////////////
void memread()
{
int x;
for(x=0;x<15;x++)
55
{
setting[x]=Eeprom_ReadWord(x);
}
}
//////////////////////////////////////////////////////////
void memwrite()
{
int x;
for(x=0;x<15;x++)
{
if(flags.setup==0)
Eeprom_WriteWord(x,factory[x]);
else
Eeprom_WriteWord(x,setting[x]);
}
}
//////////////////////////////////////////////
void modedisp()
{
if(flags.msgrtn)
return;
if((key==upsmode)||(key==stbyups))
{
printmes(str22,100); //"\fU.P.S MODE ON";
if(key==upsmode)
{
aclo=setupslo;
achi=setupshi;
}
}
if((key==invmode)||(key==stbyinv))
printmes(str21,100); //"\fINVERTER MODE ON";
}
//////////////////////////////////////////////////////
void swdisp()
{
if(flags.msgrtn)
return;
56
if((key==upsmode)||(key==invmode))
printmes(str24,100); //"\fSBY SWITCH ON";
}
// MAIN ROUTINE
//
**************************************************************************
***/
int main()
{
TRISF=0X0000;
TRISE=0X010F;
TRISD=0X0000;
TRISC=0X0000;
TRISB=0XFFFF;
OVDCON=0X0000;
PWMCON1 = 0x0000;
PTCONbits.PTEN = 0;
buzzer=0;
lcd_init();
InitADC1();
init_PWM();
keyvalue=getvalue(4);
if(((keyvalue>660)&&(keyvalue<680))||((keyvalue>560)&&(keyvalue<575)))
{
flags.swon=1;
flags.firston=1;
}
prect=getvalue(2);
flags.frstdisp=0;
defaults=Eeprom_ReadWord(14);
if(defaults!=50)
{
memwrite();
}
memread();
batclb=setting[0];
mainsclb=setting[1];
chrclb=setting[2];
loadclb=700-setting[3];
setvout=setting[4];
57
setchramp=setting[5];
chshoot=setchramp;
setchramp+=30;
setupshi=setting[6];
setupslo=setting[7];
setinvhi=setting[8];
setinvlo=setting[9];
setbatful=setting[10];
setbatwrn=setting[11];
setbatlo=setting[12];
setbatres=setting[13];
defaults=setting[14];
battdisp=90;
aclo=setinvlo;
achi=setinvhi;
batrestart=setbatful-13;
menudelay=0;
while(1)
{
//lcd_init();
//
//while(1)
//{
//lcd_init();
//printmes(str36,3); //"AC CHARGR:";
//flags.msgrtn=0;
////printmes(str20,1); //"\fBATTERY V:";
//
58
//
//
//
//
//}
//
while(PORTEbits.RE8==0)
{
flags.msgrtn=0;
printmes(str31,100); // SHORT CKT FAULT
if(flags.swon==0)
__asm__ volatile ("reset");
}
while(flags.nofeed==1)
{
flags.msgrtn=0;
printmes(str34,100); // NO FEED BACK
if(flags.swon==0)
__asm__ volatile ("reset");
}
//while(flags.ctfail==1)
//{
// flags.msgrtn=0;
//printmes(str28,100); // TRIP:C-T FAULT
//if(flags.swon==0)
//__asm__ volatile ("reset");
//}
while(flags.zincfail==1)
{
flags.msgrtn=0;
printmes(str35,100); // TRIP:SYNC FAULT!
if(flags.swon==0)
__asm__ volatile ("reset");
flags.fault=1;
}
while(flags.lbcut==1)
{
flags.msgrtn=0;
printmes(str29,100); //" TRIP:LOW-BATTERY ";
if((flags.swon==0)||(resumedelay>175))
__asm__ volatile ("reset");
59
}
while(flags.olcut==1)
{
flags.msgrtn=0;
printmes(str30,100); //" TRIP:OVER-LOAD ";
if((flags.swon==0)||(resumedelay>175))
__asm__ volatile ("reset");
}
while(flags.olwarn)
{
flags.msgrtn=0;
printmes(str33,100); //" WARN:OVER-LOAD ";
if(flags.swon==0)
__asm__ volatile ("reset");
}
while(flags.lbwarn==1)
{
flags.msgrtn=0;
printmes(str32,100); //"WARN:LOW-BATTERY";
if(flags.swon==0)
__asm__ volatile ("reset");
if(flags.chon==1)
{
if(champs==0)
goto outmes;
if((key==upsmode)||(key==invmode))
{
if(flags.onflag==1)
{
printmes(str27,4); //"\fTOTAL LOAD:";
}
modedisp();
swdisp();
60
printmes(str25,2); //"\fMAINS VOLT:";
if(flags.onflag==1)
{
printmes(str26,0); //"\fINVERTER V:";
}
else
{
modedisp();
swdisp();
printmes(str25,2); //"\fMAINS VOLT:";
}
if(menudelay>=125)
{
flags.setup=1;
menudelay=0;
lcd_putc('\f');
printmes(str0,100); //"\fCALIBRATION MENU";
while(key==modekey);
while(1)
{
if(key==modekey)
{
setchramp=setting[5]/10;
loadclb=setting[3];
functions();
memwrite();
flags.setup=0;
__asm__ volatile ("reset");
}
}
}//main
61