Intelligent CAN bus star connection device and method simulating Ethernet switch
By implementing a star connection for the CAN bus using an Ethernet-like switch device, the problems of complex node configuration and insufficient communication bandwidth in CAN bus network debugging are solved, thereby improving communication efficiency and fault diagnosis capabilities.
Patent Information
- Application Number
- CN202511044052.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-10-31
AI Technical Summary
During debugging, CAN bus networks require frequent checks and verifications of node connections and configurations, and their communication bandwidth is insufficient, making it difficult to achieve efficient fault diagnosis and isolation.
An Ethernet-like switch device is used to achieve a star connection of the CAN bus through a port forwarding table. All nodes are configured as end nodes, and the port forwarding table is automatically created and updated by software to achieve point-to-point and loop-back forwarding, thereby improving communication efficiency.
It eliminates the tedious work of node configuration, increases communication bandwidth, facilitates fault diagnosis and isolation, and simplifies the network debugging process.
Smart Images

Figure CN120880833A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial fieldbus communication technology, specifically relating to an intelligent CAN bus star connection device and method that mimics an Ethernet switch. Background Technology
[0002] CAN bus, as a fieldbus technology, is widely used in industrial control due to its low protocol complexity and high communication reliability. Typically, CAN bus communication systems use a bus topology. A CAN bus communication network usually consists of two or more devices with CAN bus ports connected to a pair of twisted-pair cables (bus). CAN bus devices connected to the bus are usually called nodes. During CAN bus message frame transmission, the two wires of the twisted pair form a differential voltage, and terminating resistors need to be connected at the ends of the twisted pair to form a transmission loop. CAN bus nodes connected to the ends of the twisted pair are usually connected to terminating resistors and are called end nodes; other CAN bus nodes are usually not connected to terminating resistors and are called intermediate nodes. A CAN bus communication system network has exactly two end nodes. During the debugging of a CAN bus communication system network, when the connection position of a node changes, it is often necessary to adjust the configuration of its terminating resistor. Therefore, during debugging, it is necessary to frequently check and confirm the connection and configuration of end nodes and intermediate nodes in the CAN bus communication system network. Meanwhile, in a bus-connected CAN bus communication network, each node on the CAN bus shares the transmission bandwidth of the same transmission line. When a node sends a message frame, it needs to wait for the bus to be idle. At the same time, the CAN bus message frames sent are judged by their ID field. Message frames with lower priority will stop sending and need to wait for message frames with higher priority to be transmitted before they can be resent.
[0003] Ethernet networks typically employ a star topology, achieved through Ethernet switches, to construct network communication systems. In an Ethernet network, each network node is configured by default as an end node, similar to a CAN bus, without requiring end-node or intermediate-node configuration conversion. The Ethernet switch automatically establishes a mapping table between Ethernet nodes and Ethernet switch ports based on the transmitted IP packets and forwards packets between these ports. Once each network node is connected to the Ethernet switch, the network connection is complete.
[0004] Ethernet networks, connected via switches, allow for minimal impact on network operation from adding or disconnecting network nodes. Furthermore, Ethernet switches automatically establish and update port forwarding tables, ensuring successful packet forwarding. Establishing network communication through Ethernet switches requires almost no configuration, significantly improving the network performance of Ethernet nodes. The automatic connection and plug-and-play functionality of Ethernet switches achieve the ultimate in simplicity and convenience.
[0005] In summary, the bus-shaped connection of the CAN bus network requires nodes to be configured as end nodes or intermediate nodes. Compared with the Ethernet switch connection method, the CAN bus communication network is easy to configure, but its communication bandwidth is insufficient. It has significant shortcomings in terms of ease of use, fault isolation and location efficiency, and transmission rate. Summary of the Invention
[0006] To overcome the shortcomings of existing technologies, this invention provides an intelligent CAN bus star connection device and method that mimics an Ethernet switch. By using this Ethernet switch-like device, the configuration of terminating resistors at each node in the CAN bus network can be eliminated, as well as the need for frequent checks and confirmations of the connections and configurations of end nodes and intermediate nodes in the CAN bus communication system network during debugging. The software in the Ethernet switch-like device uses the port forwarding table to look up the received message frame ID value, enabling functions such as port number login, point-to-point switching, loopback forwarding, and one-to-many switching. Utilizing the CAN bus star network of the Ethernet switch-like device, connections can be automatically re-established when nodes change connections, facilitating rapid fault diagnosis and isolation during CAN bus network debugging through disconnection methods.
[0007] The technical solution adopted by this invention to solve its technical problem is as follows:
[0008] A smart CAN bus star connection device that mimics an Ethernet switch includes a SoC / CPU, RAM, FPGA, CAN controller, high-speed optocoupler, CAN driver, terminating resistor, and SSD.
[0009] The SoC / CPU is the processing core;
[0010] The RAM is used to allocate program storage, message frame buffers, and interconnected Ethernet packet buffers;
[0011] The FPGA is used for interface expansion;
[0012] The CAN controller provides a register access interface for the SoC / CPU and converts the CAN bus protocol;
[0013] The high-speed optocoupler is used for signal isolation;
[0014] The CAN driver is connected to the CAN controller and provides level conversion between the CAN bus twisted pair and the CAN bus controller.
[0015] The SSD is used to store the operating system, driver software, application software, and port forwarding table;
[0016] The SoC / CPU expands through an interface to read CAN bus message frames received from each port of the CAN controller, and then sends out CAN bus message frames through the transmitting port according to the port forwarding table settings.
[0017] The port forwarding table includes the following data fields: the received message frame ID value, the ID value of the target node to which it needs to be forwarded, and the port number of the target node connected to the local machine; the received message frame ID value and the ID value of the target node to which it needs to be forwarded are saved and set through the configuration file of the simulated Ethernet switch device; the ID value of the target node to which it needs to be forwarded and the port number of the target node connected to the local machine are updated in real time during operation according to the registration message frame data reported by the node at regular intervals;
[0018] Each CAN bus port is connected to a terminating resistor and configured as a CAN bus end node;
[0019] The CAN bus nodes are connected to the CAN bus star connection device of the Ethernet-like switch. All CAN bus nodes are uniformly configured as end nodes, and there is no need to configure or check the end nodes and intermediate nodes. Users can control the transmission path of message frames between nodes by configuring the port forwarding table of the Ethernet-like switch device. CAN bus node message frames are forwarded through the Ethernet-like switch, and each CAN bus node can enjoy the bus transmission bandwidth exclusively.
[0020] Preferably, in the simulated Ethernet switch device, a port forwarding table is set; the software in the simulated Ethernet switch device scans the CAN bus port, and when a CAN bus message frame is received, it searches for the ID value of the CAN bus message frame in the received message frame ID value field of the port forwarding table. If a match is found, the target port of that row is retrieved from the port forwarding table, and the CAN bus message frame is sent to realize a CAN bus message frame exchange operation.
[0021] Preferably, the resistance of the terminating resistor is 120Ω.
[0022] Preferably, the CAN controller uses the SJA1000 and its compatible products.
[0023] Preferably, the high-speed optocoupler uses 6N137 and compatible products.
[0024] Preferably, the CAN driver samples the 82C250 and compatible products.
[0025] A method for intelligent CAN bus star connection mimicking an Ethernet switch, with the following specific steps:
[0026] Step 1: Configure all CAN bus devices as traditional end nodes to achieve unified configuration;
[0027] Step 2: According to the communication protocol, the CAN bus node periodically sends source address and destination address message frames;
[0028] Step 3: Based on the communication protocol, extract the source address and destination address of the port using the simulated Ethernet switch to establish and update the port forwarding table;
[0029] Step 4: When the CAN bus message frame is received by the simulated Ethernet switch, the message frame is sent from the target port according to the port forwarding table rules;
[0030] Step 5: Repeat steps 2 to 4 to complete the star connection communication of the CAN bus devices.
[0031] Preferably, in the simulated Ethernet switch, the intelligent switching workflow is as follows:
[0032] When the software starts, all CAN bus ports are initialized;
[0033] Then continuously poll each CAN bus port;
[0034] When a registration message frame is received from a CAN bus node, the characteristic ID information is extracted from its DATA field. The ID value of the target node to be forwarded is searched in the port forwarding table. If it matches the ID information, the value of the port number of the target node connected to the local machine in that record is updated.
[0035] When other message frames are received from a CAN bus node, the characteristic ID information is extracted from its DATA field. The received message frame ID value is then searched in the port forwarding table. If it matches the ID information, the port number of the target node connected to the local machine is taken from that record, and the received message frame is forwarded from the found port number.
[0036] The beneficial effects of this invention are as follows:
[0037] In this invention, each CAN bus port of the Ethernet-like switch device is connected to a terminating resistor and configured as a CAN bus end node. This eliminates the need to configure terminating resistors for each node in the CAN bus network and to frequently check and confirm the connection and configuration of end nodes and intermediate nodes in the CAN bus communication system network during debugging.
[0038] The port forwarding table of this invention's simulated Ethernet switch device includes the received message frame ID value, the ID value of the target node to which the message needs to be forwarded, and the port number of the target node connected to the local machine. On the simulated Ethernet switch, each time a CAN bus message frame is received, the value of the ID field in the message frame is parsed, and the received message frame ID value can be looked up in the port forwarding table, realizing functions such as "port number login", "point-to-point" switching, "loopback" forwarding, and "one-to-many" switching.
[0039] This invention disconnects any CAN bus node in the network, and the system can automatically rebuild the star connection, facilitating rapid fault diagnosis, isolation, and location during CAN bus network debugging by using the "disconnection" method. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the device composition of the present invention;
[0041] Figure 2 This is a schematic diagram of the method of the present invention;
[0042] Figure 3 This is a flowchart of the intelligent switching process of the present invention. Detailed Implementation
[0043] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0044] This invention presents a method and apparatus for star-connection of intelligent CAN bus ports, mimicking an Ethernet switch. Based on the Ethernet switch-like device, a star-connected CAN bus network can be implemented, offering simple and flexible connections, improving communication efficiency between nodes in the CAN bus network, and facilitating fault isolation and location.
[0045] This invention provides a CAN bus star connection method using an Ethernet switch-like architecture. Through this Ethernet switch-like device, all CAN bus nodes in the CAN bus communication network are configured as end nodes (with terminating resistors, typically 120Ω, connected across the twisted pair). CAN bus nodes can be connected to the Ethernet switch via connectors, just like Ethernet devices connect to an Ethernet switch, thus achieving a star connection in the CAN bus network. This eliminates the need for configuring node types and frequently checking and confirming the connections and configurations of end nodes and intermediate nodes in the CAN bus communication system network during debugging. The Ethernet switch-like software and protocols automatically establish communication connections between CAN bus node devices, improving transmission bandwidth.
[0046] To achieve this objective, the present invention provides an Ethernet-like switch device with multiple CAN bus ports. The SoC (System on Chip) or CPU (Central Processing Unit) is the processing core; RAM (Random Access Memory) is used to allocate program storage, message frame buffers, interconnected Ethernet packet buffers, etc.; FPGA (Field-Programmable Gate Array) is used for interface expansion; the CAN controller (commonly SJA1000 and compatible products) provides register access interfaces for the SoC / CPU and converts the CAN bus protocol; a high-speed optocoupler (commonly 6N137 and compatible products) is used for signal isolation; the CAN driver (commonly 82C250 and compatible products) is connected to the CAN controller, providing level conversion between the CAN bus twisted pair and the CAN bus controller; and the SSD (Solid State Drive) is used to store the operating system, driver software, application software, and port forwarding table. The SoC / CPU expands through the interface, reads the CAN bus message frames received from each port of the CAN controller, and then sends out the CAN bus message frames through the transmitting port according to the port forwarding table settings.
[0047] This invention provides an Ethernet-like switch device with multiple CAN bus ports, comprising the following hardware components: SoC / CPU, RAM, FPGA, CAN controller, high-speed optocoupler, CAN driver, terminating resistor, SSD, etc. CAN bus message frame port switching is implemented based on port forwarding table configuration parameters.
[0048] The port forwarding table contains the following data fields: the received message frame ID, the ID of the target node to which the message is to be forwarded, and the port number on which the target node is connected locally. The received message frame ID and the ID of the target node to which the message is to be forwarded are stored and configured in the configuration file of the Ethernet-like switch device. The ID of the target node to which the message is to be forwarded and the port number on which the target node is connected locally are updated in real time based on the registration message frame data periodically reported by the nodes.
[0049] This invention provides an Ethernet-like switch device with multiple CAN bus ports, each of which is connected to a terminating resistor and configured as a CAN bus end node. Therefore, all CAN bus nodes in the CAN bus communication network are configured as end nodes. This eliminates the need for frequent checks and verifications of the connection and configuration of end nodes and intermediate nodes in a bus-connected CAN bus network.
[0050] The CAN bus nodes are connected to the CAN bus star topology of the emulated Ethernet switch. All CAN bus nodes are uniformly configured as end nodes, eliminating the need for end node and intermediate node configuration and checks. Users can control the transmission path of message frames between nodes by configuring the port forwarding table of the emulated Ethernet switch. CAN bus node message frames are forwarded through the emulated Ethernet switch, and each CAN bus node can exclusively enjoy the bus transmission bandwidth.
[0051] Using an Ethernet-like switch device to connect the CAN bus communication network in a star topology makes it easier to isolate and locate faults when a CAN bus network failure occurs.
[0052] In the simulated Ethernet switch device, a port forwarding table is configured. The software in the simulated Ethernet switch device scans the CAN bus ports. When a CAN bus message frame is received, the ID value of the CAN bus message frame is searched in the port forwarding table. If a match is found, the target port for that row is retrieved from the port forwarding table. This CAN bus message frame is then sent. This completes one CAN bus message frame exchange operation.
[0053] To achieve the above objectives, a method for forming a network system by connecting CAN bus devices in a star topology as Ethernet devices is provided, with the following specific steps:
[0054] S1. Configure all CAN bus devices as traditional end nodes to achieve unified configuration;
[0055] S2. According to the communication protocol, the CAN bus node periodically sends source address and destination address message frames;
[0056] S3. Based on the communication protocol, the source address and destination address of the port are extracted by the simulated Ethernet switch to establish and update the port forwarding table;
[0057] S4. When the CAN bus message frame is received by the simulated Ethernet switch, the message frame is sent from the target port according to the port forwarding table rules;
[0058] S5. Repeat S2-S4 to complete the star connection communication of the CAN bus devices.
[0059] The intelligent switching workflow in a simulated Ethernet switch is as follows: Upon software startup, all CAN bus ports are initialized. Then, each CAN bus port is continuously polled. When a registration message frame from a CAN bus node is received (based on the value of its ID field), the characteristic ID information is extracted from its DATA field. The ID value of the target node to be forwarded is searched in the port forwarding table. If a match is found, the port number of the target node connected to the local machine in that record is updated. When other message frames from CAN bus nodes are received, the characteristic ID information is extracted from their DATA field. The received message frame ID value is searched in the port forwarding table. If a match is found, the port number of the target node connected to the local machine in that record is retrieved, and the received message frame is forwarded from that port number.
[0060] Example:
[0061] An Ethernet-like switch device features six independent CAN bus controllers and CAN bus drivers, forming six ports for CAN bus message frame "exchange". The CAN bus controllers are connected to the SoC / CPU expansion bus via an FPGA, and each CAN bus driver is connected to a matching resistor (120Ω). Thus, each port can connect to one CAN bus node, which is also connected to a matching resistor (120Ω), configuring it as a bus-shaped CAN bus connection endpoint. In the intelligent CAN bus star connection of the Ethernet-like switch, all CAN bus nodes are bus-shaped CAN bus connection endpoints, uniformly configured, allowing nodes in the CAN bus network to connect to any port of the Ethernet-like switch.
[0062] This invention implements a star-connected CAN bus network through a CAN bus star connection device that mimics an Ethernet switch. Through this Ethernet switch-like device, the exchange and forwarding of CAN bus message frames can achieve various forwarding functions such as self-sending and self-receiving by the local node, one-to-one forwarding, and one-to-many forwarding.
[0063] like Figure 1As shown, in the first preferred embodiment of the present invention, an Ethernet-like switch device comprises: a SoC / CPU, RAM, an FPGA, a CAN controller, a high-speed optocoupler, a CAN driver, a terminating resistor, and an SSD. The main components of the Ethernet-like switch device are selected as follows: the SoC / CPU is a Loongson 2K1000 (LS2K1000LA) SoC, the RAM is configured to be 2GB, the CAN controller is an SJA1000, the high-speed optocoupler is a 6N137, the CAN driver is an 82C250, and the SSD capacity is 64GB. The interface is expanded by connecting the FPGA to the Loongson 2K1000's LocalBUS bus, enabling 6 channels compatible with CAN 2.0A / CAN 2.0B protocols.
[0064] like Figure 2 As shown, this invention provides a CAN bus star connection method based on an Ethernet switch-like CAN bus star connection device, realizing a star-connected CAN bus network. In this star connection method, all CAN bus nodes are configured as end nodes, which can be connected to any port of the Ethernet switch-like device. This makes the CAN bus network connection simple and flexible, improves the communication efficiency between nodes in the CAN bus network, and facilitates fault isolation and location.
[0065] In this invention, the software of an Ethernet-like switch device is developed based on the LoongOS operating system of the Loongson open-source community, and the CAN bus message frame exchange is implemented by the port forwarding table configuration parameters.
[0066] The port forwarding table contains the following data fields: the received message frame ID, the ID of the target node to which the message is to be forwarded, and the port number on which the target node is connected locally. The received message frame ID and the ID of the target node to which the message is to be forwarded are configured through the configuration file of the Ethernet-like switch device. The ID of the target node to which the message is to be forwarded and the port number on which the target node is connected locally are updated in real-time after connection is established, based on the registration message frame data periodically reported by the node.
[0067] This invention discloses an Ethernet-like switch device in which the mapping between the ID value of the target node to be forwarded and the port number of the target node connected to the local machine is dynamically updated in its port forwarding table. During system operation, CAN bus nodes can change their connected ports at any time without requiring manual updates to configuration parameters. Each CAN bus node periodically sends a CAN bus reporting message frame. The ID field of this message frame is set to a fixed value, and the first four bytes of the DATA field store the node's ID value. Each time the Ethernet-like switch receives such a message frame, it parses the node's ID value from the message frame, matches it against the ID value field of the target node to be forwarded to in the port forwarding table, and if a match is found, updates the value of the port number field of the target node connected to the local machine in that row.
[0068] This invention discloses an Ethernet-like switch device that scans CAN bus ports. Upon receiving a CAN bus message frame, the device determines the destination port based on the message frame's ID value. The Ethernet-like switch device software searches for the received message frame's ID value in the port forwarding table. If a match is found, the device retrieves the port number of the target node connected to it and sends the received message frame to that port. When the retrieved port number of the target node connected to it matches the port number of the received message frame, the Ethernet-like switch device returns the received message frame to the original sending CAN bus node, implementing a loopback forwarding mechanism. During matching, each row of the port forwarding table is traversed. If only one row is successfully matched in the port forwarding table, the Ethernet-like switch device forwards the received message frame to one port number, achieving point-to-point switching. If multiple rows are matched in the port forwarding table, and the target nodes are connected to different ports, the Ethernet-like switch device forwards the received message frame to multiple port numbers, achieving one-to-many switching. If multiple rows are matched in the port forwarding table, and the target node has duplicate port numbers connected to the local machine, the emulated Ethernet switch device will not repeatedly forward the received message frames on the same port to avoid bandwidth consumption.
Claims
1. A smart CAN bus star connection device mimicking an Ethernet switch, characterized in that, This includes SoC / CPU, RAM, FPGA, CAN controller, high-speed optocoupler, CAN driver, terminating resistor, and SSD; The SoC / CPU is the processing core; The RAM is used to allocate program storage, message frame buffers, and interconnected Ethernet packet buffers; The FPGA is used for interface expansion; The CAN controller provides a register access interface for the SoC / CPU and converts the CAN bus protocol; The high-speed optocoupler is used for signal isolation; The CAN driver is connected to the CAN controller and provides level conversion between the CAN bus twisted pair and the CAN bus controller. The SSD is used to store the operating system, driver software, application software, and port forwarding table; The SoC / CPU expands through an interface to read CAN bus message frames received from each port of the CAN controller, and then sends out CAN bus message frames through the transmitting port according to the port forwarding table settings. The port forwarding table includes the following data fields: the received message frame ID value, the ID value of the target node to which it needs to be forwarded, and the port number of the target node connected to the local machine; the received message frame ID value and the ID value of the target node to which it needs to be forwarded are saved and set through the configuration file of the simulated Ethernet switch device; the ID value of the target node to which it needs to be forwarded and the port number of the target node connected to the local machine are updated in real time during operation according to the registration message frame data reported by the node at regular intervals; Each CAN bus port is connected to a terminating resistor and configured as a CAN bus end node; The CAN bus nodes are connected to the CAN bus star connection device of the simulated Ethernet switch. All CAN bus nodes are uniformly configured as end nodes, and there is no need to configure or check the end nodes and intermediate nodes. Users can control the transmission path of message frames between nodes by configuring the port forwarding table of the simulated Ethernet switch device. CAN bus node message frames are forwarded through the simulated Ethernet switch, and each CAN bus node can enjoy the bus transmission bandwidth exclusively.
2. The intelligent CAN bus star connection device simulating an Ethernet switch according to claim 1, characterized in that, In the simulated Ethernet switch device, a port forwarding table is set up. The software in the simulated Ethernet switch device scans the CAN bus port. When a CAN bus message frame is received, the ID value of the CAN bus message frame is searched in the received message frame ID value field of the port forwarding table. If a match is found, the target port of that row is retrieved from the port forwarding table, and the CAN bus message frame is sent to complete a CAN bus message frame exchange operation.
3. The intelligent CAN bus star connection device simulating an Ethernet switch according to claim 2, characterized in that, The terminating resistor has a resistance of 120Ω.
4. The intelligent CAN bus star connection device simulating an Ethernet switch according to claim 3, characterized in that, The CAN controller uses SJA1000 and its compatible products.
5. The intelligent CAN bus star connection device for an Ethernet-like switch according to claim 4, characterized in that, The high-speed optocoupler uses 6N137 and its compatible products.
6. The intelligent CAN bus star connection device for an Ethernet-like switch according to claim 5, characterized in that, The CAN driver samples the 82C250 and its compatible products.
7. A connection method for the intelligent CAN bus star connection device of the Ethernet-like switch as described in claim 1, characterized in that, The specific steps are as follows: Step 1: Configure all CAN bus devices as traditional end nodes to achieve unified configuration; Step 2: According to the communication protocol, the CAN bus node periodically sends source address and destination address message frames; Step 3: Based on the communication protocol, extract the source address and destination address of the port using the simulated Ethernet switch to establish and update the port forwarding table; Step 4: When the CAN bus message frame is received by the simulated Ethernet switch, the message frame is sent from the target port according to the port forwarding table rules; Step 5: Repeat steps 2 to 4 to complete the star connection communication of the CAN bus devices.
8. The connection method according to claim 7, characterized in that, The intelligent switching workflow in the simulated Ethernet switch is as follows: When the software starts, all CAN bus ports are initialized; Then continuously poll each CAN bus port; When a registration message frame is received from a CAN bus node, the characteristic ID information is extracted from its DATA field. The ID value of the target node to be forwarded is searched in the port forwarding table. If it matches the ID information, the value of the port number of the target node connected to the local machine in the record is updated. When other message frames are received from a CAN bus node, the characteristic ID information is extracted from its DATA field. The received message frame ID value is then searched in the port forwarding table. If it matches the ID information, the port number of the target node connected to the local machine is taken from that record, and the received message frame is forwarded from the found port number.