CAN network communication design for heating network field controller
2026-04-06 05:46:13··#1
Abstract: This paper focuses on the application of CAN bus in a heating network monitoring system, designs a DSP-based field controller hardware system, formulates a user-level communication protocol, and details the hardware and software of the CAN network communication part. Keywords: Network communication; CAN; Field controller; DSP; Heating network monitoring Introduction Currently, many cities in northern China have already undertaken or are about to undertake heating network renovation projects, transforming traditional decentralized heating into centralized heating. Due to the numerous advantages of CAN bus compared to other fieldbus technologies, its application in industry is becoming increasingly widespread. This paper develops a field control and communication subsystem for a heating network monitoring system based on this bus technology, which can safely and reliably realize field data acquisition, closed-loop control, and data transmission. Due to space limitations, this paper focuses on the design and implementation of the CAN network communication part. System Structure and Hardware CompositionSystem Structure The heating network monitoring system mainly consists of a host computer and field controllers, and the overall structure is shown in Figure 1. The heating network monitoring system monitors and controls the heating network based on primary equipment (sensors, transmitters, and various actuators). It ensures the safe, reliable, efficient, and stable operation of the heating network by adjusting the water supply flow, temperature, and pressure. Based on these requirements, this system, while ensuring reliable operation and reducing costs, considers factors such as versatility, real-time performance, and scalability. It adopts a system structure mainly composed of a host computer system and field controllers. The system operation process is as follows: The host computer first initializes the CAN network card, sets the network card working mode, receive code, receive mask, and baud rate, and then enters the running state, communicating with the field controllers under appropriate conditions. The field controllers mainly complete the functions of field data acquisition and processing, and control of field equipment, communicating with the host computer via polling or interrupt methods. Figure 1 shows the overall structure of the heating network monitoring system hardware system . The CAN network topology adopts a bus structure, which is simple, low-cost, and highly reliable. Information transmission uses the CAN communication protocol, and the communication medium is twisted-pair cable. Figure 2. Block Diagram of the Field Controller and Host Computer The host computer , an industrial control computer, is responsible for managing the entire system. It communicates with the field controller via a CAN network card and connects to the factory or company's computer network via a local area network or public telephone exchange to achieve information sharing. The host computer has functions such as configuration, data acquisition, parameter setting, remote control, process display, data storage, trend display, report printing, and communication. Figure 3. CAN Network Communication Interface Unit Circuit. The CAN network card is the functional module responsible for data exchange between the CAN bus and the host computer. Data exchange occurs in two directions on the CAN network card: data exchange between the CAN network card and the host computer (implemented through dual-port RAM) and data exchange between the CAN network card and the CAN bus (implemented by the microprocessor accessing the CAN controller's receive and transmit buffers). The CAN controller on the CAN network card uses the PHILIPS SJA1000 chip. Figure 4. General Timer Periodic Interrupt Service Routine for the Field Controller The block diagram of the field controller is shown in Figure 2. This field controller features 14 analog input ports, 2 analog output ports, 4 digital input ports, 4 digital output ports, as well as clock, data storage, LCD, network communication, and alarm output interfaces. The system uses the TI TMS320LF2407A DSP chip with a 10-bit ADC and CAN controller as its CPU. The network communication interface unit is the control circuit used for reading and writing to the CAN bus. When data needs to be sent, the CPU hands the data to the network interface unit circuit, which performs data format conversion, serial-to-parallel conversion, and signal form conversion, and then sends the data to the CAN bus according to the CAN protocol signal format. When there is data on the CAN bus, it is responsible for reading the data from the CAN bus. First, it uses a frame filtering function to determine whether to receive the frame. If received, it passes the data to the CPU through the reverse process of sending. Table 1 shows the identifier allocation scheme. The network communication interface unit mainly consists of the CAN controller and the CAN transceiver PCA82C250 within the TMS320LF2407A chip. The CAN controller is responsible for converting the data format and undertaking the control tasks of network communication. The PCA82C250 CAN transceiver serves as the interface between the CAN controller and the physical bus, responsible for signal level and format conversion. It provides differential transmission capability to the bus and differential reception capability to the CAN controller. To prevent interference on the CAN bus from entering the board, this system uses the 6N137 opto-isolator to achieve bidirectional isolation between transmission and reception. The specific circuit of the network communication interface unit is shown in Figure 3. CAN Communication Software Design and Implementation: CAN follows the OSI model. According to the OSI baseline model, the CAN structure is divided into two layers: the data link layer and the physical layer. However, in practical applications, even for simple CAN-based distributed systems, the physical and data link layers alone are far from sufficient. For example, it cannot handle data blocks longer than 8 bytes, data transmission processes with handshake protocols, identifier allocation, and functions related to network management nodes. Therefore, an additional layer is needed to support the application process, namely the application layer. This layer corresponds to the upper five layers in the OSI baseline model, mainly performing the work of the network and transport layers, providing an interface to separate the communication module from the specific application module. For heating network monitoring systems, the application layer protocol needs to be specifically negotiated and formulated by both communicating parties. CAN Communication Application Layer Protocol Communication with the host computer is one of the most critical parts of the field controller software design. For heating network monitoring systems, CAN fieldbus network technology is used, and a CAN application layer protocol has been formulated. The main tasks completed by the application layer include: identifier allocation, processing of multi-message data packets, message sending and receiving, etc. Identifier Allocation Scheme : The TMS320LF2407A supports the CAN 2.0B protocol. The information frames used in this system communication adopt extended frames with 29-bit identifiers. The identifier allocation scheme is shown in Table 1. DIR indicates direction. When DIR=0, it indicates that the master station is sending data to the slave station; when DIR=1, it indicates that the slave station is sending data to the master station. TYPE is the message frame type. When TYPE.2=0, it indicates point-to-point transmission; when TYPE.2=1, it indicates broadcast transmission. When TYPE.~TYPE.0Xb, it represents a single-frame message; when TYPE.1~TYPE.0=11b, it represents a non-terminated multi-frame message; when TYPE.1~TYPE.0=10b, it represents a terminated multi-frame message. Additionally, there are seven bits each for the destination address and source address, and eight bits for the command symbol. The command symbol is used to identify the control commands from the host computer to the field controller, or the upload commands from the field controller to the host computer. Message Processing This design specifies the following for message processing in CAN communication: Single Message: A single message is determined by the data type TYPE.1 in the identifier. When it is 0, it represents a single message. In this case, the data to be transmitted does not exceed 8 bytes, and the data segment contains the actual data to be transmitted. First and middle frames of a multi-message: The first and middle frames of a multi-message are determined by TYPE.1 to TYPE.0. When it is 11b, it indicates a non-ending multi-message, which is the first and middle frames of the multi-message. In this case, the data to be transmitted exceeds 8 bytes. The first byte in the data segment is the index, and the following 7 bytes are the transmitted data. Last frame of a multi-message: The last frame of a multi-message is determined by TYPE.1 to TYPE.0. When it is 10b, it indicates a ending multi-message, which is the last frame of the multi-message. In this case, the data length in this frame is specified to be 2 bytes. The first byte in the data segment is the index, and the second byte is the total length of the data to be transmitted, in bytes. CAN Communication Initialization: CAN communication initialization mainly involves setting the CAN communication parameters, including configuring the bit timer and initializing the mailbox. Registers that need to be initialized include: Bit Configuration Register 2, Bit Configuration Register 1, Identifier Register, Control Register, and Local Mask Register. It is important to note that bit timers can only be configured when the change configuration enable bit in the global status register is high; the identifier register, control register, and data field can only be configured when the change configuration request bit in the master controller is 1, i.e., the CAN controller is in reset mode. When accessing the bit configuration register, since its content determines the baud rate, the initialization word of the bit configuration register must be set according to the crystal oscillator frequency of each CAN controller in the system. Data Transmission The transmission of information from the CAN controller to the CAN bus is automatically completed by the CAN controller. The transmitting program only needs to send the information frame to be transmitted to the relevant CAN register and start the transmission command. Data transmission uses a general-purpose timer periodic interrupt to periodically send the collected data to the host computer for data storage and user retrieval. Since the collected data exceeds 8 bytes, the data packets need to be fragmented to construct the message. The general-purpose timer periodic interrupt service routine is shown in Figure 4. Data Reception The transmission of information from the CAN bus to the CAN receive mailbox is automatically completed by the CAN controller, using a mailbox interrupt. The received data is read, decoded, and the corresponding flag bits are set in the interrupt service routine. The main program loop checks the flag bit. When a flag bit is detected as set, the corresponding processing routine is entered, and the flag bit is cleared. Conclusion The application layer protocol is crucial for CAN network applications. Therefore, the focus of this system is on the communication between the field controller and the host computer, utilizing CAN fieldbus network technology to develop a user-layer communication protocol. Furthermore, this system has completed its laboratory debugging phase, and the communication section functions correctly. The CAN communication design presented in this paper has strong versatility, and its results can be applied to many data acquisition scenarios.