A distributed fire alarm control system based on CAN bus
2026-04-06 02:23:10··#1
Abstract: This paper proposes a design scheme for a distributed fire alarm control system based on CAN bus. The system uses AT89C51 microcontroller as the node controller, MCP2510 as the bus controller, and MCP2551 as the bus transceiver. The paper mainly introduces the SPI interface implementation method of AT89C51 and MCP2510, as well as the initialization method of MCP2510. Keywords: CAN fieldbus, MCP2510, centralized control unit, area control unit. With the development of economic construction, the demand for large-scale fire alarm control systems is increasing. To meet market needs, this paper designs a distributed fire alarm control system using CAN fieldbus technology. This system is flexible in structure, easy to use, and can meet the requirements of fire alarm and fire protection control of various scales, from large to small. CAN (Controller Area Network) is an effective serial communication network that supports distributed and real-time control. Due to its high performance, high reliability, and unique design, it is receiving increasing attention. Its bus specification has been formulated as an international standard by the ISO International Organization for Standardization and is recognized as one of the most promising fieldbuses. This paper mainly introduces the application of a CAN fieldbus composed of MCP2510 and MCP2551 in a distributed fire alarm control system. 1. System Composition and Working Principle Overview The network structure of the distributed fire alarm control system based on the CAN fieldbus proposed in this paper is shown in Figure 1. Each node uses an AT89C51 microcontroller as the node controller, an MCP2510 as the bus controller, and an MCP2551 as the bus transceiver. The node connected to the control console workstation is called the central unit, and the rest are area units. In the central unit, the control console workstation is essentially a PC, and the microcontroller exchanges information with the control console workstation through an external serial interface. Each area unit is distributed in a different geographical location and independently executes a complete task. In this system, an area unit can connect to various fire detectors such as smoke detectors, light detectors, and heat detectors through a specially designed detector bus. It can also control various fire-fighting equipment such as sprinkler valves and roller shutters, as well as various audible and visual alarm devices, through adapters. The devices on the detector bus are collectively referred to as front-end devices. By networking the area units using CAN communication technology, administrators can monitor the status of each unit from the central control unit. This facilitates management and monitoring, allowing them to monitor the normal operation of each area unit and detect any alarms. It also enables resource sharing and coordinated control between the area units through information exchange. Each area unit is an independent basic alarm control unit, functioning exactly as it would when used individually. It collects data from its own detectors. In case of an alarm, it activates the relevant fire-fighting equipment in its area and transmits an alarm signal to the central control unit via the CAN bus. The central control unit then determines which fire-fighting equipment under the jurisdiction of other area units needs to be activated and issues a linkage command via the CAN bus. Furthermore, because the CAN bus is message-based, nodes on the bus are plug-and-play, resulting in good system scalability. Adding or removing any node on the CAN bus other than the central control unit will not affect the other nodes. The MCP2510 in Figure 1 is an independent CAN controller chip designed by Microchip to simplify the interface application of the CAN bus [3]. It supports CAN protocol 2.0A/2.0B and has a maximum programmable baud rate of 1Mbps. The MCP2551 is a fault-tolerant high-speed CAN bus transceiver chip produced by Microchip [4]. It supports an operating rate of 1Mbps, can connect up to 112 nodes, is suitable for 12V and 24V systems, and its pin characteristics are fully compatible with the MCP2510. 2 Hardware Circuit and SPI Interface Technology Figure 2 is the hardware circuit diagram of the system nodes in this paper for CAN communication. In the schematic diagram, the bus controller MCP2510 and the bus transceiver MCP2551 are directly connected because their pins are fully compatible. In addition, considering that the system bus rate is relatively low, the slope resistor input pin RS of the MCP2551 is left floating and the minimum slope is selected. In this way, the RFI can be minimized and the circuit design can be simplified. The following section focuses on the interface technology between MCP2510 and AT89C51. [align=center] Figure 2 Hardware interface circuit for CAN communication of nodes[/align] The MCP2510 has a high-speed SPI interface (5MHz) for microcontrollers, which consists of four pins: chip select control input CS, shift pulse input SCK, serial data input SI, and output SO. The AT89C51 does not have a standard SPI interface, but it can communicate with the SPI interface using the UART interface. Figure 3 shows the timing diagram of the AT89C51's UART interface when it is working in mode 0, i.e., shift register mode [2]. The AT89C51's UART has four operating modes. In mode 0, serial data is input or output from RXD, and a shift pulse is output from TXD. Each transmission or reception consists of 8 bits of data. The baud rate is fixed at 1/12 of the clock frequency, meaning one bit cycle corresponds to one machine cycle. One machine cycle consists of 12 clock cycles, divided into 6 states (S1 to S6). Each state is further divided into two phases, P1 and P2. Therefore, the 12 clock cycles of one machine cycle can be denoted as S1P1, S1P2, S2P1, ..., S6P2. The shift pulse output from TXD is low during S3, S4, and S5 of each machine cycle, and high for the remaining time. During transmission, data is output at S6P2 of each machine cycle. The valid data time completely covers the negative half-cycle of the TXD output pulse. Clearly, the peripheral can input valid data from RXD regardless of whether it is the rising or falling edge of TXD. During reception, the S5P2 input data is received in each machine cycle. Obviously, if the peripheral outputs data on the falling edge of TXD, the microcontroller can receive valid data. Because the MCP2510's SPI interface inputs data on the rising edge of SCK and outputs data on the falling edge of SCK, TXD can be directly used as the input signal of SCK in the circuit diagram. During the read process, the MCP2510's SPI interface first receives the read command and address issued by the microcontroller. At this time, the output signal line SO is in a high-impedance state. Afterwards, when outputting data, the state of the input signal line SI can be any value. During the write process, SO is always in a high-impedance state. The start or end of a write or read process is controlled by the chip select signal CS. Based on this working mechanism of the SPI interface, in the circuit diagram, the SI and SO of the MCP2510 are connected together to form a bidirectional signal line, which is then connected to the quasi-bidirectional data line RXD of the AT89C51. Experimental results prove that this connection method between the MCP2510 and the AT89C51 is completely correct. Because the 51 series microcontrollers have always been mainstream products in the microcontroller application field, applying them to the CAN bus system can undoubtedly reduce costs and shorten the development cycle. To achieve SPI interface interaction with the MCP2510, the microcontroller's UART interface is set to mode 0, using a 12MHz crystal oscillator as the microcontroller's clock frequency. In mode 0, the baud rate is fixed at 1Mbps. With the support of the hardware circuit shown in Figure 2, the AT89C51 can interact with the MCP2510 as a regular shift register. Assembly language subroutines for writing and reading operations on the MCP2510 are omitted. It is worth noting that because the SPI data transmission order is high-order bits first, which is the reverse of the UART data transmission order, when writing the interface program between the microcontroller and the MCP2510, the control word, status word, and register address of the MCP2510 must be processed in binary-to-order. For example, the starting address of the MCP2510's receive buffer register RXB0 is 01010110B. When the microcontroller reads its contents, the address value written to the microcontroller's serial port buffer register SBUF should be 01101010B. 3. MCP2510 Initialization The initialization of the MCP2510 includes setting the programmable pin functions, bus baud rate, and receive filter and mask. The following mainly introduces the initialization of the bus baud rate and the receive filter and mask. 3.1 Baud Rate Initialization The baud rate generator contained in the MCP2510 consists of a programmable prescaler, a fixed divider by 2, and a cascaded bit timer, allowing designers to easily select any desired baud rate. In the bit timer, the MCP2510 divides one bit period sequentially into four time segments: a synchronization segment, a propagation segment, phase buffer segment 1, and phase buffer segment 2. The length of each time segment is an integer multiple of the input signal period TQ. The synchronization segment is fixed at 1TQ, while the lengths of the other three time segments are programmable. The so-called baud rate initialization is to set the values of the programmable prescaler and the bit timer for each programmable time period to meet the baud rate requirements. According to the CAN technology protocol, the communication distance is 40m when the baud rate is 1Mbps and the maximum communication distance can reach 10km when the baud rate is 5Kbps [1]. Considering that the system in this paper can be used as a fire alarm control network for a high-rise building and as a fire alarm control network for multiple warehouses and workshops within a unit, the communication distance should be more than several kilometers. However, the amount of data to be transmitted is not large, so a lower baud rate can be selected. In practical applications, the author chooses a baud rate of 8Kbps. The system in this paper selects a 12MHz crystal oscillator to provide a clock signal for the MCP2510. According to the constraint that the length of each time period in the bit timer must meet, the propagation segment register PRSEG=3, the phase buffer segment 1 register PHSEG1=4, and the phase buffer segment 2 register PHSEG2=4 are initialized; then the prescaler BRP=49 is initialized. Therefore, the total frequency division coefficient is (49+1)×2×[1+(3+1)+(4+1)+(4+1)]=1500, ultimately achieving a baud rate of 8Kbps. 3.2 Filter and Shielder Initialization The MCP2510 has a complete bus contention function and can be used in distributed systems. However, in fire alarm control systems, because the central unit is responsible for monitoring the area units, this system adopts a centralized-distributed control method. The central unit continuously circulates and queries the area units, reflecting the working status of the area units on the workbench at any time, providing staff with a basis for equipment maintenance. The MCP2510 supports standard frames, extended frames, and remote frames, with data segment lengths of 0-8 bytes. The device receives data on the CAN bus through a combination of 2 receive buffers, 6 receive filters, and 2 receive shields. Frames on the CAN bus can only be received if they meet the conditions of at least one receive filter. To explain the initialization method of filters and shields, message frames are introduced first. This system only uses standard data frames for data transmission. The standard data frame is 44 + 8n bits long. The 11-bit ID segment in this system is divided into two parts: the high 7 bits represent the logical address code of the area machine (maximum of 50 area machines are allowed to access the entire system), and the low 4 bits represent the message type code. The message frames sent by the central unit are shown in Table 1, and the message frames sent by the area machines are shown in Table 2. The 8n-bit data segment is optional. In Table 1, only the selective call linkage message contains a data segment, indicating the device number requesting linkage. In Table 2, only the request point name message does not contain a data segment; all other messages must contain at least one byte of data to represent the logical address code of the area machine. The remaining data is used to represent the detector number and device number for faults and alarms, or the area machine configuration. Table 1: Message frames sent by the central unit; Table 2: Message frames sent by the area machines. In Table 1, xx xxxx represents the logical address code of the area machine that the central unit wants to access. The messages in Table 1 are sent to the area unit, and the messages in Table 2 are sent to the central unit. Whether a message can be received depends on the filters of the MCP2510. Therefore, during initialization, the central unit writes the data in Table 2 into the filters RXF1 to RXF5 of the MCP2510 in a top-to-bottom order. After the area unit replaces the xx xxxx in Table 1 with its own logical address code, it also writes the data in Table 1 into the filters RXF1 to RXF5 of the MCP2510 in a top-to-bottom order. The unused filter RXF0 is set to all "1"s, so that it does not receive any valid messages on the bus. During initialization, on the area unit side, both receiver shields are set to all "1"s. On the central unit side, receiver shield RXM1 is set to all "1"s, while RXM0 is set to 101 1011 1010B. This indicates that, except for the four bits SID9, SID6, SID2, and SID0 of the central unit's filter RXF1, all other bits of the filter participate in information filtering. This is because these four bits correspond to the recessive bits at the transition positions of the ID code in the request naming frame. Since many area units can send request naming frames simultaneously, inter-symbol interference caused by transmission delays can potentially render the state of these bits uncertain. 4. Brief Introduction to the Communication Process The communication process of a distributed fire alarm control system is essentially a cyclical naming and querying process between the central unit and the area units. During the roll call phase, the central unit sends a broadcast roll call frame, and the regional units respond with a request roll call frame. If a request roll call frame is received from an unregistered regional unit, the central unit performs selective roll call, and the regional units respond with a configuration frame. During the query phase, the central unit repeatedly checks for self-test requests. If a self-test request is received, it selects and calls each regional unit for self-testing, and the regional units respond with a configuration frame. After the self-test ends, selective querying continues, and the regional units respond with a normal frame, a fault frame, or an alarm frame. If an alarm signal is received during the query, a selective linkage frame is sent as needed, and the regional units confirm with a normal frame. 5. Conclusion Experimental results show that because the MCP2510 has a complete fieldbus management mechanism and a microcontroller-oriented SPI interface, it simplifies the system's hardware and software design on the one hand, and frees the node controller from frequent intervention in network communication on the other, thus greatly improving the overall system performance. Compared with distributed systems using other serial communication technologies such as RS232, the distributed fire alarm control system based on the CAN bus proposed in this paper has higher security, reliability, and real-time performance, and can be used for fire alarm control in various situations. References: 1. Yang Xianhui, Fieldbus Technology and Its Applications, Beijing: Tsinghua University Press, 2000. 2. Zhang Youde, Philips 80C51 Series Microcontroller Principles and Applications Manual, Beijing: Beijing University of Aeronautics and Astronautics Press, 1992. 3. MCP2510 Independent CAN Controller with SPI™ Interface, Microchip Corporation, 2004, http://ww1.microchip.com/downloads/en/DeviceDoc/21291e_cn.pdf 4. MCP2551 High-Speed CAN Transceiver Data Sheet, DS21667, Microchip Technology, Inc.