A Novel Electric Bicycle Battery Monitoring System Based on Android Client

The batterymonitoring system (BMS) plays a crucial role inmaintaining the safe operation of the lithiumbattery electric bicycle and prolonging the life of the battery pack. This paper designed a set of new battery monitoring systems based on the Android system and ARM single-chip microcomputer to enable direct management of the lithium battery pack and convenient monitoring of the state of the battery pack.The BMS realizes the goal ofmonitoring the voltage, current, and ambient temperature of lithium batteries, estimating the state of charge (SOC) and state of health (SOH), protecting the battery from abuse during charging or discharging, and ensuring the consistency of the batteries by integrating the passive equalization circuit. The BMS was proven effective and feasible through several tests, including charging/discharging, estimation accuracy, and communication tests.The results indicated that the BMS could be used in the design and application of the electric bicycle.


Introduction
Social progress and economic development have resulted in the continued gradual aggravation of environmental pollution and the decrease of fossil energy reserves.Developing energy-saving and environmentally friendly vehicles has become the new target.In recent years, electric bicycles have gained wide attention because of its characteristics, such as convenience, low noise, and less pollution [1][2][3][4][5].The popularity rate of electric bicycles has also been expanding gradually.In many countries and regions with a dense population, such as California in the United States, Central and Southeast China, and Japan and other Southeast Asian countries, the electric bicycle is generally used in urban traffic as a form of short-range transportation [6][7][8].
However, despite the increasing popularity of electric bicycles, current technology still has the following limitations: first, the energy density of the bulky lead-acid batteries is extremely low.Second, lead is harmful to human health during the making; furthermore, scrap batteries have the potential to pollute the environment.Finally, the power battery pack is a key component in electric bicycles and the battery status information is generally displayed through the micro-dashboard in front of the electric bicycle, making the checking of the battery capacity and status difficult.The accuracy of state of charge (SOC) is extremely poor, and estimating the SOH (state of health) of the battery can be difficult.The lithium battery has been considered one of the major viable energy storage media in electric vehicles [9].Lithium batteries have high energy density and power density and hence are the most promising power battery.Therefore, replacing the lead-acid batteries with lithium-ion batteries can reduce the volume/weight of the battery pack and achieve a qualitative leap in travel distance.However, because of the characteristics of lithium battery, the battery pack is prone to damage due to overcharging, overdischarging, and overheating [10,11].Therefore, monitoring battery status and managing the cells according to the characteristics of the lithium battery are meaningful for battery safety and maintenance effectiveness [12].This function has utmost significance for the stable operation of the bicycle.Most of the electric bicycles now use lead-acid battery, which does not need extra management.While current research on the battery management system is mostly focused on electric vehicles, studies on electric bicycles BMS are relatively limited.In the replacement of lead-acid batteries with lithium-ion batteries, research on electric bicycle BMS is highly necessary.Reference [13] designed a low-cost intelligent Li-ion BMS based on Atmega16 and used multichannel analog switch and differential amplifier to detect the voltage on each cell.Therefore, the voltages of the cells were not collected at the same time, and the current fluctuation during driving can lead to voltage changes.The voltages collected in this way may not be sufficiently accurate.Reference [14] presents the development of an over current protection scheme for BMS that protects the battery and other system components from damage.Reference [15] presents a fast charging scheme for the Li-FePO4 battery pack used in electric bicycles.The BMS adjusts the charging current to the maximum possible limit that corresponds to the voltage of the cell that has the highest voltage in the pack so that no individual cell suffers overvoltage during charging.Reference [16] presents a direct measure voltage of each individual cell to avoid overcharge.The measurement has a resolution as good as 7.8 mV, which is not sufficient, because the required voltage measurement accuracy is 1 mv in this paper.What is more, the current electric bike does not have enough display interfaces to display all the serial cell information; and most electric bicycles are not able to accurately tell the owner how many miles are left during the current drive.This ability can be achieved by the battery management system in this article through the Android client.The user can control the charging and discharging process, as well as provide a timely charging reminder through a mobile phone.Further, the mobile client BMS can be transplanted in the application of electric kart, home energy reserve system, and other fields that require power systems.Therefore, designing the lithium battery monitoring system based on the Android platform and ARM microcontroller is necessary.The novelty of the designed BMS in this paper is the monitoring method using Android client.And the system has higher voltage measurement accuracy; what is more, it is able to balance the cells and estimate SOH.

Composition and Function of the Battery Monitoring System
The power battery pack used in electric bicycle is originally the 48 V, 20 Ah, lead-acid battery.This paper will use the pack of NCR18650B (3.7 V, 3250 mAh) cells to replace leadacid battery.The lithium battery pack consists of 13 elements in a series, each consisting of eight cells in parallel.
Compared with the lead-acid batteries, this pack's nominal voltage is 48.1 V, the total capacity increased by 28%, and the volume and weight reduced to approximately 63% and 80%, respectively.Specifically, the lithium battery pack significantly improves the bicycle's performance and simultaneously reduces the volume and total mass of the bicycle.The battery monitoring system in this paper consists of the following two parts: the upper and lower machines.Figure 1 is the architecture of the lower machine installed in the electric bike; the lower machine obtains the signals, such as voltage, current, and temperature.The master control unit utilizes these messages to estimate the batteries' SOC and SOH (state of health).The back-to-back MOSFET controls the charging and discharging procession, thereby ensuring the security of the circuit.The equalization circuit can improve the consistency of series connected cells.Scientific and technological progress has brought the smart phones to numerous households allowing for the monitoring of information of electric bicycle batteries by mobile phone [17].
The data exchange between cell phones and lower machine can be achieved via Wi-Fi.Accordingly, a Wi-Fi sending and receiving module is added to the system as follows: the battery status information was sent to mobile phones via Wi-Fi, and the lower machine could obtain the commands sent by mobile phones.
Figure 2 shows the architecture of client-monitoring software installed on the Android phone (upper machine).First, in the upper machine, the Wi-Fi module reads the IP and port number before it establishes a connection between the lower machine and the upper machine after adding the parameters to the database and enters the main control interface, which processes the received data and displays related messages.The user can send a command to control the procession of discharging/charging through the Wi-Fi.
Information displayed by the upper machine includes all cells' voltage, equalization status, battery pack's voltage, current, temperatures of the environment and inside the battery pack, the SOCs, and capacities of the cells, and apart from displaying the messages, the upper machine can also record information for playback analysis.
2.1.Signal Acquisition.Voltage, current, and temperature are the foundation of estimation, protection, and control.The voltages of the pack and cells were utilized to protect the cells from overcharging and overdischarging and can also be used to estimate the cells' capacity when the voltages are adequately stable.Current was used to calculate the SOC.The temperature of multiple points was utilized to correct temperature-related battery characteristics, such as internal resistance and capacity.

Lithium Battery Protection.
Because of the characteristics of lithium battery, the battery pack is prone to damage by overcharging, overdischarging, and overheating.Thus, cutting the power from the circuit is important when the voltages, current, or temperature reaches the thresholds and provides the corresponding warning for malfunction.Thus, the back-to-back MOSFET was employed to control the on/off of the main circuit.Battery charging control is an important part of BMS.Panasonic recommended the Constant Current-Constant Voltage charging method, and the standard charging current is 1.625 A. As the experimental electric bicycle uses eight batteries in parallel as a group, thus, the battery pack's standard charging current is 13 A. However, the charge current of the commonly used charger for electric bicycle is only from 1.5 A to 3 A, which is safe in the constant current charging stage.When the charge voltage reaches 54 V, it will go to the constant voltage charging mode.During the entire process of charging, the main control unit monitors the voltage of each cell in real-time.When any of the cell voltages reaches 4.2 V, the system will immediately control the MOSFET to turn off the power bus to suspend charging.When cell voltages are equalized, the control unit will control the MOSFET to turn on the power bus to go on charging until the discharge current reaches below 520 mA (65 mA * 8).Similarly, the discharge phase needs to be controlled as well.The NCR18650B datasheet recommends that the end of discharge voltage is 2.5 V, but to extend battery life, the undervoltage protection is set to 2.7 V. Hence, during the discharge process, when any one of the battery voltage reaches or falls below 2.7 V, the system will immediately control the MOSFET to turn off the power bus and remind the user to charge the battery through the mobile client.
To extend battery life, the maximum charge current is set as 15 A. After calculation, in normal working conditions, the maximum discharge current can reach 30 A. To prevent short circuit and ensure the safety of the battery, we set the maximum discharge current to 40 A. When the circuit current exceeds threshold, the MOSFET will automatically turn off the power bus.

SOC and SOH Estimation.
The SOC of a pack of batteries is analogous to the fuel gauge of a conventional motorcycle.SOC can be used to predict travel distance in the current load conditions and is highly dependent on individual cell performance.SOC was calculated in Coulomb counting using Formula (1), which is a simple technique that integrates the current with time [18].However, the process actually suffers from drift and requires periodic recalibration [19].SOC ( 0 ) was recalibrated by SOC-OCV (open circuit voltage) curve when the voltage is adequately stable.
The SOH of a battery cell used to describe its physical condition is characterized by a cell parameter correlated with its aging, which in turn is correlated with the battery's ability to store energy [20].
SOH was calculated using Formulas ( 2) and ( 3) as follows: where SOC( 0 ) is the SOC at the beginning of the discharge or charge; () is the working current;   is the current capacity of the battery;   is the brand new capacity of the battery; Passed Charge is the total capacity flow out of the battery; and SOC 1 and SOC 2 are the SOCs of the battery before and after discharge, respectively, and they are both obtained by using the OCV method according to the OCV-SOC curve.

Passive Equalization.
Differences are observed in terms of capacity, internal resistance, and voltage among different batteries, even the same type and batch of batteries.Second, the change in battery temperature in the battery pack, ventilation conditions, self-discharging factors, and electrolyte density difference and the inconsistency of cells will increase along with the increasing working time.The pack's capacity will also be affected by the poor cells.Thus, the equalization circuit is required.The passive equalization circuit has a simple structure, with low-cost, easy-to-implement, and highreliability features, suitable for the lithium battery pack in the electric bicycle.

Android Client-Monitoring Application.
The screen in front of the electric bicycle is extremely simple, which cannot display all necessary information of the lithium-ion battery pack.An Android client app can solve this problem; the user can use a smart phone to check the status (voltage, current, SOC, and SOH) of the battery pack.Thus, client interface display is a great supplement for the screen in the electric bicycle.
The Android system is designed for the mobile Internet system, which is supported by several Internet links.As an open access intelligent operating system, Android has the most obvious advantage because it can support users' software with comprehensive functionality.Each application can design its unique function module and when the module is set up in accordance with the rules of the application framework, it can gain the support of the Android system and interact with other function modules.Based on the advantages of Android [17], the smart phone's efficient processor and large high-resolution screens can efficiently monitor the lithium battery pack of electric bicycle using smart phones [21].
SOC characterizes the proportion between the residual battery capacity in its present state and total capacity after completely charging the battery.However, SOC is unable to clearly tell the user how many miles the bike can run, which is a major concern to the user.The remaining mileage can be calculated by (4) as follows.
where   is the left miles,   is the current capacity of the battery, Trip is the driven distance during time Δ; ΔSOC is SOC change during Δ;   is the motor speed (/min),   is the transmission ratio between motor and wheels, and  represents the radius of the drive wheels; Voltage 1 is the equivalent voltage related to the current SOC and Voltage 2 is the equivalent voltage during time Δ.Equivalent voltage related to the current SOC is the current nominal voltage.It can be calculated by dividing the remaining energy (Wh) by the remaining capacity (Ah) of the battery.
Then the remaining mileage is sent to the mobile client to display through the Wi-Fi module.

Design of the Hardware System
3.1.The Control Unit.To improve accuracy of SOC estimation, we collected current and voltage data with high accuracy.The microcontroller collects battery voltage, temperature, and current.Further, the microcontroller calculates the SOC by Formula (1) and the SOH by Formula (3).Other features include the ability to manage and control serialconnected 13 cells, obtain motor speed from motor controller through controller area network (CAN) bus, and communicate with mobile client through the WIFI model.Given that the workload is very large and we want to apply further the system to the electric kart BMS, thus, we used a microcontroller with stronger performance.This paper uses low power consumption, 32-bit STM32F401RCT6 single-chip microcomputer as the main control unit's microprocessor and has the following features: frequency up to 180 MHz, 512 kB of flash memory, 128 KB of SRAM, up to 20 communication interfaces, and up to 24 channels of 2.4 MSPS ADC.An external 256 KB of EEPROM chip is used to save the last SOC and SOH when the BMS suddenly loses power value.The main chips and peripheral circuit structure are shown in Figure 3.

Voltage Acquisition.
The lithium battery pack contains 13 cells in series and thus, 13 voltages need to be acquired.Finding a chip to collect the voltages of 13 cells simultaneously can be difficult.LTC6804-2 is one of the few voltage collection chips which can simultaneously collect the voltages of the 12 cells.Its measurement error is also less than 1.2 mV, and the measurement time is less than 290 s.Therefore, the former 12-battery voltage is measured with the chip, and for the 13th battery, this paper used the continuously self-calibrating analog to digital (A/D) converter (ADS1100) to sample voltage.The device has high precision and can communicate with a single-chip microcomputer through IIC interface.Given the long-term connection between the battery management system and the 13th cell, we designed a voltage follower based on the op amp, which can improve the input impedance and reduce leakage current, to avoid excessive power consumption.This configuration does not seem to be as strong as two LTC6804s, but we have tested the setup to meet the requirement of the system (the measurement error of the 13th cell's voltage is 0.018%.).This proposed system can save one LTC6804 chip, which could greatly reduce costs.

Current Acquisition.
Circuit current is not only an important parameter of battery protection system but also crucial to the estimation of the SOC.This design adopts shunt resistance to measure the current through the ADS1246, which is a highly integrated precision 24-bit analog to digital converter (ADC), to ensure accurate current measurement.The resistance of the shunt resistor is 1 mR and accuracy is 1%, with ±100 PPM/ ∘ C. We used the open-loop voltage and the ampere-hour counting method to calculate the SOC.The dynamic range of current is quite large, which is almost up to 30 A, but typically, the current value is below 5 A. To reduce energy loss and impact of temperature drift, we used this small resistance measurement resistor.The planned accuracy for the current measurement is 1 mA, which needs a high-resolution sampling method.Thus, we used the AD1246 chip, which is a 24-bit resolution, with integrated gain and differential input A/D, and has up to 2 kSPS conversion chips.In this design, the current is integrated every 5 ms.To obtain the highest possible accuracy, we set the sampling frequency as 200 Sps. of the temperature sensor is to ensure that the temperature of the battery does not exceed the temperature specified in the manual (charge −10∼+45 ∘ C, discharge −20∼+60 ∘ C).Thus, the five temperature sensors are evenly placed inside the battery packs and stick on the surface of the cells.We have roughly marked the position of the temperature sensors with red arrow in Figure 4(b).

Equalization Function.
Passive equalization is used for its simple structure, low-cost, easy-to-implement, and highreliability features.Figure 5 shows the principle of passive equalization.The bypass resistance is 100 Ω.The maximum current that the equalization resistor can withstand is 60 mA.The power of the equalization resistor is 1/3 W. We used the LTC6804 chip to control the first 12 equalization resistors and used PMOSFET to control the 13th equalization resistor in LTC6804's control principle.The PMOSFET is controlled by the control unit using opt coupler (PC817) isolation technology.During the charging process, if the voltages of some cells were higher than others by 50 mV, the electronic control unit (ECU) in the lower machine will control the bypass switches to deplete the excess energy of the higher voltage cells.

Design of Software System
4.1.Software Design of Lower Machine. Figure 7 shows that the control module obtains the voltages of 13 cells through the voltage collection module and calculates the total voltage.The control model supervises the charging and discharging processes according to the current acquired by the current module and the temperature acquired by the temperature module.The SOC and SOH of batteries were estimated through Formulas ( 1) and ( 2), and the serial cells were balanced through the passive equalizer module.The control model communicates with the Android client to send the batteries' message or receive the user's command simultaneously.clients by assigning a port number for each client.When the users log in to the system by using the port number and IP address, the Android client receives the message posted by the lower machine and then analyzes and assigns parameters to the monitor interface.The actual process is shown in Figure 8.

Validations of System Functions
An experimental circuit board was designed according to the lower machine function and installed on the experimental electric bicycle to verify the feasibility and practicability of the battery monitoring system.A BMS app (based on Android 4.4) was designed according to the upper machine function.After installing the app on a Samsung GALAXY NOTE 3 and connecting to the Wi-Fi network launched by the lower machine, the NOTE 3 could receive and display messages from the battery pack.The experimental tools and monitoring system are shown in Figure 9. ), which has accuracy of 0.15%.The battery monitoring system uploads data to the Android monitoring software via Wi-Fi for monitoring and storage while simultaneously measuring the voltages of the battery cells, the current in the circuit, and ambient temperature through a multimeter.Table 1 shows that the errors of voltage and current were within 0.2% and the errors of temperature were within 2%, which were sufficiently precise for application in the electric bicycle.

Verification of Battery Protection Function.
Verification of battery protection function is focused mainly on whether the circuit can automatically disconnect when the batteries encounter too low or too high voltage, as well as extraordinary current, and temperature.Battery protection is verified by this concept: MOSFET switches off when any one of the battery voltages reaches below 2.7 V or higher than 4.2 V (the range of 2.7 V to 4.2 V is safe).The NCR18650B datasheet recommends that the end of discharge voltage is 2.5 V, but to extend battery life, the undervoltage protection is set to 2.7 V.
The test shows that the back-to-back MOSFET can guarantee the batteries to work safely in any condition.

Verification of Equalization Function.
Verification of balance function is centered on the charging stage and should ensure that all series cells can simultaneously achieve the fully charged stage.Figure 10 shows the equalization effect of each cell.The results indicate that the voltage difference among all battery cells was below 50 mV at the end of the charge.actually tested SOC.The actually tested SOC is calculated using the programmable power N7954A (Figure 9(a)), and the difference between the two is within 3%, which is higher than the SOC precision requirement of electric bicycles.

Verification of SOH Estimation Function.
To verify that the SOH estimation can automatically correct, we set up three different cell capacities.The first group's initial capacity was set to 4000 mAh, which was far greater than the actual value; the second group's initial capacity was set to 3250 mAh, which was equal to the actual value; and the third group's initial capacity was set to 2000 mAh, which was far lower than the actual value.Then, we controlled battery discharge intermittently by using programmable power supply N7954A.Figure 12(b) shows battery voltage.When the voltage of the battery pack stabilizes after discharge and meets the SOH update conditions (the SOH updates only when the voltages become stable before and after a charge or discharge process, and the amount of passed charge is greater than 30% of the battery capacity; Formula (2) will be used when these conditions are met), the cell capacity will be automatically updated in accordance with Formula (2).As shown in Figure 12(a), the cell capacity can be automatically corrected by Formula (2), which results in a gradually close solution to the ideal value, regardless of the initial value.The estimated SOH then can be calculated by Formula (3) and can be corrected automatically to nearly the actual value, after the multiple discharge cycles.

Verification of Communication
System.The verification communication system was created by connecting the mobile phone to the Wi-Fi network delivered by the low computer.Figure 13 shows that after connecting successfully, the monitoring software begins to receive the data and display them on the interface.The Android client can provide a more flexible interface, as shown in Figures 13(a  The Android client displays each cell's voltage, balance state, the pack's SOC and SOH, and total power to the user.In addition, the program reports how many miles the battery can provide, which allows the users to understand their ebike better.Figure 13(d) shows the commands send interface.By the power on or power off button, we can send command to the lower machine to control the MOSFET's on or off.When we turn the MOSFET off, the pack cannot charge or discharge any more.Data with time stamping will be recorded into the new notepad for further experimental analysis and data playback.

Verification of Protecting Battery Life.
Reference [22] shows that when the cut-off voltage decreases from 4.2 v to 4.1 v, the capacity degradation rate will be reduced by 38%, and that when the charging current rate is greater than 1 C, the increase rate of 1 s resistance will be accelerated rapidly, which is a key parameter to identify the battery life.Reference [23] provides some principles to prolong battery life, such as charging the battery just before using and charging only when the capacity for next use is insufficient.The aging test in [24] shows that the cycle count is 4,200 when 20% capacity is consumed by cycling in the SOC range 0.4-0.7,and the cycle count is reduced to 550 when 20% capacity is consumed by cycling in the SOC range 0-1.
To prolong the battery life, this paper monitors the battery pack through the app running on the mobile phone.When the SOC is less than 20%, the phone will remind the user to charge in time.When the SOC is higher than 80%, it will remind the user to stop charging, and when the SOC reaches 95%, the app will send a message to the lower machine to stop charging.In our experiment, we collected data every 100 cycles.Figure 14(a) shows the capacity fading when the BMS does not have charge management, the battery is cycling in the SOC range 0-1, and the capacity fades quickly.The battery capacity will be reduced by 20% when the cycle count is 600. Figure 14(b) shows that the capacity fading is very slow when the BMS has charge management; the battery is cycling in the SOC range 0.2-0.8;and the capacity is reduced by only 3% when the cycle count is 600.Next step, we will specifically develop a matching charger.When we enter the travel plan through a mobile phone, the BMS will automatically command the charger to charge the battery to a reasonable SOC a few hours just before the trip.This approach will prolong the battery life further.

Conclusions
This paper designed a battery monitoring system based on Android client and the ARM microcontroller for electric bicycle, which can not only meet the requirements of the conventional battery monitoring functions effectively but also facilitate easy monitoring of the state of the battery pack.The battery monitoring system with the Android client system has been successfully applied in electric bicycles, and the experimental schemes in this paper have been found to be feasible and replicable.
The main conclusions are as follows: (i) The battery monitoring system in this paper can effectively manage the lithium battery pack in the electric bicycle and replacing lead-acid battery with the lithium battery in the electric bicycle can be considered.
(ii) Monitoring the lithium battery pack through the Android client app is feasible and convenient.

Figure 3 :
Figure 3: Structure of the main control unit.

Figure 6 :
Figure 6: Schematic diagram of communication between the upper monitor and the lower computer.

3. 6 .
Wi-Fi Sending and Receiving.Figure6shows that the Wi-Fi module selects the UART ETH WIFI chip HLK-RM04.The chip is based on universal serial interface and abides by the TCP/IP protocol.It can also be used in a port equipment to transmit data through the network.The Android smart phone devices typically have Wi-Fi communication functions, which can communicate with the lower machine through Wi-Fi.

Figure 7 :
Figure 7: Control flow of the lower computer.

4. 2 .
Android Client Design.A Samsung GALAXY NOTE 3 N9006, Android version 4.3, was used as a platform to run the upper machine software and test the Android client system.The development environment for the software is Android SDK, Java JDK6, and Eclipse.The flowchart of the operating program is shown in Figure 8.The lower machine can communicate simultaneously with multiple Android Accuracy.Verifications of voltage and current acquisition are obtained by comparing voltage and current values collected from the measurement module and measured by Agilent 34450A (Figure 9(c)), which is a 5.5 Digit Multimeter.After calibration, the fabricated circuit can obtain almost the same measurement results as that of the 34450A.The accuracy of temperature is verified by the Yokogawa MV2000 (Figure 9(b)

Figure 11 :
Figure 11: SOC comparison between the calculated and the estimated.
), 13(b), and 13(c), without adding too much cost or upgrading the existing front panel.

Figure 14 :
Figure 14: Effect of the charging management.

Table 1 :
Comparison of acquisition value with measured value.
Function.Verification of SOC estimation is conducted by controlling the discharge current through a programmable power supply and comparing the estimated SOC value with the actual tested SOC value.When the voltage is stable, we used the OCV-SOC lookup table to estimate the SOC.In the discharge/charge process, SOC is calculated by ampere-hour counting method, and thus, SOC's accuracy also depends on current measurement accuracy.Figure11is used to compare the BMS estimated and