Implementation method of Ethernet-to-CAN (Controller Area Network) device

Through the Ethernet to CAN device, the design of the Ethernet interface and CAN interface is solved, and the problem that traditional master controllers cannot expand the CAN network and remote shared control is realized, flexible expansion and remote control of the CAN network are improved, and the CAN bus is improved. Application scenarios and efficiency.

CN119254561AInactive Publication Date: 2025-01-03BEIJING INST OF COMP TECH & APPL
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411256281.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2025-01-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the early stage of design, traditional master computers must fix the number of CAN networks and cannot be expanded later. Moreover, the CAN bus is prone to command loss or errors during long-distance transmission, which is difficult to meet the needs of remote sharing control.

Method used

Design an Ethernet to CAN device, including an Ethernet CAN conversion driver and device, connect to a switch or router through an Ethernet interface, and use an Ethernet to CAN driver to realize the expansion and remote sharing control of the CAN network, including the CAN driver interface layer and communication The management layer, network communication layer and CAN communication layer realize compatibility and data management of PCIe-CAN driver interface.

Benefits of technology

It realizes arbitrary expansion and remote sharing control of CAN network, expands the application scenarios and methods of CAN bus, and solves the problems of fixed number of networks and low long-distance transmission efficiency in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254561A_ABST
    Figure CN119254561A_ABST
Patent Text Reader

Abstract

The invention relates to a realization method of an Ethernet-to-CAN device, and belongs to the technical field of networks. The method comprises the following steps of: designing an Ethernet CAN (Controller Area Network) conversion drive and an Ethernet-to-CAN device operated on a main control computer; wherein one end of the Ethernet to CAN device is an Ethernet interface, and the other end of the Ethernet to CAN device is a CAN interface; the main control computer is connected to a switch or a router through an Ethernet interface, one end of the Ethernet-to-CAN device is connected to the switch or the router through an Ethernet interface, the other end of the Ethernet-to-CAN device is connected to a CAN network through a CAN interface, and a plurality of controlled nodes exist in the CAN network; the Ethernet to CAN driver comprises a CAN driver interface layer and a communication management layer; the Ethernet to CAN device comprises a network communication layer and a CAN communication layer. According to the invention, the CAN network can be expanded at will, and meanwhile, the requirement of remotely sharing and controlling the controlled nodes of the CAN network through the access of the router is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of network technology, and in particular relates to a method for realizing an Ethernet to CAN device. Background Art

[0002] Fieldbus CAN (Controller Area Network) has been widely used in industrial control, robotics, medical equipment, sensors and other fields due to its high performance, high reliability and unique design. Figure 1 As shown, it includes a master control machine and multiple controlled nodes. The master control machine is provided with a CAN interface. The master control machine controls all controlled nodes in the control system through the CAN bus connected to the CAN interface. Traditional master control machines generally use PCI or PCIe bus to expand peripherals. PCIe is a high-speed serial computer expansion bus standard that uses a full-duplex point-to-point working mode. Generally, when designing the master control machine, it is necessary to plan the expansion of peripherals. After the pice slot design of the expansion peripherals is completed, it is not convenient to expand more PCIe peripherals. In this way, for a control system with multiple CAN networks, the number of networks must be determined at the beginning of the design, and it is impossible to arbitrarily expand more CAN networks according to changes in usage scenarios or increased demand in the later stage. At the same time, as a field bus, the CAN bus supports a transmission distance of 40m at a rate of 1M. For long-distance transmission requirements, it is necessary to reduce the transmission speed, otherwise the probability of command loss or error will increase. It is difficult to meet the remote shared control requirements of controlled nodes. Summary of the invention

[0003] 1. Technical issues to be resolved

[0004] The technical problem to be solved by the present invention is how to provide an implementation method of an Ethernet to CAN device to solve the problem of the need for the host control machine to arbitrarily expand the CAN network and remote shared control during use.

[0005] (II) Technical solution

[0006] In order to solve the above technical problems, the present invention proposes an implementation method of an Ethernet to CAN device, which includes: an Ethernet to CAN conversion driver design running on a host control machine and an Ethernet to CAN device design; wherein one end of the Ethernet to CAN device is an Ethernet interface and the other end is a CAN interface; the host control machine is connected to a switch or a router through the Ethernet interface, one end of the Ethernet to CAN device is connected to the switch or the router through the Ethernet interface, and the other end is connected to a CAN network through the CAN interface, and there are multiple controlled nodes in the CAN network;

[0007] The Ethernet to CAN driver includes: CAN driver interface layer and communication management layer; the CAN driver interface layer is responsible for providing the application layer with various function interfaces of CAN communication. The application layer uses various function interfaces to communicate and control the controlled nodes to achieve compatibility with the PCIe-CAN driver interface; the communication management layer is responsible for network data transmission and reception and data management;

[0008] The Ethernet to CAN device includes: a network communication layer and a CAN communication layer; the network communication layer is responsible for network interface communication related operations in the device; the CAN communication layer is responsible for CAN interface communication related operations in the device.

[0009] (III) Beneficial effects

[0010] The present invention proposes a method for realizing an Ethernet to CAN device. The technical solution proposed by the present invention provides an Ethernet to CAN device, which can be used to arbitrarily expand the CAN network and realize the need for remote shared control of controlled nodes of the CAN network through router access. The application scenarios and methods of the CAN bus are expanded. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 It is an application solution for the traditional fieldbus CAN;

[0012] Figure 2 This is an application scenario example of the present invention;

[0013] Figure 3 It is the software hierarchy diagram of the present invention;

[0014] Figure 4 It is a sending sequence diagram of the present invention;

[0015] Figure 5 This is a receiving sequence diagram of the present invention. DETAILED DESCRIPTION

[0016] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0017] The present invention proposes a method for realizing an Ethernet to CAN device, wherein the Ethernet to CAN device used is relatively independent of a main control computer, and the method comprises: designing an Ethernet to CAN conversion driver running on the main control computer and designing an Ethernet to CAN device, wherein one end of the Ethernet to CAN device is an Ethernet interface, and the other end is a CAN interface.

[0018] Figure 2This is a usage scenario of the device. The main control machine is connected to a switch or router through an Ethernet interface. One end of the Ethernet to CAN device is connected to the switch or router through an Ethernet interface, and the other end is connected to the CAN network through a CAN interface. There are multiple controlled nodes in the CAN network. The main control machine communicates and controls the controlled nodes in the CAN network through the Ethernet to CAN device.

[0019] Ethernet to CAN driver

[0020] The software hierarchy and data flow of the present invention are as follows Figure 3 The Ethernet to CAN driver includes: CAN driver interface layer and communication management layer.

[0021] The CAN driver interface layer is responsible for providing the application layer with various function interfaces for CAN communication. The application layer uses various function interfaces to communicate and control the controlled nodes. It shields the Ethernet characteristics and achieves compatibility with the traditional PCIe-CAN driver interface, including:

[0022] 1) CAN configuration interface function: Provides the application layer with a configuration interface for the CAN channel to which the Ethernet-to-CAN device is connected, including setting the acceptance code, shielding code, baud rate, shielding mode, etc. After the application layer completes the configuration of the CAN channel using the CAN configuration interface function, the Ethernet-to-CAN device will start in working mode.

[0023] 2) CAN data transmission interface function: The application layer sends the CAN message to be sent to the Ethernet to CAN device through this interface function. The content sent includes CAN frame and frame number, where each frame contains: frame ID, frame type (standard frame, extended frame, data frame, remote frame), frame data length. The CAN data transmission interface function is responsible for converting one or more CAN message frames into a network message, and then passing it to the communication management layer for sending the network message.

[0024] 3) CAN data receiving interface function: obtains the CAN data sent by the controlled node from the CAN receiving cache in the communication management layer. The application layer specifies the waiting time, number of frames and application layer data cache address for receiving CAN frames through this interface function. If there is data in the CAN receiving cache within the specified receiving time, the data is copied to the application layer data cache address specified by the user, and the function returns OK. Otherwise, it means that no CAN message is received within the specified time, and the function returns ERROR.

[0025] 4) CAN status query interface function: The application layer queries the status of the CAN interface on the Ethernet-to-CAN device, including: working mode, error count, self-test results, and statistical counts of received and sent data. This interface function composes the information to be queried into an Ethernet message and passes it to the communication management layer for sending network messages.

[0026] The communication management layer is responsible for network data transmission and reception and data management. The specific module units include:

[0027] 1) Communication management layer initialization: Initialize the network interface, including creating a socket, binding a port number, adding the local IP to the specified multicast group for multicast reception, setting the socket's IP_MULTICAST_LOOP and IP_MULTICAST_IF properties, etc.; creating a CAN receive buffer for caching received CAN frames; starting the CAN message reception task and auxiliary management tasks;

[0028] 2) Ethernet transmission: The CAN message and CAN channel configuration information transmitted through the CAN driver interface layer are sent to the Ethernet to CAN device through the Ethernet interface;

[0029] 3) CAN message receiving task: Create a network receiving task, which is specifically used to wait for the Ethernet message sent by the Ethernet to CAN device through the network interface, parse it to obtain the CAN frame, and put the received CAN frame into the CAN receiving buffer;

[0030] 4) Auxiliary management tasks: used to receive CAN data transmission frame number feedback, CAN configuration completion result feedback, and CAN status query feedback from the Ethernet to CAN device, and synchronize the CAN configuration interface function, CAN data transmission interface function, and CAN status query interface function in the form of semaphores;

[0031] Since the transmission rate of Ethernet is much higher than that of CAN, the CAN driver interface layer also needs to limit the current of the transmitted data. The present invention uses the counting signal method to control it: create a CAN transmission counting signal with N counting values ​​in the CAN configuration interface function, obtain the transmission counting signal in the CAN data transmission interface function, and obtain a counting signal for each CAN frame sent; if the acquisition fails, it means that there are N CAN frames that have not been sent on the Ethernet to CAN device, and it is necessary to wait for a certain period of time before sending. In the auxiliary management task, when the feedback of CAN transmission data is received, the number of CAN frames sent this time is analyzed, and a CAN transmission counting signal is released for each CAN frame sent after it is completed.

[0032] Ethernet to CAN Device

[0033] The Ethernet to CAN device includes: a network communication layer and a CAN communication layer.

[0034] The network communication layer is responsible for network interface communication related operations in this device, including the following units:

[0035] 1) Network sending interface: completes the operation of the conversion device sending network messages to the main control machine through the network interface.

[0036] 2) Network initialization: Complete the initialization of the Ethernet interface on the Ethernet to CAN device and start the network reception processing service.

[0037] 3) Network receiving and processing service: Receives network messages sent by the host computer and processes them. Network messages include configuration messages, CAN data sending messages, and CAN status query messages. The processing of each message includes:

[0038] When receiving the CAN device configuration message, call the CAN interface configuration interface to configure the CAN interface on this device, including the acceptance code, shielding code, baud rate, shielding mode, etc. After completion, the configuration result is fed back to the main control machine through the network sending interface.

[0039] When receiving a CAN data transmission message, parse the CAN frame and frame number from the received message, start the CAN interface transmission function in the CAN communication layer to send each CAN frame, and when all the CAN frames to be sent this time are sent, the number of CAN frames sent this time is fed back to the main control machine through the network transmission interface.

[0040] When receiving a CAN status query message, the corresponding information is fed back to the host computer through the network sending interface according to the query content.

[0041] The CAN communication layer is responsible for the CAN interface communication related operations in this device, including the following units:

[0042] 1) CAN communication layer initialization: complete the CAN interface initialization on the Ethernet to CAN device, create a CAN receive queue, and start the CAN message receiving and processing task.

[0043] 2) CAN interface configuration interface: complete the configuration of the CAN interface of the Ethernet to CAN device.

[0044] 3) CAN interface sending function, completes the operation of starting the CAN interface to send.

[0045] 4) CAN interface receiving callback function: Send the data received from the CAN interface to the CAN receiving queue. The CAN interface receives data in an interrupt manner. When the CAN interface is initialized, a CAN interface receiving callback function is registered. When a CAN message is received from the controlled node, the callback function will be automatically called to receive the data.

[0046] 5) CAN message receiving and processing task: Receive data in the CAN receiving queue, assemble the data into network messages and transmit them to the main control machine through the network sending interface.

[0047] Key points of the present invention

[0048] The key points of the present invention are the hierarchical structure of software, the interactive mode of data and the current limiting method for converting high-speed equipment to low-speed equipment.

[0049] Effects of the Invention

[0050] The technical solution proposed in the present invention provides an Ethernet to CAN device, by which the CAN network can be expanded at will, and at the same time, the demand for remote shared control of controlled nodes of the CAN network through router access is realized, and the application scenarios and methods of the CAN bus are expanded.

[0051] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for implementing an Ethernet to CAN device, characterized in that: The method comprises: designing an Ethernet-CAN conversion driver and an Ethernet-to-CAN device running on a main control machine; wherein one end of the Ethernet-to-CAN device is an Ethernet interface and the other end is a CAN interface; the main control machine is connected to a switch or a router through the Ethernet interface, one end of the Ethernet-to-CAN device is connected to the switch or the router through the Ethernet interface, and the other end is connected to a CAN network through the CAN interface, and there are multiple controlled nodes in the CAN network; The Ethernet to CAN driver includes: CAN driver interface layer and communication management layer; the CAN driver interface layer is responsible for providing the application layer with various function interfaces of CAN communication. The application layer uses various function interfaces to communicate and control the controlled nodes to achieve compatibility with the PCIe-CAN driver interface; the communication management layer is responsible for network data transmission and reception and data management; The Ethernet to CAN device includes: a network communication layer and a CAN communication layer; the network communication layer is responsible for network interface communication related operations in the device; the CAN communication layer is responsible for CAN interface communication related operations in the device.

2. The method for implementing the Ethernet to CAN device according to claim 1, characterized in that: The CAN driver interface layer includes: CAN configuration interface function: provides the application layer with a configuration interface for the CAN channel connected to the Ethernet-to-CAN device. After the application layer completes the configuration of the CAN channel using the CAN configuration interface function, the Ethernet-to-CAN device will start in working mode. CAN data transmission interface function: The application layer sends the CAN message to be sent to the Ethernet to CAN device through this interface function. The CAN data transmission interface function is responsible for converting one or more CAN message frames into a network message, and then passing it to the communication management layer for sending the network message; CAN data receiving interface function: obtains CAN data sent by the controlled node from the CAN receiving buffer in the communication management layer. The application layer specifies the waiting time, frame number and application layer data buffer address for receiving CAN frames through this interface function. If there is data in the CAN receiving buffer within the specified receiving time, the data is copied to the application layer data buffer address specified by the user, and the function returns OK. Otherwise, it means that no CAN message is received within the specified time, and the function returns ERROR. CAN status query interface function: The application layer queries the status of the CAN interface on the Ethernet to CAN device. This interface function composes the information to be queried into an Ethernet message and passes it to the communication management layer for sending the network message.

3. The method for implementing the Ethernet to CAN device according to claim 2, characterized in that: The CAN configuration interface function sets the acceptance code, mask code, baud rate and mask mode.

4. The method for implementing the Ethernet to CAN device according to claim 2, characterized in that: The content sent by the CAN data transmission interface function includes CAN frames and frame numbers, where each frame includes: frame ID, frame type and frame data length.

5. The method for implementing the Ethernet to CAN device according to claim 2, characterized in that: The status queried by the CAN status query interface function includes: working mode, error count, self-test result and statistical count of sent and received data.

6. The method for implementing the Ethernet to CAN device according to claim 2, characterized in that: The communications management layer includes: Communication management layer initialization: implement network interface initialization, including creating socket, binding port number, adding local IP to the specified multicast group for multicast reception, setting socket IP_MULTICAST_LOOP and IP_MULTICAST_IF properties; creating CAN receive buffer for caching received CAN frames; starting CAN message reception task and auxiliary management task; Ethernet transmission: The CAN message and CAN channel configuration information transmitted through the CAN driver interface layer are sent to the Ethernet to CAN device through the Ethernet interface; CAN message receiving task: Create a network receiving task, which is used to wait for the Ethernet message sent by the Ethernet to CAN device through the network interface, parse it to get the CAN frame, and put the received CAN frame into the CAN receiving buffer; Auxiliary management tasks: used to receive CAN data transmission frame number feedback, CAN configuration completion result feedback, and CAN status query feedback from the Ethernet to CAN device, and synchronize the CAN configuration interface function, CAN data transmission interface function, and CAN status query interface function in the form of semaphores.

7. The method for implementing the Ethernet to CAN device according to claim 6, characterized in that: In the CAN configuration interface function, create a CAN send count semaphore with N count values, and obtain the send count semaphore in the CAN data sending interface function. Get a count semaphore each time a CAN frame is sent. If the acquisition fails, it means that there are N CAN frames that have not been sent on the Ethernet to CAN device, and you need to wait for a certain period of time before sending them again. In the auxiliary management task, when feedback on CAN send data is received, parse the number of CAN frames sent this time, and release a CAN send count semaphore each time a CAN is sent.

8. The method for implementing the Ethernet to CAN device according to claim 6, characterized in that: The network communication layer includes the following units: Network sending interface: completes the operation of the conversion device sending network messages to the main control machine through the network interface; Network initialization: complete the initialization of the Ethernet interface on the Ethernet to CAN device and start the network receiving and processing service; Network receiving and processing service: Receives and processes network messages sent by the host computer. Network messages include configuration messages, CAN data sending messages, and CAN status query messages.

9. The method for implementing the Ethernet to CAN device according to claim 8, characterized in that: The network reception processing service processes each type of message including: When receiving the CAN device configuration message, call the CAN interface configuration interface to configure the CAN interface on the device, including the acceptance code, shielding code, baud rate, and shielding mode. After completion, the configuration result is fed back to the main control machine through the network sending interface. When receiving a CAN data transmission message, parse the CAN frame and frame number from the received message, start the CAN interface transmission function in the CAN communication layer to send each CAN frame, and when all the CAN frames to be sent this time are sent, the number of CAN frames sent this time is fed back to the main control machine through the network transmission interface; When a CAN status query message is received, the corresponding information is fed back to the main control machine through the network sending interface according to the query content.

10. The method for implementing the Ethernet to CAN device according to claim 8, characterized in that: The CAN communication layer includes the following units: CAN communication layer initialization: complete the CAN interface initialization on the Ethernet to CAN device, create a CAN receive queue, and start the CAN message receiving and processing task; CAN interface configuration interface: complete the configuration of the CAN interface of the Ethernet to CAN device; CAN interface sending function, completes the operation of starting the CAN interface to send; CAN interface receiving callback function: sends the data received from the CAN interface to the CAN receiving queue; The reception of the CAN interface adopts the interrupt mode. When the CAN interface is initialized, a CAN interface reception callback function is registered. When a CAN message sent by the controlled node is received, the callback function will be automatically called to receive the data. CAN message receiving and processing task: Receive data in the CAN receiving queue, compose the data into network messages and transmit them to the main control machine through the network sending interface.

Citation Information

Patent Citations

  • Ethernet-(controller area network) CAN protocol converter

    CN102780705A

  • Switching device of IP network interface and CAN bus interface

    CN104320497A

  • Gateway and method for carrying out data conversion on basis of CANopen protocol and Ethernet protocol

    CN108881001A

  • Laboratory access control system based on CAN bus and Ethernet

    CN111599055A