PC computer + I / O interface numerical control system G instruction and switch value instruction cooperation method and device

By using a PC + I/O interface CNC system, the coordinated control of G-code and digital input commands is realized, solving the coordination problem between G-code and digital input commands in the CNC system and improving the operating efficiency and machining effect of the CNC system.

CN117008538BActive Publication Date: 2026-04-24FUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
FUZHOU UNIV
Filing Date
2023-04-18
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In existing CNC systems, the coordination and control problem between G-codes and digital input commands has not been effectively solved, resulting in low operating efficiency and poor machining effects.

Method used

The system employs a PC + I/O interface CNC system. The PC performs the decoding and coarse interpolation of G-codes and switch commands, while the I/O interface card performs fine interpolation and executes M-codes. Combined with the status control of channels A, B, and C, it achieves coordinated control and ordered decoding of G/M codes.

Benefits of technology

It achieves efficient operation of the CNC system and optimized machining results, improves the decoding efficiency of G code and M, S, T auxiliary function instructions, and ensures coordinated control of G code and switch quantity instructions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117008538B_ABST
    Figure CN117008538B_ABST
Patent Text Reader

Abstract

The application provides a PC+I / O interface numerical control system G instruction and switch value instruction coordination method and device. The PC is used to complete G code / switch value instruction decoding and G code movement track rough interpolation. The switch value instruction is M code including M, S and T instruction codes. The I / O interface card is used to complete fine interpolation and control M code execution. The PC is provided with a decoding preprocessing module, a G code buffer, an M code buffer for switch value instruction buffering, a rough interpolation module, a rough interpolation data buffer, a channel B for rough interpolation data output, a channel A for switch value instruction data input control, an M code coordination module for switch value instruction coordination, and a channel C for M code data output control. The on / off states of the channel A, the channel B and the channel C are controllable. The I / O interface card is provided with an interpolation data buffer, a fine interpolation module, an M data buffer and an M code execution module. The application can realize efficient operation of the numerical control system and optimized machining effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of numerical control automation technology, and in particular to a method and apparatus for coordinating G-instructions and digital input instructions in a PC + I / O interface numerical control system. Background Technology

[0002] With the continuous development of the manufacturing industry, CNC systems have become one of the indispensable key technologies in manufacturing. Developing open, high-performance, intelligent, and low-cost CNC systems is a hot topic in the field of CNC technology. Currently, high-performance, high-real-time open CNC systems based on general-purpose PC platforms are attracting much attention. In this field, the primary issue is to solve the efficient decoding of G-codes and auxiliary function instructions such as M, S, and T in NC programs, as well as the coordinated control of G-codes and switching instructions. Only by solving these problems can the efficient operation of the CNC system and optimized machining results be achieved. Summary of the Invention

[0003] This invention proposes a method and device for coordinating G-instructions and switch instructions in a CNC system with a PC + I / O interface, which can achieve efficient operation of the CNC system and optimize machining results.

[0004] The present invention adopts the following technical solution.

[0005] The PC-based CNC system with I / O interface includes a G-code and digital input / output command coordination device. This control device comprises a PC and an I / O interface card. The PC decodes the G-code / digital input / output commands and performs coarse interpolation of the G-code motion trajectory. The digital input / output commands are M-codes, including M, S, and T instruction codes. The I / O interface card performs fine interpolation of the motion trajectory and controls the execution of the M-codes. The PC includes a decoding preprocessing module, a G-code buffer, an M-code buffer for digital input / output command buffering, a coarse interpolation module and a coarse interpolation data buffer, channel B for coarse interpolation data output, channel A for digital input / output command data input control, an M-code coordination module for digital input / output command coordination, and channel C for M-code data output control. The on / off states of channels A, B, and C are all controllable.

[0006] The I / O interface card is equipped with an interpolation data buffer, a fine interpolation module, an M data buffer, and an M code execution module.

[0007] The method for coordinating G-code and digital input commands in a PC + I / O interface CNC system, using the aforementioned PC + I / O interface CNC system G-code and digital input command coordination device, is used for the coordinated control of G-code and digital input commands in an open CNC system based on a "PC + I / O interface" structure. The coordination method is used for the efficient decoding of G-code and M, S, T auxiliary function commands in data processing NC programs, as well as the coordinated control of G-code and digital input commands, and includes the following steps;

[0008] Step S1: First, the G code and M code in the preprocessed NC program are encapsulated into an NMLmsg data structure format, where the data structure contains the data type type. Then, the task command processing function taskCmdHandle() stores the G code and M code into the G code buffer and M buffer respectively according to the type in the NMLmsg data structure.

[0009] In step S2, the data from the G code buffer is sent to the coarse interpolation module for speed planning and coarse interpolation calculation. The data from the coarse interpolation buffer is then sent to the interpolation data buffer of the I / O interface card via channel B, where the fine interpolation module controls the motion trajectory. The data from the M code buffer is sent to the buffer of the M code coordination control module via channel A, and then to the M data buffer of the I / O interface card via channel C. The M code execution module then executes the M, S, and T auxiliary function instruction codes.

[0010] Step S3: The PC controls the on / off states of channels A, B, and C to achieve correct and orderly coordinated decoding and control execution of G / M codes.

[0011] The M, S, and T instruction code data structures of the pre-decoded NC program are equipped with "pre-identifiers". During the decoding process, the "pre-identifiers" of the M code data are stored in the G code buffer to coordinate the joint execution of G and M instructions. The open / closed state of the channel B is controllable, and its state depends on the variable value B. The variable value B depends on variables B1 and B2, and the logical relationship is B = B1 ∩ B2.

[0012] When B=1, channel B is open, and data from the coarse interpolation buffer of the PC coarse interpolation module can be sent to the interpolation data buffer of the I / O interface card; when B=0, channel B is closed, closing the channel between the coarse interpolation buffer of the PC and the interpolation data buffer of the I / O interface card, and the PC cannot send coarse interpolation data to the I / O interface card.

[0013] When the coarse interpolation data buffer of the PC's coarse interpolation module is to transmit the "prefix flag" of the M instruction, set B1=0; when the data to be transmitted by the M code coordination control module is the "end flag" of the M instruction or the buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, and set B1=1; when the I / O interface card's switch control related interface is ready, set B2=1, otherwise set B2=0.

[0014] The on / off state of channel A is controllable, and its state depends on the state of variable A. When the buffer data of the M code coordination module is empty, or when the M instruction "end flag" is detected, A is set to 1, and channel A is in the on state. The M code buffer can continue to send the next M instruction to the M code coordination module. Once the M code coordination module receives a new complete M instruction data, it sets A to 0 and closes channel A. The M code coordination module only accepts and processes one switch instruction at any given time.

[0015] The on / off state of channel C can be controlled, depending on the state of variable C. When C=1, channel C is open, the M code coordination module can send M instruction data to the M data buffer of the I / O interface card, and the M code execution module of the I / O interface card executes the M instruction; when C=0, channel C is closed, the M code coordination module cannot send M instruction data to the I / O interface card.

[0016] The state of channel C is determined by state variables C1, C2, and B2. The logical relationship is C = C1 ∩ C2 ∩ B2. That is, if any one of the three state variables C1, C2, and B2 is 0, then C = 0; otherwise, C = 1.

[0017] When the fine interpolation module of the I / O interface card has completed the fine interpolation motion trajectory control, i.e., is ready, set C2=1; otherwise, set C2=0. When the M code execution module of the I / O interface card has completed the execution of the switch quantity and is ready, set B2=1; otherwise, set B2=0.

[0018] When the data to be transmitted in the coarse interpolation data buffer of the PC's coarse interpolation module is the "prefix flag" of the M instruction, set B1=0 and C1=1. When the data to be transmitted in the M code coordination module is the "accept flag" of the M instruction, or when the data buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, set C1=0 and B1=1.

[0019] The coarse interpolation module and the M-code coordination module are encapsulated into two different threads. They lock the global variables B1 and C1 using a mutex. Only the coarse interpolation thread or the M-code coordination thread can acquire the mutex and operate on B1 and C1 at the same time. The other thread waits for the thread that acquired the mutex to release the lock before it can try to acquire the lock, in order to prevent two threads from operating on the variables B1 and C1 at the same time and producing erroneous results.

[0020] After the coarse interpolation module and the M-code coordination module are encapsulated into two different threads, synchronization between the threads is achieved using condition variables. The condition variables utilize the shared global variables B1, B2, C1, and C2 for synchronization. The condition variables compensate for the shortcomings of mutexes by allowing threads to block and wait for signals from other threads. In use, a condition variable is used to block a thread. When the condition is not met, the thread unlocks the corresponding mutex and waits for the condition to change. Once another thread changes the condition variable, it will notify the corresponding condition variable to wake up one or more threads that are blocked by this condition variable. These threads will relock the mutex and retest whether the condition is met.

[0021] When the coarse interpolation thread encapsulated in the coarse interpolation module needs to transmit the "prefix flag" of the M instruction code to the I / O interface card, the coarse interpolation thread is suspended and put into a sleep state. It will only be woken up by the zq_cond.notify_all() function when B2=1, that is, the relevant ports of the I / O interface card are ready, and C2=1, that is, the I / O interface card has completed fine interpolation.

[0022] When the M-code coordinating thread detects that the data to be transmitted is an M-instruction "end marker," it indicates that the M-code instruction data transmission is complete, meaning the PC has finished processing this M-code instruction. At this point, the appearance of the M-instruction "end marker" indicates that the data buffer of the M-code instruction coordinating module is empty. The M-code coordinating thread suspends and enters a sleep state, only waking up the sleeping M-code sending thread through the zq_cond.notify_all() function when B2=1, meaning the I / O interface card's switch control-related ports are ready. This allows the two threads to synchronize and achieve correct and orderly coordinated decoding and control execution of G / M codes.

[0023] When the data processing NC program is an NC program that begins with G-code, at the start of the NC program, B1=1 and C1=0 are initially set. When the G-code data is sent to the coarse interpolation module, if the fine interpolation of the I / O interface card is ready, C2=1 is set. If the I / O interface switch control related interface is ready, B2=1 and K=C2∩B2=1 are set, making B=B1∩B2=1 and C=C1∩K=0. This allows for the transmission of G-code coarse interpolation data to the I / O interface card, and fine interpolation is performed. Simultaneously, any M-code transmission and execution are prohibited. When the data to be transmitted from the "data buffer" of the "coarse interpolation module" is detected to be the M-instruction "prefix",... When the "recognition" signal is received, B1=0 and C1=1 are triggered. At this time, if the relevant ports of the I / O interface card's switch control are ready, then B2=1, and the I / O interface card has completed the "fine interpolation signal" C2=1, K=C2∩B2=1, B=B1∩B2=0, making B=0, and making C=C1∩K=1. At this time, the "M code coordination module" of the PC executes one M instruction code and transmits the M instruction data to the I / O interface card. The relevant modules of the I / O interface card execute the M instruction. When the data to be transmitted by the "M code coordination module" is the "end marker" of the M instruction, it means that the data transmission of this M code instruction is complete, which means that the PC has completed the transmission of this M code. During instruction processing, the M-code coordination module's data buffer is empty, i.e., B1 = 1 and C1 = 0. If the I / O interface card's switch control ports are ready, then B2 = 1, making B = B1∩B2 = 1. The I / O interface card has completed the "fine interpolation signal" C2 = 1, K = C2∩B2 = 1, making C = C1∩K = 0, thus opening the data transmission channel from the G-code coarse interpolation data to the I / O interface card. Simultaneously, when the "decoding preprocessing module" detects that the M-code coordination module's buffer is empty, it detects the M instruction "end flag," indicating that the M instruction execution is complete, and sets A = 1. At this point, the M-code of the "decoding preprocessing module"... The data buffer can continue to send the next M-code to the "M-code Coordination Module". When it is detected that the new data to be transmitted in the "data buffer" of the "coarse interpolation module" is the "pre-identifier" of a new M-code instruction, B1=0 and C1=1 are triggered. If the relevant ports of the I / O interface card are ready, then B2=1, making K=B1∩B2=1. If it is detected that the I / O interface card has completed fine interpolation, then C2=1 and K=C2∩B2=1, making C=C1∩K=1. A new M-code is then executed in the "M-code Coordination Module", transmitting the M-code data to the I / O interface card. The relevant modules of the I / O interface card then execute the M-code.This process repeats until an M02 instruction is encountered. When the data to be transmitted from the "data buffer" of the "coarse interpolation module" is detected to be the M-code "pre-identifier," i.e., the M02 instruction, B1=0 and C1=1, making B=B1∩B2=0. It then waits for the "fine interpolation signal" C2=1 to be received, and the I / O interface card's switch-related port ready signal B2=1, making K=B2∩C2=1 and C=C1∩K=1. The "M-code coordination module" then executes a new M02 instruction code and transmits the M02 instruction data to the I / O interface card. The relevant module on the I / O interface card executes the M02 instruction, completing its execution and sending a signal to the PC.

[0024] When the data processing NC program is an NC program starting with M code, when the CNC program starts running, first set B1=1 and C1=0; firstly, the decoding preprocessing module sends the data to the data buffer of the coarse interpolation module. When it detects that the data to be transmitted by the coarse interpolation module to the I / O interface card is the "pre-signal" of the M instruction code, it triggers B1=0 and C1=1. At this time, if the I / O interface card's switch control related ports are ready, then B2=1, making B=B1∩B2=0. If it detects that the I / O interface card has completed fine interpolation, that is, C2=1 and K=C2∩B2=1, making C=C1∩K=1, it starts executing one M instruction code in the M code coordination module and transmits the M instruction data to the I / O interface card, which is then executed by the relevant modules of the I / O interface card. When it detects that the data to be transmitted by the M code coordination module is the "end sign" of the M instruction, it says... Once the M-code instruction data transmission is complete, it means the PC has finished processing the M-code instruction. At this point, the M-code instruction "end flag" appears, indicating that the M-code instruction coordination module's data buffer is empty, i.e., B1 = 1 and C1 = 0. If the I / O interface card's switch control ports are ready, then B2 = 1, making B = B1 ∩ B2 = 1, thus opening the data transmission channel B for G-code coarse interpolation data to the I / O interface card. Simultaneously, since C1 = 0, C = C1 ∩ K = 0, thus closing the data transmission channel C for M-code data to the I / O interface card. At the same time, when the "decoding preprocessing module" detects that the "M-code coordination module" buffer is empty, it detects the M-code instruction "end flag," indicating that the M-code instruction has been executed, and sets A = 1. At this point, the M-code data buffer of the decoding preprocessing module can continue to send the next M-code instruction to the M-code coordination module.

[0025] When new G code is sent to the "coarse interpolation module", the "coarse interpolation module" performs coarse interpolation of the G code. Since B=1 and C=0 at this time, the coarse interpolation data can be transmitted to the I / O interface card. The I / O interface card performs fine interpolation motion control and temporarily prohibits any M code from being transmitted to the I / O interface card.

[0026] When the "data buffer" of the "coarse interpolation module" detects that the data to be transmitted is the M-code "prefix identifier," it triggers B1=0 and C1=1. At this time, if the relevant ports of the I / O interface card's switch control are ready, then B2=1 and B=B1∩B2=0. If the signal that the I / O interface card has completed fine interpolation is detected, C2=1 and K=C2∩B2=1, making C=C1∩K=1, a new M-instruction code is executed in the "M-code coordination module," and the M-instruction data is transmitted to the I / O interface card. The relevant modules of the I / O interface card execute this M-instruction. When the "M-code coordination module" detects that it needs to transmit... When the data is the "end marker" of the M instruction, it means that the data transmission of this M code instruction has been completed, which means that the PC has completed the processing of this M code instruction. At this time, the appearance of the "end marker" of the M instruction indicates that the data buffer of the M code instruction coordination module is empty, that is, B1=1 and C1=0 are set. At this time, if the relevant ports of the I / O interface card switch control are ready, then B2=1, making B=B1∩B2=1. If the signal that the I / O interface card has completed fine interpolation is detected, C2=1, K=C2∩B2=1, C=C1∩K=0, that is, the data transmission channel of G code coarse interpolation data to the I / O interface card is opened again. Make B = B1∩B2 = 1. When the data transmitted from the coarse interpolation module's data buffer is detected to be the M instruction code "pre-identifier" of the M02 instruction, B1 = 0 and C1 = 1 is triggered again. At this time, if the I / O interface card's switch control related ports are ready, then B2 = 1 and B = B1∩B2 = 0. If the signal that the I / O interface card has completed fine interpolation is detected, C2 = 1 and K = C2∩B2 = 1, making C = C1∩K = 1, and starting again in the M code... The coordination module executes a new M-code, namely the M02 instruction, and transmits the M02 instruction data to the I / O interface card. The relevant modules of the I / O interface card then execute the M02 instruction. When the data to be transmitted by the "M-code coordination module" is the "end flag" of the M02 instruction, it means that the PC has completed the transmission of this M-code instruction data to the I / O interface card. The process continues until the I / O interface card completes the execution of the M02 instruction and sends a completion signal to the PC, at which point B2 = 1, indicating the end of the M02 instruction.

[0027] This invention enables the efficient operation of CNC systems and optimizes machining results. Attached Figure Description

[0028] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:

[0029] Appendix Figure 1 This is a schematic diagram of the coordination mechanism between G instructions and switch instructions of the present invention;

[0030] Appendix Figure 2This is a schematic diagram of the NC program types of the present invention (a is an NC program that starts with G code, and b is an NC program that starts with M code). Detailed Implementation

[0031] As shown in the figure, the PC + I / O interface CNC system includes a G-code and digital input / output command coordination device. The control device comprises a PC and an I / O interface card. The PC decodes the G-code / digital input / output commands and performs coarse interpolation of the G-code motion trajectory. The digital input / output commands are M-codes, including M, S, and T instruction codes. The I / O interface card performs fine interpolation of the motion trajectory and controls the execution of the M-codes. The PC includes a decoding preprocessing module, a G-code buffer, an M-code buffer for digital input / output command buffering, a coarse interpolation module and a coarse interpolation data buffer, channel B for coarse interpolation data output, channel A for digital input / output command data input control, an M-code coordination module for digital input / output command coordination, and channel C for M-code data output control. The on / off states of channels A, B, and C are all controllable.

[0032] The I / O interface card is equipped with an interpolation data buffer, a fine interpolation module, an M data buffer, and an M code execution module.

[0033] The method for coordinating G-code and digital input commands in a PC + I / O interface CNC system, using the aforementioned PC + I / O interface CNC system G-code and digital input command coordination device, is used for the coordinated control of G-code and digital input commands in an open CNC system based on a "PC + I / O interface" structure. The coordination method is used for the efficient decoding of G-code and M, S, T auxiliary function commands in data processing NC programs, as well as the coordinated control of G-code and digital input commands, and includes the following steps;

[0034] Step S1: First, the G code and M code in the preprocessed NC program are encapsulated into an NMLmsg data structure format, where the data structure contains the data type type. Then, the task command processing function taskCmdHandle() stores the G code and M code into the G code buffer and M buffer respectively according to the type in the NMLmsg data structure.

[0035] In step S2, the data from the G code buffer is sent to the coarse interpolation module for speed planning and coarse interpolation calculation. The data from the coarse interpolation buffer is then sent to the interpolation data buffer of the I / O interface card via channel B, where the fine interpolation module controls the motion trajectory. The data from the M code buffer is sent to the buffer of the M code coordination control module via channel A, and then to the M data buffer of the I / O interface card via channel C. The M code execution module then executes the M, S, and T auxiliary function instruction codes.

[0036] Step S3: The PC controls the on / off states of channels A, B, and C to achieve correct and orderly coordinated decoding and control execution of G / M codes.

[0037] The M, S, and T instruction code data structures of the pre-decoded NC program are equipped with "pre-identifiers". During the decoding process, the "pre-identifiers" of the M code data are stored in the G code buffer to coordinate the joint execution of G and M instructions. The open / closed state of the channel B is controllable, and its state depends on the variable value B. The variable value B depends on variables B1 and B2, and the logical relationship is B = B1 ∩ B2.

[0038] When B=1, channel B is open, and data from the coarse interpolation buffer of the PC coarse interpolation module can be sent to the interpolation data buffer of the I / O interface card; when B=0, channel B is closed, closing the channel between the coarse interpolation buffer of the PC and the interpolation data buffer of the I / O interface card, and the PC cannot send coarse interpolation data to the I / O interface card.

[0039] When the coarse interpolation data buffer of the PC's coarse interpolation module is to transmit the "prefix flag" of the M instruction, set B1=0; when the data to be transmitted by the M code coordination control module is the "end flag" of the M instruction or the buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, and set B1=1; when the I / O interface card's switch control related interface is ready, set B2=1, otherwise set B2=0.

[0040] The on / off state of channel A is controllable, and its state depends on the state of variable A. When the buffer data of the M code coordination module is empty, or when the M instruction "end flag" is detected, A is set to 1, and channel A is in the on state. The M code buffer can continue to send the next M instruction to the M code coordination module. Once the M code coordination module receives a new complete M instruction data, it sets A to 0 and closes channel A. The M code coordination module only accepts and processes one switch instruction at any given time.

[0041] The on / off state of channel C can be controlled, depending on the state of variable C. When C=1, channel C is open, the M code coordination module can send M instruction data to the M data buffer of the I / O interface card, and the M code execution module of the I / O interface card executes the M instruction; when C=0, channel C is closed, the M code coordination module cannot send M instruction data to the I / O interface card.

[0042] The state of channel C is determined by state variables C1, C2, and B2. The logical relationship is C = C1 ∩ C2 ∩ B2. That is, if any one of the three state variables C1, C2, and B2 is 0, then C = 0; otherwise, C = 1.

[0043] When the fine interpolation module of the I / O interface card has completed the fine interpolation motion trajectory control, i.e., is ready, set C2=1; otherwise, set C2=0. When the M code execution module of the I / O interface card has completed the execution of the switch quantity and is ready, set B2=1; otherwise, set B2=0.

[0044] When the data to be transmitted in the coarse interpolation data buffer of the PC's coarse interpolation module is the "prefix flag" of the M instruction, set B1=0 and C1=1. When the data to be transmitted in the M code coordination module is the "accept flag" of the M instruction, or when the data buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, set C1=0 and B1=1.

[0045] The coarse interpolation module and the M-code coordination module are encapsulated into two different threads. They lock the global variables B1 and C1 using a mutex. Only the coarse interpolation thread or the M-code coordination thread can acquire the mutex and operate on B1 and C1 at the same time. The other thread waits for the thread that acquired the mutex to release the lock before it can try to acquire the lock, in order to prevent two threads from operating on the variables B1 and C1 at the same time and producing erroneous results.

[0046] After the coarse interpolation module and the M-code coordination module are encapsulated into two different threads, synchronization between the threads is achieved using condition variables. The condition variables utilize the shared global variables B1, B2, C1, and C2 for synchronization. The condition variables compensate for the shortcomings of mutexes by allowing threads to block and wait for signals from other threads. In use, a condition variable is used to block a thread. When the condition is not met, the thread unlocks the corresponding mutex and waits for the condition to change. Once another thread changes the condition variable, it will notify the corresponding condition variable to wake up one or more threads that are blocked by this condition variable. These threads will relock the mutex and retest whether the condition is met.

[0047] When the coarse interpolation thread encapsulated in the coarse interpolation module needs to transmit the "prefix flag" of the M instruction code to the I / O interface card, the coarse interpolation thread is suspended and put into a sleep state. It will only be woken up by the zq_cond.notify_all() function when B2=1, that is, the relevant ports of the I / O interface card are ready, and C2=1, that is, the I / O interface card has completed fine interpolation.

[0048] When the M-code coordinating thread detects that the data to be transmitted is an M-instruction "end marker," it indicates that the M-code instruction data transmission is complete, meaning the PC has finished processing this M-code instruction. At this point, the appearance of the M-instruction "end marker" indicates that the data buffer of the M-code instruction coordinating module is empty. The M-code coordinating thread suspends and enters a sleep state, only waking up the sleeping M-code sending thread through the zq_cond.notify_all() function when B2=1, meaning the I / O interface card's switch control-related ports are ready. This allows the two threads to synchronize and achieve correct and orderly coordinated decoding and control execution of G / M codes.

[0049] When the data processing NC program is an NC program that begins with G-code, at the start of the NC program, B1=1 and C1=0 are initially set. When the G-code data is sent to the coarse interpolation module, if the fine interpolation of the I / O interface card is ready, C2=1 is set. If the I / O interface switch control related interface is ready, B2=1 and K=C2∩B2=1 are set, making B=B1∩B2=1 and C=C1∩K=0. This allows for the transmission of G-code coarse interpolation data to the I / O interface card, and fine interpolation is performed. Simultaneously, any M-code transmission and execution are prohibited. When the data to be transmitted from the "data buffer" of the "coarse interpolation module" is detected to be the M-instruction "prefix",... When the "recognition" signal is received, B1=0 and C1=1 are triggered. At this time, if the relevant ports of the I / O interface card's switch control are ready, then B2=1, and the I / O interface card has completed the "fine interpolation signal" C2=1, K=C2∩B2=1, B=B1∩B2=0, making B=0, and making C=C1∩K=1. At this time, the "M code coordination module" of the PC executes one M instruction code and transmits the M instruction data to the I / O interface card. The relevant modules of the I / O interface card execute the M instruction. When the data to be transmitted by the "M code coordination module" is the "end marker" of the M instruction, it means that the data transmission of this M code instruction is complete, which means that the PC has completed the transmission of this M code. During instruction processing, the M-code coordination module's data buffer is empty, i.e., B1 = 1 and C1 = 0. If the I / O interface card's switch control ports are ready, then B2 = 1, making B = B1∩B2 = 0. The I / O interface card has completed the "fine interpolation signal" C2 = 1, K = C2∩B2 = 1, making C = C1∩K = 1, thus opening the data transmission channel from the G-code coarse interpolation data to the I / O interface card. Simultaneously, when the "decoding preprocessing module" detects that the M-code coordination module's buffer is empty, it detects the M instruction "end flag," indicating that the M instruction execution is complete, and sets A = 1. At this point, the M-code of the "decoding preprocessing module"... The data buffer can continue to send the next M-code to the "M-code Coordination Module". When it is detected that the new data to be transmitted in the "data buffer" of the "coarse interpolation module" is the "pre-identifier" of a new M-code instruction, B1=0 and C1=1 are triggered. If the relevant ports of the I / O interface card are ready, then B2=1, making K=B1∩B2=1. If it is detected that the I / O interface card has completed fine interpolation, then C2=1 and K=C2∩B2=1, making C=C1∩K=1. A new M-code is then executed in the "M-code Coordination Module", transmitting the M-code data to the I / O interface card. The relevant modules of the I / O interface card then execute the M-code.This process repeats until an M02 instruction is encountered. When the data to be transmitted from the "data buffer" of the "coarse interpolation module" is detected to be the M-code "pre-identifier," i.e., the M02 instruction, B1=0 and C1=1, making B=B1∩B2=0. It then waits for the "fine interpolation signal" C2=1 to be received, and the I / O interface card's switch-related port ready signal B2=1, making K=C2∩B2=1 and C=C1∩K=1. The "M-code coordination module" then executes a new M02 instruction code and transmits the M02 instruction data to the I / O interface card. The relevant module on the I / O interface card executes the M02 instruction, completing its execution and sending a signal to the PC.

[0050] When the data processing NC program is an NC program starting with M code, when the CNC program starts running, first set B1=1 and C1=0; firstly, the decoding preprocessing module sends the data to the data buffer of the coarse interpolation module. When it detects that the data to be transmitted by the coarse interpolation module to the I / O interface card is the "pre-signal" of the M instruction code, it triggers B1=0 and C1=1. At this time, if the I / O interface card's switch control related ports are ready, then B2=1, making B=B1∩B2=0. If it detects that the I / O interface card has completed fine interpolation, that is, C2=1 and K=C2∩B2=1, making C=C1∩K=1, it starts executing one M instruction code in the M code coordination module and transmits the M instruction data to the I / O interface card, which is then executed by the relevant modules of the I / O interface card. When it detects that the data to be transmitted by the M code coordination module is the "end sign" of the M instruction, it says... Once the M-code instruction data transmission is complete, it means the PC has finished processing the M-code instruction. At this point, the M-code instruction "end flag" appears, indicating that the M-code instruction coordination module's data buffer is empty, i.e., B1 = 1 and C1 = 0. If the I / O interface card's switch control ports are ready, then B2 = 1, making B = B1 ∩ B2 = 1, thus opening the data transmission channel B for G-code coarse interpolation data to the I / O interface card. Simultaneously, since C1 = 0, C = C1 ∩ K = 0, thus closing the data transmission channel C for M-code data to the I / O interface card. At the same time, when the "decoding preprocessing module" detects that the "M-code coordination module" buffer is empty, it detects the M-code instruction "end flag," indicating that the M-code instruction has been executed, and sets A = 1. At this point, the M-code data buffer of the decoding preprocessing module can continue to send the next M-code instruction to the M-code coordination module.

[0051] When new G code is sent to the "coarse interpolation module", the "coarse interpolation module" performs coarse interpolation of the G code. Since B=1 and C=0 at this time, the coarse interpolation data can be transmitted to the I / O interface card. The I / O interface card performs fine interpolation motion control and temporarily prohibits any M code from being transmitted to the I / O interface card.

[0052] When the "data buffer" of the "coarse interpolation module" detects that the data to be transmitted is the M-code "prefix identifier," it triggers B1=0 and C1=1. At this time, if the relevant ports of the I / O interface card's switch control are ready, then B2=1 and B=B1∩B2=0. If the signal that the I / O interface card has completed fine interpolation is detected, C2=1 and K=C2∩B2=1, making C=C1∩K=1, a new M-instruction code is executed in the "M-code coordination module," and the M-instruction data is transmitted to the I / O interface card. The relevant modules of the I / O interface card execute this M-instruction. When the "M-code coordination module" detects that it needs to transmit... When the data is the "end marker" of the M instruction, it means that the data transmission of this M code instruction has been completed, which means that the PC has completed the processing of this M code instruction. At this time, the appearance of the "end marker" of the M instruction indicates that the data buffer of the M code instruction coordination module is empty, that is, B1=1 and C1=0. At this time, if the relevant ports of the I / O interface card switch control are ready, then B2=1, making B=B1∩B2=0. If the signal that the I / O interface card has completed fine interpolation is detected, C2=1, K=C2∩B2=1, C=C1∩K=0, that is, the data transmission channel of G code coarse interpolation data to the I / O interface card is opened again. Make B = B1∩B2 = 1. When the data transmitted from the coarse interpolation module's data buffer is detected to be the M instruction code "pre-identifier" of the M02 instruction, B1 = 0 and C1 = 1 is triggered again. At this time, if the I / O interface card's switch control related ports are ready, then B2 = 1 and B = B1∩B2 = 0. If the signal that the I / O interface card has completed fine interpolation is detected, C2 = 1 and K = C2∩B2 = 1, making C = C1∩K = 1, and starting again in the M code... The coordination module executes a new M-code, namely the M02 instruction, and transmits the M02 instruction data to the I / O interface card. The relevant modules of the I / O interface card then execute the M02 instruction. When the data to be transmitted by the "M-code coordination module" is the "end flag" of the M02 instruction, it means that the PC has completed the transmission of this M-code instruction data to the I / O interface card. The process continues until the I / O interface card completes the execution of the M02 instruction and sends a completion signal to the PC, at which point B2 = 1, indicating the end of the M02 instruction.

Claims

1. A method for coordinating G-instructions and digital input instructions in a PC + I / O interface CNC system, using a device for coordinating G-instructions and digital input instructions in a PC + I / O interface CNC system, for coordinating the control of G-instructions and digital input instructions in an open CNC system based on a "PC + I / O interface" structure, characterized in that: The collaborative device includes a PC and an I / O interface card. The PC decodes G-code / switching commands and performs coarse interpolation of the G-code motion trajectory. The switching commands are M-codes, which include M, S, and T instruction codes. The I / O interface card performs fine interpolation of the motion trajectory and controls the execution of the M-codes. The PC is equipped with a decoding preprocessing module, a G-code buffer, an M-code buffer for switching command buffering, a coarse interpolation module and a coarse interpolation data buffer, a channel B for coarse interpolation data output, a channel A for switching command data input control, an M-code coordination module for switching command coordination, and a channel C for M-code data output control. The on / off states of channels A, B, and C are all controllable. The I / O interface card is equipped with an interpolation data buffer, a fine interpolation module, an M data buffer, and an M code execution module; The aforementioned collaborative method is used for the efficient decoding of G-codes and M, S, T auxiliary function instructions in data processing NC programs, as well as the coordinated control of G-codes and switching instructions. Includes the following steps; Step S1: First, the G code and M code in the preprocessed NC program are encapsulated into an NMLmsg data structure format, where the data structure contains the data type type. Then, the task command processing function taskCmdHandle() stores the G code and M code into the G code buffer and M buffer respectively according to the type in the NMLmsg data structure. In step S2, the data from the G code buffer is sent to the coarse interpolation module for speed planning and coarse interpolation calculation. The data from the coarse interpolation buffer is then sent to the interpolation data buffer of the I / O interface card via channel B, where the fine interpolation module controls the motion trajectory. The data from the M code buffer is sent to the buffer of the M code coordination control module via channel A, and then via channel C to the M data buffer of the I / O interface card. The M code execution module then executes the M, S, and T auxiliary function instruction codes. Step S3: The PC controls the on / off states of channels A, B, and C to achieve correct and orderly coordinated decoding and control execution of G / M codes. The M, S, and T instruction code data structures of the NC program after decoding and preprocessing have "pre-identifiers"; During the decoding process, the "pre-identifier" of the M code data is stored in the G code buffer to coordinate the joint execution of G instructions and M instructions; The open / closed state of channel B is controllable, and its state depends on the variable value B. The variable value B depends on variables B1 and B2, and the logical relationship is B=B1∩B2. When B=1, channel B is open, and data from the coarse interpolation buffer of the PC coarse interpolation module can be sent to the interpolation data buffer of the I / O interface card; when B=0, channel B is closed, closing the channel between the coarse interpolation buffer of the PC and the interpolation data buffer of the I / O interface card, and the PC cannot send coarse interpolation data to the I / O interface card. When the coarse interpolation data buffer of the PC's coarse interpolation module is to transmit the "prefix flag" of the M instruction, set B1=0; when the data to be transmitted by the M code coordination control module is the "end flag" of the M instruction or the buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, and set B1=1; when the I / O interface card's switch control related interface is ready, set B2=1, otherwise set B2=0.

2. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 1, characterized in that: The on / off state of channel A is controllable, and its state depends on the state of variable A. When the buffer data of the M code coordination module is empty, or when the M instruction "end flag" is detected, A is set to 1, and channel A is in the on state. The M code buffer can continue to send the next M instruction to the M code coordination module. Once the M code coordination module receives a new complete M instruction data, it sets A to 0 and closes channel A. The M code coordination module only accepts and processes one switch instruction at any given time.

3. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 2, characterized in that: The on / off state of channel C can be controlled, depending on the state of variable C. When C=1, channel C is open, the M code coordination module can send M instruction data to the M data buffer of the I / O interface card, and the M code execution module of the I / O interface card executes the M instruction. When C=0, channel C is closed, and the M code coordination module cannot send M instruction data to the I / O interface card. The state of channel C is determined by state variables C1, C2, and B2. The logical relationship is C = C1 ∩ C2 ∩ B2. That is, if any one of the three state variables C1, C2, and B2 is 0, then C = 0; otherwise, C = 1. When the fine interpolation module of the I / O interface card has completed the fine interpolation motion trajectory control, i.e. is ready, set C2=1; otherwise, set C2=0. When the M code execution module of the I / O interface card has completed the execution of the switch quantity and is ready, set B2=1; otherwise, set B2=0. When the data to be transmitted in the coarse interpolation data buffer of the PC's coarse interpolation module is the "prefix flag" of the M instruction, set B1=0 and C1=1. When the data to be transmitted in the M code coordination module is the "accept flag" of the M instruction, or when the data buffer of the M code coordination module is empty, it means that the PC has completed the processing of the current M instruction, set C1=0 and B1=1.

4. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 3, characterized in that: The coarse interpolation module and the M-code coordination module are encapsulated into two different threads. They lock the global variables B1 and C1 using a mutex. Only the coarse interpolation thread or the M-code coordination thread can acquire the mutex and operate on B1 and C1 at the same time. The other thread waits for the thread that acquired the mutex to release the lock before it can try to acquire the lock, in order to prevent two threads from operating on the variables B1 and C1 at the same time and producing erroneous results.

5. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 4, characterized in that: After the coarse interpolation module and the M-code coordination module are encapsulated into two different threads, synchronization between threads is achieved using condition variables. The condition variables utilize the shared global variables B1, B2, C1, and C2 for synchronization. The condition variables compensate for the shortcomings of mutexes by allowing threads to block and wait for signals from other threads. In use, a condition variable is used to block a thread. When the condition is not met, the thread unlocks the corresponding mutex and waits for the condition to change. Once another thread changes the condition variable, it will notify the corresponding condition variable to wake up one or more threads that are currently blocked by this condition variable. These threads will relock the mutex and retest whether the condition is met.

6. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 5, characterized in that: When the coarse interpolation thread encapsulated in the coarse interpolation module needs to transmit the "pre-identifier" of the M instruction code to the I / O interface card, the coarse interpolation thread is suspended and put into a sleep state. It will only be woken up by the zq_cond.notify_all() function when B2=1, that is, the relevant ports of the I / O interface card are ready, and C2=1, that is, the I / O interface card has completed fine interpolation. When the M-code coordinating thread detects that the data to be transmitted is an M-instruction "end marker," it indicates that the M-code instruction data transmission is complete, meaning the PC has finished processing this M-code instruction. At this point, the appearance of the M-instruction "end marker" indicates that the data buffer of the M-code instruction coordinating module is empty. The M-code coordinating thread suspends and enters a sleep state, only waking up the sleeping M-code sending thread through the zq_cond.notify_all() function when B2=1, meaning the I / O interface card's switch control-related ports are ready. This allows the two threads to synchronize and achieve correct and orderly coordinated decoding and control execution of G / M codes.

7. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 6, characterized in that: When the data processing NC program is an NC program that begins with G-code, when the CNC program starts running, B1=1 and C1=0 are initially set. When the G-code data is sent to the coarse interpolation module, if the fine interpolation of the I / O interface card is ready, C2=1 is set; if the I / O interface switch control related interface terminals are ready, B2=1 is set. ,make , The system performs G-code coarse interpolation data transmission to the I / O interface card and fine interpolation, while simultaneously prohibiting any M-code transmission and execution. When the data to be transmitted from the coarse interpolation module's data buffer is detected to be an M-instruction "prefix flag," B1=0 and C1=1 are triggered. At this time, if the I / O interface card's switch control ports are ready, then B2=1, and the I / O interface card has completed the "fine interpolation signal" C2=1. , Make B=0, make At this point, the M-code coordination module of the PC executes one M-instruction code and transmits the M-instruction data to the I / O interface card. The relevant module of the I / O interface card executes the M-instruction. When it detects that the data to be transmitted by the M-code coordination module is the "end marker" of the M-instruction, it means that the data transmission of this M-code instruction is complete, which means that the PC has completed the processing of this M-code instruction. At this time, the data buffer of the M-code coordination module is empty, that is, B1=1 and C1=0. At this time, if the relevant ports of the I / O interface card for switch control are ready, then B2=1, thereby enabling... The I / O interface card has completed the "fine interpolation signal" C2=1. ,make This means that the data transmission channel for G-code coarse interpolation data to the I / O interface card is opened; simultaneously, when the "decoding preprocessing module" detects that the buffer data of the "M-code coordination module" is empty, it detects the "end flag" of the M instruction, that is, the execution of the M instruction has been completed, and sets A=1. At this time, the M-code data buffer of the "decoding preprocessing module" can continue to send the next M-code code to the "M-code instruction coordination module"; when it detects that the new data to be transmitted in the "data buffer" of the "coarse interpolation module" is the "prefix flag" of a new M-code instruction, it triggers B1=0 and C1=1. At this time, if the relevant ports for I / O interface card switch control are ready, then B2=1, making... If it is detected that the I / O interface card has completed fine interpolation C2=1, ,make The "M-code Coordination Module" begins executing a new M-instruction code, transmitting M-instruction data to the I / O interface card. The relevant modules on the I / O interface card then execute this M-instruction. This process repeats until the M02 instruction is encountered. When the "Coarse Interpolation Module's" "Data Buffer" detects that the data to be transmitted is the M-code "prefix flag," i.e., the M02 instruction, B1=0 and C1=1, causing... Waiting to receive the "fine interpolation completed" signal C2=1 and the I / O interface card's switch-related port ready signal B2=1, so that... , The M code coordination module executes a new M02 instruction code and transmits the M02 instruction data to the I / O interface card. The relevant module of the I / O interface card executes the M02 instruction to complete the execution of the M02 instruction, that is, it sends a signal to inform the PC.

8. The method for coordinating G-instructions and digital input / output instructions in a PC + I / O interface CNC system according to claim 7, characterized in that: When the data processing NC program is an NC program starting with M code, when the CNC program starts running, first set B1=1 and C1=0; the decoding preprocessing module first sends the data to the data buffer of the coarse interpolation module. When it detects that the data to be transmitted by the coarse interpolation module to the I / O interface card is the "prefix flag" of the M instruction code, it triggers B1=0 and C1=1. At this time, if the I / O interface card's switch control related ports are ready, then B2=1, making... If a signal indicating that the I / O interface card has completed fine interpolation is detected, i.e., C2=1, ,make The process begins by executing one M-instruction code in the M-code coordination module and transmitting the M-instruction data to the I / O interface card. The relevant modules on the I / O interface card then execute the M-instruction. When the M-code coordination module detects that the data to be transmitted is the M-instruction "end marker," it indicates that the M-code instruction data transmission is complete, meaning the PC has finished processing the M-code instruction. At this point, the appearance of the M-instruction "end marker" indicates that the M-code instruction coordination module's data buffer is empty, i.e., B1=1 and C1=0 are set. If the I / O interface card's switch control ports are ready, then B2=1, making... This means opening the data transmission channel B from G-code coarse interpolation data to the I / O interface card; simultaneously, since C1=0, it enables... This means closing the data transmission channel C from the M code data to the I / O interface card; at the same time, when the decoding preprocessing module detects that the M code coordination module buffer is empty, it detects the M instruction "end flag", that is, the M instruction has been executed, and sets A=1. At this time, the M code data buffer of the decoding preprocessing module can continue to send the next M instruction code to the M code coordination module. When new G code is sent to the coarse interpolation module, the coarse interpolation module performs coarse interpolation of the G code. Since B=1 and C=0 at this time, the coarse interpolation data can be transmitted to the I / O interface card. The I / O interface card performs fine interpolation motion control and temporarily prohibits any M code from being transmitted to the I / O interface card. When the data to be transmitted from the coarse interpolation module's data buffer is detected to be the M code "prefix identifier", B1=0 and C1=1 are triggered. At this time, if the relevant ports for I / O interface card switch control are ready, then B2=1. If the signal C2=1 indicates that the I / O interface card has completed fine interpolation, ,make The system then begins executing a new M-instruction code in the M-code coordination module and transmits the M-instruction data to the I / O interface card. The relevant modules on the I / O interface card execute this M-instruction. When the M-code coordination module detects that the data to be transmitted is the M-instruction "end marker," it indicates that the M-code instruction data transmission is complete, meaning the PC has finished processing this M-code instruction. At this point, the appearance of the M-instruction "end marker" indicates that the M-code instruction coordination module's data buffer is empty, i.e., B1=1 and C1=0 are set. If the I / O interface card's switch control ports are ready, then B2=1, making... If the signal C2=1 indicates that the I / O interface card has completed fine interpolation, , That is, the data transmission channel from G-code coarse interpolation data to the I / O interface card is opened again; make ,make When the data transmitted from the coarse interpolation module's data buffer is detected to be the M instruction code "prefix flag" of the M02 instruction, B1=0 and C1=1 are triggered again. At this time, if the I / O interface card's switch control related ports are ready, then B2=1. If the signal C2=1 indicates that the I / O interface card has completed fine interpolation, ,make Then, a new M-instruction code, namely the M02 instruction, is executed in the M-code coordination module, and the M02 instruction data is transmitted to the I / O interface card. The relevant module of the I / O interface card executes the M02 instruction. When the data to be transmitted by the M-code coordination module is the "end flag" of the M02 instruction, it means that the PC has completed the transmission of this M-code instruction data to the I / O interface card. The process continues until the I / O interface card finishes executing the M02 instruction and sends a completion signal to the PC, at which point B2=1, indicating the end of the M02 instruction.

Citation Information

Patent Citations

  • Numerical control interpolation system with PC+DSP timing and interruption

    CN103926882A

  • Method of setting date in numerical control apparatus

    WO1984003960A1