Design and Implementation of a Battery Pack Detection Sensor Based on CAN Bus
2026-04-06 06:28:56··#1
Abstract: With the continuous development of communication, electronics, and energy technologies, storage batteries are increasingly widely used and play an increasingly important role in civilian and industrial production. To ensure the continuous and stable operation of control systems, it is essential to research and design efficient, inexpensive, accurate, convenient, and practical storage battery detection devices. Keywords: Storage battery, CAN bus, LPC935, sensor 1 Introduction Storage batteries in DC power systems generally operate in two modes: float charging and charge-discharge-charge, as shown in Figure 1. In float charging mode, the battery bank is connected in parallel to the output terminal of the rectifier (DC load input terminal) to ensure uninterrupted power supply to the load, mainly used in fixed locations. Charge-discharge-charge mode is generally used in mobile equipment. Since the battery bank consists of multiple identical individual batteries connected in series, overcharging, over-discharging, or under-discharging of individual batteries can easily cause battery failure. A failure in one individual battery can also lead to the failure and damage of the entire battery bank. Therefore, it is necessary to identify damaged or significantly degraded batteries by monitoring parameters such as the charging and discharging voltage of each individual battery, the temperature rise during charging and discharging, and the charging and discharging current and voltage of the entire battery pack in real time online, in order to ensure the stability and reliability of the DC power system. Therefore, battery pack testing should adopt a distributed acquisition and centralized monitoring approach. General testing uses RS-232 or RS-485 buses, but because they are master-slave buses, the testing terminal cannot actively send data to the host computer. This system designs a non-master-slave CAN bus as the distributed acquisition bus for the battery pack, giving the testing system advantages such as high reliability, scalability, and real-time performance. Figure 1 shows two operating modes of the battery pack . 2. System Overall Composition and Working Principle2.1 Introduction to CAN Bus CAN (Controller Area Network) is a serial communication network designed by BOSH GmbH in Germany for automotive monitoring and control systems. The CAN bus can operate in multi-master mode without master-slave distinction, and can transmit and receive data in point-to-point, point-to-multipoint, and global broadcast modes. It also features non-destructive bus arbitration technology. With a communication speed of 5kbps, the maximum communication distance is up to 10km, and the transmission medium can be twisted-pair cable, coaxial cable, or optical fiber. The CAN bus uses a short frame structure, with each frame being 8 bytes, ensuring an extremely low data error rate. It is widely recognized as one of the most promising fieldbuses. 2.2 Overall Design of the Battery Testing System The overall system design block diagram is shown in Figure 2. 24 individual cell testing units detect the voltage and current of the 24 individual cells in the battery pack. The hardware structures of each testing unit are very similar. There is also a separate testing unit to detect the overall voltage and current of the battery pack. The testing units monitor in real time and send data to the CAN bus. The host computer receives the data from each testing unit, and analyzes, processes, stores, displays, and prints the data. Simultaneously, it diagnoses and alarms for individual cell faults. Figure 2 Overall Block Diagram of Battery Testing System 2.3 Design of Individual Battery Testing Unit The function of the individual battery voltage detection unit is to detect and transmit the voltage and temperature of individual batteries over a network. This unit consists of a voltage signal converter, a microcontroller system, a CAN bus interface, and a power supply. This unit is a voltage detection module based on CAN communication. The detected analog voltage signal is processed and digitized, then transmitted to the control and management unit via the CAN bus. The circuit diagram of the individual battery testing unit is shown in Figure 3: Figure 3 Overall Design Block Diagram of Individual Battery Testing System After the detection terminal collects the voltage and temperature signals of the individual batteries, it amplifies, filters, performs analog-to-digital conversion, and isolates them before sending them to the microcontroller. The microcontroller communicates with the host computer via the CAN bus. The detection circuit uses a 12-bit A/D converter with a serial interface and a cycle of less than 20ms, connected to the microcontroller via opto-isolation. The microcontroller used is the low-power, small-size 8-bit LPC935. The unit uses LEDs to indicate its operating status. It is connected to the microcontroller via a CAN controller with a serial interface, and the CAN bus is used to transmit the detection data to the host computer. The isolated power supply within the unit uses a small DC/DC module power supply. 2.4 Working Principle Analysis of the Detection System Each detection unit stores the detected current, voltage, and temperature data into a CAN buffer according to the CAN bus specification, and initiates a send command to send the data to the CAN bus. This data is then sent to the host computer via the CAN bus. The host computer's CAN controller stores the received data in a buffer and sends an interrupt request to the host computer's CPU. If the host computer responds to the interrupt, it receives and processes this data, converting it into voltage, current, and temperature signals for display. Simultaneously, it performs some analysis and diagnosis on these signals. If any abnormality is detected, a warning message is issued (buzzer sounds, red light illuminates). 3 Design of Individual Detection Unit Node Circuit3.1 Temperature Acquisition Circuit Since the battery's performance is highly dependent on temperature, it is necessary to acquire the battery's temperature information. The system cyclically detects the battery temperature. After acquiring the data, it is amplified, filtered, and converted by an A/D converter before being sent to the microcontroller and then to the CAN bus. Its temperature acquisition circuit is shown in Figure 4. Operational amplifier A1 provides a constant voltage, and resistors R3, R4, R6 and thermistor R5 form a bridge circuit, which outputs differentially after passing through operational amplifier A2. Figure 4 Temperature sampling circuit 3.2 Voltage acquisition circuit The voltage of a single battery cell collected by the system is a relative voltage. In order to ensure the accuracy of voltage detection and not affect the operation of the system, an opto-isolator is used for isolation. After passing through the operational amplifier, it is input to the microcontroller. Its circuit structure is shown in Figure 5. Figure 5 Voltage sampling circuit The voltage sampling circuit uses a linear optocoupler isolation chip TIL300. The input voltage change is converted into a current change, and its internal linear relationship is as follows: (1) From the feedback loop, the linear relationship between the input voltage and the output voltage can be obtained as: (2) The current sampling circuit is similar in structure to the voltage sampling circuit, except that the voltage signal is converted into a current signal through a resistor before acquisition. This will not be described in detail here. 3.3 Microcontroller and CAN Bus Connection Circuit The microcontroller selected for this system is the enhanced 51 microcontroller LPC935. The LPC932 is connected to the CAN controller MCP2510 via the SPI bus, and then connected to the CAN transceiver 82C250 via the high-speed opto-isolator 6N137. The 82C250 is connected to the CAN bus to implement differential transmission and differential reception [1]. The specific circuit diagram is shown in Figure 6. 4 System Communication Software Development The system software includes a self-test program, a digital display program, a filter processing program, and a communication program, among which the communication program is the core and key of the software design. The communication program mainly consists of three parts: the initialization program, the sending program, and the receiving program. Figure 6 Microcontroller and CAN Bus Connection Circuit Diagram 4.1 Initialization Program The initialization program includes the initial settings of the status of each port of the microcontroller LPC935, the initial settings of the stack, the settings of the timer, the initialization of the memory, the initialization of the interrupt, the initialization of the serial port, and the initial settings of the CAN controller. The operating mode of the CAN controller is determined by writing control words into the registers in the control section of the CAN controller. The CAN controller used in this system is the MCP2510. In the system reset mode, the microcontroller LPC935 needs to perform register operations on the MCP2510; write the receive code register and receive mask register to determine the information ID that the node needs to receive; write the bus timing register to determine the bus communication baud rate; and write the output control register to select the normal output control mode. 4.2 Transmission Program The transmission of data from the MCP2510 to the CAN bus is done automatically by the MCP2510. The transmission process of the LPC935 is as follows: (1) Edit the identifier ID of the transmitted information and then store the frame information in the external data memory. (2) The LPC935 starts to query the status flag bit of the transmission buffer in the status register of the CAN controller. If it is 0, the information is written into the transmission buffer of the MCP2510, and the TC bit of the post-command register is 1 to send the information. 4.3 Receiving Program The CAN controller automatically completes the information transfer from the CAN bus to the CAN receive buffer. The LPC935 receiving program only needs to read the information to be received from the receive buffer. Each time the MCP2510 successfully receives a frame of information, it stores the information in its internal FIFO and generates a receive interrupt. After responding to the interrupt, the LPC935 reads the information from the FIFO into external RAM and then releases the MCP2510 buffer occupied by the information. 5 Conclusion This paper introduces a CAN bus-based distributed battery detection system. This system has good real-time performance, high detection accuracy, easy expansion, good anti-interference ability, and strong applicability. Furthermore, a temperature compensation circuit can be added to protect against overcharging and over-discharging of the battery. With the increasing use of batteries, battery detection and maintenance technology will be a hot topic in power technology research. The CAN bus-based distributed battery detection system has significant advantages and practical application value.