CNC numerical control system, method, device and equipment and readable storage medium
By adopting a distributed architecture that separates real-time and non-real-time units in the CNC system, along with standardized communication protocols and delay compensation algorithms, the flexibility and scalability issues of traditional CNC systems are solved, achieving efficient distributed control and precise motion compensation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-03-13
AI Technical Summary
The highly integrated architecture of traditional CNC systems results in poor system flexibility and scalability, making it difficult to achieve distributed control. Furthermore, networked deployment introduces network latency and packet jitter issues.
It adopts a distributed architecture that separates real-time and non-real-time units, introduces standardized communication protocols and dynamic delay compensation algorithms, realizes data exchange through shared memory or network communication, and performs motion compensation within the servo cycle.
It improves the system's flexibility, scalability, and development and maintenance efficiency, ensures the accuracy and compatibility of distributed control, and overcomes the transmission delay and trajectory error problems caused by networked deployment.
Smart Images

Figure CN121657585A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of automatic control technology, specifically relating to a CNC numerical control system, method, device, equipment, and readable storage medium. Background Technology
[0002] With the continuous development of CNC technology, CNC systems are being used more and more widely in industrial production. Traditional CNC systems, which have long been the mainstream, typically employ a highly integrated architecture, centralizing real-time and non-real-time tasks on a single device. While this highly coupled design met basic control requirements in the early days, its inherent limitations have become increasingly apparent as modern industrial scenarios have become more urgent for distributed control and multi-machine collaboration.
[0003] Specifically, integrated architecture severely restricts the flexibility and scalability of the system. In multi-device collaborative processing scenarios, a single controller struggles to efficiently coordinate multiple processing units, and system expansion often means a significant increase in hardware costs and a leap in architectural complexity. Furthermore, during the system development, debugging, and maintenance phases, reliance on the actual machine tool hardware environment is essential. This not only increases the maintenance time window and costs but also presents substantial obstacles to remote diagnostics and cloud-based operations and maintenance.
[0004] Meanwhile, while CNC systems that introduce network communication technology to improve system flexibility have solved the problem of distributed deployment to some extent, they inevitably introduce uncertainties such as network latency and data packet jitter.
[0005] Therefore, in order to address the above-mentioned technical problems, it is necessary to provide a CNC numerical control system, method, apparatus, equipment, and readable storage medium.
[0006] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a CNC numerical control system, method, apparatus, device, and readable storage medium, which can significantly improve the system's flexibility, scalability, and development and maintenance efficiency.
[0008] To achieve the above objectives, a specific embodiment of the present invention provides the following technical solution:
[0009] In a first aspect, the present invention provides a CNC numerical control system, which includes: a real-time unit, a non-real-time unit, and a standardized communication protocol;
[0010] The real-time unit is configured to run on a real-time operating system or a real-time hardware platform and to independently execute real-time tasks, including motion control command generation and servo driver management.
[0011] The non-real-time unit is configured to run on a general-purpose operating system and independently execute non-real-time tasks, including user interface operations, G-code parsing, and path planning.
[0012] The standardized communication protocol is predefined and embedded in the non-real-time unit and the real-time unit to standardize the data exchange format between the non-real-time unit and the real-time unit.
[0013] In one or more embodiments of the present invention, the CNC numerical control system further includes a communication interface module;
[0014] The communication interface module is connected to both the non-real-time unit and the real-time unit, and is configured to support shared memory communication and / or network communication.
[0015] When the non-real-time unit and the real-time unit are running on the same physical device, the communication interface module enables shared memory communication mode to exchange data between the non-real-time unit and the real-time unit through a predefined shared memory area.
[0016] When the non-real-time unit and the real-time unit are running on different physical devices, the communication interface module enables network communication and exchanges data between the non-real-time unit and the real-time unit based on a preset network protocol.
[0017] Secondly, the present invention provides a CNC numerical control method, comprising:
[0018] A predefined standardized communication protocol, including binary formats for instruction data packets and status data packets, wherein the binary format includes a header, a data body, and a checksum;
[0019] The non-real-time unit serializes the instruction data packet based on the standardized communication protocol and sends it to the real-time unit.
[0020] In response to the instruction data sent from the non-real-time unit, the real-time unit generates corresponding motion control instructions to control the servo drive, and deserializes the status data packet based on the standardized communication protocol and feeds it back to the non-real-time unit.
[0021] In one or more embodiments of the present invention, the method further includes:
[0022] During each servo cycle, the real-time unit monitors for system errors based on real-time status indicators.
[0023] If an error occurs in the system, the real-time unit immediately performs a preset local safety operation within the servo cycle. The local safety operation includes disconnecting the servo driver enable signal and / or triggering an emergency stop circuit.
[0024] After initiating the local security operation, the real-time unit generates an error data packet containing error codes and context information, and sends it to the non-real-time unit after deserialization.
[0025] In one or more embodiments of the present invention, the step of monitoring whether there are errors in the system based on real-time status indicators during each servo cycle includes:
[0026] Read and verify the validity of the feedback data from the sensor; and / or
[0027] Parse the servo drive status word to check for internal drive errors; and / or
[0028] Calculate the following error between the command position and the actual feedback position. If the following error exceeds a preset threshold, an error exists in the system; and / or
[0029] Heartbeat data packets are exchanged between the non-real-time unit and the real-time unit at a fixed frequency. If no heartbeat response is received within the current servo cycle, an error exists in the system. The heartbeat data packet contains a counter value.
[0030] In one or more embodiments of the present invention, the method further includes:
[0031] The instruction data packet is parsed, and the instruction data packet contains a transmission timestamp and an instruction increment; the network latency is calculated based on the transmission timestamp and the reception time of the real-time unit;
[0032] Based on the network latency and servo cycle length, calculate the small step increment for motion compensation;
[0033] Based on the small step increment, the instructions in the instruction data packet are divided into multiple micro-instructions, and the micro-instructions are executed sequentially in each servo cycle, wherein each micro-instruction corresponds to the motion amount of one servo cycle.
[0034] In one or more embodiments of the present invention, the formula for calculating the small step increment for motion compensation based on the network latency and servo cycle length is as follows:
[0035]
[0036] in, Use small step increments; Due to network latency; This refers to the servo cycle length. The instruction increment is the total distance that the motion axis needs to move, as indicated in the instruction sent to the real-time unit.
[0037] In one or more embodiments of the present invention, the method further includes:
[0038] The real-time unit reads the actual position feedback from the encoder;
[0039] The actual position is compared with the target position corresponding to the micro-instruction. If the deviation between the actual position and the target position of the micro-instruction exceeds a preset threshold, the small step increment is updated.
[0040] In one or more embodiments of the present invention, the formula for updating the small step increment is:
[0041]
[0042] in, This is the updated small step increment; This is the small step increment before the update; This is the proportionality coefficient; This represents the deviation between the actual position and the target position of the micro-instruction.
[0043] Thirdly, the present invention provides a CNC numerical control device, comprising:
[0044] A definition module is used to predefine standardized communication protocols, including binary formats for instruction data packets and status data packets, wherein the binary format includes a packet header, a data body, and a checksum;
[0045] The first control module is used to instruct the non-real-time unit to serialize the instruction data packet and send it to the real-time unit based on the standardized communication protocol.
[0046] The second control module is used to respond to the instruction data sent from the non-real-time unit. The real-time unit generates corresponding motion control instructions to control the servo driver, and feeds back the status data packet after deserialization based on the standardized communication protocol to the non-real-time unit.
[0047] Fourthly, the present invention provides a computer device comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the CNC numerical control method by executing the computer instructions.
[0048] Fifthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the CNC numerical control method.
[0049] Compared with existing technologies, the CNC numerical control method provided by this invention, by adopting a distributed architecture that separates real-time units and non-real-time units, and introducing a protocol-based interaction mechanism compatible with shared memory and network communication, as well as a dynamic latency compensation algorithm, fundamentally solves the tight coupling problem of traditional integrated architecture. This makes the non-real-time units no longer dependent on a specific real-time environment, supports independent deployment and cross-platform operation, and significantly improves the system's flexibility, scalability, and development and maintenance efficiency.
[0050] Meanwhile, by intelligently switching communication media and using network latency compensation technology, the transmission delay and trajectory error problems caused by network deployment are effectively overcome. While ensuring the accuracy of distributed control, it also takes into account the compatibility with older equipment. Without sacrificing real-time performance, it gives the CNC system significant architectural advantages and the ability to adapt to the needs of future intelligent and networked manufacturing. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a schematic diagram of the CNC numerical control system architecture in one embodiment of the present invention;
[0053] Figure 2 This is a flowchart of a CNC numerical control method in one embodiment of the present invention;
[0054] Figure 3 This is a structural block diagram of a CNC numerical control device according to another embodiment of the present invention;
[0055] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0056] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0057] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprises" shall be understood to include the stated elements or components without excluding other elements or other components.
[0058] In existing CNC implementations, the functionality of real-time units is often encapsulated as dynamic link libraries (DLLs), allowing non-real-time units to directly call their interface functions to read and write shared memory areas, thus achieving data interaction. However, this architecture has significant drawbacks: non-real-time units are strictly dependent on the dynamic libraries provided by the real-time units and the specific real-time operating system environment they depend on during compilation, linking, and runtime. This strong coupling makes it difficult to achieve distributed deployment, non-real-time units cannot run and debug independently of real-time units, the overall architecture has poor scalability, and system upgrade and maintenance costs are high, severely restricting the development of CNC systems towards high performance, high flexibility, and remote collaboration.
[0059] To address the aforementioned problems, this invention proposes a novel technical approach: decoupling the traditional strong-binding model based on dynamic library calls, configuring non-real-time and real-time units as two completely independent and equal processes or physical devices. Based on this, a standardized communication protocol is designed to clearly define the data structure and semantics of the interaction between the two parties, thereby achieving complete decoupling at the logical level.
[0060] Furthermore, to address the transmission delay issue introduced by network communication under this architecture, this invention designs a closed-loop delay compensation algorithm based on dynamic measurement. This algorithm monitors parameters such as network round-trip delay, servo cycle, and command increment in real time. Based on the proposed compensation formula, it decomposes the trajectory error caused by macroscopic network delay into small, executable increments within multiple servo cycles. Through the advance execution of real-time units and dynamic feedback adjustments, it achieves proactive compensation for trajectory deviations. This mechanism effectively maintains machining accuracy and motion control stability while ensuring the flexibility of the system's distributed deployment.
[0061] In summary, this technical solution achieves complete decoupling and cross-platform distributed deployment of non-real-time and real-time units through protocol standardization, adaptive switching of communication modes, and dynamic latency compensation. While improving system maintainability, scalability, and ease of development and debugging, it still ensures high real-time performance and high-precision machining requirements, providing a feasible architectural foundation for the development of next-generation intelligent CNC systems.
[0062] Please refer to Figure 1 The diagram shows a schematic of the CNC numerical control system architecture provided by the present invention under one embodiment. The architecture specifically includes: a non-real-time unit 101, a real-time unit 102, and a communication interface module 103.
[0063] The non-real-time unit 101 is an application or process deployed in a general-purpose operating system, primarily responsible for computational and management tasks that do not require microsecond-level response times. For example, it provides a graphical user interface for operators to program, set parameters, monitor status, and perform manual operations; it performs syntax checking, semantic analysis, and toolpath planning on input G-code and other machining programs, converting them into specific machining trajectories; it sends the planned instruction sequence to the real-time unit 102 via the communication interface module 103, and continuously monitors the feedback information from the real-time unit 102, making dynamic adjustments or manual interventions based on the execution status. The key features of the non-real-time unit 101 are its high performance and flexibility. It eliminates the dependence on the real-time unit's dynamic library and real-time operating system, allowing it to run on powerful commercial servers or PCs, facilitating computations such as path planning using high-performance CPUs. Furthermore, this unit can be independently developed, debugged, and upgraded, greatly improving the system's maintainability and scalability.
[0064] The real-time unit 102 is an independent process or dedicated hardware device deployed in a real-time operating system environment, used to execute highly real-time tasks with strict timing requirements. For example, it receives machining instructions from the non-real-time unit 101 and generates precise control signals based on the servo cycle to drive servo motors or actuators to complete high-precision movements. Simultaneously, it monitors and adjusts the status of each servo axis in real time, including closed-loop control of position, speed, and torque, and collects real-time feedback data from sensors such as encoders. The key features of the real-time unit 102 are its independence and strong real-time performance. It does not depend on the code or operating environment of the non-real-time unit 101 and can be started, run, and maintained independently. Its operating basis is a deterministic real-time operating system (RTOS) or an industrial computing platform equipped with a real-time kernel, thereby ensuring that all critical tasks can be reliably completed within a predetermined time window.
[0065] The communication interface module 103 is the foundation for establishing a communication connection between the real-time unit 101 and the non-real-time unit 102. In one embodiment, the communication interface module 103 can support corresponding communication modes depending on whether the real-time unit 101 and the non-real-time unit 102 are deployed on the same physical machine. Of course, in another embodiment, the communication interface module 103 can also be a communication middleware layer supporting multiple modes, used to achieve decoupling and deployment flexibility between the real-time unit 101 and the non-real-time unit 102.
[0066] This is because if a dynamic library for the real-time unit is used to implement shared memory communication, it will lead to a strong dependency of the non-real-time unit on the real-time unit. In other words, without the runtime environment of the real-time unit, the non-real-time unit will also be unable to run. At the same time, even if the dependency problem is solved, the real-time unit 101 and the non-real-time unit 102 still need to run on the same physical machine. If the CPU performance on the running machine is not high and there is no debugging environment, then the problem will still not be solved.
[0067] Therefore, this invention does not use dynamic library calls, but instead employs a network communication strategy. In a specific embodiment, when the non-real-time unit and the real-time unit run on the same physical device, the communication interface module enables shared memory communication, exchanging data between the non-real-time unit and the real-time unit through a predefined shared memory region; when the non-real-time unit and the real-time unit run on different physical devices, the communication interface module enables network communication, exchanging data between the non-real-time unit and the real-time unit based on a preset network protocol.
[0068] The network communication method may include, but is not limited to, TCP or UDP, and this embodiment of the invention does not impose any restrictions. TCP is slower and has lower latency than UDP. Under normal circumstances, TCP's advantage lies in reliable connections, preventing packet loss, while UDP is an unreliable connection and prone to packet loss. However, in one implementation, UDP can be made reliable through algorithmic implementation, thus compensating for UDP's shortcomings. In scenarios requiring higher-speed networks, software can further employ DPDK, XDP, bypass, and other methods to further reduce network consumption, while hardware can utilize FPGAs and bandwidth upgrades to enhance the network. If the hardware supports this, a bus or EtherCat can also be used.
[0069] It should be noted that, in one implementation, the CNC numerical control system can also be configured with a user terminal. The user terminal can be equipped with computer software programs that match the CNC numerical control method provided by this method, providing a platform for users to input the custom parameters required for the implementation of this invention; the user terminal 103 can be, but is not limited to, portable electronic devices or wearable electronic devices such as desktop computers (PCs), smartphones, handheld computers, tablet computers, personal digital assistants (PDAs), etc., and the embodiments of this invention do not limit the above contents.
[0070] Please refer to Figure 2 The diagram shown is a flowchart of CNC numerical control in one embodiment of the present invention. The CNC numerical control method specifically includes the following steps:
[0071] S201: A predefined standardized communication protocol, including binary formats for instruction data packets and status data packets, wherein the binary format includes a header, a data body, and a checksum;
[0072] It should be noted that the standardized communication protocol is designed to enable data exchange between real-time and non-real-time units, and to ensure the accurate and orderly transmission of control commands and status information in scenarios where network latency or shared memory communication may exist.
[0073] In one implementation, the standardized communication protocol mainly defines two types of data packets: command data packets sent from non-real-time units to real-time units, and status data packets sent from real-time units to non-real-time units. The command data packet format includes command type, motion parameters, and timestamp fields; the status data packet format includes axis position, error code, and heartbeat response fields. Both follow a preset data packet structure, consisting of a header, data body, and checksum.
[0074] The packet header is the metadata header of the data packet, with a fixed length and containing key fields controlling the transmission and parsing of the data packet. Specifically, it may further include: a start identifier used by the receiver for data stream synchronization and packet boundary positioning; the packet type used as the basis for parsing the data body content, which may include motion command packets, error alarm packets, etc., depending on the differences in the data body content; a sequence number used to detect packet loss and out-of-order delivery; and a timestamp representing the absolute or relative time of data packet generation. This field allows subsequent receivers to estimate one-way or round-trip network latency by comparing the local reception time with the data packet timestamp, providing crucial input for the latency compensation algorithm of the real-time unit. It can also be used to determine whether there is a command timeout issue, thereby deciding whether to discard the command.
[0075] The data body is the core payload of the data packet. Its specific content and structure are determined by the packet type field, and its length is variable. Compact binary encoding is preferred to minimize the amount of data transmitted and improve communication efficiency. Furthermore, for command data packets, the data body may contain parameters such as target position, velocity, acceleration, axis selection, and I / O control commands; for status data packets, the data body may contain real-time information such as the actual position and velocity of each axis, servo enable status, limit switch status, current error code, and system load rate.
[0076] A checksum is located at the end of the data packet and is used to verify data integrity. In one specific implementation, the checksum can be a 2-byte cyclic redundancy check value, and the calculation range of the checksum covers all bytes of the header and data body. After receiving the complete data packet, the receiver recalculates the checksum using the same algorithm and compares it with the checksum at the end of the packet. If they do not match, it indicates that a bit error may have occurred during data transmission, and the data packet will be discarded. This may trigger a retransmission mechanism or error reporting, thereby ensuring the integrity and reliability of data transmission.
[0077] S202: The non-real-time unit serializes the instruction data packet based on the standardized communication protocol and sends it to the real-time unit;
[0078] It should be noted that the instruction data can be a collection of all information used to directly control the machine tool's motion, generated by a non-real-time unit and sent to the real-time unit via a communication interface. In one embodiment, during CNC numerical control, the instruction data should at least include: command types to distinguish different operational intentions; motion parameters such as feed rate / acceleration; context information and synchronization information such as sequence number and timestamp. This embodiment of the invention does not limit the specific content of the instruction data.
[0079] Because non-real-time and real-time units may run on different hardware architectures and operating systems, their internal representations of data may differ. Therefore, instruction data packets need to be serialized using a predefined standardized communication protocol before data transmission.
[0080] In one implementation, the non-real-time unit first generates specific control commands based on user operations or G-code. These commands are typically stored internally as high-level data structures or objects. Before transmission, they must be converted into the format specified by the protocol. Specifically, this includes: selecting the corresponding value for the appropriate packet type based on the nature of the command (e.g., jogging, continuous trajectory, parameter setting, emergency stop command, etc.); arranging the command parameters according to the field order, data type, and byte order specified by the protocol to form a binary data body; obtaining the next sequence number from a monotonically increasing counter and filling it into the packet header. This sequence number globally and uniquely identifies this command packet and is used for subsequent confirmation and sorting; at the moment the command packet is generated, obtaining the high-precision system time and filling it into the timestamp field of the packet header, which serves as the benchmark for subsequent calculation of network latency and judgment of command validity.
[0081] Among them, the instruction parameters can be, for example, for a straight trajectory, the data volume may include the target point coordinates X, Y, Z, feed speed F, axis mask, etc.; the sequence number can be assigned based on a preset order, rather than monotonically increasing / decreasing; the system time corresponding to the timestamp can be the number of microseconds since the system started or UTC time. This invention does not make specific limitations on the specific selection and configuration of the above parameters.
[0082] Subsequently, the non-real-time unit calls the serialization function provided by the communication interface module to complete the construction of the complete data packet. Specifically, this may include: constructing the packet header, writing the start identifier (0xAA55), packet type, sequence number, and timestamp in sequence, and calculating the length of the data body and writing it into the "data body length" field; performing cyclic redundancy check calculation on the entire packet header and the prepared data body, and appending the resulting 2-byte checksum to the end of the data body; concatenating the packet header, data body, and checksum in sequence to form a complete binary byte stream that conforms to the protocol specification, and submitting it to the communication interface module for transmission.
[0083] S203: In response to the instruction data sent from the non-real-time unit, the real-time unit generates corresponding motion control instructions to control the servo driver, and feeds back the status data packet after deserialization based on the standardized communication protocol to the non-real-time unit.
[0084] It should be noted that, due to the independent configuration of real-time and non-real-time units, servo drive control must be based on the real-time unit. The basis for this control is the instruction data sent from the non-real-time unit. This process is not limited to simple instruction execution, but is a closed-loop process integrating instruction reception and deserialization, motion instruction generation and execution, safety monitoring, and status feedback.
[0085] Specifically, for instruction reception and deserialization, the real-time unit listens to and acquires the data stream through the communication strategy provided by the communication interface module. In one implementation, after receiving the raw byte stream, the start position of the data packet can be located by finding the start identifier, and then the complete packet data can be extracted according to the length of the data body. The checksum of the entire data packet is then calculated and compared with the checksum at the end of the packet to verify the integrity of the data packet. After successful verification, the real-time unit deserializes the data packet, reads the "packet type" to determine the nature of the instruction, reads the "sequence number" and "timestamp" to determine the instruction order, and calculates the network transmission delay of the current instruction. According to the format definition corresponding to the "packet type," the specific instruction parameters are parsed from the "data body" and converted into a data structure usable by the real-time unit's internal control system.
[0086] Furthermore, for the generation and execution of motion control commands, in an exemplary embodiment, it may include: parsing the command data packet, the command data packet containing a transmission timestamp and a command increment; calculating the network delay based on the transmission timestamp and the reception time of the real-time unit; calculating the small step increment for motion compensation based on the network delay and the servo cycle length; dividing the commands in the command data packet into multiple micro-instructions based on the small step increment, and executing the micro-instructions sequentially in each servo cycle, wherein each micro-instruction corresponds to the motion amount of one servo cycle.
[0087] It is understandable that network latency can be simply described as the difference between the time a data packet is received and the timestamp recorded in the data packet. However, it is also understandable that the calculation of network latency in a single test may have a large error and cannot accurately reflect the average situation of network jitter. Therefore, in another implementation, to avoid sudden changes in latency values caused by network jitter, the real-time unit can maintain a latency sliding window (such as a queue of the most recent 10 latency values) and use a weighted average or simple average method to calculate a smoothed effective network latency (Latency_eff) for compensation calculation.
[0088] Based on the network latency and servo cycle length, the formula for calculating the small step increment for motion compensation can be expressed as:
[0089]
[0090] in, Use small step increments; Due to network latency; This refers to the servo cycle length. The instruction increment is the total distance that the motion axis needs to move, as indicated in the instruction sent to the real-time unit.
[0091] It should be noted that, based on the above algorithm using network latency, a preset servo cycle, and motion increments in the instructions as input, the calculated result dynamically decomposes the received macroscopic motion instructions into a series of denser micro-instruction sequences adapted to the current servo cycle. This allows the execution start point to be advanced, thereby offsetting the overall trajectory lag caused by network latency. The compensated and refined control instructions can be accurately and timely sent to the servo driver through the hardware interface of the real-time unit. The real-time unit strictly follows the timing of its servo cycle to ensure the determinism of the control signal. The servo cycle can be predefined based on user needs and differences in usage scenarios, and the hardware interface can be an EtherCAT master station, a pulse direction interface, etc., which are not limited in this embodiment of the invention.
[0092] While performing control, the real-time unit can also provide real-time feedback of system status to the non-real-time unit to enable human-machine monitoring and upper-level decision-making. In one embodiment, status information collection can be performed every one or several servo cycles. The real-time unit 101 collects key information including the actual position and speed of each axis, driver status word, current error code, system load rate, and the last confirmed instruction sequence number. Similar to the aforementioned data transmission from the non-real-time unit to the real-time unit, data transmission from the real-time unit to the non-real-time unit also requires the same standardized communication protocol and symmetrical serialization operations as the sending end, which will not be elaborated here. Finally, the deserialized status data packet is sent back to the non-real-time unit via shared memory or network.
[0093] It should be noted that, in one implementation, during the servo control process of the real-time unit, the real-time unit can also read the actual position feedback of the encoder; compare the actual position with the target position corresponding to the micro-instruction; if the deviation between the actual position and the target position of the micro-instruction exceeds a preset threshold, then update the small step increment.
[0094] The updated small step increment formula is as follows:
[0095]
[0096] in, This is the updated small step increment; This is the small step increment before the update; This is the proportionality coefficient; This represents the deviation between the actual position and the target position of the micro-instruction.
[0097] Furthermore, it should be noted that this invention also provides a security monitoring strategy. This involves monitoring the system's status to identify system errors. For critical errors or alarm information, the real-time unit does not need to wait for instructions from the non-real-time unit; it immediately disables the servo at the interrupt level, achieving a millisecond-level security response. After completing the emergency security action, the corresponding error alarm packet is immediately generated and prioritized for transmission, ensuring that the non-real-time unit can be promptly notified and issue a warning via the human-machine interface.
[0098] In an exemplary embodiment, during each servo cycle, the real-time unit monitors whether there are errors in the system based on real-time status indicators; if there are errors in the system, the real-time unit immediately executes a preset local safety operation during the servo cycle, the local safety operation including disconnecting the servo driver enable signal and / or triggering an emergency stop circuit; after initiating the local safety operation, the real-time unit generates an error data packet containing error codes and context information, and sends it to the non-real-time unit after deserialization.
[0099] Specifically, within each servo cycle, the real-time unit monitors for system errors based on real-time status indicators, including: reading and verifying the validity of feedback data from sensors; and / or parsing the servo driver status word to check for internal driver errors; and / or calculating the following error between the command position and the actual feedback position; if the following error exceeds a preset threshold, the system has an error; and / or exchanging heartbeat data packets between the non-real-time unit and the real-time unit at a fixed frequency; if no heartbeat response is received within the current servo cycle, the system has an error, and the heartbeat data packet contains a counter value.
[0100] Please refer to Figure 3 As shown, based on the same inventive concept as the aforementioned CNC numerical control method, one embodiment of the present invention provides a CNC numerical control device 300, including: a definition module 301, a first control module 302 and a second control module 303.
[0101] It should be noted that the CNC numerical control method of this embodiment can be applied to the CNC numerical control device 300 of this embodiment. The CNC numerical control device 300 can be configured on a terminal. The terminal may include, but is not limited to, a PC (Personal Computer), a PDA (Tablet PC), a smartphone, a smart wearable device, etc.
[0102] Specifically, the definition module 301 is used to predefine a standardized communication protocol, including the binary format of instruction data packets and status data packets, wherein the binary format includes a packet header, a data body, and a checksum.
[0103] The first control module 302 is used to instruct the non-real-time unit to serialize the instruction data packet and send it to the real-time unit based on the standardized communication protocol.
[0104] The second control module 303 is used to respond to the instruction data sent from the non-real-time unit. The real-time unit generates corresponding motion control instructions to control the servo driver, and feeds back the status data packet after deserialization based on the standardized communication protocol to the non-real-time unit.
[0105] Please refer to Figure 4 As shown, embodiments of the present invention also provide an electronic device 400, which includes at least one processor 401, a memory 402 (e.g., non-volatile memory), a memory 403, and a communication interface 404, wherein the at least one processor 401, the memory 402, the memory 403, and the communication interface 404 are connected together via an internal bus 405. The at least one processor 401 is used to invoke at least one program instruction stored or encoded in the memory 402, so that the at least one processor 401 performs various operations and functions of the CNC numerical control methods described in the various embodiments of this specification.
[0106] In the embodiments of this specification, electronic device 400 may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile electronic device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable electronic device, consumer electronic device, etc.
[0107] This invention also provides a computer-readable medium carrying computer-executable instructions. When executed by a processor, these instructions can be used to implement various operations and functions of the CNC numerical control methods described in the various embodiments of this specification.
[0108] The computer-readable medium in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0109] In this invention, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.
[0110] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0111] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, systems, and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0112] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.
[0113] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0114] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A CNC numerical control system, characterized in that, include: Real-time units, non-real-time units, and standardized communication protocols; The real-time unit is configured to run on a real-time operating system or a real-time hardware platform and to independently execute real-time tasks, including motion control command generation and servo driver management. The non-real-time unit is configured to run on a general-purpose operating system and independently execute non-real-time tasks, including user interface operations, G-code parsing, and path planning. The standardized communication protocol is predefined and embedded in the non-real-time unit and the real-time unit to standardize the data exchange format between the non-real-time unit and the real-time unit.
2. The CNC numerical control system according to claim 1, characterized in that, The CNC numerical control system also includes a communication interface module; The communication interface module is connected to both the non-real-time unit and the real-time unit, and is configured to support shared memory communication and / or network communication. When the non-real-time unit and the real-time unit are running on the same physical device, the communication interface module enables shared memory communication mode to exchange data between the non-real-time unit and the real-time unit through a predefined shared memory area. When the non-real-time unit and the real-time unit are running on different physical devices, the communication interface module enables network communication and exchanges data between the non-real-time unit and the real-time unit based on a preset network protocol.
3. A CNC numerical control method, characterized in that, include: A predefined standardized communication protocol, including binary formats for instruction data packets and status data packets, wherein the binary format includes a header, a data body, and a checksum; The non-real-time unit serializes the instruction data packet based on the standardized communication protocol and sends it to the real-time unit. In response to the instruction data sent from the non-real-time unit, the real-time unit generates corresponding motion control instructions to control the servo drive, and deserializes the status data packet based on the standardized communication protocol and feeds it back to the non-real-time unit.
4. The CNC numerical control method according to claim 3, characterized in that, The method further includes: During each servo cycle, the real-time unit monitors for system errors based on real-time status indicators. If an error occurs in the system, the real-time unit immediately performs a preset local safety operation within the servo cycle. The local safety operation includes disconnecting the servo driver enable signal and / or triggering an emergency stop circuit. After initiating the local security operation, the real-time unit generates an error data packet containing error codes and context information, and sends it to the non-real-time unit after deserialization.
5. The CNC numerical control method according to claim 4, characterized in that, Within each servo cycle, the real-time unit monitors for system errors based on real-time status indicators, including: Read and verify the validity of the feedback data from the sensor; and / or Parse the servo drive status word to check for internal drive errors; and / or Calculate the following error between the command position and the actual feedback position. If the following error exceeds a preset threshold, an error exists in the system; and / or Heartbeat data packets are exchanged between the non-real-time unit and the real-time unit at a fixed frequency. If no heartbeat response is received within the current servo cycle, an error exists in the system. The heartbeat data packet contains a counter value.
6. The CNC numerical control method according to claim 3, characterized in that, The method further includes: The instruction data packet is parsed, and the instruction data packet contains a transmission timestamp and an instruction increment; the network latency is calculated based on the transmission timestamp and the reception time of the real-time unit; Based on the network latency and servo cycle length, calculate the small step increment for motion compensation; Based on the small step increment, the instructions in the instruction data packet are divided into multiple micro-instructions, and the micro-instructions are executed sequentially in each servo cycle, wherein each micro-instruction corresponds to the motion amount of one servo cycle.
7. The CNC numerical control method according to claim 6, characterized in that, Based on the network latency and servo cycle length, the formula for calculating the small step increment for motion compensation is as follows: in, Use small step increments; Due to network latency; This refers to the servo cycle length. The instruction increment is the total distance that the motion axis needs to move, as indicated in the instruction sent to the real-time unit.
8. The CNC numerical control method according to claim 6, characterized in that, The method further includes: The real-time unit reads the actual position feedback from the encoder; The actual position is compared with the target position corresponding to the micro-instruction. If the deviation between the actual position and the target position of the micro-instruction exceeds a preset threshold, the small step increment is updated.
9. The CNC numerical control method according to claim 8, characterized in that, The updated small step increment formula is as follows: in, This is the updated small step increment; This is the small step increment before the update; This is the proportionality coefficient; This represents the deviation between the actual position and the target position of the micro-instruction.
10. A CNC numerical control device, characterized in that, include: A definition module is used to predefine standardized communication protocols, including binary formats for instruction data packets and status data packets, wherein the binary format includes a packet header, a data body, and a checksum; The first control module is used to instruct the non-real-time unit to serialize the instruction data packet and send it to the real-time unit based on the standardized communication protocol. The second control module is used to respond to the instruction data sent from the non-real-time unit. The real-time unit generates corresponding motion control instructions to control the servo driver, and feeds back the status data packet after deserialization based on the standardized communication protocol to the non-real-time unit.
11. A computer device, characterized in that, include: A memory and a processor are interconnected, the memory storing computer instructions, and the processor executing the computer instructions to perform the CNC numerical control method according to any one of claims 3-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the CNC numerical control method according to any one of claims 3-9.
Citation Information
Patent Citations
Implementation method for networked system structure of numerical control system
CN102253657A
Split type numerical control system based on wireless communication
CN108037736A
Numerical control system control method and device, numerical control system and computer storage medium
CN112346405A
Numerical control system and numerical control method
CN115079641A
Cutter cutting path machining error compensation method based on online monitoring
CN120044877A