2014 Fifth International Conference on Intelligent Systems, Modelling and Simulation Building of A Low-Cost Wireless Battery Analyzer Boon-Huat Wilson Tan Chee-Chiang Derrick Tiew SIM University, School of Science & Technology, Singapore e-mail: wilsontan002@unisim.edu.sg SIM University, School of Science & Technology, Singapore e-mail: derricktiew001@unisim.edu.sg Abstract—This paper presents the design methodology, implementation and testing of a low cost wireless battery analyzer. The initial goal of this project is to build a battery analyzer to enable the remote monitoring of a 24V backup battery installed in a submarine. The implemented battery analyzer is microcontroller-based, incorporates features to sense and monitor the battery voltage level, discharge current and the surrounding ambient temperature. Each of the sensing signals is converted and stored as 10 bits stream. The data values are reported to the crew via the screen of a laptop/PC over a Bluetooth wireless communication link. Alarm will be triggered whenever the battery voltage level, current and/or ambient temperature fall out of preset allowable limits. x Keywords-battery analyzer; current sensor; temperature sensor; wireless; bluetooth technology; serial port x x x x x I. INTRODUCTION The 24V backup battery system is one of the most important systems onboard a submarine as it continues to provide the required load (electrical supply for equipment) for sustained silent operations and fighting capability when the main 24V supply is not operative. Hence, when the 24V backup battery is activated, it is critical for the submarine crew to monitor the health and capacity of the batteries so as to ensure the submarine continues her mission without any restriction and limitation. The original idea of designing a wireless battery analyzer is to assist the submarine crew to monitor the 24V back up battery. Due to the space constraint on board the submarine, it is a challenge to monitor the battery status in such a constraint space where the battery was installed. Hence, a wireless battery analyzer will definitely be useful for the crew to monitor the battery performance in the event when the 24V back up battery system is activated. II. x Bluetooth Module: To communicate and provide wireless link between microcontroller and PC for displaying real time readings. Microcontroller: To record the voltage, current and temperature readings from the battery sensors and converts the data to obtain the real time battery’s parameters to be displayed. When the limitation of the battery system is reached, it will send a signal to alert the users. PC Display: To display battery’s parameters for monitoring purposes. Buzzer: Alert the users when the battery limitation has reached. LEDs: To indicate the status of the analyzer and the battery. GUI: Using ASP.NET (Visual Studio) to graphically display the readings of the battery analyzer. 5V power supply: To supply 5V to the microcontroller. HARDWARE DEVICES A. System Architecture The system architecture of the wireless battery analyzer using Bluetooth technology is illustrated in Fig. 1. The system is made up of the following components: x 24V DC battery: 24V backup battery system to be monitored. x Battery Sensors: To record the voltage, current and temperature of the 24V backup battery system in the submarine and send the readings to the microcontroller. 2166-0662/14 $31.00 © 2014 IEEE DOI 10.1109/ISMS.2014.140 Figure 1. System architecture of the wireless battery analyzer 765 B. Bill of Materials Table I lists the hardware devices used in constructing the wireless battery analyzer. The total purchase cost falls below USD $70 for the components, and well within the budget allocated to this project. TABLE I. BILL OF MATERIALS FOR THE CONSTRUCTION OF THE WIRELESS BATTERY ANALYZER Figure 3. ACS712 current sensor and its pin-out The analog signal from the current sensor is transmitted to the microcontroller and this signal is then converted to digital values by the ADC module in the microcontroller. This digital value will be used to compare with the preset value and determine whether a high current has been detected. E. Temperature Monitoring Circuit There is a need to monitor the ambient temperature of the battery as the rise of temperature would speed up the discharging rate of the battery, and drain the battery at a faster pace [3]. Hence, the battery’s ambient temperature needs to be monitored closely, and appropriate action is required to bring down the temperature once it exceeds certain pre-determined unacceptable level. LM35 temperature sensor was selected for this project. The LM35 series are precision integrated-circuit temperature sensors, with an output voltage linearly proportional to the temperature (in °C). The scale factor for LM35 is 10.0 mV/°C with 0.5°C accuracy (at +25°C), and temperature measuring range from −55°C to +150°C [4]. Fig. 4 shows the pin out of LM35DZ while Fig. 5 shows the connection of its output to AN0 (analog channel input) of PIC18F4520 microcontroller. C. Voltage Monitoring Circuit As the monitoring battery is 24V, there is a need to step down the battery voltage level to ~3V before feeding it to the PIC18F4520 microcontroller for analog to digital conversion (ADC). Fig. 2 shows the voltage monitoring circuit comprises a voltage divider. Figure 2. Voltage monitoring using voltage divider The analog signal from the battery voltage is transmitted to the microcontroller and this signal is then converted to 10bit binary stream by the ADC module in the microcontroller. This digital value will be used to compare with the preset value to determine whether a low voltage has been detected. The maximum input voltage at AN4 is 3.13V which is safe for the microcontroller. The equation for the voltage divider is shown below. Vout (to AN4 ADC) = R2 / (R1+R2) * 24V = (1.5 / 11.5) * 24V = 3.13V The resolution of the sensing voltage Vout is given by 3.13V / (210 - 1) = 3.06 mV. Figure 4. Temperature sensor LM35DZ pin-out D. Current Sensing Circuit The battery efficiency decreases as the average discharge current from the battery increases [1]. There is a need to closely the monitor and limit the discharge current from the battery in order to prolong the battery lifetime. Module type ACS712 current sensor was selected for monitoring the discharge current from the battery. The ACS712 current sensor provides economical and precise AC and DC current sensing and also allows easy implementation. It consists of a precise, low-offset and linear Hall sensor circuit [2]. Fig. 3 shows the ACS712 current sensor and its pin-out. Figure 5. Integration of temperature sensor LM35DZ with micro-controller PIC18F4520 F. Bluetooth Module This prototype uses Roving Networks RN-42-SM Bluetooth module to implement the wireless communication link. Roving Networks is the subsidiary company of Microchip. Hence, the compatibility between the Bluetooth module and PIC microcontroller is assured. It requires only a simple connection as shown in Fig. 6. 766 graphical user interface (GUI) for displaying the values of sensed signals using Microsoft Visio Studio IDE. A. Microcontroller Programming After sensing the battery voltage level, current and the ambient temperature, those analog signals need to be converted to binary numbers for digital control and display purpose. The analog to digital conversion (ADC) were carried out via PIC18F4520 microcontroller. The codes were written in C language. The software integrated platform MPLAB IDE provided by Microchip was used to write the program codes, test and debug the PIC18F4520 microcontroller. PICkit3 was then used to program the prototype [7]. Once the integration and testing of the hardware and software were successful, the program codes were permanently transferred and stored in the microcontroller. The PIC18F4520 microcontroller pins were assigned to respective usage prior to the software programming. Table II shows the configuration of PIC18F4520 ports for the wireless battery analyzer. Figure 6. Connection diagram of Roving Networks RN-42-SM Bluetooth module The Bluetooth module uses the Serial Port Profile (SPP) to communicate with the microcontroller via a virtual serial (COM) port [5]. It acts as a wireless connection between the microcontroller and the laptop for data transmission. The serial output function of the microcontroller and the Bluetooth module configurations have to be matched before data can be transmitted. G. Microcontroller PIC18F4520 microcontroller was selected for the implementation of this prototype. It is a 40 pin 8-bit processor with 5 set of I/O ports and an built-in Analog to Digital Converter (ADC) which features high resolution and quick conversion of analog signals [6]. The 13 channels of analog inputs for the ADC of PIC18F4520 are more than sufficient the wireless battery analyzer. Fig. 7 shows the pin out of the 40-pin PDIP PIC18F4520. Pin 2 7 8 13 14 25 26 33 34 35 39 40 TABLE II. CONFIGURATION OF PIC18F4520 PORTS Port Usage AN0 Temperature sensor AN4 Voltage sensor AN5 Current sensor RA6 Oscillator RA7 Oscillator RC6 Bluetooth RC7 Bluetooth RB0 Green LED RB1 Red LED RB2 Buzzer RB6 PICkit3 RB7 PICkit3 Fig. 8 illustrates the microcontroller’s ADC process for the voltage monitoring circuit. The same flow chart also applies to other sensing signals, i.e. for sensing current and temperature. Figure 7. Pin out diagram of 40-pin PDIP PIC18F4520 H. LEDs PORTB pins will be used as output by setting TRISB = 0b00000000. Pin 1 to 2 of PORTB pins are used to drive the LEDs. Logic ‘1’ is set to the designated pins for the LEDs to light up, e.g. the red LED will light up whenever battery voltage level drops below 22V or the temperature rises above 40oC. Start Starts receiving voltage value Starts converting voltage value I. Buzzer Pin 3 of PORTB is used to activate the buzzer. Logic ‘1’ is set as the output to the pin for buzzer activation. The buzzer will sound whenever battery voltage level drops below 22V or the temperature rises above 40oC. No Voltage value converted? Yes Data store in buffer III. SOFTWARE DEVELOPMENT Transmit data via Bluetooth For display This section will discuss the software development involved in the building of the prototype. The first part will touch on the C programming on the microcontroller for analog to digital signal conversion and digital control of devices. The second part will discuss the development of a End Figure 8. Flow chart illustrates the process of analog-to-digital conversion (ADC) via PIC18F4520 microcontroller 767 Three analog channels (AN0, AN4 & AN5) were selected for the ADC. Channel 0 (AN0) is used for temperature sensor, Channel 4 (AN4) is for voltage sensor while Channel 5 (AN5) is for current sensor. The converted 10-bit binary stream was stored in 2 bytes with long right justified format. Fig. 9, 10 & 11 show the C program source code to perform the analog to digital conversion (ADC) of voltage, current and temperature sensing signals via PIC18F4520 microcontroller respectively. The ADCON0 register controls the operation of the A/D module. The ADCON1 configures the functions of the port pins. The ADCON2 register configures the A/D clock source, programs acquisition time and justification [4]. Red LED light will light up and buzzer will sound whenever battery voltage level drops below 22V or the ambient temperature rises above 40oC. Figure 11. C program source code for the analog-to-digital conversion (ADC) of temperature sensing signal via PIC18F4520 microcontroller B. Graphical User Interface A graphical user interface (GUI) was created for the prototype using Microsoft Visio Studio IDE. The GUI could be installed on a laptop/PC, and it will be functional as long as the distance between the wireless battery analyzer and laptop/PC is within a 20 m range. It will display the values of sensing voltage, current and temperature as well as status indication if the battery voltage level has fallen below a threshold, the current exceeds a certain value, and if the temperature has risen beyond a set point. In this case, the battery voltage level will change its indication from NORMAL to LOW whenever the voltage falls below 22V, the current’s indication will toggle from NORMAL to HIGH once it exceeds 5A, and the temperature’s indication will switch to HIGH from NORMAL once its value crosses over 40oC. Fig. 12 shows the created GUI while Fig. 13 shows the source codes to create the GUI. Figure 9. C program source code for the analog-to-digital conversion (ADC) of voltage sensing signal via PIC18F4520 microcontroller Figure 10. C program source code for the analog-to-digital conversion (ADC) of current sensing signal via PIC18F4520 microcontroller Figure 12. Graphical User Inteface (GUI) created using Microsoft Visio Studio IDE 768 A. Overall System Circuit Diagram All the components were integrated and controlled via PIC18F4520 microcontroller as shown in Fig. 14. Figure 14. System Integration of Wireless Battery Analyzer Fig. 15 shows the complete prototype of a wireless battery analyzer. All hardware devices were soldered around the PIC18F4520 microcontroller with some its signals controlled by the microcontroller. Voltage monitoring circuit Figure 15. The complete prototype of a wireless battery analyzer Flow chart as shown in Fig. 16 illustrates the program progression of the prototype wireless battery analyzer. At the start of the program when 5V is made available and the battery supply is connected to the prototype, the prototype will begins to detect the readings of the battery and sent to the laptop for display on screen via Bluetooth technology. The red LED will light up when the detected readings cross over the pre-determined threshold. The moment the red LED light up, the buzzer will also sound. Figure 13. Source codes to create the Graphical User Inteface (GUI) IV. INTEGRATION & TESTING This section will discuss the process steps involved in integrating the various components of the system, and the interfacing of software with hardware components. Testing was carried out to validate the successful integration of the various hardware devices and the developed source codes. 769 Figure 18. Battery readings appeared in Hyper Terminal C. Testing of Voltage Monitoring Circuit For the test, a power supply unit was used to simulate a 24V battery. The voltage readings were obtained from the voltage monitoring circuit and the value displayed out on the GUI. Fig. 19 shows the successful testing of the voltage monitoring circuit. . Figure 16. Operational flow chart of Wireless Battery Analyzer B. Hyper Terminal A Hyper Terminal session was set up to test the wireless communication link between the battery analyzer and laptop / PC via the Bluetooth module. This could be done by launching the Bluetooth function in laptop / PC to connect with the Bluetooth module incorporated as part of the battery analyzer. A Hyper Terminal was launched to create a new connection. A COM port was selected to connect with the Bluetooth module. Once the COM port has been selected, the correct Baud rate, Data bits, Parity, Stop bits and Flow Control have to be set as shown in Fig. 17. Figure 19. Testing of voltage sensing circuit D. Testing of Current Sensing Circuit For the test, a 12 Ω resistor was used as a simulated load to the prototype. A current of 2A was detected (24V/12Ω = 2A) as shown in Fig. 20 below. Figure 17. Port setting for Hyper Terminal After the above settings were done, HyperTerminal was then ready to communicate with the Bluetooth module. Fig. 18 below shows the battery readings appearing in the HyperTerminal which indicates a successful set up of the wireless communication link. Figure 20. Testing of current sensing circuit E. Testing of Temperature Monitoring Circuit Temperature readings were obtained from the LM35 temperature sensor at room temperature 28°C and at 34°C 770 (external heat was introduced by using hands). Fig. 21 shows the successful testing of the temperature monitoring circuit. V. CONCLUSION A low-cost functional wireless battery analyzer was successfully built. The process involved in the design and build of the wireless 24V battery analyzer using Bluetooth technology was demonstrated in this paper. The analyzer will be able to sense the lead acid battery’s voltage, current and ambient temperature, and the microcontroller will process and send the signals to the laptop/PC via Bluetooth module. The data will then be displayed on the laptop/PC real time. With the aid of the wireless battery analyzer for the 24V backup battery system, submarine crew would be able to monitor, manage and control the 24 V backup battery system which is critical for the submarine operation. ACKNOWLEDGMENT The authors would like to express gratitude and appreciation to School of Science & Technology, SIM University for the provision of budget and support of this project. Figure 21. Testing of temperature monitoring circuit F. Testing of LEDs and Buzzer The test is to ensure that the LEDs and buzzer are functioning satisfactory. The green LED will light up when the power supply is available and there is no fault detected as shown in Figure 22. REFERENCES [1] [2] [3] [4] [5] [6] Figure 22. The lit-up of Green LED during normal operation with 5 V power supply [7] Once a fault is detected or abnormality occurs, e.g. 0 V being sensed, the red LED will light up as well as the activation of the buzzer as shown in Fig. 23. Figure 23. The lit-up of Red LED and the activation of buzzer when the battery voltage level drops below 22 V 771 Massoud Pedram and Qing Wu, “Design Considerations for BatteryPowered Electronics,” IEEE 36th Design Automation Conference, pp. 861-866, Jun 1999. Allegro ACS712 Datasheet, “Fully Integrated, Hall Effect-Based Linear Current Sensor with 2.1 kVRMS Voltage Isolation and a LowResistance Current Conductor”. Dariga Meekhun, Vincent Boitier and Jean-Marie Dilhac, “Study of the ambient temperature effect on the characteristics and the lifetime of Nickel-Metal Hydride secondary battery,” IEEE Electrical Power & Energy Conference, 2009. Texas Instruments LM35 Datasheet, “LM35 Precision Centigrade Temperature Sensors”. Roving Networks RN-41-SM / RN-42-SM Datasheet, “Calss 1/Class 2 Bluetooth® Socket Module”. Microchip PIC18F2420/2520/4420/4520 Datasheet, “28/40/44-Pin Enhanced Flash Microcontrollers with 10-Bit A/D and nanoWatt Technology”. Microchip PICkitTM 3 Programmer/Debugger User’s Guide.