Data transmission method of gateway equipment, gateway equipment and system

By determining the priority of the communication channel in the gateway device and sending data in priority order, the congestion problem in the data transmission process is solved, normal and balanced transmission of data is achieved, and the stability of the industrial control system is improved.

CN118764341APending Publication Date: 2024-10-11HANGZHOU KANGJISEN AUTOMATION TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410939854.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the field of industrial automation technology, data congestion is prone to occur during the data transmission process of gateway equipment, which affects the normal transmission of data, especially when multi-channel CAN channel data is sent to the data processing chip through a single UART channel.

Method used

The priority of multiple communication channels is determined through the data transceiver chip, and the data is sent to the data processing chip in order from high priority to low to avoid data congestion and ensure balanced data transmission in each communication channel.

Benefits of technology

It effectively avoids data congestion, ensures the normal transmission of multi-channel data to the controller, and ensures the stability and reliability of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118764341A_ABST
    Figure CN118764341A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method of gateway equipment, the gateway equipment and a system, and belongs to the technical field of industrial automation. The invention provides a data transmission method of gateway equipment, the gateway equipment comprises a data transceiving chip and a data processing chip, and the method comprises the following steps: the data transceiving chip receives data from M communication channels; the data transceiver chip determines the priority of the M communication channels; sequentially sending the data from the M communication channels to a data processing chip according to the sequence of the priorities of the M communication channels from high to low; wherein the priority of the first target channel is higher than that of the second target channel, and the number of times of detecting whether the data of the first target channel arrives at the gateway equipment is lower than the number of times of detecting whether the data of the second target channel arrives at the gateway equipment; and the data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiving chip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of industrial automation technology, and specifically relates to a data transmission method for a gateway device, a gateway device, and a system. Background Art

[0002] In the field of industrial automation technology, gateway devices are important bridges for data transmission in industrial control systems such as distributed control systems.

[0003] In the related art, in order to meet the demand for large-scale data transmission, a gateway device can simultaneously access a large number of IO (Input Output) devices through multiple communication channels, and then the controller can transmit a large amount of data with a large number of IO devices through the gateway device.

[0004] However, there is a problem in the related art that the data transmission process of the gateway device is congested, which affects the normal data transmission. For example, the gateway device is provided with multiple CAN (Controller Area Network) channels on the board. When the multiple CAN channel data arrives at the gateway device, the data processing chip of the gateway device (such as an MCU chip) is required to package the multiple CAN channel data into a network data packet and send it to the controller. However, inside the gateway device, the multiple CAN channel data needs to be sent to the data processing chip of the gateway device through a single UART channel, which easily leads to data congestion, thereby affecting the normal data transmission. Summary of the invention

[0005] The embodiments of the present application provide a data transmission method, a gateway device, and a system for a gateway device, which can solve the problem in the related art that data congestion occurs during the data transmission process of the gateway device and affects the normal data transmission.

[0006] In a first aspect, an embodiment of the present application provides a data transmission method of a gateway device, the gateway device including a data transceiver chip and a data processing chip, the method comprising:

[0007] The data transceiver chip receives data from M communication channels; M is greater than 1;

[0008] The data transceiver chip determines the priorities of the M communication channels; and sends the data from the M communication channels to the data processing chip in order from high to low priorities of the M communication channels; wherein, when the data of the M communication channels arrive at the gateway device successively, there are a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections of whether the data of the first target channel arrives at the gateway device is lower than the number of detections of whether the data of the second target channel arrives at the gateway device;

[0009] The data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiver chip.

[0010] In a second aspect, an embodiment of the present application provides a gateway device, including: a data transceiver chip and a data processing chip;

[0011] The data transceiver chip is used to: receive data from M communication channels; M is greater than 1;

[0012] The data transceiver chip is also used to: determine the priorities of the M communication channels; and send the data from the M communication channels to the data processing chip in order from high to low priorities of the M communication channels; wherein, when the data of the M communication channels arrive at the gateway device successively, there are a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections of whether the data of the first target channel arrives at the gateway device is lower than the number of detections of whether the data of the second target channel arrives at the gateway device;

[0013] The data processing chip is used to package the data from the M communication channels into a network data packet, and send the network data packet to the controller through the data transceiver chip.

[0014] In a third aspect, an embodiment of the present application provides an industrial control system, comprising: a gateway device, a controller and multiple IO devices; the gateway device is connected to the controller via Ethernet, and the gateway device is connected to the multiple IO devices via a multi-channel CAN bus; the gateway device is used to implement the method described in the first aspect.

[0015] In an embodiment of the present application, a gateway device includes a data transceiver chip and a data processing chip, through which data from M communication channels are received; M is greater than 1; the data transceiver chip determines the priority of the M communication channels; in the order of the priorities of the M communication channels from high to low, the data from the M communication channels are sequentially sent to the data processing chip; wherein, when the data of the M communication channels arrive at the gateway device successively, there is a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections of whether the data of the first target channel arrives at the gateway device is lower than the number of detections of whether the data of the second target channel arrives at the gateway device; the data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiver chip. In this way, since the data transceiver chip in the present application can determine the priority of the M communication channels; in the order of the priorities of the M communication channels from high to low, the data from the M communication channels are sequentially sent to the data processing chip, data congestion of the data of the M communication channels in the gateway device can be avoided, thereby ensuring that the data is normally transmitted to the controller. Furthermore, when data from multiple communication channels arrive at the gateway device one after another, since the detection times of the communication channels with higher priorities are lower, it is possible to avoid continuously sending data from the communication channels with higher priorities, which results in the data from the communication channels with lower priorities not having the opportunity to be transmitted to the data processing chip. This ensures that the data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, thereby ensuring that the data from multiple communication channels is transmitted to the controller normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 A schematic flow chart of a data transmission method of a gateway device provided in an embodiment of the present application;

[0018] Figure 2 A schematic flowchart of another data transmission method of a gateway device provided in an embodiment of the present application;

[0019] Figure 3 A schematic flow chart of a data transmission method of another gateway device provided in an embodiment of the present application;

[0020] Figure 4 A schematic diagram of a custom protocol format for UART communication data provided in an embodiment of the present application;

[0021] Figure 5 An application scenario diagram of a gateway device for data transmission provided in an embodiment of the present application;

[0022] Figure 6-1 A diagram of an application scenario of another gateway device for data transmission provided in an embodiment of the present application;

[0023] Figure 6-2 A schematic structural diagram of an FPGA chip in a gateway device provided in an embodiment of the present application;

[0024] Figure 7 A schematic structural diagram of an industrial control system provided in an embodiment of the present application;

[0025] Figure 8 An application scenario diagram of a gateway device for data transmission provided in an embodiment of the present application;

[0026] Fig. 9 A schematic diagram of the working process of a CAN interface module in an FPGA chip of a gateway device provided in an embodiment of the present application;

[0027] Fig.10 A schematic diagram of the workflow of a UART time slot control module in an FPGA chip of a gateway device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0029] The terms "first", "second", "third", "fourth", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", "third", "fourth", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0030] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] As described in the background technology, in an industrial control system, in order to meet the needs of large-scale data transmission, a gateway device can simultaneously access a large number of IO devices through multiple communication channels (such as multiple CAN channels). When multiple CAN channel data arrives at the gateway device, the multiple CAN channel data needs to be sent to the data processing chip (such as MCU) of the gateway device through a single UART channel, which can easily lead to data congestion and affect the normal data transmission.

[0032] Based on this, the data transmission method provided in the embodiment of the present application can determine the priorities of M communication channels through a data transceiver chip; in the order of the priorities of the M communication channels from high to low, the data from the M communication channels are sent to the data processing chip in sequence. When multi-channel data arrives at the gateway device, data congestion in the gateway device can be avoided, ensuring that the multi-channel data can be transmitted normally to the data processing chip of the gateway device.

[0033] Furthermore, when data from multiple communication channels arrive at the gateway device one after another, the embodiments of the present application can reduce the number of detection times for communication channels with higher priorities, thereby avoiding continuous sending of data from communication channels with higher priorities, which results in data from communication channels with lower priorities not having a chance to be transmitted to the data processing chip, thereby ensuring that data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, thereby ensuring that data from multiple communication channels is transmitted to the controller normally.

[0034] In practical applications, the data transmission method provided in the embodiment of the present application can be applied to the gateway device of the industrial control system, which can be a multi-channel communication industrial gateway, such as a multi-channel CAN communication industrial gateway, or other application scenarios, which is not limited by the present application.

[0035] The test system provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0036] Figure 1 A schematic flowchart of a data transmission method of a gateway device provided in an embodiment of the present application.

[0037] like Figure 1As shown, an embodiment of the present application provides a data transmission method for a gateway device, the gateway device may include a data transceiver chip and a data processing chip, and the method may include:

[0038] Step 110: The data transceiver chip receives data from M communication channels;

[0039] Step 120: The data transceiver chip determines the priorities of the M communication channels; and sends the data from the M communication channels to the data processing chip in order from high to low priorities of the M communication channels;

[0040] Step 130: The data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiver chip.

[0041] In an embodiment of the present application, the gateway device may include a data transceiver chip and a data processing chip.

[0042] In the embodiment of the present application, the data transceiver chip may be a FPGA (Field Programmable Gate Array) chip for receiving and sending data.

[0043] In the embodiment of the present application, the data processing chip may be an MCU (Micro Controller Unit) chip for processing data.

[0044] In the embodiment of the present application, the communication channel can be understood as a communication link. The gateway device can be connected to a large number of IO devices through a field bus such as CAN, and the communication channel can include a CAN channel.

[0045] In other embodiments, in order to meet the communication requirements of different types of IO devices in industrial sites, the communication channel can also be other types of channels, such as Modbus channels, etc. The present application does not impose any specific restrictions on the specific types of communication channels.

[0046] In an embodiment of the present application, M is less than or equal to N, where N is the number of communication channels configured on the gateway device. When N communication channels are provided on the gateway device, the priority of each communication channel can be pre-configured. For example, the priority of a communication channel can be determined by the bus number of the communication channel. For another example, the priority of a communication channel can be determined based on the service priority of an IO device corresponding to the communication channel. For another example, the priority of a communication channel can be customized based on configuration information input by a user, and so on. The present application does not impose any specific restrictions on the method for determining the priority of a communication channel.

[0047] In practical applications, when the communication channels include CAN channels, the priorities of the N CAN channels can be determined by the bus numbers of the multiple CAN channels.

[0048] For example, for N CAN channels, the priority of the CAN channel increases as the bus number of the CAN channel decreases, that is, the smaller the bus number of the CAN channel, the higher the priority of the CAN channel.

[0049] For another example, the priority of a CAN channel decreases as the bus number of the CAN channel increases, that is, the smaller the bus number of the CAN channel, the lower the priority of the CAN channel.

[0050] It should be pointed out that when M-channel data arrives at the gateway device, the M-channel CAN channel data needs to be sent to the data processing chip (such as MCU chip) of the gateway device through a single UART channel, which can easily cause data congestion and affect the normal data transmission.

[0051] In the embodiment of the present application, since the data transceiver chip in the present application can determine the priorities of M communication channels; the data from the M communication channels are sent to the data processing chip in sequence according to the priority of the M communication channels from high to low. When multi-channel data arrives at the gateway device, data congestion in the gateway device can be avoided, ensuring that the multi-channel data can be normally transmitted to the data processing chip of the gateway device.

[0052] In addition, in an embodiment of the present application, when data from M communication channels arrive at the gateway device one after another, there are a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections on whether the data from the first target channel arrives at the gateway device is lower than the number of detections on whether the data from the second target channel arrives at the gateway device.

[0053] In this way, when data from multiple communication channels arrive at the gateway device one after another, the embodiment of the present application can reduce the number of detection times for communication channels with higher priorities, avoid continuously sending data from communication channels with higher priorities, and cause data from communication channels with lower priorities to have no chance to be transmitted to the data processing chip, thereby ensuring that data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, and further ensuring that data from multiple communication channels is transmitted to the controller normally.

[0054] According to the data transmission method of the gateway device provided in the embodiment of the present application, the gateway device includes a data transceiver chip and a data processing chip, through which the data transceiver chip receives data from M communication channels; the data transceiver chip determines the priority of the M communication channels; in the order of the priority of the M communication channels from high to low, the data from the M communication channels are sequentially sent to the data processing chip; the data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiver chip. In this way, since the data transceiver chip in the present application can determine the priority of the M communication channels; in the order of the priority of the M communication channels from high to low, the data from the M communication channels are sequentially sent to the data processing chip, it is possible to avoid data congestion in the gateway device of the data of the M communication channels, thereby ensuring that the data is normally transmitted to the controller. Furthermore, when data from multiple communication channels arrive at the gateway device one after another, the embodiments of the present application can reduce the number of detection times for communication channels with higher priorities, thereby avoiding continuous sending of data from communication channels with higher priorities, which results in data from communication channels with lower priorities not having a chance to be transmitted to the data processing chip, thereby ensuring that data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, and further ensuring that data from multiple communication channels is transmitted to the controller normally.

[0055] It can be understood that in actual applications, the number N of communication channels configured by the gateway device is relatively large, and the larger the number of communication channels, the more likely it is that data congestion will occur. For example, when data from multiple communication channels arrive at the gateway device at the same time, data congestion is likely to occur. Alternatively, when multi-channel data arrives at the gateway device one after another (not at the same time), due to the large number of communication channels, data congestion is also likely to occur. The following examples are given for these two situations respectively.

[0056] In a specific embodiment, when multiple channel data arrive at the gateway device at the same time, in order to ensure normal data transmission, Figure 2 As shown, in the data transmission method provided in the embodiment of the present application, in the above step 120, sending the data from the M communication channels to the data processing chip in sequence according to the order of priority of the M communication channels from high to low may include:

[0057] Step 1201: When it is detected that data from M communication channels arrive at the gateway device at the same time, the data from the M communication channels arriving at the same time are sent to the data processing chip in sequence according to the priority order of the M communication channels from high to low.

[0058] In the embodiment of the present application, before step 1201, the present application can simultaneously detect whether the data of N communication channels have reached the gateway device; N is the number of communication channels configured for the gateway device;

[0059] In step 1201, when it is detected that data from M communication channels arrive at the gateway device at the same time and data from other NM communication channels have not arrived at the gateway device, the data from the M communication channels that arrive at the same time are sent to the data processing chip in order of priority of the M communication channels from high to low.

[0060] In the embodiment of the present application, the data processing chip may include a UART time slot control module and a UART transmission module. The UART time slot control module is used to configure the transmission time slots of data from N communication channels, and allocate the time of N communication channels occupying the UART transmission module by means of time slot control, so as to avoid data congestion. The N communication channels have priority in occupying the UART interface (i.e., the UART transmission module), and the priority of the communication channel can be reduced as the bus number of the communication channel increases.

[0061] For example, when the UART time slot control module is in a waiting state, the UART time slot control module simultaneously detects whether data from N communication channels arrives at the gateway device, and when data from M communication channels arrives at the same time, the data from the M communication channels that arrive at the same time are sent to the data processing chip in sequence, that is, the communication channel data with a high priority is sent first, and the communication channel data with a low priority is sent later.

[0062] In the embodiment of the present application, when multiple channel data arrive at the gateway device at the same time, the communication channel data with a high priority is sent first, and the communication channel data with a low priority is sent later. Figure 6-1 The gateway device is equipped with N communication channels: CAN1 channel, CAN2 channel, ..., CANn channel. The UART time slot control module enters the waiting state and simultaneously detects whether there is data from CAN1 channel, CAN2 channel, ...CANn channel to the gateway device. When it is detected that the data from the three channels of CAN1 channel, CAN2 channel and CANn channel arrive at the gateway device at the same time, the data from CAN1 channel is sent to the MCU first, and after the data from CAN1 channel is sent, the data from CAN2 channel is sent to the MCU, and other CAN channels are skipped as empty, and finally the data from CANn channel is sent to the MCU.

[0063] In an embodiment of the present application, after the data transmission is completed, the UART time slot control module receives the transmission completion signal and bus number of any communication channel, and the UART time slot control module can return to the waiting state. When the UART time slot control module is in the waiting state, the UART time slot control module can continue to simultaneously detect whether there is data arriving on multiple communication channels.

[0064] In this way, when M channel data arrive at the gateway device at the same time, the data of the M communication channels that arrive at the same time are sent to the data processing chip in sequence according to the priority order of the M communication channels from high to low, which can avoid data congestion in the gateway device and ensure that the multi-channel data that arrives at the same time can be transmitted normally to the data processing chip of the gateway device.

[0065] In another specific embodiment, when data of M communication channels arrive at the gateway device successively, in order to ensure normal data transmission, Figure 3 As shown, in the data transmission method provided in the embodiment of the present application, in the above step 120, sending the data from the M communication channels to the data processing chip in sequence according to the order of priority of the M communication channels from high to low may include:

[0066] Step 1202: When it is detected that the data of the first communication channel arrives at the gateway device earlier than the data of other communication channels, the data of the first communication channel is sent to the data processing chip;

[0067] Among them, the other communication channels are communication channels other than the first communication channel among the N communication channels;

[0068] Step 1203: After the data of the first communication channel is sent, detecting whether the data of the second communication channel has reached the gateway device; wherein the priority of the second communication channel is lower than the priority of the first communication channel;

[0069] For example, the second communication channel may be a communication channel having a lower priority than the first communication channel among the N communication channels;

[0070] Step 1204: When it is detected that the data of the second communication channel arrives at the gateway device, the data of the second communication channel is sent to the data processing chip.

[0071] In an embodiment of the present application, the data transceiver chip includes N interface modules, and the N interface modules are used to receive data from N communication channels; M is less than or equal to N.

[0072] In the embodiment of the present application, before step 1202, the present application can simultaneously detect whether the data of N communication channels have reached the gateway device; N is the number of communication channels configured for the gateway device;

[0073] In step 1202, when it is detected that data of the first communication channel arrives at the gateway device first and data of communication channels other than the first communication channel among the N communication channels have not arrived at the gateway device, the data of the first communication channel is sent to the data processing chip.

[0074] In the embodiment of the present application, the data processing chip may include a UART time slot control module and a UART transmission module. The UART time slot control module is used to configure the transmission time slots of data from each communication channel, and allocate the time for each communication channel to occupy the UART transmission module by means of time slot control, so as to avoid data congestion. The multiple communication channels have priority in preempting the UART interface (i.e., the UART transmission module), and the priority of the communication channel can be reduced as the bus number of the communication channel increases.

[0075] In addition, the UART time slot control module can also reduce the number of detection times for high-priority communication channels and increase the number of detection times for low-priority communication channels, so that the length of time that each communication channel occupies the UART interface (i.e., the UART sending module) is basically balanced, ensuring that data from low-priority communication channels also have the opportunity to be sent to the data processing chip.

[0076] For example, when the UART time slot control module is in a waiting state, the UART time slot control module simultaneously detects whether data from the N communication channels has arrived at the gateway device, and when it is detected that data from the first communication channel has arrived at the gateway device first, the UART sending module is controlled to send the data from the first communication channel to the data processing chip;

[0077] When the UART sending module completes sending the data of the first communication channel, the UART time slot control module detects whether the data of the second communication channel has reached the gateway device; wherein the priority of the second communication channel is lower than the priority of the first communication channel;

[0078] When the UART time slot control module detects that the data of the second communication channel arrives at the gateway device, the UART sending module is controlled to send the data of the second communication channel to the data processing chip.

[0079] In an embodiment of the present application, when it is not detected that the data of the second communication channel has arrived at the gateway device, the data of the third communication channel continues to be detected whether it has arrived at the gateway device; wherein the priority of the third communication channel is lower than the priority of the second communication channel; when it is detected that the data of the third communication channel has arrived at the gateway device, the data of the third communication channel is sent to the data processing chip. And so on, until the communication channel with the lowest priority among the N communication channels is detected, when it is detected that the data of the communication channel with the lowest priority has arrived at the gateway device, the data of the communication channel with the lowest priority is sent to the data processing chip. Then, the UART time slot control module can return to the waiting state, and in the waiting state, it simultaneously detects whether the data of the N communication channels have arrived at the gateway device.

[0080] In an embodiment of the present application, the first communication channel may be the first target channel, the second communication channel may be the second target channel, the first communication channel has a higher priority than the second communication channel, and the detection number of the first communication channel is lower than the detection number of the second communication channel.

[0081] For example, taking the first communication channel as the CANk channel and the second communication channel as the CANk+1 channel as an example, the UART time slot control module simultaneously detects whether data from the CAN1 channel, CAN2 channel, ...CANn channel has arrived at the gateway device, and when it is detected that the CANk channel data has arrived first, the CANk channel data is sent first. After that, it no longer detects whether data from the CAN1 channel, CAN2 channel, ...CANn channel has arrived at the gateway device at the same time, but instead specifically detects whether data from the CANk+1 channel has arrived at the gateway device, that is, the number of detections of the CANk+1 channel is increased once. At this time, the number of detections of the CANk+1 channel is one more than the number of detections of the CAN1, ...CANk channels, ensuring that the data of the communication channel with a low priority also has the opportunity to be sent to the data processing chip.

[0082] It should be pointed out that after the data transmission of the first communication channel is completed, the UART time slot control module no longer simultaneously detects whether there is data arrival in multiple communication channels, that is, it no longer detects whether there is data arrival in the communication channel with the highest priority from the beginning, but instead specifically detects whether the data of the second communication channel with a lower priority has arrived at the gateway device, which is equivalent to reducing the number of detection times of the communication channel with a high priority and increasing the number of detection times of the communication channel with a low priority, so that the length of time that each communication channel occupies the UART interface (that is, the UART sending module) is basically balanced, ensuring that the data of the communication channel with a low priority also has the opportunity to be sent to the data processing chip.

[0083] For example, the gateway device is provided with CAN1 channel, CAN2 channel, ..., CANn channel. The UART time slot control module simultaneously detects whether data from CAN1 channel, CAN2 channel, ..., CANn channel arrives at the gateway device. When data from multiple channels do not arrive at the same time, the channel that arrives first is sent first. For example, when the UART time slot control module detects that the CANk channel data arrives first, it sends a data request and the bus number of the CANk channel to the UART sending module. The UART sending module reads 16 bytes of data from the data cache FIFO of the CANk channel to generate a data protocol packet, and sends it to the MCU through the UART sending module. After the sending is completed, it is determined whether the data cache FIFO of the CANk+1 channel is empty to detect whether the CANk+1 channel data has arrived; if the data cache FIFO of the CANk+1 channel is empty, it continues to detect whether the data cache FIFO of the CANk+2 channel is empty; if the data cache FIFO of the CANk+1 channel is not empty, it sends a data request and the bus number of the CANk+1 channel to the UART sending module. The UART sending module reads 16 bytes of data from the data cache FIFO of the CANk+1 channel to generate a data protocol packet, and sends it to the MCU through the UART sending module. After the sending is completed, it is detected whether the data cache FIFO of the CANk+2 channel is empty, and it returns to the waiting state until the data cache FIFO of the CANn channel is detected.

[0084] In this way, when data from M communication channels arrive at the gateway device one after another, the data from the first communication channel that arrives first is first sent to the data processing chip, and then, in order of the priority of the communication channels from high to low, it is detected in turn whether the data from each communication channel with a priority lower than the first communication channel has arrived at the gateway device, and the data arriving from each communication channel with a priority lower than the first communication channel is sent to the data processing chip in turn, which can avoid data congestion in the gateway device and ensure that multi-channel channel data that arrive at the same time can be normally transmitted to the data processing chip of the gateway device.

[0085] Furthermore, after the data of the first communication channel that arrives first is sent, it is no longer necessary to simultaneously detect whether data has arrived through the N communication channels, that is, it is no longer necessary to detect from the beginning whether data has arrived through a communication channel with a higher priority than the first communication channel, but rather to specifically detect whether data from a communication channel with a lower priority than the first communication channel has arrived at the gateway device. This is equivalent to reducing the number of detection times for communication channels with higher priorities and increasing the number of detection times for communication channels with lower priorities, thereby ensuring that the length of time that each communication channel occupies the UART interface (i.e., the UART sending module) is basically balanced, thereby ensuring that data from communication channels with lower priorities also have the opportunity to be sent to the data processing chip.

[0086] In this way, it is possible to avoid continuously sending data from communication channels with higher priorities, which results in data from communication channels with lower priorities not having the opportunity to be transmitted to the data processing chip, thereby ensuring that data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, thereby ensuring that data from multiple communication channels is transmitted normally to the controller.

[0087] In another specific embodiment, when data of M communication channels arrive at the gateway device, in order to ensure the reliability of data transmission, Figure 3 As shown, in the data transmission method provided in the embodiment of the present application, in the above step 120, sending the data from the M communication channels to the data processing chip in sequence according to the order of priority of the M communication channels from high to low may include:

[0088] For data from any one of the M communication channels, the data transceiver chip generates a data protocol packet; and sends the data protocol packet to the data processing chip.

[0089] In the examples of this application, refer to Figure 4 and Figure 5 ,The UART communication data between the data processing chip (MCU) and the data transceiver chip (FPGA) adopts a custom protocol format.

[0090] For example, a data transceiver chip sends a data protocol packet to a data processing chip, and the data protocol packet has a frame header, a data segment, and a checksum. The frame header of the data protocol packet is used to store the bus number of the communication channel and the first function code, the bus number of the communication channel is used to determine the priority of the communication channel, and the first function code is used to indicate the transaction type of the data protocol packet; the data segment of the data protocol packet includes data from the communication channel; the checksum of the data protocol packet is determined based on the frame header and the data segment. The checksum of the data protocol packet can be used to verify the correctness of the data protocol packet.

[0091] In the embodiment of the present application, for data from each communication channel, the UART sending module generates at least one data protocol packet based on the data from the communication channel.

[0092] It is understandable that, for data from the M communication channels, the UART transmission module can generate multiple data protocol packets based on the data from the M communication channels. Then, the UART time slot control module controls the UART transmission module to send the multiple data protocol packets to the data processing chip in sequence according to the priority order of the M communication channels from high to low.

[0093] Thus, in the embodiment of the present application, the data transceiver chip can package the data of the communication channel according to the customized protocol format to generate a data protocol packet. The checksum of the data protocol packet is calculated by the frame header and the data segment, which can ensure the reliability of the data.

[0094] In another specific embodiment, the data transceiver chip includes a UART time slot control module, a UART transmission module and N interface modules; the N interface modules are used to receive data from N communication channels; the N interface modules correspond to the N communication channels one by one; M is less than or equal to N;

[0095] After step 120, the data transmission method provided in the embodiment of the present application may further include:

[0096] When the UART time slot control module receives a sending completion request from the target interface module, based on the target bus number carried in the sending completion request, the UART sending module is controlled to generate a sending completion protocol packet, and the sending completion protocol packet is sent to the data processing chip through the UART sending module;

[0097] Wherein, the target bus number is the bus number of the communication channel corresponding to the target interface module; wherein the target interface module may be any one of the N interface modules;

[0098] The sending completion protocol packet has a frame header and a checksum; the frame header of the sending completion protocol packet is used to store the target bus number and the second function code, the second function code is used to indicate the transaction type of the sending completion protocol packet, and the checksum of the sending completion protocol packet is determined based on the frame header. The checksum of the data protocol packet is used to verify the correctness of the data protocol packet.

[0099] In this way, the UART sending module of the data transceiver chip sends the sending completion protocol packet to the data processing chip to notify the data processing chip that the data sending from the communication channel is completed, thereby ensuring the integrity and reliability of the data.

[0100] In another specific embodiment, before packaging the data from the M communication channels into a network data packet, the data transmission method provided in the embodiment of the present application may further include:

[0101] The data processing chip receives the time stamp information from the controller, and the time stamp information is used to control the time synchronization between the gateway device and the controller;

[0102] Correspondingly, in the above step 130, the data processing chip packages the data from the M communication channels into a network data packet, which may include:

[0103] The data processing chip packages the data from the M communication channels and the local timestamp into a network data packet.

[0104] Among them, the local timestamp can be used to mark the generation time of the network data packet.

[0105] For example, the controller sends the timestamp information to the gateway device through the RS485 interface for system time synchronization. Then, when the data processing chip (such as MCU) receives the data from the UART sending module, it packages the parsed data and the local timestamp into a network data packet in the format required by the controller, and sends the network data packet to the controller via Ethernet.

[0106] In this way, the timestamp information enables the gateway device and the controller to be synchronized in time. The network data packet sent by the gateway device to the controller contains the collected CAN data and local timestamp data. Since the gateway device and the controller are time synchronized, the controller can sort the received CAN data according to the local timestamp data in the network data packet to prevent data disorder or duplication.

[0107] Based on the same concept as any of the above method embodiments, the embodiment of the present application also provides a gateway device.

[0108] In a specific embodiment, Figure 5 As shown, the gateway device provided in the embodiment of the present application may include: a data transceiver chip and a data processing chip;

[0109] The data transceiver chip is used to receive data from M communication channels;

[0110] The data transceiver chip is also used to determine the priorities of the M communication channels; and send the data from the M communication channels to the data processing chip in sequence according to the priorities of the M communication channels from high to low;

[0111] The data processing chip is used to package the data from the M communication channels into a network data packet, and send the network data packet to the controller through the data transceiver chip.

[0112] like Figure 6-1 As shown, in the gateway device provided in the embodiment of the present application, the data transceiver chip can be an FPGA chip for receiving and sending data.

[0113] In the gateway device provided in the embodiment of the present application, the data processing chip may be an MCU chip, which is used for data processing, for example, packaging data from M communication channels into a network data packet, and sending the network data packet to the controller.

[0114] In this way, since the data transceiver chip can determine the priorities of the M communication channels; the data from the M communication channels are sent to the data processing chip in sequence according to the order of the priorities of the M communication channels from high to low. When multi-channel data arrives at the gateway device, data congestion in the gateway device can be avoided, ensuring that the multi-channel data can be normally transmitted to the data processing chip of the gateway device, thereby ensuring that the data is normally transmitted to the controller.

[0115] Moreover, in an embodiment of the present application, when data from M communication channels arrive at the gateway device one after another, there are a first target channel and a second target channel among the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections on whether the data from the first target channel arrives at the gateway device is lower than the number of detections on whether the data from the second target channel arrives at the gateway device.

[0116] In this way, when data from multiple communication channels arrive at the gateway device one after another, the embodiment of the present application can reduce the number of detection times for communication channels with higher priorities, avoid continuously sending data from communication channels with higher priorities, and cause data from communication channels with lower priorities to have no chance to be transmitted to the data processing chip, thereby ensuring that data from each communication channel is transmitted to the data processing chip in a relatively balanced manner, and further ensuring that data from multiple communication channels is transmitted to the controller normally.

[0117] In another specific embodiment, the data transceiver chip may include a UART time slot control module and a UART transmission module;

[0118] The UART time slot control module is used to control the UART sending module to send the data of the M communication channels that arrive simultaneously to the data processing chip in sequence according to the priority order of the M communication channels from high to low when it is detected that the data of the M communication channels arrive at the gateway device at the same time.

[0119] refer to Figure 6-1 and Figure 6-2 In the case where the data transceiver chip is an FPGA chip, the FPGA chip may include a UART time slot control module and a UART transmission module. The UART time slot control module is used to configure the transmission time slots of data from each CAN channel, and allocate the time for each CAN channel to occupy the UART transmission module by means of time slot control, so as to avoid data congestion. Multiple CAN channels have priority in preempting the UART interface (i.e., the UART transmission module), and the priority of the CAN channel can be reduced as the bus number of the CAN channel increases.

[0120] In this way, when data from M CAN channels arrive at the gateway device at the same time, the data from the M CAN channels that arrive at the same time are sent to the MCU chip in sequence according to the priority of the CAN channels from high to low, which can avoid data congestion in the gateway device and ensure that the data from the M CAN channels that arrive at the same time can be transmitted normally to the MCU chip of the gateway device.

[0121] In another specific embodiment, the UART sending module may be used to generate a data protocol packet for data from any one of the M communication channels; and send the data protocol packet to the data processing chip;

[0122] The data protocol packet has a frame header, a data segment and a checksum; the frame header of the data protocol packet is used to store the bus number of the communication channel and the first function code, the bus number of the communication channel is used to determine the priority of the communication channel, and the first function code is used to indicate the transaction type of the data protocol packet; the data segment of the data protocol packet includes data from the communication channel; the checksum of the data protocol packet is determined based on the frame header and the data segment.

[0123] For example, the value of the frame header and the value of the data segment are added together to obtain the checksum.

[0124] In another specific embodiment, the data transceiver chip includes a UART time slot control module, a UART transmission module and N interface modules; the N interface modules are used to receive data from N communication channels; the N interface modules correspond to the N communication channels one by one;

[0125] The UART time slot control module is used to control the UART sending module to generate a sending completion protocol packet based on the target bus number carried in the sending completion request when receiving the sending completion request from the target interface module, and send the sending completion protocol packet to the data processing chip through the UART sending module;

[0126] Wherein, the target bus number is the bus number of the communication channel corresponding to the target interface module;

[0127] Among them, the sending completion protocol packet has a frame header and a checksum; the frame header of the sending completion protocol packet is used to store the target bus number and the second function code, the second function code is used to indicate the transaction type of the sending completion protocol packet, and the checksum of the sending completion protocol packet is determined based on the frame header.

[0128] refer to Figure 6-1 In the case where the data transceiver chip is an FPGA chip, the N interface modules in the FPGA chip may include a CAN1 interface module, a CAN2 interface module, ..., a CANn interface module.

[0129] For example, when the UART time slot control module is in the waiting state, when the UART time slot control module receives a sending completion request from any CAN channel, it sends a completion signal and a bus number to the UART sending module, and the UART sending module generates a sending completion protocol packet, and sends the sending completion protocol packet to the MCU chip through the UART sending module, thereby notifying the MCU chip that the CAN data sending of the corresponding channel is completed, and returns to the waiting state after the sending is completed.

[0130] In this way, the UART sending module sends the sending completion protocol packet to the MCU chip to notify the MCU chip that the data sending from the CAN channel is completed, thereby ensuring the integrity and reliability of the data.

[0131] In practical applications, in the field of industrial automation control, in order to ensure continuous operation of factory production, higher requirements are placed on the reliability and stability of industrial control systems. In the prior art, redundant communication can improve the stability of the system. The specific method is to perform dual-channel synchronous transmission of the same data for important data in the system, thereby ensuring the continuity and reliability of field data. The gateway is an indispensable part of data transmission in the control system. The prior art mostly adopts 1:1 hot backup redundancy technology, using two identical gateways in operation at the same time. The controller selects the better gateway as the master device and the other as the slave device according to the working status of each gateway. When the master device fails, the master-slave switch occurs, and the slave device becomes the master device, completing the seamless data switch.

[0132] For example, Figure 7 As shown, the industrial control system may include: gateway A, gateway B and multiple IO devices. Gateway A and gateway B are redundant, and both can transmit data to the controller via Ethernet. During cold start, gateway A is the default master device, and the other gateway B is the slave device. The master and slave devices can communicate with each other using serial ports or other communication methods. The IO devices are connected to the master and slave devices respectively through the CAN bus. The data collected by the gateway is packaged into a network data packet and uploaded to the controller. The network data packet includes the data collected from the IO device and the local timestamp. The controller only allocates a memory space to store the data received from the master and slave devices.

[0133] At the same time, if Figure 7 As shown, the CAN channel and network channel of a single gateway board are also divided into two channels, A and B, which are redundant channels to each other. There are multiple CAN channels on the gateway board, and each CAN channel is equipped with redundant channels. Multiple CAN channels need to send data to the MCU through a single UART channel. When data from multiple CAN channels arrive at the gateway at the same time, it is easy to cause data congestion, affecting the normal data transmission.

[0134] like Figure 8 As shown in the figure, each gateway device contains multiple CAN communication links of CANA1-CANAn, CANB1-CANBn, CANAn and CANBn are a pair of redundant channels, and the data of all CANA channels are transmitted to the MCU through UARTA, and the data of all CANB channels are transmitted to the MCU through UARTB. After the MCU receives the data from UART, it packages the parsed data and the local timestamp into a network data packet according to the format required by the controller, and sends it to the controller through Ethernet NETA and NETB. The controller sends the timestamp to the gateway device (such as gateway A and gateway B) through RS485 for system time synchronization.

[0135] like Figure 8 As shown, the embodiment of the present application realizes the IO device data function of multi-channel CAN channel data acquisition through FPGA. The CAN channels are divided into two groups, A and B, which are redundant to each other, thereby improving the reliability and stability of gateway data transmission and reducing the risk of missed and wrong data.

[0136] like Figure 8 As shown, in the embodiment of the present application, the controller sends timestamp data to the gateway device through the RS485 interface, so that the gateway and the controller can be synchronized in time. The network data packet sent by the gateway device to the controller contains the collected CAN data and timestamp data. Since the gateway device and the controller are time synchronized, the controller can sort the received CAN data according to the timestamp data in the network data packet to prevent data disorder or duplication.

[0137] In addition, in the embodiment of the present application, the gateway device can use FPGA to collect IO device data through multiple CAN channels. There are two application scenarios:

[0138] For example, Figure 8 As shown, there are multiple CANA channels on the gateway board: CANA1 channel, CANA2 channel, ..., CANAn channel. The multiple CANA channels need to send data to the MCU through a single UARTA channel.

[0139] For example, Figure 8 As shown, there are multiple CANB channels on the gateway board: CANB1 channel, CANB2 channel, ..., CANBn channel. The multiple CANB channels need to send data to the MCU through a single UARTB channel.

[0140] like Figure 8 As shown, the gateway device provided in the embodiment of the present application includes a data processing chip (such as MCU) and a data transceiver chip (such as FPGA).

[0141] like Figure 6-1As shown, a data transceiver chip (such as FPGA) may include a UART time slot control module, a UART transmitting module, a UART receiving module and multiple CAN interface modules; the multiple CAN interface modules are used to receive data from multiple CAN channels; and the multiple CAN interface modules correspond one to one to the multiple CAN channels.

[0142] For example, the multiple CAN interface modules include a CAN1 interface module, a CAN2 interface module, ..., a CANn interface module; the CAN1 interface module corresponds to the CAN1 channel, the CAN2 interface module corresponds to the CAN2 channel, and the CANn interface module corresponds to the CANn channel.

[0143] In practical applications, Figure 6-1 The CAN1 interface module, CAN2 interface module, ..., CANn interface module shown can correspond one to one Figure 8 The CANA1 channel, CANA2 channel, ..., CANAn channel shown, or can correspond to Figure 8 The CANB1 channel, CANB2 channel, ..., CANBn channel shown in the present application do not limit the specific application scenarios.

[0144] For any CAN interface module, the workflow of the CAN interface module is as follows: Fig. 9 As shown, when the CAN channel completes the reset, the CAN interface module initializes the corresponding CAN channel, and after the CAN channel initialization is completed, the CAN interface module enters the waiting state; when the send enable is valid, the CAN interface module writes the information and data to be sent to the CAN channel into the corresponding register, and returns to the waiting state after the writing is completed; when an interrupt event arrives, the CAN interface module determines the type of interrupt signal through the register, if it is an error interrupt type, the CAN channel is initialized again; if it is a receive interrupt type, the information and data received from the CAN channel are read out from the corresponding register and stored in the data cache FIFO corresponding to the CAN channel, further, the corresponding interrupt bit in the interrupt register is cleared, and the module returns to the waiting state; if it is a send completion interrupt type, a completion signal is sent to the UART time slot control module, further, the corresponding interrupt bit in the interrupt register is cleared, and the module returns to the waiting state.

[0145] After receiving the receive interrupt signal, the CAN interface module stores the information and data in the data cache FIFO, and the information and data size is fixed to 16 bytes. After receiving the send completion interrupt, the CAN interface module sends a completion signal to the UART time slot control module and starts a process to wait for the UART reply. The process stops after receiving the reply.

[0146] In this embodiment, the UART interface is used for communication between the FPGA and the MCU. The UART is full-duplex communication. The MCU can parse the protocol packet sent by the UART sending module, or the UART receiving module can parse the protocol packet sent by the MCU, and determine the transaction type, the object of the operation and the size of the data segment according to the frame header of the protocol packet.

[0147] The custom protocol format of the protocol packet can refer to Table 4. The protocol packet has a frame header, a data segment, and a checksum. The frame header supports transaction type extension, and the corresponding function code can be extended according to the needs; the data segment is a variable length of 0 to 16 bytes; the checksum is calculated from the frame header and the data segment to ensure data reliability.

[0148] For example, the FPGA and MCU use the UART interface to communicate. The sender sends different protocol packets according to different transactions. The protocol includes a 1-byte frame header, a maximum of 16 bytes of data segment and a 1-byte checksum. The specific protocol is shown in Table 1:

[0149]

[0150]

[0151]

[0152] Table 1

[0153] For example, when the UART sending module in the FPGA receives the data sending request signal and the bus number sent by the UART time slot control module, the UART sending module reads 16 bytes of data from the CAN channel data cache FIFO of the bus number and generates a data protocol packet; the data protocol packet includes a frame header with a function code of 1 plus a 4-bit bus number, 16 bytes of data, and a 1-byte checksum calculated from the frame header and the data; then, the UART sending module sends the data protocol packet to the MCU.

[0154] When the UART sending module in the FPGA receives the sending completion signal and CAN bus number sent by the UART time slot control module, the UART sending module generates a sending completion protocol packet; the sending completion protocol packet includes a frame header with a function code of 3 plus a 4-bit bus number, and a checksum byte equal to the frame header; the UART sending module sends the sending completion protocol packet to the MCU to notify the MCU that the CAN data sending of the corresponding channel is completed.

[0155] In addition, when the UART receiving module in the FPGA chip receives the first byte, it parses the transaction type according to the lower 4 bits. When an undefined type is received, the receiving module discards the data and enters the error state. It continuously detects 11 bits of idle bits and returns to the receiving state.

[0156] When the UART receiving module receives function code 2, it saves the bus number, receives 16 bytes of data and 1 byte of check bit, and compares whether the locally calculated checksum is equal to the received checksum. If they are equal, it sends a request to the corresponding CAN channel and sends the data at the same time, and then re-enters the receiving state; if they are not equal, the data is discarded and the error state is entered. After continuously detecting 11 bits of idle bits, it returns to the receiving state;

[0157] When the UART receiving module receives the function code 4, it saves the bus number and compares the checksum with the frame header to see if they are equal. If they are equal, it sends a reset request to the corresponding CAN channel. If they are not equal, it enters the error state, detects 11 idle bits continuously, and returns to the receiving state.

[0158] When the UART receiving module receives the function code 5, it compares the checksum with the frame header to see if they are equal. If they are equal and the upper 4 bits are 0, it sends a reset request to the NETA chip. If they are not equal or the upper 4 bits are not 0, it enters the error state, detects 11 idle bits continuously, and returns to the receiving state.

[0159] When the UART receiving module receives the function code 6, it compares the checksum with the frame header to see if they are equal. If they are equal and the upper 4 bits are 0, it sends a reset request to the NETB chip; if they are not equal or the upper 4 bits are not 0, it enters the error state, detects 11 idle bits continuously, and returns to the receiving state.

[0160] When the UART receiving module receives the function code of 7, it receives 2 bytes of data and checksum, compares the local calculated checksum with the received checksum, and if they are equal and the upper 4 bits of the frame header are 0, sends the bit with a value of 1 in the mask byte and the corresponding data byte bit value to the corresponding panel light to update the light status. If they are not equal or the upper 4 bits are not 0, it enters the error state, detects 11 bits of idle bits continuously, and returns to the receiving state.

[0161] In this way, the UART communication data between the MCU and the FPGA adopts a custom protocol format, which can ensure the flexibility and reliability of the data, support transaction type extension, and can expand the corresponding function code according to needs. The data segment has a variable length of 0 to 16 bytes, which can realize flexible expansion with data functions. The checksum is calculated by the frame header and data segment to ensure data reliability.

[0162] In addition, in the FPGA, the UART time slot control module uses time slot control to allocate the time that N CAN channels occupy the UART sending module. N CAN channels have priority in occupying the UART interface (i.e., the UART sending module), and the priority of the CAN channel decreases as the bus number of the CAN channel increases.

[0163] For example, for the UART time slot control module, the workflow of the UART time slot control module is as follows: Fig.10 As shown, when the UART time slot control module is in the waiting state, the UART time slot control module simultaneously detects whether there is data arriving on multiple CAN channels. When data on multiple CAN channels arrive at the same time, the channel with high priority is sent first. For example, when data on channels 1, 2, and n arrive at the same time, channel 1 is sent first, and after channel 1 is sent, channel 2 is sent. Other channels are skipped if they are empty, and channel n is sent last.

[0164] like Fig.10 As shown, when multiple channels do not arrive at the same time, the channel that arrives first is sent first. For example, the UART time slot control module simultaneously detects whether data has arrived on N channels. When it is detected that the data of channel k arrives first, a data request and the bus number of channel k are sent to the UART sending module. The UART sending module reads 16 bytes of data from the data cache FIFO of channel k to generate a data protocol packet, and sends it to the MCU through the UART. After the sending is completed, it is detected whether the data cache FIFO of channel k+1 is empty. If the data cache FIFO of channel k+1 is empty, it continues to detect whether the data cache FIFO of channel k+2 is empty; if the data cache FIFO of channel k+1 is not empty, it sends a data request and a bus number to the UART sending module. The UART sending module reads 16 bytes of data from the data cache FIFO of channel k+1 to generate a data protocol packet, and sends it to the MCU through the UART. After the sending is completed, it is detected whether the data cache FIFO of channel k+2 is empty, and the waiting state is not returned until the data cache FIFO of channel n is detected.

[0165] In this way, since the data of multiple CAN channels needs to be transmitted through a single-channel UART, the time slot configuration method is used to allocate the time that N CAN channels occupy the UART sending module, so as to avoid data congestion and ensure normal data transmission.

[0166] In addition, a method of allocating high-priority CAN channels to reduce the number of detections and low-priority CAN channels to increase the number of detections allows all CAN channels to occupy the UART interface equally in time, ensuring that data from low-priority communication channels also have the opportunity to be sent to the MCU.

[0167] In addition, after the UART time slot control module returns to the waiting state, when the UART time slot control module receives a sending completion request from any CAN channel, it sends a completion signal and bus number to the UART sending module. The UART sending module generates a sending completion protocol packet and sends it to the MCU through the UART sending module, notifying the MCU that the data sending of the corresponding CAN channel is completed, and returns to the waiting state after the sending is completed.

[0168] It should be pointed out that after the FPGA sends the multiple CAN channel data to the MCU in sequence, the MCU can parse the multiple CAN channel data, package the multiple CAN channel data into network data packets, and send the network data packets to the controller.

[0169] Since the MCU chip has only one Ethernet physical interface, this application can expand two Ethernet interfaces, NETA and NETB, through FPGA for redundant transmission of network data. The FPGA and MCU are connected through the Ethernet physical interface (RMII). The FPGA is equivalent to an Ethernet PHY chip for data reception and transmission, and the MCU is used as a MAC (Media Access Control) chip for data processing.

[0170] Regarding the data interaction between the gateway and the controller, when the controller sends network data to the gateway, when any Ethernet interface of the FPGA (i.e. NETA / NETB) receives the network data, the network data is cached in the FPGA, and the CRC check calculation is performed on the received network data. If the calculation result is equal to the received CRC check value, a byte is added to the end of the data frame to identify the channel (i.e. NETA / NETB), and the entire data frame is sent to the FPGA's sending queue; if they are different, the entire data frame is discarded;

[0171] The FPGA also includes a NET (network) interface module. The network sending module of the NET interface module detects whether there is data to be sent in the NETA sending queue. If so, the data is sent out according to the Ethernet physical interface of the MCU, and the NETB sending queue is detected after the sending is completed; if not, the NETB sending queue is directly detected.

[0172] When the MCU has network data to send to the controller, a byte is added to the data frame header as the identifier of the network port (NETA / NETB). When the FPGA detects network data from the MCU, it determines whether the network port to be sent is NETA or NETB based on the first byte. After the entire frame of data is received, the FPGA adds a 4-byte CRC check at the end, generates a network data packet, starts the sending module corresponding to the network port (such as the NETA sending module or the NETB sending module in the FPGA), and sends the network data packet to the controller.

[0173] An embodiment of the present application further provides an industrial control system, including: a gateway device, a controller and multiple IO devices; the gateway device is connected to the controller via Ethernet, and the gateway device is connected to multiple IO devices via a multi-channel CAN bus; the gateway device implements each process of the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0174] An embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0175] The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory, a random access memory, a magnetic disk or an optical disk.

[0176] An embodiment of the present application further provides a gateway device, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0177] An embodiment of the present application further provides a computer program product, which includes a computer program. The computer program is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0178] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus necessary general hardware platforms, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0180] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A data transmission method for a gateway device, characterized in that: The gateway device includes a data transceiver chip and a data processing chip, and the method includes: The data transceiver chip receives data from M communication channels; M is greater than 1; The data transceiver chip determines the priorities of the M communication channels; and sends the data from the M communication channels to the data processing chip in order from high to low priorities of the M communication channels; wherein, when the data of the M communication channels arrive at the gateway device successively, there are a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections of whether the data of the first target channel arrives at the gateway device is lower than the number of detections of whether the data of the second target channel arrives at the gateway device; The data processing chip packages the data from the M communication channels into a network data packet, and sends the network data packet to the controller through the data transceiver chip.

2. The method according to claim 1, characterized in that The step of sending the data from the M communication channels to the data processing chip in sequence according to the priority order of the M communication channels from high to low includes: When it is detected that the data of the M communication channels arrive at the gateway device at the same time, the data of the M communication channels arriving at the same time are sent to the data processing chip in sequence according to the priority order of the M communication channels from high to low.

3. The method according to claim 1, characterized in that: The data transceiver chip includes N interface modules, and the N interface modules are used to receive data from N communication channels; M is less than or equal to N; The step of sending the data from the M communication channels to the data processing chip in sequence according to the priority order of the M communication channels from high to low includes: When it is detected that data of the first communication channel arrives at the gateway device before data of other communication channels, the data of the first communication channel is sent to the data processing chip; the other communication channels are communication channels other than the first communication channel among the N communication channels; When the data of the first communication channel is sent, detecting whether the data of the second communication channel has reached the gateway device; wherein the priority of the second communication channel is lower than the priority of the first communication channel; When it is detected that the data of the second communication channel arrives at the gateway device, the data of the second communication channel is sent to the data processing chip.

4. The method according to claim 1, characterized in that: The step of sending the data from the M communication channels to the data processing chip in sequence according to the priority order of the M communication channels from high to low includes: The data transceiver chip generates a data protocol packet for data from any one of the M communication channels; and sends the data protocol packet to the data processing chip; Among them, the data protocol packet has a frame header, a data segment and a checksum; the frame header of the data protocol packet is used to store the bus number of the communication channel and the first function code, and the bus number of the communication channel is used to determine the priority of the communication channel; the first function code is used to indicate the transaction type of the data protocol packet; the checksum of the data protocol packet is determined based on the frame header and the data segment; the checksum of the data protocol packet is used to verify the correctness of the data protocol packet.

5. The method according to claim 1 or 4, characterized in that: The data transceiver chip includes a universal asynchronous receiver / transmitter (UART) time slot control module, a UART transmission module and N interface modules; The N interface modules are used to receive data from N communication channels; M is less than or equal to N; The method further comprises: When the UART time slot control module receives a sending completion request from the target interface module, based on the target bus number carried in the sending completion request, the UART sending module is controlled to generate a sending completion protocol packet, and the sending completion protocol packet is sent to the data processing chip through the UART sending module; Wherein, the target bus number is the bus number of the communication channel corresponding to the target interface module; Among them, the sending completion protocol packet has a frame header and a checksum; the frame header of the sending completion protocol packet is used to store the target bus number and the second function code, the second function code is used to indicate the transaction type of the sending completion protocol packet, and the checksum of the sending completion protocol packet is used to verify the correctness of the sending completion protocol packet.

6. The method according to claim 1, characterized in that The data transceiver chip is a field programmable gate array FPGA chip; the data processing chip is a micro control unit MCU chip; and the communication channel includes a controller area network CAN channel.

7. The method according to claim 1, characterized in that Before packaging the data from the M communication channels into a network data packet, the method further includes: The data processing chip receives timestamp information from the controller, and the timestamp information is used to control the gateway device to perform time synchronization with the controller; The data processing chip packages the data from the M communication channels into a network data packet, including: The data processing chip packages the data from the M communication channels and the local timestamp into a network data packet.

8. A gateway device, characterized in that: include: Data transceiver chip and data processing chip; The data transceiver chip is used to: receive data from M communication channels; M is greater than 1; The data transceiver chip is also used to: determine the priorities of the M communication channels; and send the data from the M communication channels to the data processing chip in order from high to low priorities of the M communication channels; wherein, when the data of the M communication channels arrive at the gateway device successively, there are a first target channel and a second target channel in the M communication channels, the priority of the first target channel is higher than the priority of the second target channel, and the number of detections of whether the data of the first target channel arrives at the gateway device is lower than the number of detections of whether the data of the second target channel arrives at the gateway device; The data processing chip is used to package the data from the M communication channels into a network data packet, and send the network data packet to the controller through the data transceiver chip.

9. The gateway device according to claim 8, characterized in that: The data transceiver chip includes a universal asynchronous receiver / transmitter (UART) time slot control module and a UART transmission module; The UART time slot control module is used to: when it is detected that the data of the M communication channels arrive at the gateway device at the same time, control the UART sending module to send the data of the M communication channels that arrive at the same time to the data processing chip in sequence according to the priority order of the M communication channels from high to low.

10. The gateway device according to claim 8, characterized in that: The data transceiver chip includes N interface modules, and the N interface modules are used to receive data from N communication channels; M is less than or equal to N; The UART time slot control module is used to: when it is detected that the data of the first communication channel arrives at the gateway device earlier than the data of other communication channels, control the UART sending module to send the data of the first communication channel to the data processing chip; the other communication channels are the communication channels other than the first communication channel among the N communication channels; The UART time slot control module is also used to: when the data of the first communication channel is sent, detect whether the data of the second communication channel has reached the gateway device; wherein the priority of the second communication channel is lower than the priority of the first communication channel; The UART time slot control module is also used to: when it is detected that the data of the second communication channel arrives at the gateway device, control the UART sending module to send the data of the second communication channel to the data processing chip.

11. The gateway device according to claim 8, characterized in that: The UART sending module is used to: generate a data protocol packet for data of any one of the M communication channels; and send the data protocol packet to the data processing chip; The data protocol packet has a frame header, a data segment and a checksum; the frame header of the data protocol packet is used to store the bus number of the communication channel and the first function code, the bus number of the communication channel is used to determine the priority of the communication channel, and the first function code is used to indicate the transaction type of the data protocol packet; the checksum of the data protocol packet is determined based on the frame header and the data segment; the checksum of the data protocol packet is used to verify the correctness of the data protocol packet.

12. An industrial control system, characterized in that: include: Gateway devices, controllers and multiple input / output IO devices; The gateway device is connected to the controller via Ethernet, and the gateway device is connected to multiple IO devices via a multi-channel CAN bus; the gateway device is used to implement the method described in any one of claims 1-7.

Citation Information

Cited By

  • Method and device for converting UDP protocol to multi-channel UART protocol based on FPGA

    CN120751032A

  • Multi-channel data interaction transmission method and system based on FPGA and MCU collaborative architecture

    CN121486128A

  • Multi-channel data interaction transmission method and system based on FPGA and MCU cooperative architecture

    CN121486128B