A method for constructing a CNC system architecture based on a quad-core processor
By designing a CNC system architecture based on quad-core processors, the impact of domestic multi-core processor structure on the real-time and predictability of CNC systems is solved, and higher performance and autonomous controllability are achieved.
Patent Information
- Application Number
- CN202011277038.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-16
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-11-16
AI Technical Summary
The special structure of domestic multi-core processors leads to competition for shared resources between tasks, affecting the predictability of the time behavior of the CNC system, and thus bringing new challenges to the underlying real-time operating system.
Design a CNC system architecture based on a quad-core processor. By name the four cores of the processor as CPU cores #0, #1, #2, and #3, and isolate CPU cores #2, #3 from CPU cores #0, and #1 to perform real-time tasks. At the same time, a native network card driver is designed to redirect real-time Ethernet bus packets to the user-state real-time component of the user space, and to bind the interrupts of the native network card driver to CPU core #3.
It effectively improves the independent controllability of software and hardware, improves the performance and real-time performance of CNC systems, and reduces the impact of non-real-time tasks on real-time components.
Smart Images

Figure CN114510354B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of numerical control technology, in particular to the field of numerical control system architecture technology of multi-core processors, and specifically to a method for constructing a numerical control system architecture based on a quad-core processor. Background Art
[0002] High-end CNC systems are high-end embedded products and are basic equipment for national industry and national defense. Among them, core components such as CPU chips, industrial motherboards, and operating systems constitute the basic platform of high-end CNC systems and are important components that determine the performance, function, reliability, and cost of high-end CNC systems. At present, these basic platforms used by domestic high-end CNC systems are all foreign products, and their core technologies are still controlled by foreign countries. This has become a key factor affecting industrial security and, in turn, national security. In terms of high-performance general-purpose CPU chips, my country has achieved technological breakthroughs. Domestic multi-core CPU chips have reached a relatively advanced level and have been mass-produced. At the same time, after years of development, domestic CPU chips have gradually built their own software and hardware ecosystems, and the ecosystem has begun to take shape.
[0003] The predictability of CNC system operation and processing is closely related to the real-time performance of the system. In order to achieve real-time performance and ensure that the processing process meets expectations, the underlying CNC system needs to be supported by a real-time system. As the demand for computing power in CNC systems continues to increase, domestic multi-core processors will be widely used in this field. While improving the performance of CNC systems, it also brings new challenges to the underlying real-time operating system. The special structure of multi-core processors will cause tasks to compete for shared resources, thereby affecting the predictability of the system's time behavior. Therefore, how to design a CNC system architecture model based on the structure of domestic multi-core processors and the architecture of open source real-time operating systems has become a technical problem for the application of domestic multi-core processors in CNC systems. Summary of the invention
[0004] In order to solve the above technical problems, the present invention provides a method for constructing a numerical control system architecture based on a quad-core processor.
[0005] The present invention adopts the following technical solution: a numerical control system architecture based on a quad-core processor, comprising:
[0006] At the hardware level, the four cores of the processor used are CPU core #0, #1, #2, and #3. CPU cores #2 and #3 are isolated from CPU cores #0 and #1. CPU cores #2 and #3 are used to execute real-time tasks.
[0007] The kernel space layer includes the native network card driver module, which is used to interact with the peripheral servo driver and I / O data. The interrupt of the network card driver module is bound to the isolated CPU core #3.
[0008] The user space layer includes a human-machine interface component, a task control component, a PLC component, a motion control component, and a real-time Ethernet bus component; the human-machine interface component and the task control component are user-state non-real-time components bound to CPU core #1; the PLC component, the motion control component, and the real-time Ethernet bus component are user-state real-time components, the PLC component is bound to the isolated CPU core #2, and the motion control component and the real-time Ethernet component are bound to the isolated CPU core #3.
[0009] A method for constructing a numerical control system architecture based on a quad-core processor comprises the following steps:
[0010] A. Name the four cores of the processor CPU core #0, #1, #2, and #3, isolate CPU cores #2 and #3, and reserve them for user-mode real-time components;
[0011] B. Design a native NIC driver to redirect real-time Ethernet bus data packets to the user-mode real-time component in user space, and bind the interrupt of the native NIC driver to CPU core #3;
[0012] C. According to the user state component model, the user state functional components of the numerical control system are constructed, including: human-machine interface components, task control components, PLC components, motion control components, and real-time Ethernet bus components. The human-machine interface components and task control components are designed as non-real-time user state components, and the PLC components, motion control components, and real-time Ethernet driver components are designed as user state real-time components;
[0013] D. According to the user-state component communication model, the user-state functional components of the numerical control system are organized into a tree structure, whose structure is as follows: the top root node is the human-machine interface component, its leaf node is the task control component, the two leaf nodes of the task control component are the PLC component and the motion control component, and the leaf node of the motion control component is the real-time Ethernet bus component;
[0014] E. Bind the human-machine interface component and the task control component to CPU core #1, bind the PLC component to CPU core #2, and bind the motion control component and the real-time Ethernet bus component to CPU core #3.
[0015] Establishing communication between user-mode components includes the following steps:
[0016] a. Establish the communication between the human-machine interface component and the task control component: the human-machine interface component transmits the part processing program written in NC voice to the task control component through the command message channel in NML communication; the task control component transmits the actual processing status information to the human-machine interface component through the status message channel in NML communication;
[0017] b. Establish the communication between the task control component and the PLC component: The task control component transmits the I / O control instructions corresponding to the machining operations parsed from the part machining program to the PLC component through the command message channel in the NML communication; at the same time, the PLC component transmits the actual I / O status information to the task control component through the status message channel in the NML communication;
[0018] c. Establish the communication between the task control component and the motion control component: the task control component transmits the motion control instructions corresponding to the machining operations parsed from the part machining program, as well as the setting commands for the motion attributes, to the motion control component through the command message channel in the NML communication; at the same time, the motion control component transmits the actual machining status information to the task control component through the status message channel in the NML communication;
[0019] d. Establish communication between the motion control component and the real-time Ethernet bus component: The motion control component transmits the axis control instructions obtained by interpolation operation of the machining operation to the real-time Ethernet bus component through the command message channel of the shared memory; at the same time, the real-time Ethernet bus component transmits the actual axis status information to the motion control component through the status message channel in the shared memory.
[0020] The construction of the user state component model includes the following steps:
[0021] a. Establish input parameter channel and output parameter channel respectively;
[0022] b. Establish a read communication channel and a write communication channel respectively;
[0023] c. Design functional blocks according to tasks;
[0024] d. Build user-mode real-time threads or non-real-time threads based on the real-time requirements of the task.
[0025] The establishment of a unified user-mode component communication model includes the following steps:
[0026] A command channel for exchanging data between components using messages and a status channel for transferring data through a write communication channel are established respectively.
[0027] A command buffer and a message buffer are established respectively; the message buffer is used to cache messages, and the message buffer is located after the message channel, wherein the command buffer is connected to the command channel, and the status buffer is connected to the status channel.
[0028] The present invention has the following beneficial effects and advantages:
[0029] 1. The adoption of domestic CPU and open source real-time operating system effectively improves the autonomous controllability of software and hardware. The numerical control system of the present invention adopts autonomous and controllable domestic processor chips and open source operating systems, adopts the "Loongson" 3A high-performance processor based on the MIPS architecture for system hardware, and adopts the Linux+RT Preempt real-time preemption patch solution for real-time systems, which improves the autonomous controllability of the numerical control system in the underlying hardware and upper-level software.
[0030] 2. Functional module design technology based on user-mode components. CNC functional components are in user space, and the use of floating-point operations is more convenient and flexible. The CNC system is a floating-point operation-intensive digital control system. Whether the floating-point operation is flexible and efficient directly determines the performance of the CNC system. Combined with the real-time application characteristics of the RT Preempt Linux operating system, the kernel components of the CNC system are moved to the user space, and a unified user-mode component model is established. The floating-point operation library functions provided by the user space can be effectively used for floating-point operations, making floating-point operations flexible and convenient.
[0031] 3. Message communication technology based on named channels. By establishing a virtual named channel for communication between components, the specific data transmission and synchronization operation details are hidden, and the transparent transmission of messages is realized. In the named channel, both local communication and network-based remote communication are supported, so that components do not need to care about their specific location, but only need to receive or send data from a specific named channel.
[0032] 4. Make full use of the multi-core advantage of the processor and effectively improve the performance of the CNC system. The performance of the CNC system is closely related to the underlying operating system and the multi-core structure of the CPU. Designing the CNC system architecture for the real-time operating system and the CPU multi-core structure can effectively improve the performance of the system. At the same time, combined with the real-time application characteristics of the RT PreemptLinux operating system, the real-time components and non-real-time components are separated, and different components are bound to different specified CPU cores, which can effectively reduce the impact of non-real-time tasks on real-time components and improve the real-time performance of the CNC system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a user-mode component model diagram;
[0034] Figure 2 It is a diagram of the user-mode component communication model;
[0035] Figure 3 It is the model diagram of the CNC system architecture;
[0036] Figure 4 It is a flow chart of the present invention;
[0037] Figure 5 This is a real-time Ethernet bus network structure diagram based on AF_XDP;
[0038] Figure 6 This is a diagram of the packet capture processing method based on AF_XDP;
[0039] Figure 7 It is a real-time Ethernet bus network structure diagram based on raw sockets;
[0040] Figure 8 This is a diagram of a packet capture processing method based on a raw socket;
[0041] Fig. 9 This is a real-time Ethernet bus network structure diagram based on the network card;
[0042] Fig.10 This is a diagram of the packet capture processing method based on the network card. DETAILED DESCRIPTION
[0043] The implementation of the method of the present invention is further described in detail below with reference to the accompanying drawings.
[0044] The described method for designing the architecture of a numerical control system based on a quad-core processor, the "Loongson 3A" quad-core processor includes: Loongson 3A1000, Loongson 3A2000, Loongson 3A3000, Loongson 3A4000 and subsequent Loongson 3A quad-core series;
[0045] The CNC system architecture model based on the quad-core processor is divided into three layers:
[0046] 1) Hardware layer: The four cores of the "Loongson 3A" processor are named CPU core #0, #1, #2, and #3 respectively. CPU cores 2 and 3 are isolated from CPU cores 0 and 1 and are used to execute real-time tasks.
[0047] 2) Kernel space layer: includes the native network card driver module, which is used to interact with the peripheral servo driver and I / O data. The interrupt of the network card driver module is bound to the isolated CPU core #3.
[0048] 3) User space layer: including human-machine interface components, task control components, PLC components, motion control components, real-time Ethernet bus components and components. Among them, the human-machine interface components and task control components are user-state non-real-time components bound to CPU core #1; PLC components, motion control components and real-time Ethernet bus components are user-state real-time components, PLC components are bound to isolated CPU core #2, and motion control components and real-time Ethernet components are bound to isolated CPU core #3.
[0049] User-state components include: user-state real-time components and user-state non-real-time components. The difference between user-state real-time components and non-real-time components lies in whether a real-time thread or a non-real-time thread is constructed when a user-state thread is constructed. If a real-time thread is constructed, it is a real-time component, and if a non-real-time thread is constructed, it is a non-real-time component.
[0050] like Figure 4 As shown, the numerical control system architecture design method based on a quad-core processor includes the following steps:
[0051] 1) Use the Loongson 3A processor and the compatible open source Linux operating system, select the matching RTPreempt real-time preemption patch, and build a real-time Linux operating system;
[0052] 2) Design a unified user-mode component model based on the characteristics of real-time applications in RT Preempt Linux systems;
[0053] 3) Based on the user-mode component model established in step 2), a unified user-mode component communication model is designed;
[0054] 4) Based on the user-mode component model and component communication model established in step 2) and step 3), combined with the quad-core structure of the "Loongson 3A" processor, a numerical control system architecture model is designed.
[0055] The Loongson 3A processor and the compatible open source Linux operating system are used, and the compatible open source Linux operating system includes: the official version of the Linux operating system of the Loongson processor and the official version of the Linux operating system of the Aerospace Dragon Dream processor;
[0056] The RT Preempt real-time preemption patch matching the above is selected, and the RT Preempt real-time preemption patch is an open source real-time preemption patch that is updated synchronously with the main line of the Linux kernel;
[0057] According to the characteristics of real-time applications of RT Preempt Linux system, a unified kernel user mode component model is designed, and the component model is divided into real-time components and non-real-time components;
[0058] According to the characteristics of real-time applications of the RT Preempt Linux system, a unified kernel user-mode component model is designed, and all component models run in the user space of the RT Preempt Linux system;
[0059] According to the characteristics of real-time applications of the RT Preempt Linux system, a unified kernel user state component model is designed, in which the user state component model includes:
[0060] A. Parameter channel: used for parameter transmission, divided into input channel and output channel. The input channel is used for parameter configuration, and the output channel is used for parameter sampling.
[0061] B. Communication channel: used for component data interaction, divided into read and write communication channels, where the read channel is used to receive data from other components and the write channel is used to send data to other components.
[0062] C. Function block: A specific collection of functions used to perform a specific task.
[0063] D. User-mode thread: used to schedule the execution of a series of functions in a function block in user space. It is divided into user-mode real-time threads and non-real-time threads. Real-time threads are used for real-time components, and non-real-time threads are used for non-real-time components.
[0064] According to the characteristics of real-time applications in RT Preempt Linux system, a unified kernel user
[0065] The design method of the user-mode component model includes the following steps:
[0066] e. Establish input and output parameter channels respectively;
[0067] f. Establish read and write communication channels respectively;
[0068] g. Design functional blocks according to specific tasks;
[0069] h. Design user-mode real-time threads or non-real-time threads according to the real-time requirements of the task;
[0070] According to the user state component model established in step 2), a unified user state component communication model is designed, and the user state component communication model includes:
[0071] A. Message channel: Based on the user-mode component model, messages are used to exchange data between components. The data transmission of the read communication channel uses command messages and is defined as the command channel.
[0072] The data transmission of the write communication channel adopts status messages and is defined as a status channel.
[0073] B. Message buffer: The message buffer is used to cache messages. The message buffer is located after the message channel. The command buffer is connected to the command channel, and the status buffer is connected to the status channel.
[0074] C. Tree-like organizational structure: User-mode components adopt a tree-like organizational structure, and the communication between parent and child components is
[0075] That is, the message communication between the parent and child nodes, and the message buffer is located in the child node.
[0076] According to the user state component model established in step 2), a unified user state component communication model is designed. The design method of the user state component communication model includes the following steps:
[0077] a. Establish the command and status channels of the message respectively;
[0078] b. Establish command buffer and message buffer respectively;
[0079] The user state component model and component communication model established according to step 2) and step 3) are combined with the quad-core structure of the "Loongson 3A" processor to design a numerical control system architecture model. The design method of the numerical control system architecture model includes the following steps:
[0080] A. Name the four cores of the "Loongson 3A" processor CPU core #0, #1, #2 and #3 respectively, isolate CPU cores #2 and #3 and reserve them for real-time components;
[0081] B. Design a native NIC driver to redirect real-time Ethernet bus packets to the real-time component in user space and bind the interrupt of the native NIC driver to CPU core #3;
[0082] C. According to the user state component model and combined with the CNC system functions, the CNC system user state functional components are designed, including: human-machine interface components, task control components, PLC components, motion control components, and real-time Ethernet bus components. The human-machine interface components and task control components are designed as non-real-time user state components, and the PLC components, motion control components, and real-time Ethernet driver components are designed as real-time components. Among them:
[0083] a. Human-computer interface component: used to perform human-computer interaction functions.
[0084] The functional block design of the human-machine interface component includes: human-machine interface development environment based on the openSCADA open source system, design of information visualization function, manual operation function, processing program input function and other modules.
[0085] User-mode thread design of human-computer interface components: Based on the RCS library, design user-mode non-real-time threads.
[0086] b. Task control component: used for parsing and processing of part processing programs.
[0087] The functional block design of the task control component includes: functional modules based on the LinuxCNC open source system, design interpreter function, standard processing function, command queue function, command processing function and other modules.
[0088] The user-mode thread design of the task control component includes: designing user-mode non-real-time threads based on the RCS library.
[0089] c.PLC component: used for I / O control.
[0090] The functional block design of PLC components includes: functional modules based on LinuxCNC open source system, designing logic control functions, PLC task scheduling functions, digital input / output functions, analog input / output functions and other modules.
[0091] The user-mode thread design of the PLC component includes: designing a user-mode real-time thread based on the RT Preempt real-time preemption patch.
[0092] d. Motion control component: used to complete the relative motion control between the tool and the workpiece.
[0093] The functional block design of the motion control component includes: functional modules based on the LinuxCNC open source system, designing modules such as trajectory planning function, linear acceleration and deceleration control function, interpolation control function, coordinate conversion function, and PID control function.
[0094] The user-mode thread design of the motion control component includes: designing a user-mode real-time thread based on the RT Preempt real-time preemption patch.
[0095] e. Real-time Ethernet bus component: used to parse and encapsulate network data packets.
[0096] The functional block design of real-time Ethernet components includes: based on the IGH EtherCAT Master open source component, designing modules such as process data function, mailbox function, distributed clock function, and EtherCAT state machine function.
[0097] The user-mode thread design of the real-time Ethernet component includes: designing the user-mode real-time thread based on the RT Preempt real-time preemption patch.
[0098] D. According to the user-state component communication model, the user-state functional components of the CNC system are organized into a tree structure, whose structure is: the top root node is the human-machine interface component, its leaf node is the task control component, the two leaf nodes of the task control component are the PLC component and the motion control component, and the leaf node of the motion control component is the real-time Ethernet bus component. Among them:
[0099] a. Communication design between human-machine interface components and mission control components: Based on the NML communication mechanism of the RCS library, design the communication between the human-machine interface components and the mission control components.
[0100] The human-machine interface component transmits the part processing program written in NC voice to the task control component through the command message channel in the NML communication mechanism; the task control component transmits the actual processing status information to the human-machine interface component through the status message channel in the NML communication mechanism.
[0101] b. Communication design between task control component and PLC component: Based on the NML communication mechanism of RCS library, design the communication between task control component and PLC component.
[0102] The task control component transmits the I / O control instructions corresponding to the standard processing operations (tool selection and replacement, turning on and off coolant, opening and closing doors, etc.) parsed from the part processing program to the PLC component through the command message channel in the NML communication mechanism; at the same time, the PLC component transmits the actual I / O status information to the task control component through the status message channel in the NML communication mechanism.
[0103] c. Communication design between task control component and motion control component: Based on the NML communication mechanism of RCS library, design the communication between task control component and motion control component.
[0104] The task control component transmits the motion control instructions corresponding to the standard machining operations (rapid movement, linear feed, arc feed, spindle rotation, etc.) parsed from the part machining program, as well as the setting commands for motion properties such as machining plane and feed rate, to the motion control component through the command message channel in the NML communication mechanism; at the same time, the motion control component transmits the actual machining status information to the task control component through the status message channel in the NML communication mechanism.
[0105] d. Communication design between motion control components and real-time Ethernet bus components: Based on the shared memory mechanism, design the communication between motion control components and real-time Ethernet bus components.
[0106] The motion control component transmits the axis control instructions (position, speed, torque, etc.) obtained by the interpolation calculation of the standard processing operation to the real-time Ethernet bus component through the command message channel of the shared memory; at the same time, the real-time Ethernet bus component transmits the actual axis status information to the motion control component through the status message channel in the shared memory mechanism.
[0107] E. Bind the human-machine interface component and the task control component to CPU core #1, bind the PLC component to CPU core #2, and bind the motion control component and the real-time Ethernet bus component to CPU core #3.
[0108] like Figure 1 As shown, the user-mode component model and design method include:
[0109] Parameter channel design: used for parameter transfer, divided into input channel and output channel, where the input channel is used for parameter configuration, and the output channel is used for parameter sampling. Specifically, the parameters are transferred by reading and writing files and shared memory.
[0110] Communication channel design: used for component data interaction, divided into read and write communication channels, where the read channel is used to receive data from other components, and the write channel is used to send data to other components. Specifically, shared memory or neutral message methods are used for data exchange.
[0111] Function block design: A specific set of functions used to perform specific tasks. The function set is written in C and C++ languages according to the functional modules of the CNC system.
[0112] User-mode thread design: used to schedule the execution of a series of functions in a functional block in user space. It is divided into user-mode real-time threads and non-real-time threads. Real-time threads are used for real-time components, and non-real-time threads are used for non-real-time components. Specifically, periodic real-time threads are created according to the programming specifications of the RT Preempt real-time preemption patch, and periodic and non-periodic non-real-time threads are created according to the programming specifications of the Linux system.
[0113] like Figure 2 As shown, the user-mode component communication model and design method include:
[0114] Message channel design: Based on the user-mode component model, messages are used to exchange data between components. The data transmission of the read communication channel adopts command messages, which are defined as command channels; the data transmission of the write communication channel adopts status messages, which are defined as status channels. The command channel and status channel are defined in a cross-platform unified format to achieve platform independence of message transmission. Command messages are passed from upper-level modules to lower-level modules, that is, the upper-level modules request the execution of an operation. Status messages are passed from lower-level modules to their parent modules. The transmitted messages are data information reflecting the current status characteristics of the lower-level modules.
[0115] Message buffer design: The message buffer is used to cache messages. The message buffer is located after the message channel. The command buffer is connected to the command channel, and the status buffer is connected to the status channel. The message buffer uses a circular queue and works in producer and consumer mode. On the one hand, the upper-layer component writes the command message to the lower-layer command circular queue, and the lower-layer component reads the command message from the circular queue; on the other hand, the lower-layer buffer writes the status to the status circular queue, and the upper-layer component reads the status from the circular queue. Data reading adopts polling mode to ensure data consistency between upper and lower-layer components.
[0116] Tree-like organizational structure design: User-mode components adopt a tree-like organizational structure. The communication between parent and child components is the message communication between parent and child nodes, and the message buffer is located in the child node. The corresponding relationship between parent and child components is a one-to-many structure. A parent node component can have multiple child node components, and a child node component has one and only one parent node component.
[0117] like Figure 3 As shown, the CNC system architecture model and design method include:
[0118] CPU core isolation settings: The four cores of the "Loongson 3A" processor are named CPU cores #0, #1, #2, and #3, and CPU cores #2 and #3 are isolated and reserved for real-time components. Specifically, the isolcus=2,3 command of the Linux system is used to isolate CPU cores #2 and #3;
[0119] Native NIC driver design: redirect real-time Ethernet bus data packets to the real-time components in the user space, bind the periodic interrupts in the native NIC driver to CPU core #3, and specifically use the IRQ Affinity mechanism of the Linux system to bind the periodic interrupts to CPU core #3;
[0120] Design of user-state functional components of CNC system: Based on the user-state component model and combined with the functions of CNC system, the user-state functional components of CNC system are designed, including human-machine interface components, task control components, PLC components, motion control components, and real-time Ethernet bus components. Human-machine interface components and task control components are designed as non-real-time user-state components, and PLC components, motion control components, and real-time Ethernet driver components are designed as real-time components. The user-state components are redesigned by moving the kernel components of PLC components, motion control components, and real-time Ethernet bus components to user space.
[0121] Communication design of user-state functional components of CNC system: According to the user-state component model, the user-state functional components of CNC system are organized into a tree structure. The top root node is the human-machine interface component, and its leaf node is the task control component. The two leaf nodes of the task control component are the PLC component and the motion control component respectively. The leaf node of the motion control component is the real-time Ethernet bus component. The communication channel in the user-state component model is refined into a neutral message communication method to realize the communication between the user-state functional components of the CNC system.
[0122] CPU core binding settings: Use the CPU Affinity mechanism of the Linux system to bind the human-machine interface component and the task control component to CPU core #1, the PLC component to CPU core #2, and the motion control component and the real-time Ethernet bus component to CPU core #3.
[0123] The data packet processing method in the native network card driver can adopt one of the following three methods: a real-time Ethernet fieldbus data packet processing method based on AF_XDP, a real-time Ethernet fieldbus data packet processing method based on raw sockets, and a real-time Ethernet fieldbus network data packet processing method of a base network card.
[0124] 1. A real-time Ethernet fieldbus data packet processing method based on AF_XDP comprises the following steps:
[0125] Enable the kernel debugging function, determine the transmission path of the real-time Ethernet field bus data packet in the native network card driver through the debugging information output by the kernel, and establish a capture point for the real-time Ethernet bus data packet at the network card driver entrance;
[0126] For the real-time Ethernet bus data packet capture point at the network card driver entrance, the real-time Ethernet bus data packet is captured and forwarded based on the XDP mechanism, and the real-time Ethernet bus data packet is sent to the real-time Ethernet bus component;
[0127] According to the bus protocol type to which the real-time Ethernet bus data packet belongs, the real-time Ethernet bus data packet is parsed and processed in the real-time Ethernet bus component in the user space.
[0128] The real-time Ethernet fieldbus data packet type includes any one of the EtherCAT protocol and the SSB-III protocol.
[0129] The capture point is located before the network card driver establishes the socket buffer.
[0130] The capture and forwarding of real-time Ethernet bus data packets based on the XDP mechanism are specifically as follows:
[0131] Adopt the real-time Ethernet bus data packet receiving interrupt event to trigger XDP to process the real-time Ethernet bus data packet;
[0132] By using the redirection function of XDP, the real-time Ethernet bus data packet is directly redirected to the real-time Ethernet bus component of the user space in a zero-copy manner using the MMAP memory mapping method of AF_XDP.
[0133] The parsing process of the real-time Ethernet bus data packet in the real-time Ethernet bus component of the user space is specifically as follows:
[0134] Establish a user-state real-time thread and set the real-time thread as a periodic real-time thread, and complete the parsing and processing of real-time Ethernet bus data packets in each real-time cycle of the user-state real-time thread;
[0135] At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet bus data packet is obtained by polling using the original socket of PF_XDP;
[0136] Parsing an Ethernet protocol data packet header in a real-time thread of a user-mode real-time Ethernet bus component to determine a real-time Ethernet bus data packet type;
[0137] Parsing instruction data of a real-time Ethernet bus data packet according to the type of the real-time Ethernet bus data packet;
[0138] Organize the parsed instruction data into NML neutral message commands, and exchange data with the real-time application in the user space through the message communication channel of the user-mode real-time Ethernet bus component;
[0139] Waiting for the next cycle to poll the real-time Ethernet bus data packet.
[0140] The command data of the EtherCAT protocol includes periodic command data and non-periodic command data. The periodic command data uses the process data of the EtherCAT protocol for data transmission, and is divided into periodic command data and status data according to the transmission direction. The non-periodic command data uses the mailbox of the EtherCAT protocol for data transmission, and is divided into non-periodic command data and status data according to the transmission direction.
[0141] The command data of the SSB-III protocol includes periodic command data and non-periodic command data, and both types of data are transmitted via mailboxes.
[0142] This method is suitable for application in the field of numerical control systems, especially for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets, and specifically for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets in high-end numerical control systems. The real-time Ethernet fieldbus network data packet processing method based on AF_XDP includes the following steps:
[0143] 1) Determine the transmission path of the real-time Ethernet field bus data packet in the native network card driver, and establish a capture point of the real-time Ethernet bus data packet at the network card driver entrance;
[0144] 2) Establish a network data packet capture method based on the XDP mechanism for the network data packet capture point at the network card driver entrance;
[0145] 3) According to the XDP packet capture method, a network packet forwarding method based on the AF_XDP mechanism is established;
[0146] 4) Design a method for parsing and processing data packets in the real-time Ethernet bus component in user space according to the bus protocol type to which the data packets belong;
[0147] The transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack is determined, and the real-time Ethernet field bus is EtherCAT and SSB-III;
[0148] The determination of the transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack, the network card is an XDP supported network card;
[0149] The capture point of the real-time Ethernet bus data packet established at the network card driver entrance is located before the network card driver establishes the socket buffer;
[0150] The method for establishing a data packet capture and forwarding method based on AF_XDP, the bpf_redirect_map() method of XDP redirects the real-time Ethernet bus data packet to the real-time Ethernet bus component of the user space in a zero-copy manner;
[0151] The method for establishing a data packet capture and forwarding method based on AF_XDP adopts the programming method of the original socket of PF_XDP;
[0152] The method for establishing a data packet capture and forwarding method based on AF_XDP, AF_XDP adopts the mmap mechanism;
[0153] The method for establishing a data packet capture and forwarding method based on AF_XDP is characterized in that the data packet capture method comprises the following steps:
[0154] a. Use real-time Ethernet data packet reception interrupt event to trigger XDP to process data packets;
[0155] b. Using the redirection function of XDP, the data packet is directly redirected to the real-time Ethernet bus component in the user space in a zero-copy manner using the AF_XDP mechanism;
[0156] The method for parsing and processing a data packet in a real-time Ethernet bus component designed in user space is characterized in that the method for parsing and processing a data packet comprises the following steps:
[0157] a. Establish a user-state real-time thread and set the real-time thread to a periodic real-time thread. In each user-state thread's real-time cycle, complete the parsing and processing of real-time Ethernet field bus data packets;
[0158] b. At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet data packet is obtained by polling using the original socket of PF_XDP;
[0159] c. Parsing the Ethernet protocol packet header in the real-time thread of the user-mode real-time Ethernet bus component to determine the real-time Ethernet packet type;
[0160] d. Parsing the instruction data of the data packet according to the data packet type;
[0161] e. Organize the parsed instruction data into message commands, and exchange data with the upper-level motion control component through the message communication channel of the real-time Ethernet component; wherein the upper-level motion control component is a real-time application program used for trajectory planning, acceleration and deceleration control, and interpolation calculation.
[0162] f. Wait for the next cycle to poll the data packet.
[0163] like Figure 5 As shown, the network structure of the real-time Ethernet field bus based on AF_XDP is the left half of the figure. By default, the network data packet will first pass through the network card driver and the network protocol stack in the kernel space, and then pass through the AF_INET socket or the AF_PACKET standard socket to be sent to the application in the user space. The present invention sets a capture point for the real-time Ethernet bus data packet at the entrance of the network card driver, triggers the XDP processing program through the data reception interrupt, adopts the bpf_redirect_map() redirection function of XDP and the mechanism mmap method of AF_XDP to directly redirect the EtherCAT and SSB-III real-time Ethernet bus data packets to the real-time Ethernet bus component in the user space in a zero-copy manner, and parses and processes the data packets in the user-state real-time Ethernet bus component.
[0164] The data flow structure of the real-time Ethernet fieldbus based on AF_XDP is as follows Figure 1 As shown in the right half of the figure, the real-time Ethernet data packets are directly redirected to the circular queue of the user space in a DMA manner through the mmap mechanism of AF_XDP. The real-time thread in the upper-level real-time Ethernet bus component reads the real-time Ethernet data packets in the circular queue through the polling mechanism. The data packets are parsed and processed in the real-time Ethernet bus component, and finally exchange data with the upper-level motion control component through the message communication channel of the real-time Ethernet component.
[0165] like Figure 6 As shown, the specific implementation steps of the capture and processing method of the real-time Ethernet field bus data packet based on AF_XDP include:
[0166] A. Use real-time Ethernet data packet reception interrupt event to trigger XDP to process data packets;
[0167] B. Use the bpf_redirect_map() redirection function of XDP to redirect the data packet directly to the real-time Ethernet bus component in user space in a zero-copy manner using the AF_XDP mechanism;
[0168] C. Establish a user-state real-time thread and set the real-time thread as a periodic real-time thread. In each real-time cycle of the user-state thread, complete the parsing and processing of the real-time Ethernet field bus data packet;
[0169] C. At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet data packet is obtained by polling using the original socket of PF_XDP;
[0170] D. Parse the Ethernet protocol packet header in the real-time thread of the user-mode real-time Ethernet bus component to determine the type of the real-time Ethernet packet, which includes EtherCAT, SSB-III and other real-time Ethernet protocols;
[0171] E. Parse the command data of the data packet according to the data packet type, where the command data of the EtherCAT protocol includes periodic command data and non-periodic command data. The periodic command data uses the process data of the EtherCAT protocol for data transmission, which is divided into periodic command data and status data according to different transmission directions. The non-periodic command data uses the mailbox of the EtherCAT protocol for data transmission, which is divided into non-periodic command data and status data according to different transmission directions. The SSB-III protocol is similar to the EtherCAT protocol, and the command data also includes periodic command data and non-periodic command data. The difference is that the SSB-III protocol uses mailboxes for data transmission for both types of data.
[0172] F. Organize the parsed instruction data into message commands, and exchange data with the upper-layer motion control component through the message communication channel of the real-time Ethernet component;
[0173] G. Wait for the next cycle to poll the data packet.
[0174] The real-time Ethernet fieldbus uses a standard network card to transmit data packets. In existing CNC systems, the real-time Ethernet fieldbus still uses traditional communication boards to transmit bus data. Different fieldbuses (such as EtherCAT, SSB-III real-time Ethernet bus, etc.) correspond to different communication boards. For each fieldbus, a set of corresponding hardware boards must be developed, making the system bloated and non-reusable.
[0175] Capturing real-time Ethernet bus data packets at the entrance of the network card driver and redirecting them to the user space can effectively reduce system latency and jitter. The XDP-based mechanism is used to capture real-time Ethernet bus data at the entrance of the network card driver, and the AF_XDP-based mechanism is used to directly redirect the network data packets of the real-time Ethernet fieldbus protocol to the real-time Ethernet bus component in the user space in a zero-copy manner, avoiding multiple data copies of the data packets in the driver and kernel, reducing system latency; at the same time, it avoids the transmission of data packets in the kernel protocol stack, reducing system jitter.
[0176] 2. A real-time Ethernet fieldbus data packet processing method based on raw sockets, wherein the raw sockets adopt the PACKET_MMAP method, comprising the following steps:
[0177] According to the debugging information output by the kernel, determine the transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack, and establish a capture point for the real-time Ethernet bus data packet at the entrance of the kernel network protocol stack;
[0178] According to the real-time Ethernet bus data packet capture point at the kernel network protocol stack entrance, a real-time Ethernet bus data packet forwarding method based on PACKET_MMAP is established to map the real-time Ethernet bus data packet to the real-time Ethernet bus component;
[0179] According to the bus protocol type to which the real-time Ethernet bus data packet belongs, the real-time Ethernet bus data packet is parsed in the real-time Ethernet bus component of the user space.
[0180] The real-time Ethernet fieldbus data packet type includes any one of the EtherCAT protocol and the SSB-III protocol.
[0181] The capture point is located before the real-time Ethernet bus data packet is sent to the kernel protocol stack.
[0182] The method for establishing a real-time Ethernet bus data packet forwarding method based on PACKET_MMAP is specifically as follows:
[0183] Open up static memory in kernel space for storing real-time Ethernet bus data packets;
[0184] Shield the receiving interrupt generated when the real-time Ethernet bus data packet in the network card is mapped to the ring queue;
[0185] By continuously polling the network card, the real-time Ethernet bus data packets in the ring queue are read into the static memory opened up;
[0186] At the entrance of the kernel network protocol stack, the transmission of real-time Ethernet bus data packets to the kernel network protocol stack is shielded;
[0187] The real-time Ethernet bus data packets obtained by polling are mapped to the user space using the MMAP memory mapping method of PACKET_MMAP.
[0188] The reception of real-time Ethernet bus data is done in an interrupt-free manner.
[0189] The real-time Ethernet bus number is read using polling.
[0190] The specific steps of parsing the real-time Ethernet bus data packet in the real-time Ethernet bus component of the user space are as follows:
[0191] Establish a user-state real-time thread and set the real-time thread as a periodic real-time thread, and complete the parsing and processing of the real-time Ethernet field bus data packet in each real-time cycle of the user-state real-time thread;
[0192] At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet bus data packet is polled by using the PACKET_MMAP raw socket method;
[0193] Parsing an Ethernet protocol data packet header in a real-time thread of a user-mode real-time Ethernet bus component to determine a real-time Ethernet bus data packet type;
[0194] Parsing instruction data of a real-time Ethernet bus data packet according to the type of the real-time Ethernet bus data packet;
[0195] Organize the parsed instruction data into NML neutral message commands, and exchange data with the real-time application in the user space through the message communication channel of the user-mode real-time Ethernet bus component;
[0196] Waiting for the next cycle to poll the real-time Ethernet bus data packet.
[0197] This method is suitable for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets, and is specifically suitable for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets in low-end and medium-end CNC systems. The real-time Ethernet fieldbus network data packet processing method based on PACKET_MMAP includes the following steps:
[0198] 1) Determine the transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack, and establish a capture point of the real-time Ethernet bus data packet at the entrance of the kernel network protocol stack;
[0199] 2) Establish a network data packet forwarding method based on PACKET_MMAP;
[0200] 3) According to the bus protocol type to which the data packet belongs, design a method for parsing and processing the data packet in the real-time Ethernet bus component in the user space;
[0201] The transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack is determined, and the real-time Ethernet field bus is EtherCAT and SSB-III;
[0202] The transmission path of the real-time Ethernet field bus data packet from the network card driver to the kernel network protocol stack is determined, and the network card is any model of network card;
[0203] The capture point of the real-time Ethernet bus data packet established at the entrance of the kernel network protocol stack is located before the data is sent to the kernel protocol stack;
[0204] The method for establishing a packet capture and forwarding method based on PACKET_MMAP, PACKET_MMAP uses the programming method of raw sockets;
[0205] The method for establishing a packet capture and forwarding method based on PACKET_MMAP is characterized in that the packet capture method comprises the following steps:
[0206] a. Open up a static memory in kernel space to store Ethernet packets;
[0207] b. Data is received in a non-interruptible manner, and the reception interrupt generated by the network card DMA data packet to the ring queue is shielded;
[0208] c. Data is read in a polling manner. By continuously polling the network card device, the data in the ring queue is read into the newly opened memory;
[0209] d. At the entrance of the kernel network protocol stack, shield the transmission of data packets to the kernel network protocol stack;
[0210] e. Use the mmap mechanism of PACKET_MMAP to map the polled data packets to the user space;
[0211] The method for parsing and processing a data packet in a real-time Ethernet bus component designed in user space is characterized in that the method for parsing and processing a data packet comprises the following steps:
[0212] a. Establish a user-state real-time thread and set the real-time thread to a periodic real-time thread. In each user-state thread's real-time cycle, complete the parsing and processing of real-time Ethernet field bus data packets;
[0213] b. At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet data packet is obtained by polling using the PACKET_MMAP raw socket;
[0214] c. Parsing the Ethernet protocol packet header in the real-time thread of the user-mode real-time Ethernet bus component to determine the real-time Ethernet packet type;
[0215] d. Parsing the instruction data of the data packet according to the data packet type;
[0216] e. Organize the parsed instruction data into message commands, and exchange data with the upper-level motion control component through the message communication channel of the real-time Ethernet component. The upper-level motion control component is a real-time application used for trajectory planning, acceleration and deceleration control, and interpolation calculation.
[0217] f. Wait for the next cycle to poll the data packet.
[0218] like Figure 7 As shown, the network structure of the real-time Ethernet field bus based on PACKET_MMAP is the left half of the figure. By default, the network data packet will first pass through the network card driver and network protocol stack in the kernel space, and then pass through the AF_INET socket or the AF_PACKET standard socket to be sent to the application in the user space. The present invention sets a data packet capture point at the entrance of the kernel network protocol stack, shields the transmission of the real-time Ethernet bus data packet to the kernel protocol stack, and uses the original socket of PACKET_MMAP to directly forward the EtherCAT and SSB-III real-time Ethernet data packets to the real-time Ethernet bus component in the user space, and parses and processes the data packet in the user-state real-time Ethernet bus component.
[0219] The data flow structure of the real-time Ethernet fieldbus based on PACKET_MMAP is as follows Figure 7 As shown in the right half of the figure, the real-time Ethernet data packet is DMAed between the network cards to the circular queue inside the native network card driver. The real-time Ethernet bus data packet in the circular queue is mapped to the circular queue in the user space through the mmap mechanism of PACKET_MMAP in a polling manner. The real-time thread in the upper-level real-time Ethernet bus component reads the real-time Ethernet data packet in the circular queue through the polling mechanism. The data packet will be parsed and processed in the real-time Ethernet bus component, and finally exchange data with the upper-level motion control component through the message communication channel of the real-time Ethernet component.
[0220] like Figure 8 As shown, the specific implementation steps of the capture and processing method of the real-time Ethernet field bus data packet based on PACKET_MMAP include:
[0221] A. Statically allocate a memory area in the kernel space for storing Ethernet data packets;
[0222] B. Data is received in a non-interrupt manner, and the reception interrupt generated by the network card DMA data packet to the ring queue is shielded;
[0223] C. The data is read using the poll mechanism, which continuously polls the network card device to read the data in the ring queue into the newly opened memory;
[0224] D. At the entrance of the kernel network protocol stack, the transmission of data packets to the kernel network protocol stack is blocked by blocking the netif_receive_skb() kernel network protocol stack interface;
[0225] E. Use the mmap mechanism of PACKET_MMAP to map the polled data packets to the user space;
[0226] F. Use the real-time thread creation method of the RT_Preempt real-time patch to establish a user-state real-time thread and set the real-time thread as a periodic real-time thread. In the real-time cycle of each user-state thread, complete the parsing and processing of the real-time Ethernet field bus data packet;
[0227] G. At the beginning of the real-time thread of the user-mode real-time Ethernet bus component, the real-time Ethernet data packet is obtained by polling using the PACKET_MMAP raw socket;
[0228] H. Parse the Ethernet protocol data packet header in the real-time thread of the user-mode real-time Ethernet bus component to determine the type of the real-time Ethernet data packet, which includes EtherCAT, SSB-III and other real-time Ethernet protocols;
[0229] I. Parse the command data of the data packet according to the data packet type, wherein the command data of the EtherCAT protocol includes periodic command data and non-periodic command data, the periodic command data uses the process data of the EtherCAT protocol for data transmission, and is divided into periodic command data and status data according to different transmission directions, and the non-periodic command data uses the mailbox of the EtherCAT protocol for data transmission, and is divided into non-periodic command data and status data according to different transmission directions; the SSB-III protocol is similar to the EtherCAT protocol, and the command data also includes periodic command data and non-periodic command data, but the difference is that the SSB-III protocol uses mailboxes for data transmission for both types of data;
[0230] J. Organize the parsed instruction data into message commands, and exchange data with the upper-layer motion control component through the message communication channel of the real-time Ethernet component;
[0231] K. Wait for the next cycle to poll the data packet.
[0232] The real-time Ethernet fieldbus uses a standard network card to transmit data packets, effectively reducing the types and structures of hardware communication boards. In existing CNC systems, the real-time Ethernet fieldbus still uses traditional communication boards to transmit bus data. Different fieldbuses (such as EtherCAT, SSB-III real-time Ethernet bus, etc.) correspond to different communication boards. For each fieldbus, a set of corresponding hardware boards must be developed, making the system bloated and non-reusable.
[0233] Capturing and forwarding real-time Ethernet bus data packets at the entrance of the kernel network protocol stack avoids dependence on the network card driver, has good compatibility, and is more convenient and flexible to use. Using the PACKET_MMAP memory mapping mechanism, all network data packets of the real-time Ethernet fieldbus protocol are shared with the real-time Ethernet bus component in the user space. Data packet capture is performed at the entrance of the network protocol stack, which does not depend on a specific network card, making it more convenient and flexible.
[0234] The reception of real-time Ethernet data packets adopts a non-interrupt mode, avoiding the switching of interrupt context, improving the efficiency of data packet processing, and reducing system latency. The control structure of the real-time Ethernet fieldbus is a master-slave control mode. In the real-time Ethernet fieldbus network, the CNC system is the master station device that controls the network, and the slave station is the controlled servo drive and I / O, etc. The network communication is all initiated by the master station. Therefore, the master station will receive the data packet fed back by the slave station within a certain period of time after sending the data packet, so the polling method can be used to receive the data packet to reduce the context switching caused by the interrupt.
[0235] 3. A method for processing a real-time Ethernet fieldbus network data packet of a base network card, comprising the following steps:
[0236] Through the debugging information output by the kernel debugging function, the transmission path of the real-time Ethernet field bus data packet in the native network card driver is determined, and the capture point of the real-time Ethernet bus data packet is established inside the network card driver;
[0237] For the real-time Ethernet bus data packet capture point established inside the network card driver, the real-time Ethernet bus data packets are captured based on the native network card driver;
[0238] According to the bus protocol type to which the real-time Ethernet bus data packet belongs, the real-time Ethernet bus data packet is parsed and processed in the native network card driver;
[0239] According to the parsed real-time Ethernet bus data, data exchange is performed between the underlying driver based on the memory mapping mechanism and the real-time application program in the user space.
[0240] The real-time Ethernet fieldbus data packet type includes any one of the EtherCAT protocol and the SSB-III protocol.
[0241] The network card is a MAC controller plus a PHY chip control structure.
[0242] The capture point is located after the ring queue mapped by the network card DMA.
[0243] The capture of real-time Ethernet bus data packets based on the native network card driver is specifically as follows:
[0244] Open up static memory in kernel space for storing real-time Ethernet bus data packets;
[0245] Select the interrupt source, set the interrupt to periodic trigger and set the interrupt period. In the interrupt service routine, complete the capture of the real-time Ethernet field bus data packets.
[0246] Data is received in a non-interruptible manner, shielding the reception interruption generated when the real-time Ethernet bus data packet in the network card is mapped to the ring queue;
[0247] Data is read in a polling manner. By continuously polling the network card, the real-time Ethernet bus data packets in the ring queue are read into the opened static memory.
[0248] The specific steps of parsing the real-time Ethernet bus data packet in the native network card driver are as follows:
[0249] Open up static memory for storing parsed instruction data;
[0250] Parse the real-time Ethernet bus data packet in the native network card driver to determine the type of the real-time Ethernet bus data packet;
[0251] According to the type of the real-time Ethernet bus data packet, parsing the instruction data in the real-time Ethernet bus data packet;
[0252] The parsed instruction data is stored in the developed static memory according to the data organization format.
[0253] The data exchange between the underlying driver based on the memory mapping mechanism and the real-time application program in the user space is specifically as follows:
[0254] Adopt memory mapping mechanism to map the memory where instruction data is located to user space;
[0255] Use message communication mechanism to exchange data with real-time applications in user space;
[0256] Wait for the next cycle polling data packet.
[0257] This method is suitable for application in the field of numerical control systems, especially for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets, and specifically for applications where standard network cards are used to transmit real-time Ethernet fieldbus network data packets in mid-to-high-end numerical control systems. The real-time Ethernet fieldbus network data packet processing method based on a network card includes the following steps:
[0258] 1) Determine the transmission path of the real-time Ethernet field bus data packet in the native network card driver, and establish a capture point for the real-time Ethernet bus data packet inside the network card driver;
[0259] 2) Design a packet capture method based on the native network card driver for the network packet capture point built inside the network card driver;
[0260] 3) According to the bus protocol type to which the data packet belongs, a method for parsing and processing the data packet in the native network card driver is designed;
[0261] 4) According to the parsed real-time Ethernet data, design a data exchange method between the bottom-level driver and the upper-level user-mode component based on the memory mapping mechanism;
[0262] The transmission path of the real-time Ethernet fieldbus data packet in the native network card driver is determined, and the real-time Ethernet fieldbus is EtherCAT and SSB-III;
[0263] The transmission path of the real-time Ethernet field bus data packet is determined in the native network card driver, and the network card is a MAC controller plus a PHY chip control structure;
[0264] The transmission path of the real-time Ethernet field bus data packet is determined in the native network card driver, and the network card driver is the native network card driver of the Linux system;
[0265] The capture point of the real-time Ethernet bus data packet is established inside the native network card driver, and the capture point is located after the ring queue mapped by the network card DMA;
[0266] The method for capturing data packets based on the native network card driver comprises the following steps:
[0267] a. Statically allocate a piece of memory in the kernel space to store Ethernet packets;
[0268] b. Select the interrupt source, set the interrupt to periodic trigger and set the interrupt period. In the interrupt service routine, complete the capture and analysis of the real-time Ethernet field bus data packets;
[0269] c. Data is received in a non-interruptible manner, and the reception interrupt generated by the network card DMA data packet to the ring queue is shielded;
[0270] d. Data is read in a polling manner, by continuously polling the network card device, reading the data in the circular queue into the newly opened memory.
[0271] The data packet parsing and processing method designed in the native network card driver comprises the following steps:
[0272] a. Open up a static memory to store the parsed instruction data;
[0273] b. Parse the Ethernet protocol data packet in the native network card driver to determine the type of the real-time Ethernet data packet;
[0274] c. parse the instruction data in the data packet according to the data packet type;
[0275] d. Store the parsed instruction data in the opened static memory according to the data organization format;
[0276] The design is based on a data exchange method between a bottom-layer driver and an upper-layer user-mode component of a memory mapping mechanism, and the data packet data exchange method includes the following steps:
[0277] a. Use memory mapping mechanism to map the memory where instruction data is located to user space;
[0278] b. Use message communication mechanism to exchange data with upper user-mode motion control components, where the upper motion control components are real-time applications used for trajectory planning, acceleration and deceleration control, and interpolation calculations;
[0279] c. Wait for the next cycle to poll the data packet.
[0280] like Fig. 9 As shown, the network structure of the real-time Ethernet field bus based on the native network card driver is the left half of the figure. By default, the network data packet will first pass through the network card driver and the network protocol stack in the kernel space, and then be sent to the application in the user space. The present invention adds a real-time Ethernet field bus data packet capture and processing module inside the native network card driver, which captures the EtherCAT and SSB-III bus data packets inside the network card driver, and parses the instruction data in the data packet and sends it to the motion control component in the user space for further processing.
[0281] The data flow structure of the real-time Ethernet fieldbus based on the native network card driver is as follows: Fig. 9 As shown in the right half of the figure, the real-time Ethernet data packet is transferred to the circular queue inside the native network card driver through DMA between network cards. A data packet capture processing module is added after the circular queue to poll and read the data packets in the circular queue, parse and process the real-time Ethernet data packets, and map the parsed instruction data to the circular queue in the user space through the mmap mechanism. The motion thread in the upper-level motion control component also reads the instruction data in the circular queue through the polling mechanism.
[0282] like Fig.10 As shown, the specific implementation steps of the method for capturing and processing real-time Ethernet field bus data packets include:
[0283] A. Two memory areas are statically allocated in the kernel space, one for storing Ethernet data packets and the other for storing instruction data;
[0284] B. Use the kernel's high-precision clock timer (hrtimer) to set a periodic clock interrupt or a high-precision timing interrupt directly provided by the hardware logic. In the interrupt service routine of each periodic interrupt, complete the capture and analysis of the real-time Ethernet field bus data packet;
[0285] C. Data is received in a non-interruptible manner, and the reception interrupt generated by the network card DMA data packet to the ring queue is shielded;
[0286] D. Data packets are read using polling, which continuously polls the network card device and reads the data in the circular queue into the newly opened memory.
[0287] E. By parsing the Ethernet protocol header, determine the data packet type of the real-time Ethernet fieldbus, which includes EtherCAT, SSB-III and other real-time Ethernet protocols;
[0288] F. According to the data packet type, the command data of the data packet is parsed, wherein the command data of the EtherCAT protocol includes periodic command data and non-periodic command data, the periodic command data uses the process data of the EtherCAT protocol for data transmission, and is divided into periodic command data and status data according to different transmission directions, and the non-periodic command data uses the mailbox of the EtherCAT protocol for data transmission, and is divided into non-periodic command data and status data according to different transmission directions; the SSB-III protocol is similar to the EtherCAT protocol, and the command data also includes periodic command data and non-periodic command data, but the difference is that the SSB-III protocol uses the mailbox for data transmission for both types of data;
[0289] G. Store the parsed instruction data in the opened static memory according to the NML neutral message organization format of the RCS library, where the storage format of the memory is divided into a periodic data storage area and a non-periodic data storage area, and the periodic and non-periodic data storage areas are further divided into command message and status message storage areas. The parsed instruction data needs to be stored in the corresponding area according to the corresponding format;
[0290] H. Use mmap mechanism to map instruction data memory to user space;
[0291] I. Use the NML message communication mechanism of the RCS library to exchange data with the upper user-mode motion control component;
[0292] J. Wait for the next interrupt cycle to poll for data packets.
[0293] The real-time Ethernet fieldbus uses a standard network card to transmit data packets, effectively reducing the types and structures of hardware communication boards. In existing CNC systems, the real-time Ethernet fieldbus still uses traditional communication boards to transmit bus data. Different fieldbuses (such as EtherCAT, SSB-III real-time Ethernet bus, etc.) correspond to different communication boards. For each fieldbus, a set of corresponding hardware boards must be developed, making the system bloated and non-reusable.
[0294] Capturing and processing real-time Ethernet bus data packets in the network card driver can effectively increase the processing efficiency of data packets, reduce the amount of data interacting with user-mode components, and reduce system latency and jitter. The native network card driver is in the kernel space, and the processing of data packets is more efficient; at the same time, the command and status instructions of the data packet are parsed in the native network card driver, which can greatly reduce the amount of data interacting with user-mode components compared to the entire data packet.
[0295] The reception of real-time Ethernet data packets adopts a non-interrupt mode, avoiding the switching of interrupt context, improving the efficiency of data packet processing, and reducing system latency. The control structure of the real-time Ethernet fieldbus is a master-slave control mode. In the real-time Ethernet fieldbus network, the CNC system is the master station device that controls the network, and the slave station is the controlled servo drive and I / O, etc. The network communication is all initiated by the master station. Therefore, the master station will receive the data packet fed back by the slave station within a certain period of time after sending the data packet, so the polling method can be used to receive the data packet to reduce the context switching caused by the interrupt.
Claims
1. A method for constructing a numerical control system architecture based on a quad-core processor, characterized in that: The following steps are involved: A. Name the four cores of the processor CPU core #0, #1, #2, and #3, isolate CPU cores #2 and #3, and reserve them for user-mode real-time components; B. Design a native NIC driver to redirect real-time Ethernet bus data packets to the user-mode real-time component in user space, and bind the interrupt of the native NIC driver to CPU core #3; C. According to the user state component model, the user state functional components of the numerical control system are constructed, including: human-machine interface components, task control components, PLC components, motion control components, and real-time Ethernet bus components. The human-machine interface components and task control components are designed as non-real-time user state components, and the PLC components, motion control components, and real-time Ethernet driver components are designed as user state real-time components; D. According to the user-state component communication model, the user-state functional components of the numerical control system are organized into a tree structure, whose structure is as follows: the top root node is the human-machine interface component, its leaf node is the task control component, the two leaf nodes of the task control component are the PLC component and the motion control component, and the leaf node of the motion control component is the real-time Ethernet bus component; E. Bind the human-machine interface component and the task control component to CPU core #1, bind the PLC component to CPU core #2, and bind the motion control component and the real-time Ethernet bus component to CPU core #3.
2. The method for constructing a numerical control system architecture based on a quad-core processor according to claim 1, characterized in that: Establishing communication between user-mode components includes the following steps: a. Establish the communication between the human-machine interface component and the task control component: the human-machine interface component transmits the part processing program written in NC voice to the task control component through the command message channel in NML communication; the task control component transmits the actual processing status information to the human-machine interface component through the status message channel in NML communication; b. Establish the communication between the task control component and the PLC component: The task control component transmits the I / O control instructions corresponding to the machining operations parsed from the part machining program to the PLC component through the command message channel in the NML communication; at the same time, the PLC component transmits the actual I / O status information to the task control component through the status message channel in the NML communication; c. Establish the communication between the task control component and the motion control component: the task control component transmits the motion control instructions corresponding to the machining operations parsed from the part machining program, as well as the setting commands for the motion attributes, to the motion control component through the command message channel in the NML communication; at the same time, the motion control component transmits the actual machining status information to the task control component through the status message channel in the NML communication; d. Establish communication between the motion control component and the real-time Ethernet bus component: The motion control component transmits the axis control instructions obtained by interpolation operation of the machining operation to the real-time Ethernet bus component through the command message channel of the shared memory; at the same time, the real-time Ethernet bus component transmits the actual axis status information to the motion control component through the status message channel in the shared memory.
3. The method for constructing a numerical control system architecture based on a quad-core processor according to claim 1, characterized in that: The construction of the user state component model includes the following steps: a. Establish input parameter channel and output parameter channel respectively; b. Establish a read communication channel and a write communication channel respectively; c. Design functional blocks according to tasks; d. Build user-mode real-time threads or non-real-time threads based on the real-time requirements of the task.
4. The method for constructing a numerical control system architecture based on a quad-core processor according to claim 2, characterized in that: The user state component communication model includes the following steps: Establishing a command channel for exchanging data between components using messages and a status channel for transferring data through a write communication channel respectively; A command buffer and a message buffer are established respectively; the message buffer is used to cache messages, and the message buffer is located after the message channel, wherein the command buffer is connected to the command channel, and the status buffer is connected to the status channel.
Citation Information
Patent Citations
Implementation method for networked system structure of numerical control system
CN102253657A
Robotic hybrid system application frame based on multi-core processor architecture
CN105278940A