Design of Dual CAN Controller for Battery Management System Based on CPLD

Publisher:Serendipity22Latest update time:2012-07-15 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The battery management system is an important electronic control unit in hybrid electric vehicles. It has the function of ensuring the normal, reliable and efficient operation of the battery and is a bridge between the battery and the electrical equipment. During the development and mass production process, its internal control parameters need to be matched and calibrated offline or online, and the battery management system needs to collect and process a large amount of data. This article uses TMS320LF2407 as the CAN controller for calibration. As a CAN node on an electric vehicle, it needs to receive CAN messages sent by the vehicle to execute control commands for external relays, fans, batteries and other devices. This article uses SJA1000.


Dual CAN hardware circuit and


CPLD Logic Design


Dual CAN hardware circuit design


TMS320LF2407 is based on enhanced Harvard structure, and is a microprocessor with separate address and data lines. After multiplying the crystal oscillator, the frequency is as high as 40MHz. The multiplexing of address and data lines of SJA1000 increases the difficulty of reading and writing data between DSP and SJA1000, which is also the difficulty of this system design. The conventional design method is to add a level conversion bidirectional buffer driver between DSP and SJA1000, and its structural block diagram is shown in Figure 1. According to the circuit designed in this way, when reading and writing operations on SJA1000, first configure the I/O port of DSP, pull ALE high, latch the address, and then pull down and () through the I/O port of DSP to read (write) data, and finally pull high and (). In this way, each time the value in the SJA1000 register is read and written, the ALE, and () signals need to be set through the program, which increases the program source code. If the flash memory space of the controller is relatively tight, it is obviously not advisable to adopt this hardware connection method. Moreover, in order to read and write the status bits of the status register correctly, a certain delay needs to be added to the program when reading and writing CAN messages, which will affect the real-time performance of the battery management system.

Figure 1 General dual CAN controller hardware structure diagram


In order to minimize the program source code, save precious storage resources and improve the real-time performance of the battery management system, this paper uses CPLD to connect the interface circuit of the dual CAN controller to realize the CAN message transmission and reception. Its hardware structure is shown in Figure 2.

Figure 2 Hardware structure of dual CAN controller based on CPLD


Logic Design of CPLD


CPLD has the advantages of fast speed, small size, strong driving ability, and online programming. The logic control circuit based on CPLD is suitable for completing the decoding task. This paper selects the EPM7064 chip and completes the logic selection control of the SJA1000 input signal through the software design of the decoding circuit.


The input signal of CPLD is the signal sent by DSP, which consists of high-order address A[15…13], I/O space selection pin and write/read signal. Among them, address line A13 is used as the address and data selection line of SJA1000, and address lines A14 and A15 are used as chip selection signals after decoding. Address line A13 and I/O space selection signal generate address latch signal SJA_ALE of SJA1000, and address line A13 and read/write signal generate data and address read/write signal of SJA1000. The logical relationship of input/output signal of CPLD is shown in Table 1.


Dual CAN software programming


The transceiver program of the CAN controller consists of two parts: the CAN transceiver program of the DSP and the CAN transceiver program of the SJA1000. Each CAN transceiver program mainly consists of three functions: CAN initialization program, CAN message receiving program and CAN message sending program. Since the CAN transceiver program of the DSP is relatively easy to design, you only need to set the corresponding bits in the CAN controller register to realize the transceiver of the CAN message. Therefore, this article mainly introduces the design of the CAN message transceiver program of the SJA1000.


As can be seen from Table 1, the registers of SJA1000 are mapped to the I/O space of DSP. This paper selects 0x8000 as the SJA1000 address input port and 0xA000 as the SJA1000 data input/output port. The program mainly consists of three sub-functions: SJA1000 initialization, SJA1000 receiving message and SJA1000 sending message. The flow of its receiving and sending function is shown in Figure 3.

Figure 3 SJA1000 message sending program flow chart


SJA1000 initialization


By writing 0x01 to the CAN controller SJA1000 mode register, it enters the reset mode, and then sets the SJA1000 clock frequency division register, error alarm limit register, interrupt enable register, receive code and receive mask register, bus timing register and output control register respectively, and finally writes 0x08 to the mode register to enter the normal working mode. The initialization procedure is as follows:


#define SJA1000_Data_Port portA000


ioport unsigned int portA000; //define data input/output port


#define SJA1000_Address_Port port8000


ioport unsigned int port8000; //define address input port



SJA1000_WRITE(REG_MODE, 0x01);


TempData= SJA1000_READ(REG_MODE);


//Write 0x01 to the mode register to enter reset mode


while((TempData & 0x01) != 0x01); //Wait for SJA1000 to reset



do


{


SJA1000_WRITE(REG_MODE, 0x08);


TempData= SJA1000_READ(REG_MODE);


}while ((TempData & 0x01)!=0x00); //Wait for SJA1000 to enter normal working mode


Send CAN message


The CAN message sending function is responsible for the battery management system to send messages to the vehicle controller. When sending, the data to be sent needs to be combined into a frame message according to the CAN protocol format, sent to the SJA1000 sending buffer, and then the sending command is started. The CAN sending program is as follows:


if((TempData & 0x10) != 0x10) //CAN controller is idle


{


if((TempData & 0x08) != 0x0) //The last send was successful


{


if((TempData & 0x04) == 0x04)


//CPU can write messages to the send buffer


{


…… //Configure sending message


SJA1000_WRITE(REG_ COMMAND,0x01); //Send message command


}


}


}


Receiving CAN messages


The CAN message receiving function is mainly responsible for receiving the control instructions sent by the vehicle controller to complete the control of the charging and discharging relays, fans, batteries and other devices. The CAN receiving program is as follows:


if(TempData != 0)


{


if((TempData & 0x80) == 0x80) //bus off


{


…… //Bus close processing


}


if((TempData & 0x02) == 0x02) //Data overflow


{


…… //Data overflow processing


}


if((TempData & 0x01) == 0x01) //RXFIFO contains a complete and valid message


{


…… //Read the message in the buffer


}


}


Conclusion


The CPLD-based dual CAN controller designed in this paper has been used in practical applications. The battery management system operates reliably, and the CAN message transmission and reception are stable, which is completely suitable for the use of hybrid vehicles.


References:


1. Liu Yongjiji. Research and development of nickel-hydrogen battery management system for hybrid electric vehicles[D]. Beijing: Beijing University of Aeronautics and Astronautics, 2007.03


2. Liu Heping, Wang Weijun, Jiang Yu, Deng Li. TMS320LF240x DSP C language development and application [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2006.03


3. Wu Hongjie. Nickel-hydrogen battery management technology for hybrid electric vehicles [D]. Beijing: Beijing University of Aeronautics and Astronautics, 2005,10

Reference address:Design of Dual CAN Controller for Battery Management System Based on CPLD

Previous article:Design of analog meter for digital closed-loop fiber optic gyroscope based on FPGA
Next article:Design and implementation of variable parameter RS ​​encoder IP core

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号