Battery Testert Arduino Proyect
Battery Testert Arduino Proyect
Bachelor of Engineering
Electronics
Bachelor’s Thesis
30 August 2019
Abstract
Author Aayush Giri, Milan Kharel
Title Design of the lithium-ion battery pack tester.
Number of Pages 51 pages+ 1 appendix
Date December 2019
Instructors
Timo Kasurinen, Senior Lecturer
The goal of the work was to study several evaluation boards from Linear Technology and
use them to design a simple Lithium-ion battery test system. A detailed study on them was
done along with the search for new design components to achieve the main objective.
The main motive behind this study was to test the given sets of batteries under several
circumstances and study their behavior. Initially, the project was carried out using a charging
board, buck converter, battery stack monitor, and an advanced microcontroller called
Linduino One, all designed by Linear Technology. The supervisor handed all of these
mentioned modules in advance. However, the defect and malfunctioning of the buck
converter led to rethinking and formulating a new plan with different components to obtain
the final goal. Thus, a separate method was implemented using a simple charging module
called TP4056, some relay switches, and an Arduino UNO. A simple circuitry and codings
were sufficient to yield the desired results.
The final product can successfully test two battery cells simultaneously through numerous
cycles. With Arduino UNO and the right coding, the data generations on the state of charge
(SOC) of the cells, time taken to complete one cycle, measured voltages, cell capacity,
currents, etc are generated flawlessly throughout the operations. The tester has a benefit
over commercial products for small-scale operations and to the hobbyists. This method can
be used easily to determine the different conditions of Lithium-ion batteries. However, there
is room for improvement and upgrade to the system to achieve the capacity of being able to
test a battery pack containing more than two individual cells.
List of Abbreviations
1 Introduction 1
2 Battery Background 2
8 References 50
Appendices
Appendix 1. Automated Battery Charging/Discharging Station Arduino Code File
List of Abbreviations
CC Constant Current
COM Common
CV Constant Voltage
DC Demo Circuit
DC Direct Current
GND Ground
IC Integrated Circuit
NC Normally Closed
NO Normally Open
V Voltage
1
1 INTRODUCTION
Lithium-ion batteries are vital in today’s world of science and advancement. They are
used in almost every modern electronics and devices because of their effective charge
and discharge efficiency[1]. The success in present technologies has led to more
research and study regarding this topic to improve its performances, costs, and safety
further.
This project aims to design a simple Lithium-ion battery tester. The goal is to build a
system that has a functionality of automated charging and discharging the cells,
complete hundreds of charging/discharging cycles, and finally study the aging properties
of the cells based on the experimented results. The study provides a good insight into
the battery cell characteristics and helps determine the performance and reliability of the
cells under several conditions.
The study focuses on studying and analyzing the experimented data and vital information
on charging and discharging performances of a cell under test. Additionally, the effects
and changes in charging and discharging rate, state of charge (SOC), the energy of the
cells can be assessed with an increasing number of battery usage cycles. The system
needs to be executed well enough with different types of cells. The data collected from
the system needs to be satisfactory to deduce the battery properties and analyze their
performances. However, the designed system had to be simple, and it offered the testing
solution only for two individual cells at a time.
The theoretical background of the battery and other factors related to battery charging
and discharging is described in Chapter 2. Chapter 3 is dedicated for pre-existing battery
testing product available on the market. Various battery testing products are available in
the market. Among them, three of those products are analyzed in this chapter. Chapter
4 describes the first implementation carried out using LTC 6811, from Linear Technology
as a battery stack monitor as well as it emphasizes on various demo boards, from Linear
Technology used in this thesis for charging, discharging, and monitoring the battery.
Chapter 5 describes the second implementation regarding automated charging and
discharging station based on Arduino. Chapter 6 shows the testing and results from the
2
second implementation. Chapter 7 gives the conclusion of the project and suggests
future research on battery aging.
2 BATTERY BACKGROUND
A cell is a single power unit that stores chemical energy and converts to electrical
energy. It consists of three essential components, an anode, a cathode, and an
electrolyte. An anode is the negative side of the cell, a cathode is the positive side of the
cell, whereas electrolyte is a gel or liquid which reacts chemically with an anode and a
cathode [2], as shown in Figure 1.
Electrons flow out of the anode, whereas electrons flow into the cathode. When a circuit
is connected to the cell, a chemical reaction occurs between electrolyte and anode. This
reaction produces electrons, and the process is known as oxidation [2].Similarly, another
chemical reaction occurs between cathode and electrolyte. This process is known as
reduction [2]. For the reduction process to take place, an extra electron is required. Extra
electrons needed during the reduction process are supplied from the anode side. Without
any electrically conductive circuit between cathode and anode, electrolyte makes it
difficult for the movement of electrons from anode to cathode. Cells are usually of four
types, which are a dry cell, wet cell, reserve cell, and fuel cell [3]. A battery is simply a
combination of electrochemical cells either in series or parallel [3]. They are of two types:
primary battery and secondary battery. A primary battery is a single-use battery. It implies
that when a chemical of a cell reaches equilibrium, the reaction between anode and
3
cathode does not occur. Hence there is no flow of electrons. Recharging of the battery
is needed to eliminate chemical equilibrium. This kind of battery, which can be recharged,
is known as a secondary battery.
Batteries have been with us for a long time. They have come a long way with drastic
improvements and have only gotten better as the time has elapsed. Alessandro Volta
invented the first actual battery [3]. Zinc-Carbon battery was most common until scientist
realized the ‘alkali’ electrolyte offered more lifespan [3]. Thus, they are labeled alkaline
batteries because they use Potassium hydroxide (KOH) as an electrolyte in most primary
cells and Nickel-based rechargeable cells. The lead-acid battery would be an example
to the oldest rechargeable battery dating back to 1859 and is still being used presently
in engine cars to start internal combustion.
Lithium battery invention in 1970 [4]was a massive leap forward as today’s technologies
demand higher capacity, safety, rechargeability, and more compact batteries. Lithium is
one of the lightest elements and possesses the most substantial electrochemical
potentials [4]. It is combined with the transition metal such as cobalt, nickel, manganese,
or iron – and oxygen to form the cathode. Lithium can easily migrate from one electrode
to the other as a lithium-ion, which is how the current is formed. In 1970 M.Stanley
Whittingham and his team made the first lithium-based rechargeable battery [4]. Titanium
disulfide was used as a cathode and metallic lithium as an anode. The operating voltage
was at 2.5V. Later in 1980 John B.Goodenough used metal oxide instead of metal sulfide
as a cathode, which enabled more powerful batteries [4]. John’s team used lithium cobalt
oxide as a cathode, which significantly increased the operating voltage to 4V.In 1985
Akira Yoshina and his team used petroleum coke, a carbon-rich material derived from oil
refineries through which lithium-ion could pass in and out [4]. His team replaced highly
reactive metallic lithium anode with a safer material. This led to the development of the
first viable commercial lithium-ion batteries. After that, it has revolutionized the lives of
people. Due to their excellent work on a lithium-ion battery, the trio were awarded Nobel
prize in chemistry for the year 2019.
4
Every Battery is not similar. Even if the chemistry of the battery is the same. The main
reason for that is that batteries fall either under the high power category or high energy
category. Often the manufacturers classify the battery as high energy or high power rated
batteries, but not both [3]. The other factor for the classification of batteries is high
durability, in which the power and energy of a battery are compromised.
Rechargeable Battery
Rechargeable battery or secondary cells work with the same mechanism as primary cells
to produce current [3]. The electrochemical reaction from anode to cathode inside an
electrolyte gives the current. This reaction is reversible in secondary cells. Once the
charge stored is drained, the electrochemical reaction occurs again, in reverse, thereby
storing a new charge. They can be charged with matching chargers in general. Several
combinations such as lead-acid, nickel-cadmium (NiCd), lithium-ion, lithium-ion polymer,
rechargeable alkaline batteries, etc. are used as rechargeable batteries.
Lithium-Ion Batteries
Lithium-ion batteries works on the concept of electrochemical potential [5]. Lithium has
the highest tendency to lose electrons [5]. In its pure form, Lithium is highly reactive.
However, it is quite stable as a part of a metal oxide.
A practical lithium-ion cell uses an electrolyte and graphite. Graphite has a layered
structure, and they are loosely bonded. It helps in storing the separated lithium-ions. The
electrolyte only allows lithium-ion through.Figure 2 shows the batteries under testing.
Starting from left in Figure 2 is Pansonic NCR18650, and on the right-hand side is
Keepower 18650. Their detailed specification is explained in subheading titled ’’Batteries
under test.’’
Lithium-ion batteries are the top tier product in the modern world of engineering. From
the portability to giving high performance and long cycling life, they deliver everything.
Lithium-ion batteries have a very high energy density [5], meaning they can give higher
output voltage compared to other batteries of similar class types. Furthermore, the leaks
are negligible because the electrolyte is not water. The self-discharge rate is quite
insignificant, energy loss during charging and discharging are less, and they can handle
more charge/discharge cycles [5]. All these perks make Lithium-ion batteries more
suitable for electronic gadgets like phones and laptops.
Despite their long lists of benefits, they do have their limits like everything else. Lithium-
ion batteries are highly sensitive to higher temperatures [5], which could degrade the
battery faster. When overcharging, the potential risk of explosion is high. It means Li-ion
batteries demand protection circuit or a BMS (Battery Management System) to enhance
their performance.
This section describes the different variables of a battery and also includes general spec-
ifications of a battery. A basic understanding of battery parameters and specifications is
a necessity to study a battery life cycle.
Nominal Voltage
Nominal voltage is known as the reported voltage of a battery [6]. Nominal values are
assigned to define voltage class. The actual voltage can vary with nominal voltage de-
pending on the specifications and equipment used.
6
Cut-off Voltage
Cut-off Voltage is the voltage when the battery is considered to be fully discharged when
it reaches that specific voltage level [6].
Charge Voltage
This is the opposite of the cut-off voltage. It is defined as a condition when the battery is
charged fully to its capacity [6].
The specific current, in which battery gets charged, is known as charge current, while
the maximum current by which battery can be discharged continuously, is known as dis-
charge current [6]. The manufacturer usually defines both the operating current.
Cycle Life
Cycle life is the accumulation of charging and discharging cycles [6]. Battery life ends
when it fails to meet the standard criteria set by the manufacturer. Usually, an end of
battery life is considered when the battery reaches around 80% of its rated capacity.
Cycle life differs with battery types ranging from 500-2000 cycles before the battery
reaches the end of life.
Terminal Voltage
Terminal voltage is the voltage across the battery terminal when the load is applied to it.
It varies with different conditions such as charge, discharge current, and SOC [6].
This is the voltage of a battery when no load is applied to it [6]. It depends on a different
level of SOC and temperature. It is also known as electromotive force.
7
Internal Resistance
Internal resistance is the resistance within the battery. Usually, they are dependent on
age, chemical properties, discharge current, and size. But, mainly for lithium-ion batter-
ies, internal resistance is relatively less dependent on SOC, but it does increase with age
[6].
Capacity Rate(C-Rate)
C- rate is associated with charge and discharge characteristics of the battery [1]. C-rating
regulates the current the battery is being charged and discharged at. The capacity of a
battery is usually rated at 1C, which means a fully charged battery rated at 1000mAh
should supply its displayed amperage current, which is 1000mA in this case for one hour.
Now, the same battery, if discharged at 0.25C, should provide 250mA current for four
hours. In general, a formula shown in equation 1 [1] can be derived as
𝐶𝑟 = 𝐼/𝐸𝑟…….…………………………………………….(1)
where Cr= C-rate, Er= Rated energy in Ah, and I= Charge or discharge current.
The State of Charge is known as the remaining capacity of a cell in comparison to the
related capacity [7]. It is always represented in a range of 0% to 100%. There are differ-
ent approaches to estimate SOC. They are as follows:
• Voltage method
• Coulomb Counting
• Impedance Spectroscopy
8
Coulumb Counting
This particular method was used for the project to determine the state of charge in this
thesis project. In this specific process, SOC is calculated by measuring a cell current that
flows in and out during charge and discharges integrated with time [7]. SOC estimation
formula used for the charging and discharging process is expressed in equation 2 [8]
and equation 3 [8]. Equation 2 is used during the charging process, while equation 3 is
used to estimate SoC during the discharge process.
𝑄𝑔𝑎𝑖𝑛𝑒𝑑
𝑆𝑜𝐶 = 𝑄𝑟𝑎𝑡𝑒𝑑
∗ 100 …………………… (2)
𝑄𝑙𝑜𝑠𝑡
𝑆𝑜𝐶 = ∗ 100 ……………………... (3)
𝑄𝑟𝑎𝑡𝑒𝑑
Where Q is the capacity of a cell. Qgained and Qlost are the capacities of a cell in two
different conditions, i.e., charging and discharging.
2.3 Charging
A battery is an energy storage device. During the charging process, electrical energy is
supplied to the battery, which in the process changes the balance of charge between the
chemically active materials. The charge process converts DC electrical energy to stored
chemical energy. The stored chemical energy can be later used as electrical energy for
any remote applications [9].
In Figure 3, when a power source is added to the positive side, it attracts the electrons
from the cathode. Since the electrons cannot flow through the electrolyte, they go all the
way through the external circuit and reach the graphite layer. Hence, they are trapped in
the graphite layer. The cell is thereby fully charged when all the lithium atoms reach the
graphite sheet.
To make the charging process to be safe, efficient and effective, controlling voltage and
current is a must [9]. It is needed because the batteries must not overcharge, under-
charge, or get damaged during the process. If the charge current is too high, battery gets
overheated and can be damaged. Conversely, if the battery is charged at low current
and low charge voltage, the charging process takes too long time to complete the charg-
ing process. So, the charging process is a balancing act, in which voltage and current
should be continually monitored and maintained between high and low limits.
Any lithium-ion or lithium polymer cells charge the same way [9]. The only difference is
the charge voltage. Commonly the charge voltage is either to be 4.2v or 4.1v plus-minus
at-least 1 percent accuracy, depending on the manufacturer. Lithium-ion battery's shelf
life and the number of recharges is directly proportional to maximum charge voltage and
charge rate as well, but the charge voltage is very critical.
In Figure 4, different charging stages of a lithium-ion cell are presented. It has a two-
phase Constant Current (CC) and Constant Voltage (CV) mode. Constant Current is a
first part of the charge cycle, where charger supplies constant current and current is
regulated at C/5, as shown in the above figure 4. Once a cell reaches its high cell voltage,
which in this case is to be 4.2V, the mode changes from constant current to constant
voltage mode. In constant voltage, mode voltage remains constant at 4.2V and current
variate. The charge cycle is completed when the current drops to ~0.03C.
2.4 Discharging
As shown in the above Figure 5, any load applied across the cell tends to start the pro-
cess of electrons moving from the anode side to the cathode side. Eventually, when all
the electrons move from anode to cathode, a cell is fully discharged.
The above Figure 6 illustrates that when fully charged 12 volts battery of 7Ah capacity is
asked to supply 140milliamps, the working voltage is approximately 12.89 volts. How-
ever, when asked to provide current at 14 amps, the working voltage drops to 11.03
volts. The internal resistance of the battery could be estimated using different techniques
at a specific point on the curve. Internal resistance, among other things like temperature
and discharge period, is subject to change with the age and condition of the battery.
12
Battery capacity is ordinarily determined using four different methods. They are as fol-
lows:
⚫ Constant current
⚫ Resistive load
⚫ Constant power
The most common specification used is the constant current mode, or a battery is sub-
jected to a load that draws a constant current for a measurable quantity of time [10].
When the battery reaches a predetermined cutoff voltage, any further discharge beyond
may permanently damage the battery. If it is still in discharging after the cutoff voltage
has been reached, the remaining energy will drain to empty. It would produce lithium
dendrites, which eventually would short circuit the battery internally. Due to this, the bat-
tery will be damaged permanently and could not be used any further. Lastly, lithium-ion
batteries have specific requirements for discharging, which needed to be taken care of
during the discharging process.
A battery pack in a more significant application contains multiple lithium cells in series or
parallel. Even the two identical cells function differently because of many factors, and
their voltage level may vary when in use. It could potentially cause problems inside the
battery pack. Therefore, cell balancing is needed. Cell balancing can be referred to as a
technique that maintains the voltage level of individual cells inside a pack to the same
value [11]. Balancing maximizes the capacity and efficiency of the battery pack.The un-
balancing of cells can happen because of SoC imbalance, different internal resistances,
and temperature. It might result in various problems. For instance, if one cell is 3.6V and
the other is 3.1V, the cell with the higher voltage will be overcharged since the lower
voltage cell still requires charging. Thus, this degrades the battery over time and reduces
13
its life cycle. Similarly, lower capacity cells charge and discharge faster. When charging
a battery pack with serially connected cells, once a weaker cell achieves its maximum
charge, and the charging process is stopped, the remaining cells in the pack are left
without complete charging. And while discharging the weaker cell drains out quickly, and
as a result, the pack will be disconnected from the load despite the healthy cells having
enough energy left in it. Hence, the capacity of the battery pack remains unutilized. Fig-
ure 7 is the representation of a battery pack with three cells of different SoC levels.
Now, to overcome all these problems, outside interference is required in the form of a
Battery Balancing System. Some of the broadly used balancing methods are discussed
below:
It is the most widely used method in most of the systems because of its simplicity and
cost-effectiveness [11]. In this method, the burning of the energy of the top cell takes
place. Depending on the type, it does it only by attaching a resistor to the battery itself,
and the power is dissipated as heat from the higher voltages cell until it is equalized with
the rest in a pack. As in Figure 7, the initial burning of energy happens until Cell 1 and
Cell 2 drops down to 30% SOC as Cell 3. Since all of them now have the same amount
of energy, when charging up, they should stay consistent both at top and bottom, if all
the cell capacities are the same.
14
Unlike passive balancing, excess energy will not be wasted in this method. They are
instead transferred from one cell to another within the pack. So, the cells with higher SoC
helps out the cells with lower SoC by moving its excess charge and thereby maintaining
the equal voltage [11]. It is more useful in the packs that consist of battery cells with
different capacities. For example in Figure 7, in a battery pack of three cells A, B and C
with capacity 1Ah, 2Ah and 3Ah respectively, active balancing method can potentially
provide up to 2Ah of runtime by energy transfer between cell A and cell C, whereas
passive balancing can never exceed the runtime of 1Ah in the same configuration.
Two different types of batteries were tested in this project, which is illustrated in Table 1
with its specifications.
Various long term charge and discharge tests must be done on the battery cells to ensure
its performance and reliability. There are several battery pack testers available in the
market globally.In order to have a general understanding of the lithium-ion batteries
testing process, three commercial products were studied. This chapter also explains the
general overview of two implementations carried out in this thesis project.
Three battery pack testers were studied for the purpose of building a battery pack tester
for this thesis project. Some of the commercial product are discussed below:
CHROMA 17011
The Chroma 17011 is a high precision system with outstanding features and a wide
range of applications. The key features include [14]:
All these optimized features allow this system to perform battery lifecycle tests, safety
evaluation, quality control, analysis of battery characteristics, production tests, etc. The
functionality offered by this system are highlighted below:
The DCIR or direct current internal resistance test reveals the power characteristics
and aging characteristics of the battery. Two different types of DCIR tests are built-
in this system, and it allows the user to select the test mode manually. The results
are generated, which can further be compared with IEC standards.
The current and time readings can be taken at the start of charging/discharging until
the cut-off condition [14]. The capacity of the cells can be calculated by integrating
the readings. This test is instrumental as it can be used to analyze different products.
Battery cell capacity affects performances, and through this test, the right products
can be determined.
The system can be used to put the same battery through repeated charging and
discharging conditions. Doing so for an extended period will degrade the cell
capacity. It drops the cell capacity to 80%, the system then calculates the number of
cycles [14]. This result is highly effective in determining cell longevity and
performance. These parameters will also assist in finding the applicable condition for
the use of the batteries.
It is the ratio of discharge capacity to charge capacity. So the higher the coulombic
efficiency, the better. Provided the coulombic efficiency test is accurate, the battery
lifespan can be estimated with only a few cycles [14].
Various other tests can be done using this test system. Additionally, Chroma 17011
works with computer software, and the tests can be controlled manually. Different
17
parameters can be programmed for rapid testings. It allows real-time monitoring, and
upon the completion, the statistics reports can be generated in many formats.
ARBIN LBT21024
Arbin instruments provide this battery test system. It is superior to most of the battery
testers because of the precision it delivers while recording electrical parameters and
other electrochemical indicators. They would be lost as noise during the
measurement with ineffective testers. Higher-resolution DAC and ADC in this system
during the reconstruction and sampling of signals contribute to more accurate and
smooth outputs. The other key features are listed below [15]:
• 0-10V
• 8-channel
• 100A/25A/5A/500mA
• Four current ranges for each channel with 24-bit resolution
• 2000 points per second data logging via embedded controllers
• Integrates with Electrochemical Impedance Spectroscopy (EIS) workstations
• Interfaces with Arbin Life Cycle Chambers or other chambers
The test channels are fully independent and provide both potentiostatic and galvanostatic
control [15]. A constant current pulse is placed upon an electrode, and the variation of
the resulting current through the system is studied in the galvanostatic method. Thus,
control over the current flow through the system is achieved through this technique.
Potentiostatic approach, on the other hand, is suitable to observe anodic and cathodic
behaviors of a metal surface. The desired potential can be maintained at the sample
electrode by using the reference electrode. Thus, the behaviors, when monitored and
evaluated, can determine many properties of the material used.
The current handling capacity of this system can be spiked up by adjusting many
channels in parallel. It also provides zero switching time between charge and discharge
as there is a bipolar linear circuitry used [15]. It manages to achieve smooth CC to CV
transition as each channel has digital voltage control [15]. A software package by Arbin
can be used to analyze and plot data for user convenience, including current and power
simulations. The system is equipped with several auxiliary inputs/outputs that can further
18
be assigned to collect additional data or to monitor the temperature [15]. With several
built-in safety features and air-cooling function, this system is highly applicable to Battery
Life Cycle Testing, Electrochemical Research and Development, Half-Cell Testing and
Materials Research, Coulombic Efficiency Measurements, and so on [15].
The need to dig deep on choosing the needed electronic boards for carrying out the
project was not necessary because the project supervisor already provided the required
components.The initial target was to study the given modules thoroughly before
formulating a plan and then engineer a suitable circuitry or a setup that would fulfill the
project's end goal. The demo boards provided were from Linear Technology, which
included LTC6811 or the battery stack monitor, DC2026C Linduino One, DC1830A or
power management board, and DC1619A or DC/DC buck converter. Besides, different
types of rechargeable batteries were handed along with a smart charger from
NITECORE. More on these given modules, along with their features, are further
discussed in Chapter 4.
A detail and in-depth study were done on the modules. The datasheets were studied,
and every board was tested and experimented for a proper understanding of their
functions. Starting with the battery stack monitor and Linduino One, series of batteries
were assembled and then studied further with the help of a pre-existing GUI. During that
phase, the batteries in use were still being charged using the given charger. However,
as the project progressed, the need to develop a charger was a must to achieve the final
goal. At this point, the buck converter had a significant role to play, but unfortunately,
while testing and configuring the board, the outcomes were unexpected. It turned out the
board was faulty and did not deliver the output voltage as it was designed. Despite many
attempts to sort out the issue, the problem was persistent. Given the circumstance and
a significant setback, the need for improvisation was imminent. It was when the second
planning was performed where different electronic components were brought in, and a
20
new design system was made for the execution of the task. The second implementation
that managed to pull the job is further described in Chapter
This chapter mainly consists of important theoretical information regarding the evaluation
boards and tools provided by the supervisor to carry out the project. Additionally, few
successful applications of some of these modules are described further below, along
with the setbacks and problems encountered during the testing. In the essence, a detail
description of the given tools with their effectiveness and the need to engineer a new
approach are highlighted.
Pin1 (V+) is a positive power supply unit. The connection can be made either with the
most positive potential of battery back or external supply.
C0 to C12 (Pins 26,24,22,20,18,16,14,12,10,8,6,4,2) are the cell inputs.
22
S1 to S12 (Pins 25,23,21,19,17,15,13,11,9,7,5,3) are the pins for balancing the battery
cells. Internal MOSFET connects them, and cells are discharged when the MOSFET is
switched on.
V- is the negative supply pin.
GPIO pins can be used as digital inputs or outputs. GPIO[3:5] can be used as an I2C or
SPI port.
Pin 37 (Vreg) is a 5V regulator input.
Pin 36 (DTEN) is a discharge timer enable and can be connected to Vreg to enable the
discharge timer.
CSB, SCK, SDI are digital inputs, and SDO is an open drain NMOS output pin, and it
requires a 5k pull-up resistor .
Linduino is divided into two parts. Figure 10 is the Linduino one, which is the hardware.
The codes are written for this using a standard free Arduino IDE. All code can be loaded
through USB. It does not involve any bootloading and tricky wiring. Linduino one has
similar features to Arduino Uno with extra linear technology features. It comes with an
LTM2884 USB isolation module that protects anything that is plugged into this USB port
from anything that is plugged in on the other side.
Additionally, a 14 pin QuikEval connector is assembled in this board that facilitates the
Linduino One to connect to hundreds of existing LTC QuikEval compatible demo boards.
However, there is more to this than just this demo board. The Linduino development
23
platform consists of a vast library of example firmware. The interaction with Linear
technology parts is much more comfortable with these example firmware. Any standard
C compiler can be used to compile this library of code. The code is also Arduino
compatible. The codes are accessible even without hooking up the hardware. Due to the
easiness of Linduino, hundreds of existing codes can be modified during the big projects
that help move things quickly.
The setup is simple and easy. The Linduino One comes preloaded with a DC590
emulator program that allows the attached demo boards to run with the standard
QuikEval GUI software. It is called ”sketch,” and the sketchbook can be downloaded,
which holds the entire code base for the Linduino board. After interfacing with QuikEval,
the Linduino One can be reprogrammed as needed through Arduino IDE. Arduino IDE is
the development platform for the Arduino, and this is an absolute must to modify the
base code as well as to load programs into the Linduino One. J1-J7 pins of Lindiuno
one(see figure 10) are described below [19]:
J1 is the QuikEval header. Connection to QuikEval compatible demo boards can be
made here by using 14 conductor ribbon cable.
J2 IS an AC ADAPTOR IN, or 7V to 20V DC power input can be given as well.
J3, J6, J7, and J8 are Arduino shield headers.
J4 is an ICSP or In-circuit serial programming header.
J5 is a USB connector that allows the connection to be made to the host computer [19.].
4.3 DC1830B-A
Figure 11 is a demo circuit from Linear Technolgy, which function as a battery charge
controller and PowerPath manager, featuring the LTC4000 as its IC.
4.4 DC1619A
The above Figure 13 is a demo circuit 1619A board, which is a high voltage synchronous
buck converter with adjustable operating frequency.
The input range lies from 4V to 60V, and 7.5V is the minimum start-up voltage. The
features are as follows [21]:
Different conditions and values of the buck regulator at different parameters are shown
in Figure 14. Additionally, the operating frequency can be synchronized to an external
clock for noise-sensitive applications, and it provides short-circuit protection as well. It is
mostly used in 12V and 42V automotive and heavy equipment, 48V telecom power
supplies, avionics, and industrial control systems, distributed power converters, etc.
This smart battery charger was provided for the project. It has a 100% charging
acceleration powering up to 1A to each cell. So, the charging is rapid, and two batteries
can be charged at a time. The current selection of this charger is automatic, which means
the charger detects the battery’s need and operates accordingly.It also displays the
battery power status and charging process. It is almost compatible with all the IMR/ Li-
ion/ LiFePO4 batteries. It is also equipped with two buttons to override the automatic
charging settings of this charger. The charger also has protection settings against a non-
27
rechargeable battery [22]. An additional input slot of 12V is available on the top of this
charger, as well. On top of this below are listed more features of this charger [22]:
4.6 Application
DC2259A is a daisy chain isoSPI battery-stack monitor featuring the LTC6811. Using a
DC2026 Linduino One as a USB interface, the communication was made to a PC. A
Graphical User Interface (GUI) was used to monitor the battery voltage.
was connected to J1-4 and the positive terminal to J1-5. The rest of the cells were
connected accordingly in the sequence where the next cells were connected through J1-
5 and J1-6, J1-6, and J1-7, respectively, as shown in Figure 14. However, only four cells
were used for the testing, and the unused higher terminals in the J1 connector were
shorted together. J1 connector pins were screwed in nice and tight to maintain effective
and uninterrupted connections between the battery cells and the battery stack monitor
board.
A 14-pin ribbon was used from DC2026 to connector J2 of DC2259A board to set up
their connection. DC2026 was connected through a USB cable to a PC USB port. The
GUI program is called ’QuikEval,’ which was downloaded and installed into the PC before
hooking up DC2026.
Figure 16 is what the start-up screen looks like when the GUI is launched. The primary
control features that are available inside this GUI are briefly discussed below:
• Read configuration command button displays the Hex codes for the six bytes,
provided everything is connected correctly. This configuration appears in the
29
A combination of ceramic power resistors was built in different combinations to test the
battery discharge performance, i.e., to check the battery capacity. A total of 12 ceramic
power resistors were used. They were non-inductive resistors and had an advantage
over non-inductive wire-wound, film, and composition resistors because they did not
have film or wire to create a malfunction.
Also, they were chemically inert and thermally stable. An eight channels input, and eight
channels output Keyes relay module was used to control a different combination of a
ceramic power resistor. It was designed to switch up to eight high current or high voltage
from microcontroller. Each relay could be switched individually either on or off due to the
opto-isolated input feature in the relay board [23].
30
In Figure 17, a Keyes 8-channel 5V relay module is shown whose specifications are
listed below it [23].
⚫ 8*5v relays
⚫ Board size:14cm*5.5cm
⚫ Relay rating:10A/250VAC/30VDC
⚫ Each relay has NO and NC ports, easier to connect and control the connected de-
vices.
⚫ High-level trigger
The load comprised of 12 ceramic power resistors where the values of each resistor are
labeled as R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12. The values of each
resistor were R1, R9, R10=12ohm, R2, R4, R5, R6, R7, R8, R11, R12=2.2ohm, and
31
R3=2.2Kohm rated at 10 watts as power rating. The layout design of load modulation is
represented in Figure 18.
Figure 18: Layout design of load connection with a relay module and battery stack.
Six input pins K3, K4, K5, K6, K7, K8 of 8-channel relay were connected to the combi-
nation of power resistors. The combination of power resistors is listed below.
1. When K3 was ON R10, R11, R1, R2, R3 were connected in series, which would total
to 2.216 kOhm and was able to undertake 14.8 volts and was able to conduct a
current of 6.64mA.
2. When K4 was ON R11, R1, R2, R3 were connected in series, which would total to
2.206 kOhm and was able to conduct a current of 6.66mA.
3. When K5 was ON R1, R2, R3 was connected in series, which would total to 2.204
kOhm and was able to conduct a current of 6.67mA.
4. When K5, K6, and K7 were ON R1, R2, R3 were connected in series, R4, R5, R6
were connected in series and R7, R8, R9 were connected in series. As shown in
Figure 8, the three lines of serially connected resistors were connected in parallel to
32
each other to put three switches K5, K6, and K7 ON. The total value of resistor
equaled to 0.21 ohm and was able to conduct a current of 69mA.
5. When K5, K6 was ON R1, R2, R3 were connected in series, and R4, R5, R6 were
connected in series. As shown in Figure 8, the two lines of serially connected resis-
tors were connected in parallel to each other to put two switches K5, K6 on. The
total value of resistor equals to 0.060 ohms and can conduct a current of 246.6mA.
6. When K4 and K8 were ON R1, R2, R3, R11 were connected in series, and R4, R5,
R6, R12 were connected in series. As shown in Figure 8, the two lines of serially
connected resistors were connected in parallel to each other to put two switches K4
and K8 ON. The total value of resistor equaled to 0.11 ohm and was able to conduct
a current of 134.5mA.
The two ends, i.e., a positive terminal, and the negative terminal was connected corre-
spondingly to the positive and negative end of the battery pack.
4.6.2 Shortcomings
Demonstration circuit 1619A was used for the project. However, this step-down converter
was missing quite a few capacitors, and some surface mounts resistors. So, resistors
R4=143kohms, R6=200kohms, and R17=0.007ohms were brought in and soldered with
utmost caution back in their proper spots. These particular values were taken from the
schematic diagram-modified DC1619A as used with DC1830A, which is available in the
DC1830A datasheet. Even after all the necessary modifications, the output result was a
disaster and contradicted the expected outcome. The converter ultimately failed to
provide an output voltage, and thus the charging of the batteries was an impossible ask
down to this unanticipated failure of the buck converter. Hence, the improvisation in the
plan was a must for the completion of the project since the goal was to design an
automated battery charging/discharging system.
33
The failure of the LTC evaluation module, DC1619A, second approach was considered
for the design and implementation of an automated charging/discharging station. The
plan was straightforward, based on Arduino Uno. An LCD 16*2, I2C display was used to
display the battery parameters. Four voltage dividers were used to determine the voltage
across two load resistance. The idea of using two MOSFET was to connect and discon-
nect two load resistance separately with two isolated batteries. One 2*5v relay module
was utilized to connect two TP4056 modules.
Table 2 shows the different components used in the second implementation to build a
charging/discharging station.
9 1 DC FAN,5V,0.9A
34
Figure 19 is a TP40456 module, which is a single cell linear charger for lithium-ion
batteries using constant-current/constant-voltage (CC/CV) charging method.
TP4056 module uses the TP4056 lithium-ion charge controller IC and a separate DW01
protection IC. Thus, it provides many protection features as listed below [24]:
a. It has overcharge protection and will safely charge up to the desired 4.2v.
b. The module has the function that cuts the output from the battery if the discharge
rate goes beyond 3A or during short-circuit conditions.
c. There is over-discharge protection meaning it keeps the battery from being
discharged below 2.4V.
d. It manages the constant current to constant voltage charging of a connected lith-
ium-ion battery.
5.1.1 TP4056 IC
• TEMP1 (Pin1) is a temperature sense input. If pin1 voltage is higher than 80%
and lower than 45% of the supply voltage. The battery’s temperature is deemed
to be either high or low. If this condition does occur, then IC suspends the charg-
ing process.
• PROG (Pin2) is a constant current setting pin. It can be adjusted by connecting
a resistor from this pin to the GND.
• GND (Pin3) is a ground terminal pin.
36
• Vcc (Pin4) is a positive input supply voltage pin. It is the power supply to the
circuit.
• BAT (Pin5) is a pin where the positive end of the battery terminal is connected to.
• STDBY (Pin6) is a status output pin that indicates charge termination. And usu-
ally, it is in high impedance state.
• CHRG (Pin7) indicates status output when the battery is being charged.
• CE (Pin8) is a chip enable input pin. When the CE pin is pulled high with internal
switches, it puts the device in normal operating mode, and when it is pulled low
device goes to disable mode. A CMOS logic level or TTL can drive the pin.
5.1.2 DW01 IC
The DW01 is a single cell battery protection IC. It is designed to protect lithium-ion, lith-
ium polymer batteries from overcharge, over-discharge, and over current [25]. It is shown
in Figure 22.
Two Lithium-ion cells were monitored at a time. Two identical circuits were built, one for
each cell. The voltage across two load resistors was measured by Arduino using the
voltage divider circuit [26]. It consists of eight resistors with values 10k each, four re-
sistance for first load/power resistor, and rest four resistance for a second load/power
resistor. The output from the voltage divider has been connected to Arduino's analog
pins A0 and A1 for the first cell and pins A2 and A3 for the second cell. The voltage
divider circuit helps to monitor the voltages across the load resistance. Also, two
MOSFET(IRLZ44N) were placed, which function as a switch between the load resistance
and the battery. The PWM digital pins D3 and D6 from the Arduino control the two
MOSFET respectively. Normally when the battery voltage drops off, the current provided
by a fixed value load resistor would also drop off. So, to maintain the target current of 1
ampere, the PWM duty cycle adjusts accordingly [27]. It consumes two ADC channels
per cell to measure the current as a voltage drop across the load resistors. The goal of
using a 3-ohm power/load resistor was used to provide the target discharge current of 1
ampere at the cutoff voltage of 3.0V [27], and it could dissipate 5.88 watts of energy.
This resulted in PWM could track from about 80% to 100%, when cell voltage ranges
from fully charged to discharged [27]. Arduino checks the battery condition and then
instructs MOSFET. Upon feeding a 5V signal to the gate of MOSFET’s, it allows current
to pass from the positive terminal of the battery through the power resistor, and the
MOSFET completes the path back to the negative terminal of the battery [26]. Thus, the
battery is discharged over time.
For charging, two TP4056 modules were used connected with the 2*5v relay
module.NO1 pin of relay1 was connected to the positive end of battery1, and the COM1
pin was connected to battery positive out pin (B+) in the first TP4056 module. The battery
negative out pin(B-) of the first TP4056 module was connected to the negative end of
battery1. To establish communication with the Arduino IN1 pin of relay1 was connected
to the D11 pin of Arduino. Similarly, the NO2 pin of relay2 was connected to the positive
end of battery2, and COM2 pin was connected to battery positive out pin (B+) in the
second TP4056 module. The battery negative out pin(B-) of the second TP4056 module
was connected to the negative end of battery2, and the IN2 pin was connected to the
D12 pin of Arduino.
39
To display the battery voltage, discharge current, charge current, and capacity, the LCD
16*2 display was used. It has 128*64 resolution and uses an I2C bus to communicate
with the Arduino. Two pins SCL and SDA pins of LCD were connected to A5 and A4 pins
on Arduino. The other two pins of LCD, which were VCC and GND, were connected to
+5v on Arduino and GND pin to the GND pin of Arduino.
Step-down DC/DC converter was used to power Arduino and DC fan.DC fan of 5V was
used to cool down the load resistor,which would dissipate a lot of heat during the
discharging process.
40
In the software, if Arduino measures the voltage drop by the power resistor to be between
3.0V to 4.2V. Initially, the charging process takes place until the cells were charged to
4.2V, and till current falls to ~0.1% of 1 ampere. Figure 24 shows the basic working
structure of the Arduino code when the battery is placed into the battery holder. Now that
it had achieved the maximum threshold voltage(4.2V) set in the code, the battery starts
discharging, and it discharges till the battery reaches 3.0V, which is the cut-off voltage.
When the cut-off voltage was reached, one complete cycle of battery charging and dis-
charging had been completed. And again, the charging process started until it reached
the threshold voltage, and yet the discharge process was started.
But, in the beginning, if the battery voltage was lower than the cut-off voltage, the charg-
ing process would take place with trickle current. It means only a small amount of current
is induced by the TP4056 charging module until the voltage reaches 3.0V, and after that,
it would resume a normal charging process with 1 ampere current.
The other condition was set in the code, if the voltage reading was above the maximum
threshold voltage (4.2V) at the beginning of a process. Discharging process would gain
priority over the charging process. This would mean cell would discharge till cut-off volt-
age (3.0V), and only the charging process would start. Figure 24 is a general outlook of
the working of the software.
In order to record all the measurement results in real-time, PLX-DAQ software was used.
PLX-DAQ is a simple add-on feature for excel, which enables easy logging of data in an
excel sheet [28].
Figure 25 is a simple representation of the PLX-DAQ excel sheet on starting the PLX-
DAQ software. To run PLX-DAQ, it was easy. The process was to install the software
from the third party and open the PLX-DAQ sample excel sheet and connect the appli-
cation with the correct port and baud of the Arduino
The accuracy of the system measurement was verified and tested. The cell voltage
measurements were compared with a multimeter. The digital multimeter that used for the
test was in the type of MS8221D from mastech. The voltage range of 20V was used, and
its accuracy was ±(0.5%+1), according to the datasheet [29] [30].There are differences
42
between the measurement results on both methods. Table 2 records the measurement
results from both charging/discharging station which was arduino based and from
multimeter manually. Batteries were loaded for charging and discharging, and battery
voltages were measured every two minutes [30]. As introduced before, a power resistor
of 3 ohm was applied as the load. The load is supposed to undertake 4.2V voltage and
able to conduct a current of 1A. Both of the measurements were taken at the same time
point for the closeness.
The data shown in Table 3 is after 200th discharging cycle. The maximum measurement
difference between charging/discharging station and multimeter is about 0.02V, as seen
in Table 3. Therfore analysis of the table can prove the measurement from tester build
in this project was pretty accurate. The margin of error was 0.02V~0.03V.
Figure 26(a, b, c) is the charging profile of KeepPower 18650. The maximum threshold
voltage was 4.2V, while the cut-off voltage was 3.0V. So, it was charged from 3.0V to
4.2V. The rated capacity of a KeepPower18650 cell was 2600mAh. SoC in %, Voltage
of a cell in ‘V’ is plotted against the capacity(mAh) of a cell. All the tests were carried out
at room temperature, which was to be around 22 degree Celsius.
Figure 26(a) is the 1st charging cycle graph, which took 2.6 hours to complete with 1
ampere current induced to the cell by the TP4056 charging module. It reached a rated
capacity of 2600mAh. At 1200mAH and 46.5% SoC charging process shifted from CC
to a CV, which took approximately 45 minutes. Figure 26(b) is the 100th charging cycle,
44
which meant that specific cell had experienced the 99th discharging cycle as well. It took
2.7 hours to complete the 100th charging cycle when 1 ampere current was induced to it.
After 100 cycles of charging, the capacity of a cell was 2500mAh. 100mAh capacity was
lost after the 100th charging cycle. This resulted in a loss of 3.84% of rated capacity. At
1600mAH and at 64% SoC charging process shifted from CC to a CV, which approxi-
mately took 70 minutes. The more charging cycles were carried out. Figure 26(c) illus-
trates the 200th charging cycle before experiencing the 199-discharge cycle. It took 2.8
hours to complete the charging process, where capacity measured was to be 2400mAh
at the end of the cycle. At 1900mAH and 79.6% SoC charging process shifted from CC
to a CV, which took approximately 95 minutes.
to 1 ampere constant current. SoC in %, Voltage of a cell in ‘V’ is plotted against the
capacity(mAh) of a cell. The tests were carried out at room temperature, which was to
be around 22 degrees Celsius.
Figure 27(a) is the 1st discharging cycle graph, which took 3 hours to complete. After the
first discharging cycle, the capacity of a cell was found to be 2600mAH.Figure 27(b) is
the 100th discharging cycle. It took 3.15 hours to complete this discharging cycle. After
100 cycles of discharging, the capacity of a cell was 2490mAh. 110mAh capacity was
lost after the 100th discharging cycle. The loss was 4.2% of rated capacity. Figure 27(c)
illustrates the 200th discharging cycle. It took 3.2 hours to complete this discharging cy-
cle, where after the completion of cycle capacity, measured to be 2390mAH. 210mAh of
a cell capacity was reduced during 200 cycles of discharging, which was 8.07% loss
when compared to the capacity of a cell at the beginning of the charging process.
2500
2450
2400
2350
2300
2250
0 20 40 60 80 100 120 140 160 180 200
No. of cycles
After 200 cycles of charging and discharging, the remaining capacity of a cell was to be
2390mAh. 210 less than the rated capacity of 2600mAh.The total loss was 8.07% of
rated capacity. Figure 28 illustrates the cycle life of the KeepPower 18650 cell. One com-
plete cycle life means one charging cycle and one discharging cycle. Here in Figure 28,
46
the 200-cycle life of a cell is shown. The capacity of a cell and the number of cycle life is
plotted in the graph.
• Panasonic NCR18650B
Figure 29(a, b, c) deals with the charging profile of Panasonic NCR18650B. The rated
capacity of a cell as per the datasheet is 3350mAH. The test was carried out at room
temperature, which was to be 22 degrees Celsius. In the graph capacity of a cell is plot-
ted against cell voltage and SOC. Figure 29(a) is the first charging cycle, Figure 29(b) is
the 100th charging cycle, whereas Figure 29(c) is the 200th charging cycle. At every
charging cycle, the charge current was 1 ampere and could charge the cell in 3 hours to
3.3 hours depending on its capacity and its age. After every charging cycle, the discharg-
ing cycle occurred. So, the charging cycle alternated. Discharging played a vital role in
diminishing the capacity of a cell under test.
At the 1st charging cycle, Figure 29(a), the transmission of CC to CV phase was at
1800mAh capacity of a cell, and the SoC was at 53.73%. The capacity of a cell after the
1st charging cycle was to be at 3350mAH. The transmission from CC to CV took about
90 minutes. At 2000mAh and 62.5% SoC in Figure 29(b), which was the 100th charging
cycle CC shifted to CV in about 100 minutes, and the capacity of a cell after the end of
that particular cycle was 3200mAH. In Figure29(c), which shows the 200th charging cycle
of Panasonic NCR18650B, changes to CV from CC took about 105 minutes. It shifted at
2100mAh, and SoC recorded was 66.9%, and a cell under test capacity was 3030mAH
Figure 30(a, b, c) above is the discharging profile of Panasonic NCR18650B. The stand-
ard discharge cut-off voltage of Panasonic NCR18650B is 2.5V [13], but in this project,
48
the cut-off voltage was set at 3.0V. It was discharged at 0.3C at 1 ampere constant cur-
rent. SoC in %, Voltage of a cell in ‘V’ is plotted against the capacity(mAh) of a cell. The
tests were carried out at room temperature which was to be around 22 degrees Celsius.
Figure 30(a) is the 1st discharging cycle graph of Panasonic NCR18650B, which took 3
hours to complete. After the first discharging cycle, the capacity of a cell was found to be
3350mAH.Figure 30(b) is the 100th discharging cycle, which also took 3 hours to com-
plete the 100th discharging cycle. After 100 cycles of discharging, the capacity of a cell
was 3200mAh. 150mAh capacity was lost after the 100th discharging cycle. The loss was
4.47% of rated capacity. Figure 30(c) demonstrates the 200th discharging cycle. It took
3.5 hours to complete the discharging process, where after the completion of cycle ca-
pacity, measured to be 3030mAH. 320mAh of a cell capacity was reduced during 200
cycles of discharging, which was 9.95% loss of rated capacity.
3300
Capacity(mAh)
3200
3100
3000
2900
2800
0 20 40 60 80 100 120 140 160 180 200
No of cycles
At the beginning of the process, the rated capacity of a cell was 3350mAh. When 200
cycles of charging and discharging were completed, the capacity of a Panasonic
NCR18650B cell was at 3030mAH. It meant during the process of charging and
discharging a cell had lost a capcity of 320mAH. The total loss resulted in 9.95% of rated
49
capacity which is shown in Figure 31. Figure 31 shows the life cycle of the Panasonic
NCR18650B cell. The capacity of a cell and the number of cycle life is plotted in the
graph.
The final design or the battery tester has the potential to charge and discharge up to two
cells simultaneously to the desired capacity. With an LCD wired into the system, the cell
voltages, cell capacity, charging, and discharging current are displayed throughout the
operation. Thus, battery cell monitoring and supervision is easy and reliable. This system
can tolerate hundreds of charging/discharging cycles with good efficiency and accurate
results. It is an immense result considering how simple the design is. The project is a
success since several types of lithium-ion batteries are tested and studied under several
conditions using the developed tester.
Despite all the perks and capabilities of this system, there are rooms for future improve-
ment for better results. For instance, DC1619A by Linear Technology is a far superior
buck converter, and the use of it can intensify the performance of the charger along with
its efficiency. The use of multiplexer or an Arduino Mega over Arduino UNO provides
more analog pins options, which increase the quantity of the battery that the system can
monitor at a given time. Also, PWM pins in Arduino UNO when substituted with a DAC
and an operational amplifier, the system gives more precise data and is more efficient.
The addition of chips such as MCP23017 works like a port expander and gives identical
ports to that of Arduino UNO, resulting in an increment in I/O pins that can be very useful
50
8 References
[14] ”Battery Cell Charge/Discharge Test System | Chroma ATE Inc.,” [Online].
Available:
http://www.chromaate.com/product/17011_Battery_Charge_Discharge_Test_Sy
stem.htm. [Accessed 30 09 2019]
[15] ”Arbin LBT21024 Battery Test System | ATEC Rentals,” [Online]. Available:
https://www.atecorp.com/products/arbin/lbt21024. [Accessed 30 09 2019].
[26] ”DIY Arduino Battery Capacity Tester - V1.0 : 12 Steps (with Pictures),” [Online].
Available: https://www.instructables.com/id/DIY-Arduino-Battery-Capacity-
Tester-V10-/. [Accessed 12 10 2019].
1 (7)
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define MOSFET_Pin 3
#define Bat_Pin A0
#define Res_Pin A1
#define nRelayDrive_Pin 9
#define MOSFET1_Pin 5
#define Bat1_Pin A2
#define Res1_Pin A3
#define nRelayDrive1_Pin 10
float sample1 = 0;
float sample2 = 0;
float sample3 = 0;
float sample4 = 0;
int x = 0;
int row = 0;
//
boolean discharging = false;
boolean charging = true;
2 (7)
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(9600);
pinMode(MOSFET_Pin, OUTPUT);
pinMode(nRelayDrive_Pin, OUTPUT);
pinMode(MOSFET1_Pin, OUTPUT);
pinMode(nRelayDrive1_Pin, OUTPUT);
3 (7)
// beep(200);
Serial.println( "Attention High-V! ");
Serial.print("DATA,TIME,"); Serial.print(Bat_Volt);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Attention High-V! ");
lcd.setCursor(0,1);
lcd.print( Bat_Volt);
discharging = true;
charging = false;
delay(1000);
lcd.clear();
}
delay(1000);
lcd.clear();
4 (7)
digitalWrite(MOSFET1_Pin, LOW);
digitalWrite(nRelayDrive1_Pin, LOW);
discharging1 = true;
charging1 = false;
delay(1000);
}
if (Bat_Volt > Bat_Low && Bat_Volt < Bat_High ) { // Check if the battery
voltage is within the safe limit
if (discharging) {
digitalWrite(MOSFET_Pin, HIGH);
digitalWrite(nRelayDrive_Pin, LOW);
millisPassed = millis() - previousMillis;
Current = (Bat_Volt - Res_Volt) / Res_Value;
mA = Current * 1000.0 ;
Capacity = Capacity + mA * (millisPassed / 3600000.0); // 1 Hour =
3600000ms
previousMillis = millis();
Serial.print("DATA,TIME,"); Serial.print(Bat_Volt); Serial.print(",");
Serial.println(Capacity); Serial.print(","); Serial.println(Current);
//lcd.clear();
lcd.setCursor(0,0);
lcd.print(Bat_Volt);
lcd.setCursor(5,0);
lcd.print(Capacity);
lcd.setCursor(10,0);
lcd.print(Current);
Appendix 1
5 (7)
lcd.setCursor(14,0);
lcd.print(" D");
row++;
x++;
}
else if (charging) {
digitalWrite(MOSFET_Pin, LOW );
digitalWrite(nRelayDrive_Pin, HIGH);
// digitalWrite(LED_BUILTIN, HIGH);
// beep(200);
millisPassed = millis() - previousMillis;
Current = (Bat_Volt - Res_Volt) / Res_Value;
mA = Current * 1000.0 ;
Capacity = Capacity + mA * (millisPassed / 3600000.0); // 1 Hour =
3600000ms
previousMillis = millis();
Serial.print("DATA,TIME,"); Serial.print(Bat_Volt); Serial.print(",");
Serial.println(Capacity); Serial.print(","); Serial.println(Current);
//lcd.clear();
lcd.setCursor(0,0);
lcd.print(Bat_Volt);
lcd.setCursor(5,0);
lcd.print(Capacity);
lcd.setCursor(10,0);
lcd.print(Current);
lcd.setCursor(14,0);
lcd.print(" C1");
delay(1000);
if (Bat_Volt1 > Bat_Low1 && Bat_Volt1 < Bat_High1 ) { // Check if the bat-
tery voltage is within the safe limit
if (discharging1) {
digitalWrite(MOSFET1_Pin, HIGH);
digitalWrite(nRelayDrive1_Pin, LOW);
millisPassed = millis() - previousMillis;
Current1 = (Bat_Volt1 - Res_Volt1) / Res_Value1;
mA1 = Current1 * 1000.0 ;
Capacity1 = Capacity1 + mA1 * (millisPassed / 3600000.0); // 1 Hour =
3600000ms
Appendix 1
6 (7)
previousMillis = millis();
Serial.print("DATA,TIME,"); Serial.print(Bat_Volt1); Serial.print(",");
Serial.println(Capacity1); Serial.print(","); Serial.println(Current1);
//lcd.clear();
lcd.setCursor(0,1);
lcd.print(Bat_Volt1);
lcd.setCursor(5,1);
lcd.print(Capacity1);
lcd.setCursor(10,1);
lcd.print(Current1);
lcd.setCursor(14,1);
lcd.print(" D");
row++;
x++;
}
else if (charging1) {
digitalWrite(MOSFET1_Pin, LOW );
digitalWrite(nRelayDrive1_Pin, HIGH);
//lcd.clear();
lcd.setCursor(0,1);
lcd.print(Bat_Volt1);
lcd.setCursor(5,1);
lcd.print(Capacity1);
lcd.setCursor(10,1);
lcd.print(Current1);
lcd.setCursor(14,1);
lcd.print(" C");
delay(1000);
//*************LCD DISPLAY*************
Appendix 1
7 (7)