A numerical control system data flow cooperative control method and device, a terminal and a medium
Patent Information
- Application Number
- CN202611132966.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2046-07-29
AI Technical Summary
[0004]然而,上述分离架构虽然解决了计算效率问题,却引入了新的技术问题:非实时计算模块运行于非实时操作系统或低优先级线程中,其任务执行受操作系统调度影响,存在不可预测的调度抖动
将缓冲区状态分为高水位区和低水位区两种异常状态,分别执行相应处理策略:当剩余存储空间低于高水位线阈值时,控制非实时计算模块暂停写入,防止缓冲区溢出造成数据覆盖;当未读数据量低于低水位线阈值时,触发降级减速保护,使实时端主动降低运动速度。相比于仅调整生产者端执行速率的单端调节方案,本发明实现了生产者端与消费者端的双向协同控制,即使非实时端因极端负载无法加速生产,实时端也能通过主动降速保障系统不失控,显著提升了系统的鲁棒性和安全性。
Smart Images

Figure CN122653106B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of motion control and numerical control technology, specifically to a method, device, terminal, and medium for collaborative control of data flow in a numerical control system. Background Technology
[0002] In high-speed, high-precision CNC systems or robot controllers, trajectory planning, look-ahead control, and interpolation calculations are typically performed within a real-time operating system. As machining complexity increases, the look-ahead algorithm needs to calculate a large number of geometric constraints and dynamic equations, resulting in an exponential increase in computational load. Real-time threads have strict time deterministic constraints; if the look-ahead calculation is not completed within a given period, it will trigger a real-time task timeout, leading to system crashes or motor jitter.
[0003] To resolve the conflict between high computational demands and strong real-time requirements, related technologies split interpolation calculations into two parts: non-real-time discrete calculations and real-time interpolation calculations. For example, complex trajectory planning algorithms are placed in non-real-time calculations, allowing trajectory planning to escape the time constraints of real-time interpolation cycles, while the real-time end only performs fine interpolation calculations. Furthermore, other related technologies separate the allocation process of digital control information from the real-time control process, transmitting control information through a non-real-time interface, while the real-time interface is simplified to sending linkage commands according to the control rhythm.
[0004] However, while the aforementioned separation architecture solves the computational efficiency problem, it introduces new technical challenges: the non-real-time computing module runs on a non-real-time operating system or in a low-priority thread, and its task execution is affected by the operating system's scheduling, resulting in unpredictable scheduling jitter. When the non-real-time end experiences output delays due to changes in system load, background task interference, or blockages caused by complex geometric operations, the data supply rate decreases, leading to the risk of data interruption when the real-time end reads data from the buffer, i.e., the "data starvation" phenomenon.
[0005] Related technologies address data flow interruption issues by setting overflow and underflow warning thresholds in the cache and monitoring the rate of change of cached data volume. When an underflow risk is detected, the scheduling cycle of the producer's real-time tasks is adjusted to increase data output. This scheme uses a K-order Markov model to predict the direction of data volume change and determines the timing of adjustments based on the prediction results. However, this scheme only prevents data flow interruption by adjusting the execution rate of producer tasks, making it a single-end adjustment solution. When the producer cannot effectively increase its production rate due to extreme system load, the security of real-time data supply cannot be guaranteed, and the consumer end may still experience motion command interruptions due to data flow interruptions. Summary of the Invention
[0006] To address the aforementioned issues, this invention provides a data flow collaborative control method, device, terminal, and medium for CNC systems. This method enables bidirectional collaborative control between the production and consumption ends in CNC systems where real-time and non-real-time operations are separated. It avoids servo command interruptions and mechanical shocks caused by data flow interruptions, and prevents data overwriting due to buffer overflows, thereby improving system operational stability and machining safety.
[0007] In a first aspect, the technical solution of the present invention provides a data flow collaborative control method for a numerical control system, comprising the following steps: The non-real-time calculation module receives the machining trajectory data, performs geometric calculation, look-ahead velocity planning and coarse interpolation calculation, and generates coarse interpolation data blocks containing position, velocity and acceleration information; The coarse interpolation data block is written to a double-ended shared memory buffer; the non-real-time computing module acts as a producer to write data to the buffer, and the real-time control module acts as a consumer to read data from the buffer. The real-time control module reads coarse interpolation data blocks from the buffer at hardware servo cycles, performs fine interpolation calculations based on the coarse interpolation data blocks, and generates servo drive instructions. The real-time control module monitors the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the non-real-time computing module is controlled to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer.
[0008] Secondly, the technical solution of the present invention provides a data flow collaborative control device for a numerical control system, comprising: The non-real-time calculation module is used to receive machining trajectory data, perform geometric calculations, look-ahead velocity planning and coarse interpolation calculations, and generate coarse interpolation data blocks containing position, velocity and acceleration information; A dual-ended shared memory buffer is used to connect the non-real-time computing module and the real-time control module. The non-real-time computing module acts as a producer, writing coarse interpolation data blocks to the buffer, while the real-time control module acts as a consumer, reading coarse interpolation data blocks from the buffer. The real-time control module is used to read coarse interpolation data blocks from the buffer at hardware servo cycles, perform fine interpolation calculations based on the coarse interpolation data blocks, generate servo drive instructions, and monitor the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the module controls the non-real-time calculation module to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer.
[0009] Thirdly, the technical solution of the present invention provides a terminal, including: The memory is used to store the data flow coordination control program of the CNC system; A processor is configured to implement the steps of the CNC system data flow collaborative control method as described above when executing the CNC system data flow collaborative control program.
[0010] Fourthly, the present invention provides a computer-readable storage medium storing a CNC system data flow collaborative control program, wherein when the CNC system data flow collaborative control program is executed by a processor, it implements the steps of the CNC system data flow collaborative control method as described in any of the above claims.
[0011] As can be seen from the above technical solutions, this application has the following advantages: The buffer state is divided into two abnormal states: high-water mark and low-water mark, and corresponding handling strategies are implemented for each: when the remaining storage space is lower than the high-water mark threshold, the non-real-time computing module is controlled to pause writing to prevent buffer overflow and data overwriting; when the amount of unread data is lower than the low-water mark threshold, degradation and deceleration protection is triggered, causing the real-time end to actively reduce its movement speed. Compared with a single-end adjustment scheme that only adjusts the execution rate of the producer end, this invention achieves bidirectional collaborative control between the producer end and the consumer end. Even if the non-real-time end cannot accelerate production due to extreme load, the real-time end can still ensure that the system does not go out of control by actively reducing its speed, significantly improving the robustness and security of the system.
[0012] After triggering the deceleration protection, the instruction speed for the current cycle is reduced proportionally based on the amount of data remaining in the buffer, rather than stopping directly or abruptly decelerating. The less data remaining, the greater the speed reduction, ensuring that the speed change matches the data supply status. This achieves a continuous and smooth speed transition, effectively preventing servo instruction interruptions and mechanical shocks caused by data flow interruptions, thus protecting the safety of the machine tool and workpiece.
[0013] The control method for the producer side involves pausing the non-real-time computing module's write operation during high-water mark conditions and shortening the coarse interpolation cycle to accelerate data production during low-water mark conditions. Both controls apply to the non-real-time computing module. The control method for the consumer side involves recalculating the polynomial coefficients during fine interpolation calculations using a safe speed value as the speed boundary condition. This process only changes the output instructions at the fine interpolation calculation level and does not involve adjusting the real-time task scheduling cycle. Neither of these control methods requires intervention in the real-time operating system's task scheduling mechanism, avoiding the additional real-time overhead and uncertainty introduced by adjusting the real-time task scheduling cycle. Attached Figure Description
[0014] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 This is a schematic flowchart of a data flow collaborative control method for a numerical control system provided in an embodiment of the present invention.
[0016] Figure 2 This is a schematic block diagram of a data flow collaborative control device for a numerical control system provided in an embodiment of the present invention.
[0017] Figure 3 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation
[0018] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this application and in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0020] Figure 1 This is a schematic flowchart of a data flow collaborative control method for a numerical control system provided in an embodiment of the present invention. Figure 1 The executing entity can be a CNC system data flow collaborative control system. The CNC system data flow collaborative control method provided in this embodiment is executed by a computer device; correspondingly, the CNC system data flow collaborative control system runs on the computer device. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0021] like Figure 1 As shown, the method includes the following steps.
[0022] S1 receives the machining trajectory data from the non-real-time calculation module, performs geometric calculation, look-ahead velocity planning, and coarse interpolation calculation, and generates a coarse interpolation data block containing position, velocity, and acceleration information.
[0023] The non-real-time computing module runs on a non-real-time operating system or in a low-priority thread, and its coarse interpolation cycle is... The value ranges from 4ms to 10ms. Each coarse interpolation data block generated by this module contains at least the target displacement. Target speed Target acceleration And the status identifier, Status, is used to describe the motion state at the end of a coarse interpolation cycle.
[0024] Optionally, the non-real-time calculation module also performs geometric continuity smoothing on the machining trajectory, which is at least G2 continuity or C2 continuity to ensure the smoothness of the machining path. Forward-looking speed planning is based on the machine tool system's maximum acceleration limit, maximum jerk limit, and contour error limit, and can employ S-curve speed planning or T-curve speed planning.
[0025] Specifically, the machining trajectory segment is read and smoothed for geometric continuity (G2 / C2 continuity). Based on the machine tool system's maximum acceleration, jerk, and contour error limitations, multi-segment look-ahead speed planning (S-curve or T-curve) is performed. The coarse interpolation cycle is used. Discretize the calculation for the step size and output the target displacement of the k-th coarse interpolation point. Target speed Target acceleration The encapsulated coarse interpolation data frame Push it into the shared memory buffer.
[0026] S2 writes the coarse interpolation data block into a double-ended shared memory buffer; the non-real-time computing module acts as a producer, writing data to the buffer, while the real-time control module acts as a consumer, reading data from the buffer.
[0027] The buffer adopts a lock-free circular queue structure, established in the operating system kernel mode. The non-real-time computing module acts as a producer, writing data to the tail of the buffer, while the real-time control module acts as a consumer, reading data from the head of the buffer. No mutex lock is set between the two to avoid blocking and priority inversion problems caused by locking mechanisms, thus meeting the time determinism requirements of the real-time control module.
[0028] A circular queue achieves conflict-free reading and writing of data by maintaining write pointers and read pointers. When the write pointer catches up with the read pointer, it means the buffer is full; when the read pointer catches up with the write pointer, it means the buffer is empty.
[0029] S3 is a real-time control module that reads coarse interpolation data blocks from the buffer at hardware servo cycles, performs fine interpolation calculations based on the coarse interpolation data blocks, and generates servo drive instructions.
[0030] The real-time control module runs in a real-time operating system or a high-priority hardware interrupt, with a fine interpolation cycle. The value ranges from 250μs to 1ms. When each fine interpolation cycle is triggered, the real-time control module checks whether the buffer is empty; if it is not empty, it reads a coarse interpolation data block from the head of the buffer as the input for the current fine interpolation cycle.
[0031] The fine interpolation calculation employs a high-order polynomial interpolation algorithm to interpolate the fine position command at each fine interpolation cycle between two adjacent coarse interpolation data blocks. Let the current position be within the coarse interpolation cycle corresponding to the k-th coarse interpolation data block, with a relative time... ,in The time step within the fine interpolation cycle. Then the position command after fine interpolation satisfy:
[0032] Among them, polynomial coefficients The position and velocity boundary conditions of the k-th coarse interpolation data block and the (k+1)-th coarse interpolation data block are uniquely determined.
[0033] Optionally, the fine interpolation calculation can employ cubic Hermite polynomial or quintic polynomial interpolation algorithms. Cubic Hermite polynomial interpolation ensures continuity of position and velocity at both ends of the interpolation interval, while quintic polynomial interpolation further guarantees acceleration continuity. The axis position control quantity obtained after fine interpolation is converted into an industrial bus data message and sent to the servo drive. This industrial bus can be an EtherCAT bus.
[0034] S4, the real-time control module monitors the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the non-real-time calculation module is controlled to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer.
[0035] Specifically, after the real-time control module completes the fine interpolation calculation in each fine interpolation cycle, or while performing the fine interpolation calculation, it checks two key status indicators of the buffer: 1) remaining storage space, which is the difference between the total capacity of the buffer and the currently used space; 2) unread data volume, which is the number of coarse interpolation data blocks that have been written to the buffer but have not yet been read.
[0036] When the remaining storage space is lower than the preset high water level threshold When the buffer is nearing full capacity, further data writing by the non-real-time computing module could lead to data overwriting or loss. At this point, the real-time control module sends a pause write signal to the non-real-time computing module. Upon receiving this signal, the non-real-time computing module pauses writing new coarse-impregnated data blocks to the buffer until the remaining storage space recovers to above the high-water mark threshold. During this period, the real-time control module continues to read data from the buffer and perform fine-impregnation calculations, and the consumer operates normally.
[0037] The amount of unread data is below the preset low watermark threshold. This indicates that there is insufficient data in the buffer for the real-time control module to read. If the non-real-time computing module cannot replenish the data in time, the real-time control module will face the risk of data interruption. At this time, the real-time control module triggers a degradation and deceleration protection strategy based on the number of unread data blocks remaining in the buffer. Reduce the instruction speed of the current cycle proportionally. .
[0038] The degradation and deceleration protection is designed to reduce the speed as the amount of remaining data decreases, with the speed changing synchronously with the amount of remaining data. In a preferred embodiment of this invention, the instruction speed for the current cycle is reduced proportionally based on the amount of remaining data in the buffer. Specifically, this includes: real-time acquisition of the number of remaining data blocks in the buffer; calculation of the ratio of this number to the number of data blocks corresponding to the low-water mark threshold; using this ratio as a speed adjustment coefficient; and multiplying the instruction speed for the current cycle by the speed adjustment coefficient to obtain the degraded safe speed instruction value. The number of data blocks corresponding to the low-water mark threshold refers to the number of unread data blocks in the buffer that triggers the degradation and deceleration protection.
[0039] Specifically, safe speed Calculate using the following formula:
[0040] in, The downgraded safe speed command value. The instruction rate for the current cycle. This represents the number of coarse interpolation data blocks currently remaining in the buffer. This represents the number of data blocks corresponding to the low watermark threshold.
[0041] This formula uses the ratio of the number of remaining data blocks to the low watermark threshold as a scaling factor to scale the current speed proportionally. When the number of remaining data blocks equals the low watermark threshold, the ratio is 1, and the speed remains unchanged; when the number of remaining data blocks approaches 0, the ratio approaches 0, and the speed approaches 0. In other words, when... hour, This means the speed decreases. The less data remaining, the faster the speed. The smaller the value, the greater the speed reduction. The speed change matches the data supply status, achieving continuous and smooth speed adjustment.
[0042] The degraded speed protection can employ either linear deceleration or S-shaped deceleration. Once the amount of unread data in the buffer recovers to above the low water level threshold, the real-time control module exits the degraded speed protection mode and resumes normal command speed.
[0043] The working principle of this method is as follows: During the operation of the CNC system, the non-real-time calculation module uses a coarse interpolation cycle. The real-time control module continuously generates coarse interpolation data blocks and writes them to the buffer for each beat, while maintaining a fine interpolation cycle. The system reads data from the buffer and performs fine interpolation to maintain a consistent output. Under normal operating conditions, the production and consumption rates are macroscopically balanced, and the amount of data in the buffer remains within the low-water mark threshold range. When the non-real-time computing module experiences output delays due to system scheduling jitter, background task interference, or complex geometric operations blocking, its data production rate decreases, and the amount of unread data in the buffer continuously decreases. When the amount of unread data falls below the low-water mark threshold, the real-time control module triggers a degradation and deceleration protection mechanism, proportionally reducing the instruction speed of the current cycle, thereby reducing its own data consumption rate and buying time for upstream data production to recover. When the non-real-time computing module rapidly generates a large amount of data due to sudden tasks, the amount of data in the buffer increases rapidly, and the remaining storage space continuously decreases. When the remaining storage space falls below the high-water mark threshold, the real-time control module controls the non-real-time computing module to pause writing to prevent buffer overflow. By implementing the corresponding processing for high and low water levels, bidirectional collaborative control between the non-real-time and real-time ends can be achieved: at low water levels, the real-time end actively slows down (throttling), while the non-real-time end accelerates production (open source); at high water levels, the non-real-time end pauses writing (flow limiting), while the real-time end consumes data normally (unblocking), forming a complete closed-loop feedback system. This avoids the limitations of the traditional one-way adjustment mode that only adjusts the producer end, and can effectively cope with the risk of data interruption under extreme load conditions on the non-real-time end. Furthermore, the control over the production end (pausing writing or accelerating production) applies to the non-real-time computing module, while the control over the consumption end (degradation and slowdown) only changes the speed boundary conditions at the fine interpolation calculation level, without involving adjustments to the real-time task scheduling cycle, thus avoiding the additional real-time overhead and uncertainty introduced by interfering with the real-time operating system's scheduling mechanism.
[0044] In some alternative implementations, the high water level threshold and the low water level threshold can be preset fixed values, determined by relevant personnel based on experience or system design parameters.
[0045] In some alternative implementations, the high-water level threshold and low-water level threshold are adaptively set. It should be noted that during the operation of the CNC system, the data production rate of the non-real-time calculation module... and the data consumption rate of the real-time control module It is not constant. The production rate is affected by factors such as the complexity of the processing trajectory, the amount of look-ahead computation, and the system load; the consumption rate is affected by factors such as the current feed rate and the fine interpolation cycle. Meanwhile, because the non-real-time computing module runs on a non-real-time operating system, its task execution is subject to unpredictable scheduling jitter, resulting in output delays. The system state changes dynamically. Therefore, a fixed threshold may not simultaneously meet the safety and efficiency requirements of the system under different operating states. Based on this, adaptive settings are implemented: monitoring the data production rate of the non-real-time computing module and the data consumption rate of the real-time control module; calculating the low-water level threshold and high-water level threshold based on the data production rate, data consumption rate, and the output delay time of the non-real-time computing module due to operating system task scheduling; and dynamically updating the high-water level threshold and / or low-water level threshold according to a preset update cycle. Specifically, this includes the following steps.
[0046] Step 1: Monitor the data production rate and data consumption rate.
[0047] Continuous monitoring of the data production rate of the non-real-time computing module Data consumption rate with real-time control module .
[0048] Data production rate This represents the number of coarse interpolation data blocks written to the buffer by the non-real-time computing module per unit time. Specifically, the counter is incremented every time the non-real-time computing module generates a coarse interpolation data block and successfully writes it to the buffer. At the end of each monitoring cycle, the total number of writes within that cycle is counted and divided by the monitoring cycle duration to obtain the average production rate within that monitoring cycle.
[0049] Data consumption rate This represents the number of coarse interpolated data blocks read from the buffer by the real-time control module per unit time. Specifically, the real-time control module increments the counter by one each time it reads a coarse interpolated data block from the buffer. At the end of each monitoring cycle, the total number of reads within that cycle is calculated and divided by the monitoring cycle duration to obtain the average consumption rate within that monitoring cycle.
[0050] The duration of the monitoring cycle can be set according to the actual needs of the system, for example, it can be set as a coarse interpolation cycle. Integer multiples of.
[0051] Step 2: Measure the system scheduling jitter time.
[0052] The output delay time of the non-real-time computing module caused by the operating system task scheduling is measured. .
[0053] The non-real-time computing module runs in a non-real-time operating system or a low-priority thread. Its task execution may experience output delays due to operating system scheduling, interrupt responses, background task interference, or blocking by complex geometric operations. This delay manifests as the time interval between the non-real-time computing module being awakened and actually completing the generation and writing of the coarse interpolation data block to the buffer exceeding its theoretical execution time.
[0054] Specifically, a timestamp can be recorded each time a data block is written in the non-real-time computing module. Simultaneously record the theoretical completion time corresponding to this data block. Then the output will be delayed. The output latency of multiple data blocks is continuously monitored, and the maximum value is taken as the maximum output latency time within the current monitoring period. .
[0055] Step 3: Calculate the low water level threshold.
[0056] Based on data consumption rate Maximum output delay time and fine interpolation cycle Calculate the low water level threshold , represented as:
[0057] This formula calculates the worst-case scenario where the non-real-time computing module completely stops production due to scheduling jitter, and how many data blocks the buffer needs to pre-store to ensure that the real-time control module does not experience data interruption during the jitter period. (Numerator) This indicates the total number of data blocks that the real-time control module will consume at the current consumption rate within the maximum jitter time. This indicates the number of data blocks that the real-time control module may consume within the maximum output delay time. This is the preset number of safety margin data blocks used to provide additional safety buffers.
[0058] The low water level threshold should ensure that, in the worst-case scenario, when the non-real-time computing module suspends data production due to scheduling jitter, the existing data blocks in the buffer are sufficient to support the real-time control module to continue operating within the maximum output delay time without data interruption.
[0059] Step 4: Calculate the high water level threshold.
[0060] Based on the preset total capacity C and data production rate Maximum output delay time and fine interpolation cycle Calculate the high water level threshold , represented as:
[0061] This formula calculates the worst-case scenario where the non-real-time computing module continuously produces at maximum rate due to sudden tasks, and how much remaining space needs to be reserved in the buffer to ensure that data overflow or overwriting does not occur during jitter. (Numerator) This represents the total number of data blocks that the non-real-time computing module will generate at the current production rate within the maximum jitter time. This indicates the number of data blocks that the non-real-time calculation module may generate within the maximum output delay time; C is the preset total capacity of the buffer, which is allocated and determined during the initialization of the CNC system and remains unchanged during the machining process.
[0062] The high watermark threshold should ensure that, in the worst-case scenario, when the non-real-time computing module rapidly generates a large amount of data due to a sudden task, there is still enough remaining space in the buffer to accommodate the data that may be generated within the maximum output delay time, without data overflow or overwriting.
[0063] Step 5: Periodic dynamic update of the threshold.
[0064] According to the preset update cycle, steps 1 to 4 are repeated to dynamically update the high water level threshold and / or low water level threshold.
[0065] The preset update cycle can be set by relevant personnel according to the actual needs of the system. An update cycle that is too short may cause frequent fluctuations in the threshold, affecting system stability; an update cycle that is too long will fail to reflect changes in the system's operating status in a timely manner. Preferably, the update cycle can be set to a coarse interpolation cycle. Integer multiples of.
[0066] Through dynamic updates, the high and low water level thresholds can be adaptively adjusted according to changes in the system's operating status, avoiding the problem of fixed thresholds triggering degradation and deceleration too early under high load (sacrificing efficiency) or triggering too late under low load (insufficient security), thus maximizing processing efficiency while ensuring data flow security.
[0067] In other preferred implementations, statistical prediction models are used to quantitatively analyze the fluctuation characteristics of data production and consumption rates, improving the stability and reliability of the threshold and avoiding frequent threshold jumps caused by instantaneous rate fluctuations. Specifically, the data production and consumption rates are continuously monitored over multiple update cycles, and their mean and standard deviation are calculated respectively. The upper and lower limits of the rates are predicted using the mean and standard deviation, and the predicted values are used to replace the instantaneous values for threshold calculation.
[0068] Specifically, the data production rate and the data consumption rate are continuously monitored over M update cycles, and the average production rate is calculated for each. Production rate standard deviation Average consumption rate Standard deviation of consumption rate The mean reflects the central trend of the rate, while the standard deviation reflects the fluctuation range of the rate. The larger the standard deviation, the more unstable the system's operating state and the more drastic the rate fluctuations; the smaller the standard deviation, the more stable the system's operating state.
[0069] Then, the upper limit of the production rate forecast is calculated based on the mean and standard deviation of the production rate. ,in The production rate confidence coefficient is set; the lower limit of the predicted consumption rate is calculated based on the mean and standard deviation of the consumption rate. ,in The confidence coefficient for the preset consumption rate.
[0070] in, This is a preset confidence coefficient used to control the coverage of rate fluctuations within the prediction interval. A larger value results in a wider prediction interval and higher coverage of rate fluctuations, but reduces the threshold's sensitivity to changes in system state. Conversely, a smaller value results in a narrower prediction interval and a more sensitive threshold to changes in system state, but may lead to insufficient threshold setting due to failure to cover actual fluctuations. The value can be set according to the system's actual requirements for safety and sensitivity. The value of .
[0071] Based on the upper limit of the production rate forecast Alternative data production rate Calculate the high water level threshold using the lower bound prediction of the consumption rate. Alternative data consumption rate Calculate the low water level threshold, and then obtain the low water level threshold:
[0072] And the high water level threshold:
[0073] In steps 3 and 4 above, the number of safety margin data blocks These are preset parameters used to provide an additional safety buffer in threshold calculations. Preferably, the number of safety margin data blocks is dynamically adjusted based on the historical water level fluctuations in the buffer. This mechanism automatically reduces the buffer level when the system is stable and automatically increases it when system fluctuations intensify. Specifically, it monitors the level fluctuation amplitude of the buffer over multiple update cycles, where the level fluctuation amplitude is the change in the amount of unread data in the buffer per unit time. When the level fluctuation amplitude exceeds a preset fluctuation threshold, the number of safety margin data blocks is increased; when the level fluctuation amplitude is below the preset fluctuation threshold, the number of safety margin data blocks is decreased.
[0074] Specifically, continuously monitor the amount of unread data in the buffer. Changes over time. Let... For a moment Unread data volume at that time For a moment The amount of unread data at any given time, then the time period Water level fluctuation range for:
[0075] in, This represents the change in the amount of unread data per unit of time. When the data production rate exceeds the data consumption rate, the amount of unread data increases, and the water level rises; when the data consumption rate exceeds the data production rate, the amount of unread data decreases, and the water level falls. The fluctuation range of the water level reflects the dynamic changes in the balance between data supply and demand.
[0076] The calculated water level fluctuation amplitude is compared with the preset fluctuation threshold. Comparisons can be made. The preset fluctuation threshold can be pre-set by technicians based on the actual operating characteristics of the system, or it can be determined through system identification or experimental calibration.
[0077] When the water level fluctuation exceeds the preset fluctuation threshold, it indicates that the system is operating unstable and data stream fluctuations are intensified. In this case, the number of safety margin data blocks should be increased. Specifically, the increment of the safety margin... It can be determined based on the degree of deviation between the water level fluctuation amplitude and the preset fluctuation threshold:
[0078] in, This is a preset proportional coefficient used to convert deviations in water level fluctuations into incremental safety margins. When hour, With increased safety margin, the low water level threshold is raised accordingly, and the system triggers degradation and deceleration protection in advance, enhancing its ability to absorb data flow fluctuations and resist shocks.
[0079] When the water level fluctuation is below the preset fluctuation threshold, it indicates that the system is operating stably. At this time, the number of safety margin data blocks should be reduced.
[0080] in, This is a preset scaling factor. When... hour, With the safety margin reduced, the low water level threshold is lowered accordingly, and the system delays the triggering of degradation deceleration protection, reducing unnecessary protection actions and maintaining processing efficiency.
[0081] It should be noted that an initial safety margin value should be set in advance. For example, the initial value can be set to 5% to 10% of the preset total capacity of the buffer.
[0082] In some alternative implementations, after triggering the degraded speed protection, bidirectional coordinated adjustment is performed, including the following steps.
[0083] Step 1: Feedback transmission of safe speed command value.
[0084] The real-time control module will calculate the degraded safe speed command value. Send to the non-real-time computing module.
[0085] Since a shared memory buffer exists as a data channel between the real-time control module and the non-real-time computing module, this feedback signal can be transmitted through a status field in the shared memory or a dedicated signal channel. The non-real-time computing module checks this signal value at the beginning of each coarse interpolation cycle to obtain the current safe speed command value from the real-time end.
[0086] Step 2: The non-real-time computing module accelerates data production.
[0087] The non-real-time computing module shortens the coarse interpolation cycle to accelerate data production based on the current safe speed command value.
[0088] Specifically, coarse interpolation period Adjust dynamically according to the following formula:
[0089] in, For the current coarse interpolation period, This is the adjusted coarse interpolation period. When degraded deceleration protection is triggered, ,therefore This means that the coarse interpolation cycle is shortened, the non-real-time calculation module performs more coarse interpolation calculations per unit time, generates more coarse interpolation data blocks, and the data production rate is increased accordingly.
[0090] This step allows the non-real-time end to switch from normal production mode to accelerated production mode, replenishing buffer data from the source.
[0091] Step 3: The real-time control module recalculates the fine interpolation polynomial coefficients using the safe speed value as the speed boundary condition.
[0092] When performing fine interpolation calculations, the real-time control module uses the current safe speed command value as the end speed boundary condition of the current fine interpolation cycle and recalculates the fine interpolation polynomial coefficients.
[0093] Specifically, obtain the position of the current coarse interpolation data block. With speed As the initial position boundary condition and initial velocity boundary condition; to obtain the position of the next coarse interpolation data block. As the boundary condition for the endpoint position, and with the safe speed command value As the boundary condition for the final velocity.
[0094] Substitute the four boundary conditions mentioned above into the cubic polynomial interpolation formula. Use dimensionless relative time. Normalization is performed, assuming the current location is within the coarse interpolation period corresponding to the k-th coarse interpolation data block, and the relative time... Where t is the time elapsed since the start of the current coarse interpolation cycle. For the coarse interpolation cycle, the position command after fine interpolation... satisfy:
[0095] The polynomial coefficients are uniquely determined by the following system of boundary condition equations. :
[0096] in, Corresponding to the starting point of the coarse interpolation period, Corresponding to the end of the coarse interpolation cycle, and These are the positions of the k-th and (k+1)-th coarse interpolation data blocks, respectively. For the speed of the k-th coarse interpolation data block, This is the boundary condition for the end velocity of the current fine interpolation cycle, calculated after the deceleration protection is triggered. Multiply by in velocity boundary conditions The reason is: position commands relative time derivative The derivative with respect to actual time t Between Therefore, when expressed in relative time, the velocity boundary condition needs to be multiplied by... The conversion is performed to ensure that the velocity value of the position command output by the fine interpolation is consistent with the boundary conditions on the actual time scale.
[0097] Through the above calculations, the coefficients of the fine interpolation polynomial are redefined, and the velocity of the position command output by the fine interpolation on the actual time scale smoothly transitions to the safe velocity command value at the end of the coarse interpolation cycle. The acceleration remains bounded, thus effectively avoiding mechanical shocks caused by sudden changes in velocity.
[0098] The foregoing has described in detail an embodiment of a CNC system data flow collaborative control method. Based on the CNC system data flow collaborative control method described in the above embodiment, the present invention also provides a CNC system data flow collaborative control device corresponding to the method.
[0099] Figure 2 This is a schematic block diagram of a CNC system data flow collaborative control device provided in an embodiment of the present invention. In this embodiment, the CNC system data flow collaborative control device can be divided into multiple functional modules according to the functions it performs. A module, as referred to in this invention, is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory.
[0100] The non-real-time calculation module is used to receive machining trajectory data, perform geometric calculations, look-ahead velocity planning, and coarse interpolation calculations, and generate coarse interpolation data blocks containing position, velocity, and acceleration information.
[0101] A dual-ended shared memory buffer is used to connect the non-real-time computing module and the real-time control module. The non-real-time computing module acts as a producer, writing coarse interpolation data blocks to the buffer, while the real-time control module acts as a consumer, reading coarse interpolation data blocks from the buffer.
[0102] The real-time control module is used to read coarse interpolation data blocks from the buffer at hardware servo cycles, perform fine interpolation calculations based on the coarse interpolation data blocks, generate servo drive instructions, and monitor the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the module controls the non-real-time calculation module to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer.
[0103] The CNC system data flow collaborative control device of this embodiment is used to implement the aforementioned CNC system data flow collaborative control method. Therefore, the specific implementation of this device can be found in the embodiment section of the CNC system data flow collaborative control method above. Thus, its specific implementation can be referred to the description of the corresponding embodiments, and will not be elaborated here.
[0104] Furthermore, since the CNC system data flow collaborative control device in this embodiment is used to implement the aforementioned CNC system data flow collaborative control method, its function corresponds to the function of the above method, and will not be described again here.
[0105] Figure 3 This is a schematic diagram of a terminal 300 provided in an embodiment of the present invention, including: a processor 310, a memory 320, and a communication unit 330. The processor 310 is used to implement the process steps of the above-described embodiment of the CNC system data flow collaborative control method when implementing the CNC system data flow collaborative control program stored in the memory 320.
[0106] This invention also provides a computer storage medium, which may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. The computer storage medium stores a CNC system data flow collaborative control program. When the CNC system data flow collaborative control program is executed by a processor, it implements the process steps of the above-described CNC system data flow collaborative control method embodiment.
[0107] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data flow collaborative control method for a numerical control system, characterized in that, Includes the following steps: The non-real-time calculation module receives the machining trajectory data, performs geometric calculation, look-ahead velocity planning and coarse interpolation calculation, and generates coarse interpolation data blocks containing position, velocity and acceleration information; The coarse interpolation data block is written to a double-ended shared memory buffer; the non-real-time computing module acts as a producer to write data to the buffer, and the real-time control module acts as a consumer to read data from the buffer. The real-time control module reads coarse interpolation data blocks from the buffer at hardware servo cycles, performs fine interpolation calculations based on the coarse interpolation data blocks, and generates servo drive instructions. The real-time control module monitors the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the non-real-time calculation module is controlled to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer. This includes: obtaining the number of remaining data blocks in the buffer in real time, calculating the ratio of the number of remaining data blocks to the number of data blocks corresponding to the low watermark threshold, using this ratio as the speed adjustment coefficient, and multiplying the instruction speed of the current cycle by the speed adjustment coefficient to obtain the degraded safe speed instruction value. The method also includes the following steps: Monitor the data production rate of the non-real-time computing module and the data consumption rate of the real-time control module; Based on the data production rate, data consumption rate, and output latency caused by operating system task scheduling in non-real-time computing modules, the low-water mark threshold and high-water mark threshold are calculated. Specifically, this includes obtaining the preset total capacity C of the buffer and the fine interpolation cycle of the real-time control module. ;Measure the maximum output delay time of the non-real-time computing module within a preset time period. According to data consumption rate Maximum output delay time and fine interpolation cycle Calculate the low water level threshold , represented as: Based on the preset total capacity C and data production rate Maximum output delay time and fine interpolation cycle Calculate the high water level threshold , represented as: ;in, The preset safety margin number of data blocks. The rounding up symbol; The high water level threshold and / or low water level threshold are dynamically updated according to a preset update cycle. After the degradation and deceleration protection is triggered, the method also includes the following steps: The real-time control module sends the current safe speed command value to the non-real-time calculation module; The non-real-time computing module shortens the coarse interpolation cycle to accelerate data production based on the current safe speed command value, i.e., the coarse interpolation cycle. Adjust dynamically according to the following formula: In the formula, For the current coarse interpolation period, This is the adjusted coarse interpolation period. The downgraded safe speed command value. The instruction rate for the current cycle; When performing fine interpolation calculations, the real-time control module uses the current safe speed command value as the end speed boundary condition of the current fine interpolation cycle and recalculates the fine interpolation polynomial coefficients.
2. The CNC system data flow collaborative control method according to claim 1, characterized in that, The method also includes the following steps: Continuously monitor the data production rate and data consumption rate over M update cycles, and calculate the average production rate for each. Production rate standard deviation Average consumption rate Standard deviation of consumption rate ; Calculate the upper limit prediction of production rate based on the mean and standard deviation of production rate. ,in The preset production rate confidence coefficient; Calculate the lower bound forecast value of consumption rate based on the mean and standard deviation of consumption rate. ,in The confidence coefficient for the preset consumption rate; Based on the upper limit of the production rate forecast Alternative data production rate Calculate the high water level threshold using the lower bound prediction of the consumption rate. Alternative data consumption rate Calculate the low water level threshold.
3. The CNC system data flow collaborative control method according to claim 1 or 2, characterized in that, The method also includes: The water level fluctuation amplitude of the monitoring buffer is the amount of unread data in the buffer per unit time. When the water level fluctuation exceeds the preset fluctuation threshold, the number of safety margin data blocks is increased; when the water level fluctuation is below the preset fluctuation threshold, the number of safety margin data blocks is decreased.
4. A data flow collaborative control device for a numerical control system, characterized in that, The apparatus is used to implement the method according to any one of claims 1 to 3, and the apparatus comprises: The non-real-time calculation module is used to receive machining trajectory data, perform geometric calculations, look-ahead velocity planning and coarse interpolation calculations, and generate coarse interpolation data blocks containing position, velocity and acceleration information; A dual-ended shared memory buffer is used to connect the non-real-time computing module and the real-time control module. The non-real-time computing module acts as a producer, writing coarse interpolation data blocks to the buffer, while the real-time control module acts as a consumer, reading coarse interpolation data blocks from the buffer. The real-time control module is used to read coarse interpolation data blocks from the buffer at hardware servo cycles, perform fine interpolation calculations based on the coarse interpolation data blocks, generate servo drive instructions, and monitor the status of the buffer. When the remaining space in the buffer is lower than the preset high watermark threshold, the module controls the non-real-time calculation module to pause writing. When the amount of unread data in the buffer is lower than the preset low watermark threshold, the real-time control module triggers a degradation and deceleration protection strategy. This strategy is configured to reduce the instruction speed of the current cycle proportionally based on the amount of data remaining in the buffer.
5. A terminal, characterized in that, include: The memory is used to store the data flow coordination control program of the CNC system; A processor is configured to implement the steps of the CNC system data flow collaborative control method as described in any one of claims 1 to 3 when executing the CNC system data flow collaborative control program.
6. A computer-readable storage medium, characterized in that, The readable storage medium stores a CNC system data flow collaborative control program, which, when executed by a processor, implements the steps of the CNC system data flow collaborative control method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Method and device for controlling memory overflow
CN103927305A
Distributed numerical control system based on PC and SOC
CN122363064A
