Design of a distributed control system for battery pack charging and discharging based on CAN bus
2026-04-06 07:21:29··#1
Abstract : This paper addresses the practical engineering problem of parameter detection and control during the charging and discharging process of battery packs. A distributed control system scheme based on CAN bus for battery pack charging and discharging is proposed, focusing on the characteristics of CAN bus, control system design, node unit circuits, and program design. Keywords : CAN bus; microcontroller; battery pack; real-time detection Introduction With the rapid development of high technology and its industries, large-capacity battery pack energy systems have gained increasing attention and are widely used in many fields such as electric vehicles, high-power UPS, DC systems in power plants and substations, and communication systems. A battery pack consists of a certain number of individual batteries connected in series, which may undergo hundreds to thousands of charge and discharge cycles during use. Overcharging, over-discharging, or under-discharging of individual batteries can easily cause battery failure, and a failure of a single battery can lead to the failure and damage of the entire battery pack. Therefore, real-time online monitoring of the charging and discharging voltage of each individual battery cell, the temperature rise during charging and discharging, and the charging and discharging current and voltage of the entire battery pack are crucial for timely identification of damaged or significantly degraded batteries. This is essential for extending battery life, reducing costs, and especially improving the reliability of DC power supply systems. In light of this, we have developed a distributed control system for battery pack charging and discharging. This system overcomes the shortcomings of early centralized data acquisition and monitoring methods, such as excessive wiring, long lines, wasted manpower and resources, and susceptibility to interference. Furthermore, the CAN bus's multi-master node, high reliability, and good expandability give this system excellent control performance and broad application prospects. System Composition and Working Principle Introduction to CAN Bus Controller Area Network (CAN) bus belongs to the fieldbus category. It is a serial communication network designed by BOSH GmbH of Germany for the reliable operation of distributed systems in strong electromagnetic interference environments. It has the following significant features: (1) Multi-master mode operation, each node can actively send information to other nodes on the network at any time without master or slave distinction, and no node information such as station address is required. This feature can be used to easily form a multi-machine backup system; (2) Adopting a unique non-destructive bus arbitration technology, nodes with higher priority transmit data first, which can meet different real-time requirements; (3) Broadcast data communication, using CSMA/CD protocol for bus control and data communication. When a node sends data to the network, other nodes receive the data simultaneously, and it has the functions of point-to-point, point-to-multipoint and global broadcast data transmission; (4) High transmission reliability, the number of effective bytes per frame on the bus is up to 8, and there are CRC and other verification measures, the data error rate is extremely low, and when a serious error occurs in a certain node, it can automatically disconnect from the bus, so that other operations on the bus are not affected; (5) It is particularly suitable for networked intelligent devices, with a maximum speed of up to 1Mbps, at which time the communication distance is 40m. When the communication rate is selected as 5kbps, the communication distance can be up to 10km, and it can be selected according to actual needs. The CAN bus has only two wires, and when the system is expanded, the new node can be directly connected to the bus, and the system can easily achieve redundant design. Therefore, from the perspective of applicability, reliability and low cost, we chose the CAN bus to form the underlying communication network in this system. The basic structure and working principle of the distributed control system: The system consists of a host computer (general-purpose PC with a CAN interface adapter card), n intelligent voltage, temperature, and other data acquisition node units (the specific number depends on the number of individual batteries, but does not exceed 110-2 = 108), one field intelligent voltage and current monitoring, display, and alarm node unit, and a CAN bus network. Its system structure is shown in Figure 1. Figure 1: Block diagram of the distributed control system. Each node in the system is based on an Intel 80C196KC microcontroller, equipped with a Philips SJA1000 independent CAN controller and a PCA82C250 CAN transceiver. A dual-port RAMIDT7132 is used as a bidirectional data transmission channel between the PC and the CAN controller. The field intelligent voltage and current monitoring, display, and alarm node unit also uses an LCM320240ZK LCD module and a simple keyboard from Beijing Qingyun Innovation Technology Development Co., Ltd., to display the field data sent by each intelligent detection node unit and to send brief PID adjustment and other control commands to each intelligent detection node unit. The intelligent voltage and temperature detection node units are equipped with corresponding voltage, current, and temperature sensors and processing circuits to acquire voltage, current, and temperature signals. In Figure 1, each intelligent voltage and temperature detection node unit is installed and fixed next to each individual battery cell, and they have the same hardware structure. Their main function is to collect field data such as the charging and discharging voltage of each individual battery cell and the temperature rise during charging and discharging. After filtering and corresponding transformation, this data is sent to the host computer and the field monitoring and alarm node unit via the CAN bus network. The field intelligent voltage and current monitoring and alarm node unit is responsible for detecting the charging and discharging voltage and current of the battery pack, receiving the filtered and transformed field data from each intelligent detection node unit, displaying and storing the main parameters, completing the digital PID regulation and control of the charging and discharging voltage and current of the battery pack, and performing fault diagnosis, locking, and alarm functions for each individual battery cell. Data exchange is also sent to the host computer via the CAN bus network. The CAN bus network mainly consists of the CAN bus communication medium and corresponding communication software. This system uses twisted-pair cable as the communication medium, with the load connected between CANH and CANL. The terminating impedance is the characteristic impedance of the signal, approximately 120Ω. Node Unit Hardware Design Node Unit Working Principle: This system includes different types of nodes, such as on-site intelligent voltage and current monitoring, display, and alarm node units, and intelligent voltage and temperature detection node units. However, their core circuits are basically similar, differing only in peripheral interface circuits and sensor acquisition circuits. Taking a node unit with monitoring, display, and alarm functions as an example, its structural block diagram is shown in Figure 2. Figure 2: Block Diagram of Node Unit. Analog quantities such as AC/DC voltage, current, and temperature during battery charging and discharging are filtered and shaped before entering the A/D converter port of the 80C196KC microcontroller via a multiplexer. The microcontroller samples and performs A/D conversion at regular intervals. Digital inputs pass through optocouplers and buffers to the microcontroller's I/O ports. The microcontroller detects and processes the I/O port data to generate corresponding actions such as audible and visual alarms, shutting down the charging/discharging power supply module, and relay activation. The microcontroller compares the A/D converted data with set parameters and performs digital calculations. The high-speed output port HSO outputs a PWM signal, which, after isolation, shaping, and filtering, is sent out as a PID control signal to control the charging/discharging voltage and current. Due to the large number of peripheral interface circuits, the microcontroller's I/O ports are expanded using an 8155 microcontroller. The keyboard and LCD allow users to scroll up, down, forward, and backward to view monitoring information (charging/discharging power supply status, battery status, charging/discharging curves, etc.) and change system parameter settings (voltage, current thresholds, temperature compensation coefficients, etc.). To facilitate CAN bus communication and data exchange with the host computer, the node unit also includes a CAN communication interface circuit and an RS232 serial communication interface circuit. The hardware circuit diagram of the CAN bus portion of the node unit is shown in Figure 3. The node unit's CAN bus interface consists of an independent controller SJA1000 and a CAN controller interface chip 82C250. The SJA1000, as an external expansion chip for the microcontroller, has its chip select pin CS connected to the microcontroller's address decoder, thus determining the addresses of the registers in the CAN controller within the microcontroller. The SJA1000 is connected to the physical bus through the CAN controller interface chip 82C250. The transceiver 82C250 provides differential transmission capability to the bus and differential reception capability to the CAN controller, is fully compatible with the "ISO11898" standard, and features high speed, anti-interference, automatic output shutdown upon power failure, and support for up to 110 node connections. System Software Design The software of this system consists of two parts: host PC software and node unit software. The PC software, operating under Windows, uses configuration software to generate a user-friendly human-machine interface. It reads data transmitted from each node unit in real time, displays the data after assembly, and provides immediate insight into the working characteristics and status of each battery. Alarm signals are issued for batteries that do not meet requirements, allowing for timely intervention and identification of the optimal operating point for each battery. This ensures the normal operation of the battery charging and discharging system and improves the efficiency of the battery pack's charging and discharging. The node unit software includes modules such as a self-test program, a multi-channel A/D conversion filtering program, a digital PID adjustment program, an LCD display program, and a communication program. It is written in assembly language, simulated and debugged offline, and then stored in an EPROM. Figure 3 shows the CAN bus communication interface circuit diagram of the node unit. The node unit main program flowchart is shown in Figure 4. It performs data analysis of the A/D conversion results, processes I/O port digital switch quantities, calls the battery charging and discharging parameter adjustment program, and handles CAN bus communication, keyboard, and LCD display programs. Data analysis includes comparison of battery pack charging and discharging voltage and current, float charge voltage judgment, and adjustment of low-voltage cutoff voltage threshold. I/O digital switch quantity processing includes judgment of switch quantities and alarm functions. Figure 4: Flowchart of the main program for the node unit. The CAN bus communication program consists of three main parts: initialization program, sending program, and receiving program. The initialization program mainly selects the working mode of the CAN controller, i.e., writes control words to the registers in the control section of the CAN controller. This system uses SJA1000, which completes the initialization process shown in Figure 5 in system reset mode. The information sent from the CAN controller to the CAN bus or from the CAN bus to the CAN receive buffer is automatically completed by the CAN bus controller SJA1000. The flowcharts for sending and receiving interrupts are shown in Figures 6 and 7, respectively. Figure 6: Flowchart of the CAN bus communication sending program. Figure 7: Flowchart of the CAN bus communication receiving program. LCD Display Program. The LCD display program framework is shown in Figure 8. The large dot matrix graphic LCD module LCM320240ZK with Chinese character library can display 300 characters per screen and can clearly display the charging and discharging voltage, current, V/I characteristic curves of the battery pack. The monitoring sub-menu on the first screen includes parameters such as current time, AC voltage, current, load voltage, current, ambient temperature, individual battery temperature, and equalization/float charging status. Pressing the function selection key on the main screen to start or reset will access the main menu screen, which includes sub-menus such as battery status monitoring, charging/discharging parameter control, and fault alarms. The cursor can be used to select the desired sub-menu. Information switching between screens, cursor movement within a screen, and parameter increases/decreases are achieved through combinations of the up, down, left, right, and confirm keys. Figure 8: LCD Display Program Flowchart Conclusion The CAN bus-based distributed control system for battery pack charging and discharging exhibits good real-time performance in charging and discharging parameter detection and control, strong anti-interference capabilities, and ease of upgrades. It provides valuable reference for improving the reliability of DC power supply systems, reducing the workload of staff, and minimizing the blind spots in maintenance work.