A tapping method for internal thread based on spindle encoder feedback

By using a dynamic speed planning algorithm and a catch-up algorithm based on spindle encoder feedback, the synchronization problem of multi-start thread cutting in traditional internal thread tapping is solved, achieving high-precision internal thread machining, which is suitable for CNC machine tools.

CN117008536BActive Publication Date: 2026-04-21广东亚数智能科技股份有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
广东亚数智能科技股份有限公司
Filing Date
2023-06-12
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In traditional internal thread tapping, the method of determining the encoder zero mark pulse synchronization signal during multi-start thread cutting is cumbersome, which affects the machining accuracy and makes it difficult to maintain the synchronization relationship between the spindle and the thread cutting tool in multi-start thread machining.

Method used

A dynamic speed planning algorithm based on spindle encoder feedback is adopted. By mapping the absolute value of the spindle encoder to the spindle position for starting point determination, combined with the overtaking and chasing algorithm, the precise machining of repetitive threads and multi-start threads is achieved, ensuring that the spindle and thread cutting tool remain in a follow-up state within the clearance distance.

Benefits of technology

It simplifies the operation process, improves machining accuracy, and can maintain the synchronization of the spindle and thread cutting tool in multi-start thread machining to ensure thread quality. It is suitable for various CNC machine tools with spindle encoders, such as lathes and mill-turn machines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117008536B_ABST
    Figure CN117008536B_ABST
Patent Text Reader

Abstract

This invention discloses a method for internal thread tapping based on spindle encoder feedback. By mapping the modulo and positive values ​​of the encoder's absolute value to the spindle position, the starting point is determined and captured based on the encoder value. Interval and hysteresis capture can achieve capture of the starting point within one spindle revolution. By incorporating the tapping axis displacement corresponding to the spindle encoder change into the planned displacement each cycle and replanning the displacement for each cycle, a catch-up alignment effect is achieved upon startup. Dynamic speed planning constrains the maximum tapping speed throughout the process. Virtual operation before tap startup adjusts the planned acceleration to ensure the tap enters a follow-up state within the clearance distance, ensuring that the tap follows the spindle speed when it enters the workpiece. Thread lead is corrected in both the tapping and retraction directions. Distance compensation is performed in the retraction direction when the spindle reverses. This invention can achieve repetitive thread machining and multi-start thread machining, and has the advantages of simple operation and high machining accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of internal thread tapping in CNC machining, and in particular to an internal thread tapping method based on spindle encoder feedback, which can be applied to various CNC machine tools with spindle encoders, such as lathes and milling-turning machines. Background Technology

[0002] Tapping is a machining method for internal threads. Internal thread tapping is usually the last step in machining a workpiece. If the tapped thread quality is unsatisfactory, the entire workpiece must be re-machined. Therefore, tapping is a relatively important cutting function in CNC machine tools. Foreign countries started researching tapping earlier, but the technology is strictly confidential. Currently, tapping is mainly divided into two types: flexible tapping and rigid tapping. Flexible tapping without encoder feedback usually uses a floating tool holder to improve thread accuracy, but it has disadvantages such as low accuracy and non-repeatable tapping. In rigid tapping, the control system uses spindle encoder feedback to maintain a strict synchronous relationship between the tap and the spindle, generally without using a spring collet tool holder, resulting in better tapping quality.

[0003] However, in traditional thread machining applications, when cutting the same thread multiple times, the feed start of each thread cutting is based on the encoder zero mark pulse as a synchronization signal. However, the encoder usually only emits one zero mark pulse per revolution. When machining multi-start threads, the thread cutting tool must first be offset by a pitch length from the original starting point, and then wait for the zero mark pulse to appear again. When machining two-start threads, the acceleration parameters of the spindle and thread cutting tool cannot be changed. Although this starting judgment method is very accurate and convenient when machining single-start threads, it is more cumbersome for CNC operation and can easily affect machining accuracy when machining multi-start threads. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide an internal thread tapping method based on spindle encoder feedback. It adopts a tapping interpolation algorithm that performs dynamic speed planning based on spindle encoder feedback. The starting point is determined by mapping the absolute value of the spindle encoder to the spindle position, and repeated threading and multi-start threading are achieved by overtaking and chasing. It has the advantages of simple operation and high machining accuracy.

[0005] To achieve the above objectives, the technical solution provided by this invention is as follows:

[0006] A method for internal thread tapping based on spindle encoder feedback, implemented using the G33 tapping command of a CNC system, includes:

[0007] S1. Pre-processing for tapping and interpolation motion;

[0008] S2. The overtaking algorithm, which performs dynamic speed planning based on feedback from the main spindle encoder, enables the tapping spindle to accelerate to the follow-up state within the clearance distance.

[0009] S3. The tapping spindle performs follow-up tapping according to dynamic speed planning. When the target chasing distance exceeds the theoretical tapping length, it proceeds to the next step.

[0010] S4. After the tapping reaches the target endpoint, the spindle decelerates and stops.

[0011] In the first interpolation cycle of this stage, the spindle deceleration and stop motion planning is performed. In the remaining cycles, the tapping axis remains in a follow-up state. When the status uclnpStatus of the spindle single-axis structure is identified as INP_FINISHED, it indicates that the spindle deceleration and stop is completed. At this time, the G33 spindle reversal pause time unG33SpindlePauseTimeBeforeRev in the system parameter structure g_SSystemPara is judged to determine whether to pause. If the pause time is not zero, the spindle reversal pause stage S5 is entered. If the pause time is zero, the spindle reversal stage S6 is entered directly.

[0012] S5. Decrease the pause time before G33 spindle reverses cycle by cycle. When the change is 0, enter the S6 spindle reverse planning stage.

[0013] S6, spindle reverses, tapping spindle retracts and decelerates to stop at the starting point;

[0014] After the spindle encoder direction is detected to be reversed in this stage, the reverse tapping compensation function is completed according to the tapping reverse compensation distance parameter that can be set by the user. During the compensation period, the corresponding displacement fed back by the encoder is accumulated and added to the displacement of the dynamic speed planning after compensation. In the tapping spindle retraction stage, it is in the follow-up stage before the avoidance distance. After entering the avoidance distance, the deceleration used for speed planning is calculated according to the distance from the tapping start point. It no longer completely follows the encoder, but decelerates and stops at the tapping start point, and then enters S7.

[0015] S7, Spindle deceleration stop;

[0016] In this stage, the spindle deceleration and stop motion planning is performed in the first interpolation cycle. The tapping axis remains stationary in the remaining cycles. When the status ucInpStatus of the spindle single-axis structure is identified as INP_FINISHED, it indicates that the spindle deceleration and stop are complete. At this time, the number of processed heads ucAlreadlyL is incremented by 1. When ucAlreadlyL equals the number of heads to be processed by G33 ucL, the tapping of G33 is completed, and the system no longer enters S8. The system directly executes the next line of G code instructions in the next cycle. When ucAlreadlyL < ucL, the system enters S8.

[0017] S8, Multi-start thread tapping spindle acceleration before feed;

[0018] In the first interpolation cycle of this stage, the acceleration planning of the spindle in the forward tapping direction is performed. In the remaining cycles, the tapping axis remains stationary. When the status ucInpStatus of the spindle single-axis structure is identified as INP_FINISHED, it indicates that the spindle acceleration is complete and returns to S2.

[0019] Furthermore, the pretreatment before tapping and interpolation includes:

[0020] The spindle speed and lead of the tapping command input by the user are judged. When the spindle speed and lead exceed the maximum tapping speed limit, an alarm is triggered and the tapping motion is stopped.

[0021] Determine if the length of the start and end points in the G33 code is zero. If the length is zero, directly change the running status of the G33 tapping command to complete.

[0022] Determine whether the spindle has completed acceleration before starting tapping; only proceed to the next step after acceleration is complete.

[0023] Initialize the current velocity and velocity planning structure in the tapping structure;

[0024] Determine if the number of processed heads ucAlreadyL in the tapping structure is zero. If it is zero, initialize only the driving point and simulation time point in the tapping structure as real-time points.

[0025] Initialize the member variables in the tapping structure;

[0026] Enable spindle speed measurement.

[0027] Furthermore, the overtaking and catching-up algorithm, which performs dynamic speed planning based on feedback from the spindle encoder, enables the tapping spindle to accelerate to a follow-up state within the clearance distance, including:

[0028] A dynamic velocity planning model is constructed for tapping interpolation motion planning;

[0029] Perform tapping start judgment and start-up error compensation;

[0030] By using virtual operation to correct the acceleration and deceleration of the catch-up plan, the tapping spindle can complete the catch-up within the avoidance distance and enter the follow-up state.

[0031] Furthermore, the constructed dynamic velocity planning model divides the target catching distance TargetL into two parts: the already caught distance PreL and the remaining catching distance CurLeftL. After startup, each interpolation cycle calculates the displacement increment ΔL based on encoder feedback, and simultaneously adds ΔL to TargetL and CurLeftL. The dynamic velocity planning takes the periodically changing remaining catching distance CurLeftL as the planning object, and uses the current velocity dCurrentSpeed ​​as the initial velocity, the G33 catching maximum velocity G33MaxVel as the planned maximum velocity, and the theoretical follow-up velocity as the final velocity for dynamic velocity planning.

[0032] Furthermore, the dynamic velocity planning model adopts a trapezoidal acceleration / deceleration model, specifically including:

[0033] The formula for speed-time is as follows:

[0034]

[0035] The displacement-time formula is as follows:

[0036]

[0037] The formulas for calculating accelerated displacement, uniform displacement, and decelerated displacement are as follows:

[0038]

[0039] The formulas for calculating acceleration time, constant velocity time node, and total time are as follows:

[0040]

[0041] In the above formula, a ac and a de These are the acceleration and deceleration of the trapezoidal acceleration / deceleration system, respectively; V max The target maximum speed V of the trapezoidal acceleration / deceleration curve s and V e Let S1 be the initial velocity and final velocity of the plan; S2 and S3 be the acceleration displacement, uniform displacement and deceleration displacement, respectively; T1 and T2 and T3 be the acceleration time, uniform displacement time node and total time, respectively.

[0042] Furthermore, the tapping start judgment and start-up error compensation include:

[0043] The tapping spindle starts with the encoder value as a reference. usEncoderCircleNum represents the encoder increment for one spindle revolution. The absolute encoder value lEncoderAbsValue is modulo and positively divided by usEncoderCircleNum to establish a mapping between the encoder value and the spindle position. Let ucAlreadlyL be the number of threads already processed, ucL be the number of threads to be processed, and StartERValue be the relative encoder value at tapping spindle start. The calculation formula is as follows:

[0044]

[0045] The calculated relative value of the encoder, StartERValue, when the tapping spindle starts is a double variable, while the absolute value of the encoder, lEncoderAbsValue, is a long integer variable. To avoid the influence of the encoder feedback value constantly changing with the spindle speed, a capture interval is set for startup, and the error of early or late movement is compensated during the catch-up process.

[0046] Furthermore, methods for starting by setting a capture range include:

[0047] Method 1: Maintain the encoder structure and store the absolute value lEncoderLastAbsValue of the encoder in the previous cycle and the absolute value lEncoderAbsValue of the encoder in the current cycle to form a capture interval. By checking whether the relative value StartERValue corresponding to the start of the tapping axis is in this interval, it can be determined whether the encoder is started.

[0048] Method 2:

[0049] The starting point is captured by determining a left and right interval with a width of 1.1 times the encoder increment width corresponding to the spindle speed, centered on the calculated relative value StartERValue corresponding to the start encoder of the tapping spindle.

[0050] After capturing the start point, the compensation displacement Comp corresponding to the start deviation EncoderStartupDeviation is calculated according to the following formula:

[0051]

[0052] When the start deviation is negative, it means that the start was earlier than the target start point. The catch-up distance CompL corresponding to the early start is subtracted from the target catch-up distance TargetL and the remaining catch-up distance CurLeftL. When the start deviation is positive, it means that the start was later than the target start point. The catch-up distance CompL corresponding to the late start is added to the target catch-up distance TargetL and the remaining catch-up distance CurLeftL.

[0053] Furthermore, the formulas for acceleration and deceleration in the catch-up planning are corrected through virtual operation as follows:

[0054]

[0055]

[0056] Among them, a ac and a de These are the acceleration and deceleration for catching up with the plan, respectively. PreL0 is the original alignment distance, and G33AvoidEmptyL is the clearance distance. The system requires the clearance distance to be no less than 1mm.

[0057] Further, step S6 includes:

[0058] The first cycle of this stage involves reversing the spindle at the same speed but in different directions. After the spindle reverses, the tapping axis has a reverse distance compensation function. This distance is the system parameter dG33RevCompDistance and is different from the backlash compensation of the linear module. When this distance is 0, no compensation is needed. When the compensation distance is not 0, the dynamic speed planning function is no longer used in the compensation stage. Instead, the entire compensation distance is planned once, using trapezoidal acceleration and deceleration by default. The cumulative spindle rotation angle during the compensation stage corresponds to the displacement that the tapping axis should make, which is stored in the tapping structure member dSpindleRevCompZAxisCumulaDis. The tapping axis only compensates once in the reverse retraction stage when the encoder reverse is first detected. If there is an abnormal reverse in subsequent stages, no further compensation will be made.

[0059] The spindle reverse recognition relies on whether the encoder direction cEncoderDir and the G33 forward tapping spindle direction cTappingSpindleDir have opposite signs.

[0060] The first cycle of the main spindle reverse is determined by the main spindle reverse start flag bit bSpindleRevBegin of the G33 structure member, and the reverse compensation planning is set to TRUE after the first cycle of the reverse.

[0061] Reverse compensation end judgment: When the remaining displacement of the motion plan is 0, it means that the reverse compensation is completed. At this time, the reverse compensation end flag bit bSpindleRevCompEnd of the tapping structure member G33 is set to TRUE.

[0062] During the reverse compensation stage, the corresponding displacement of the encoder feedback is accumulated and recorded in the tapping structure variable dSpindleRevCompZAxisCumulaDis to identify the encoder's positive and negative directions. The retraction direction is a positive value, and the tapping direction is a negative value.

[0063] After compensation is completed, the dynamic speed planning method is still used for movement. At this time, the current real-time point is used as the starting point and the G33 tapping start point is used as the final endpoint for reverse planning. In the first cycle of planning, the displacement that the tapping axis should move corresponding to the cumulative spindle rotation angle during the compensation stage is added to the planning. The reverse retraction planning model does not allow the target chasing distance TargetL to exceed the G33 tapping start point G33StartPoint. After entering the avoidance distance, it no longer moves in follow mode, but calculates the planned deceleration based on the distance from the tapping start point, and plans with the minimum system speed as the final speed until it decelerates and stops at the tapping start point G33StartPoint.

[0064] When the follow-up tool retracts into the clearance distance, the distance from the current point to the tapping start point, DisToStartPoint, is less than the clearance distance. It is important to note that the target chasing distance, TargetL, cannot exceed the actual tapping length L′ of G33. At this point, dynamic programming no longer uses the maximum acceleration / deceleration based on 5 times the system parameters during follow-up. Instead, it uses the distance from the current point to the tapping start point, DisToStartPoint, to inversely calculate the deceleration using the following formula based on the deceleration model:

[0065]

[0066] Using this deceleration as a planning parameter and the system's minimum speed as the final speed, the planning continues until the tapping start point is reached, where V min The minimum final velocity of the system; when the distance from the current point to the tapping start point DisToStartPoint is 0, it means that the tool has been retracted to the G33 start point, and at this time, the S7 spindle deceleration and stop stage is entered.

[0067] Compared with existing technologies, the principles and advantages of this solution are as follows:

[0068] This solution eliminates the traditional use of encoder zero-mark pulses as the start synchronization signal for repetitive and multi-start thread tapping. Instead, it maps the encoder's absolute value (modulo and positive) to the spindle position, capturing the start point by judging the encoder value. Two capture methods, left / right interval and delayed capture, allow the start point to be captured within one spindle revolution. When machining multiple threads, it eliminates the need to move the tool for one lead; only the start value corresponding to the multi-start thread needs to be calculated. By incorporating the spindle encoder change corresponding to the tapping axis displacement into the planned displacement each cycle and replanning the displacement every cycle, it achieves a start-up-and-follow-up alignment effect. Dynamic speed planning constrains the maximum tapping speed throughout the process. Virtual operation before tap start-up and acceleration adjustment ensures entry into follow-up mode within the clearance distance, guaranteeing that the tap follows the spindle speed when entering the workpiece. Thread lead can be corrected in both the tapping and retraction directions. Distance compensation in the retraction direction can be performed when the spindle reverses.

[0069] In summary, this solution can identify the spindle position and accelerate the tapping process by judging the encoder value when performing thread tapping. It can achieve overtaking and catching up alignment within the clearance distance. It can ensure that the tapping spindle and the spindle remain in a follow-up state during the tapping cutting process. When the tool retracts, it decelerates and stops at the tapping starting point after entering the clearance distance. It can realize the machining of multi-axis threads and the repeated machining of single-start threads. Attached Figure Description

[0070] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the services required in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0071] Figure 1 This is a flowchart illustrating the principle of an internal thread tapping method based on spindle encoder feedback according to the present invention.

[0072] Figure 2 This is a diagram illustrating the tapping process.

[0073] Figure 3 This is a classification diagram of internal threads (a represents single-start threads, b represents multi-start threads);

[0074] Figure 4 A schematic diagram of the tapping overtaking and chasing algorithm (a is the tap starting and following, b is the overtaking and chasing algorithm).

[0075] Figure 5 The diagram shows the dynamic speed planning model for tapping (a is the dynamic speed planning model for forward tapping, and b is the dynamic speed planning model for retraction).

[0076] Figure 6 This is a trapezoidal acceleration / deceleration curve diagram;

[0077] Figure 7 This is a diagram showing the acceleration characteristics of the first cycle of a trapezoidal acceleration / deceleration curve.

[0078] Figure 8 Diagram showing the starting point for multi-start thread tapping;

[0079] Figure 9 Diagram illustrating the principle of delayed capture tapping start point (a is the main spindle forward rotation, b is the main spindle reverse rotation);

[0080] Figure 10 Schematic diagram for capturing the starting point of tapping in the left and right intervals (a is the main axis forward rotation, b is the main axis reverse rotation);

[0081] Figure 11 A speed planning model diagram for entering the avoidance distance during tapping tool retraction;

[0082] Figure 12 The direction following model diagram is shown when the encoder is in the positive direction in the current cycle and the motion planning in the previous cycle is in the reverse direction (a is when the current point has not exceeded the theoretical end point of tapping, b is when the current point has exceeded the theoretical end point of tapping).

[0083] Figure 13 Simulation diagram of single-start internal thread tapping (a is the Z-axis and spindle speed curve, b is the tap Z-axis coordinate and encoder value);

[0084] Figure 14 Simulation diagram of double-headed internal thread tapping (a is the Z-axis and spindle speed curve, b is the tap Z-axis coordinate and encoder value);

[0085] Figure 15 Finished product image of 6061 aluminum alloy material tapped with an M10F1.5 tap;

[0086] Figure 16 Finished product image of 6061 aluminum alloy material tapped with M6F1 tap;

[0087] Figure 17 A finished product image of 45 steel material tapped with an M6F1 tap. Detailed Implementation

[0088] The present invention will be further described below with reference to specific embodiments:

[0089] like Figure 1 As shown in the figure, the internal thread tapping method based on spindle encoder feedback described in this embodiment specifically includes:

[0090] S1. Pre-processing for tapping and interpolation motion;

[0091] This invention focuses on the development of the G33 tapping command in CNC systems. A schematic diagram of the G33 tapping command is shown below. Figure 2 As shown. Its instruction format is: G33 Z(W)__F(I)__L__.

[0092] Instruction code explanation: The movement trajectory of the tap is from the starting point to the ending point, and then back from the ending point to the starting point. During the tapping process, the spindle moves one lead along the Z-axis for each revolution, always keeping pace with the lead of the tap, forming a helical groove in the inner hole of the workpiece, thus completing the threading of the inner hole in one cut.

[0093] Z(W): Specifies the endpoint coordinates of the tapping. If Z or W is not entered, thread cutting will not be performed, and the program will proceed to the next line of G-code.

[0094] F: Lead of the internal thread to be machined;

[0095] I: Number of threads per inch;

[0096] L: The number of threads in a multi-start thread. When L is omitted, it defaults to 1 thread.

[0097] The function of S1 is to have the G33 tapping command input to the CNC panel checked and parsed by the G-code parsing module for motion planning by the interpolation module. Main contents include:

[0098] (1) The G-code parsing module judges the spindle speed dSpindleSpeed ​​(r / min) and lead dF (mm) of the tapping command input by the user. When the relationship between the spindle speed and lead conforms to Equation 1, that is, it exceeds the maximum tapping speed dG33MaxVel (mm / ms) limit in the system parameter structure g_SSystemPara, the G-code parsing module will alarm and the tapping motion will not be performed.

[0099]

[0100] (2) Determine whether the length of the start and end points in the G33 code is zero. If the length is zero, directly change the running status of the G33 instruction to complete.

[0101] (3) Currently, there is a spindle switch delay in the program, but this delay time may be less than the spindle acceleration time, which may cause the spindle to not have accelerated to the required speed when entering G33 motion. Therefore, before running G33, it is necessary to determine whether the spindle has completed acceleration. If it has not completed, the next step will not be carried out until the spindle acceleration and deceleration are completed. This can be determined by whether the status ucInpStatus of the single-axis structure in the spindle is INP_FINISHED.

[0102] (4) Initialize the relevant variables of the current speed dCurrentSpeed ​​and SPlanData structures in the tapping structure.

[0103] (5) Determine whether G33 is paused and resumed by checking whether the number of processed heads ucAlreadyL in the tapping structure is zero. If it is not zero, simply initialize the tapping structure members G33StartRealTimePoint and G33AnalogRealTimePoint as real-time points and directly perform G33 movement.

[0104] (6) After all the above situations are ruled out, initialize the member variables in the tapping structure.

[0105] (7) Enable spindle speed measurement and set the spindle speed measurement flag bCalculateSpindleSpeedFlag to TRUE. When the flag is TRUE, the system measures the average spindle speed over several cycles. This speed is used to calculate the maximum starting deviation of G33. The spindle speed variable is dSpindleRealSpeed.

[0106] S2, the tapping spindle accelerates before following the movement;

[0107] S2 is the first stage of the G33 tapping motion. In this stage, the overtaking and chasing algorithm based on the feedback of the spindle encoder described in this invention is used to complete the tapping start point capture, start deviation compensation, acceleration overtaking and chasing within the clearance distance to enter the follow-up. When the chasing is completed, the G33 running stage is changed to tapping the tapping axis follow-up, that is, step 3 is entered.

[0108] In thread machining, it is necessary to ensure that the feed axis where the tap is located moves by one thread lead for every revolution of the spindle. That is, when the tap follows the encoder to machine the thread, it must be fed according to Equation 2. If this relationship is not met, the helix of the thread will be non-standard, resulting in misaligned teeth.

[0109]

[0110] Wherein, ΔL is the tapping spindle feed amount, usDelta is the change in the count of the main spindle encoder in the previous cycle, usEncoderCircleNum is the encoder increment for one revolution of the main spindle, dF is the thread lead, dPercentageOfG33EnterLeadCorrection is the tapping lead correction percentage parameter; dPercentageOfG33ReturnLeadCorrection is the tapping retraction lead correction percentage parameter, which can independently compensate and correct the lead in both the tapping and retraction directions.

[0111] The requirements and challenges of G33 tapping are as follows:

[0112] First, alignment requirements. As mentioned above, thread machining requires ensuring that the spindle rotation and tap feed maintain a proportional relationship corresponding to the lead. However, internal thread machining involves repeated tapping and multi-start threading, which necessitates that the tap's entry point with the workpiece be precisely defined when the tap spindle accelerates to its follower speed—that is, thread alignment. The alignment requirements are as follows:

[0113] like Figure 3 As shown in (a), for the G33 single-start internal thread (L=1) command, if the spindle is restarted after running a G33 command, and the same G33 command is run again, the tap must be machining the same helix in both runs; Figure 3 As shown in (b), for the G33 multi-start internal thread (L>1) instruction, the first and second start threads are 180° apart at the entry point on the workpiece end face, that is, the distance between the two thread lines (pitch) is equal.

[0114] Secondly, it achieves a follow-up state within the avoidance distance. For example... Figure 2As shown, before machining, there is a distance between the tap and the workpiece end face for acceleration, which is called the clearance distance. Thread machining must be accelerated within the clearance distance before entering the follow-up state in order to ensure that the thread machining is qualified. Therefore, the alignment algorithm must enter the follow-up state within the clearance distance.

[0115] Secondly, the tap should be decelerated and stopped at the starting point during the final retraction. After the tap is withdrawn from the workpiece, it should return to the tapping starting point, but it cannot continuously move to the starting point; it must decelerate in advance.

[0116] Finally, the tapping direction should follow the encoder throughout the entire tapping process. When the spindle decelerates and reverses, due to mechanical vibration, the spindle direction fed back by the encoder is not first forward and then reverse, but will repeatedly change between forward and reverse. Furthermore, if the tap gets clogged or breaks during the machining process, the spindle direction must be adjusted to remove the tap. Therefore, the tapping direction should follow the encoder direction throughout the entire tapping process, so that whether tapping in the forward direction or retracting in the reverse direction, the spindle can move in the direction of the encoder.

[0117] In traditional thread cutting, the feed start for each cut is based on the encoder's zero-mark pulse as a synchronization signal. However, the encoder typically only emits one zero-mark pulse per revolution. When machining multi-start threads, the thread cutting tool must be offset by a pitch length from its original starting point, and then another zero-mark pulse must be waited for. The acceleration parameters of the spindle and thread cutting tool cannot be changed when machining two-start threads. This starting method satisfies the requirements for accuracy and convenience when machining single-start threads, but it requires changing the starting point position when machining multi-start threads, which is cumbersome for CNC operations. To achieve tapping alignment, this invention proposes a tapping interpolation algorithm based on dynamic speed planning using spindle encoder feedback. This algorithm is described below.

[0118] (1) Dynamic velocity programming model

[0119] Ignoring the acceleration phase of the tap, such as Figure 4 As shown in (a), if the start-up mechanism can be followed immediately, then as long as the start-up is ensured at the same encoder feedback spindle position each time, the thread lines of the two machining operations can be guaranteed to coincide.

[0120] As shown in 4(b), this paper proposes a catch-up algorithm to achieve the same processing effect as "start-up follow-up". The idea is as follows:

[0121] "Overtaking and catching up" means that during the acceleration of the tapping spindle, its speed exceeds the theoretical follow-up speed, thereby catching up with the distance that the black filling part travels less during the acceleration phase. At this time, the maximum speed after overtaking is limited to the system parameter dG33MaxVel to prevent loss of control. When the speed decreases to the theoretical follow-up speed, the displacement of the overtaken part just makes up for the distance that is less traveled during the acceleration phase compared to the "start-up follow-up" machining. If it can be ensured that the tap is within the clearance distance when entering the follow-up state after overtaking, the purpose of tapping alignment can be achieved.

[0122] Based on the approach of overtaking and catching up with speed curves, this embodiment proposes a dynamic real-time velocity planning model for tapping interpolation motion planning. The structure of the dynamic velocity planning model is as follows: Figure 5 As shown.

[0123] To achieve the processing effect of overtaking and catching up from the start, dynamic speed planning requires accumulating and recording the corresponding target catching distance TargetL calculated according to Equation 1 from the start. TargetL increases cycle by cycle as catching begins. Therefore, the object of speed planning changes every cycle. The planning model divides the target catching distance TargetL into two parts: the already caught distance PreL and the remaining catching distance CurLeftL. After the start, each interpolation cycle calculates the displacement increment ΔL based on encoder feedback and simultaneously adds ΔL to TargetL and CurLeftL. Dynamic speed planning uses the cycle-changing remaining catching distance CurLeftL as the planning object, the current speed dCurrentSpeed ​​as the initial speed, the G33 catching maximum speed G33MaxVel as the planned maximum speed, and the theoretical catching speed as the final speed for speed planning.

[0124] The characteristic of dynamic velocity planning is that CurLeftL is time-divided and velocity planning is performed once in each interpolation cycle, and each planning only follows the planned displacement of the first segment cycle. Because the planning is restarted in each cycle, dynamic velocity planning uses a trapezoidal acceleration / deceleration plan that consumes fewer resources. The trapezoidal acceleration / deceleration curve is shown below. Figure 6 As shown, in the acceleration / deceleration model, the velocity-time formula is Equation 3, and the displacement-time formula is Equation 4, where a ac and a de These are the acceleration and deceleration of the trapezoidal acceleration / deceleration system, respectively; V max V represents the target maximum speed of the trapezoidal acceleration / deceleration curve. s and V e The initial and final velocities are defined by equation 5; S1, S2, and S3 are the acceleration displacement, uniform displacement, and deceleration displacement, respectively, calculated by equation 5; T1, T2, and r3 are the acceleration time, uniform time node, and total time, respectively, calculated by equation 6.

[0125]

[0126]

[0127]

[0128]

[0129] like Figure 7 As shown in the first-cycle acceleration characteristics, during the acceleration phase with an initial velocity V s and acceleration a ac The actual velocity change in the first planning cycle after performing trapezoidal programming is Only starting from the second planning cycle can the speed be maintained according to the overall plan. ac Incremental, since the dynamic programming model only goes through the first cycle of planning in each cycle, the acceleration and deceleration are both expanded to twice the original values ​​when planning speed.

[0130] The criterion for successful catching up is that the remaining catching distance CurLeftL after planning can be completed in just one cycle. Afterward, the tapping enters the follow-up stage, i.e., feeding according to Equation 2. To ensure that the planned displacement CurLeftL is completed in one cycle during the follow-up stage, the planned acceleration a is... ac and deceleration a de Increased to 5 times the original value.

[0131] Because the overtaking and catching-up algorithm is limited by the maximum catching speed dG33MaxVel, when the spindle speed and thread lead are too large, the theoretical follower speed will exceed the maximum catching speed dG33MaxVel. In this case, the catching-up algorithm cannot follow the maximum catching speed. Figure 4 To achieve this, the spindle speed and lead of the G33 command need to be judged in S1. When the spindle speed and the G33 thread lead satisfy the relationship of Equation 1, an alarm will be triggered to remind the G code writer that the speed is too high and cannot be processed.

[0132] (2) Tapping start judgment and start error compensation;

[0133] The overtaking algorithm can achieve the same machining effect as "start-up follow-up," but to achieve alignment, the spindle position at startup must be constrained. In this embodiment, the tapping spindle starts with the encoder value as a reference. usEncoderCircleNum is the encoder increment for one revolution of the spindle. Taking the modulo and positive of the absolute value of the spindle encoder lEncoderAbsValue divided by usEncoderCircleNum establishes a mapping relationship between the encoder value and the spindle position. Let ucAlreadlyL be the number of threads already processed (the number of threads already processed is updated only after one thread is tapped), ucL be the number of threads to be processed, and StartERValue be the relative value of the encoder at the start of the tapping spindle. The calculation formula is Equation 7. Figure 8 This refers to the positional relationship of the starting points of the thread lines in a multi-start thread.

[0134]

[0135] The calculated relative encoder value, StartERValue, at the start of the tapping spindle is a double-precision variable, while the absolute encoder value, EncoderAbsValue, is a long integer variable. Furthermore, the encoder's feedback value continuously changes in increments of the spindle speed. Therefore, it is difficult to directly capture the StartERValue value for startup; instead, a capture interval must be set for startup, and errors from early or late starts must be compensated for during the catch-up process. This embodiment uses two startup methods, which will be described below.

[0136] Method 1: For example Figure 9 As shown, the encoder maintenance structure stores the absolute value of the encoder in the previous cycle, lEncoderLastAbsValue, and the absolute value of the encoder in the current cycle, lEncoderAbsValue, forming a capture interval. The start-up status is determined by checking if the relative value StartERValue corresponding to the tapping spindle's encoder start-up is within this interval. The encoder increment usEncoderCircleNum for one spindle revolution is 10000, which divides the spindle position into 10000 equal parts, mapping the spindle position with an accuracy of 0.036°. This start-up capture method can only lag behind the ideal start-up point position; the maximum start-up deviation is one cycle encoder increment value, i.e., a late start. The encoder start-up deviation corresponding to the late start is recorded in EncoderStartupDeviation.

[0137] Method 2: Using the calculated relative value StartERValue corresponding to the tapping spindle start encoder as the center point, a left-right interval with a width of 1.1 times the encoder increment width corresponding to the spindle speed is determined to capture the start point. The characteristic of this capture method is that it requires calculating the endpoints of the left and right intervals; in actual startup, either early or late startup is possible. Figure 10 (a) shows a late walk with a forward turn, as shown in the image. Figure 10 (b) shows the reverse early start, with a maximum start deviation of 0.55 times the spindle encoder increment per cycle. The encoder start deviation should also be recorded in EncoderStartupDeviation.

[0138] After capturing the start point, calculate the compensation displacement CompL corresponding to the start deviation (EncoderStartupDeviation) according to Formula 8. When the start deviation is negative, it means that the start point is earlier than the target start point, and the catch-up distance CompL corresponding to the early start should be subtracted from the target catch-up distance TargetL and the remaining catch-up distance CurLeftL. When the start deviation is positive, it means that the start point is later than the target start point, and the catch-up distance CompL corresponding to the late start should be added to the target catch-up distance TargetL and the remaining catch-up distance CurLeftL.

[0139]

[0140] (3) Enter the follow-up movement within the avoidance distance;

[0141] The overtaking alignment algorithm completes the overtaking and entering the follower phase, and the already caught distance PreL involves the G33 overtaking maximum speed dG33MaxVel, spindle speed, thread lead dF, and the acceleration a of the trapezoidal velocity planning. ac and deceleration a de Since it is a dynamic speed planning, it is impossible to quantify the relationship between the already caught-up distance PreL and the above variables when the catch-up is completed and the follow-up is entered by formula. This project proposes a scheme of virtual operation to correct the acceleration and deceleration of the catch-up planning so that the tapping shaft can complete the catch-up and enter the follow-up within the avoidance distance.

[0142] The purpose of virtual operation is to overtake and catch up based on the current actual spindle speed and initial acceleration and deceleration, obtaining the alignment distance under the initial acceleration and deceleration. In actual machine tool operation, interpolation planning calculates the pulses for each axis and changes the real-time coordinate points. Virtual operation is implemented by calculating the pulses each axis should travel during virtual operation in each interpolation cycle, updating the real-time points, clearing the pulses, saving the virtual operation real-time points in a separate variable, and restoring the actual machine tool real-time points. In the next cycle, the machine tool real-time points are replaced with the virtual operation real-time points for interpolation movement. These steps are repeated until virtual catching up is complete. The distance already caught up at this point is called the alignment distance. The alignment distance required for overtaking and catching up using initial acceleration and deceleration has the following two cases:

[0143] Scenario 1: If the aiming distance is less than the evasive distance, no correction is needed for acceleration or deceleration during the acceleration phase;

[0144] Scenario 2: If the aiming distance is greater than the avoidance distance, the original acceleration or deceleration needs to be amplified and corrected.

[0145] Table 1 lists the alignment distances (mm) corresponding to different rotational speeds (in r / min) with a lead of 1 mm, a clearance distance of 1 mm, and an initial acceleration / deceleration of 0.001 mm / ms². ac1 and a de1For the acceleration and deceleration at the approach avoidance distance obtained from multiple simulation tests, a ac2 and a de2 The original alignment distance PreL0 is directly used as the magnification factor to amplify the chasing acceleration and deceleration.

[0146]

[0147] Table 1

[0148] It can be observed that the original alignment distance PreL0 is used as the magnification factor to correct the original acceleration / deceleration a. ac0 and a de0 The alignment displacement is satisfied within the clearance distance, so the scheme for correcting acceleration and deceleration during virtual operation is corrected according to Equations 9 and 10.

[0149]

[0150]

[0151] Among them, G33AvoidEmptyL is the clearance distance, and the system requires that the clearance distance be no less than 1mm.

[0152] S3, tapping spindle follows the tapping action;

[0153] To ensure that the planned displacement CurLeftL is fully traversed within one cycle during the follow-up phase, the planned acceleration a is... ac and deceleration a de Increase it to five times the original value. For example... Figure 5 As shown in the dynamic speed planning model for tapping, dynamic speed planning is divided into two directions: forward tapping and retraction. During forward tapping, since the spindle needs to decelerate and reverse after passing the theoretical endpoint of G33, the tap still needs to follow and exceed the theoretical endpoint of G33. Therefore, the planning model in the forward tapping stage allows the target chasing distance TargetL to exceed the theoretical length L of G33. When the system determines that the current chasing distance PreL has exceeded the theoretical length L of G33, the G33 interpolation motion state is changed to S5. After tapping reaches the target endpoint, the spindle decelerates and stops.

[0154] S4, the spindle decelerates and stops after the tapping reaches the target endpoint;

[0155] In the first interpolation cycle of this stage, the spindle deceleration and stop motion planning is performed. In the remaining cycles, the tapping spindle remains in a follow-up state. When the status ucInpStatus of the spindle single-axis structure is identified as INP_FINISHED, it indicates that the spindle deceleration and stop are completed. At this time, the G33 spindle reversal pause time unG33SpindlePauseTimeBeforeRev(ms) in the system parameter structure g_SSystemPara is judged to determine whether to pause. If the time is not zero, the S5 spindle reversal pause stage is entered. If the pause time is 0, the S6 spindle reversal stage is entered directly.

[0156] S5, pause before spindle reverses;

[0157] After entering S5, the pause time before the G33 spindle reverses is decreased cycle by cycle. When the change is 0, the spindle reverse planning stage of S6 is entered.

[0158] S6, the main spindle reverses, the tapping spindle retracts and decelerates to stop at the starting point;

[0159] The first cycle in this stage involves reversing the spindle at the same speed but in different directions.

[0160] After the spindle reverses, the tapping axis has a reverse distance compensation function. This distance is a system parameter dG33RevCompDistance and is different from the backlash compensation of the linear module. When this distance is 0, no compensation is needed; when the compensation distance is not 0, the dynamic speed planning function is no longer used during the compensation stage, but the entire compensation distance is planned once. Since the compensation distance is very small, trapezoidal acceleration and deceleration are used by default. During the compensation stage, the cumulative displacement of the tapping axis corresponding to the spindle rotation angle is stored in the tapping structure member dSpindleRevCompZAxisCumulaDis. The tapping axis only compensates once during the reverse retraction stage when the encoder reverse is first detected; if there is an abnormal reverse in subsequent stages, no further compensation is performed.

[0161] The spindle reverse recognition relies on whether the encoder direction cEncoderDir and the G33 forward tapping spindle direction cTappingSpindleDir have opposite signs.

[0162] The first cycle of the main axis reverse is determined by the main axis reverse start flag bSpindleRevBegin (initially FALSE) of the G33 structure member, and the reverse compensation plan is set to TRUE after the first cycle of the reverse.

[0163] Reverse compensation completion judgment: When the remaining displacement of the motion plan is 0, it indicates that the reverse compensation is complete. At this time, the reverse compensation completion flag bSpindleRevCompEnd of the tapping structure member G33 is set to TRUE (initially FALSE).

[0164] During the reverse compensation stage, the corresponding displacement of the encoder feedback is accumulated and recorded in the tapping structure variable dSpindleRevCompZAxisCumulaDis. Note that this process also needs to identify the encoder's positive and negative directions. The retraction direction is a positive value, and the tapping direction is a negative value.

[0165] After compensation, the dynamic speed planning method is still used for movement. At this time, the current real-time point is used as the starting point and the G33 tapping start point is used as the final endpoint for reverse planning. In the first cycle of planning, the displacement that the tapping axis should move corresponding to the cumulative spindle rotation angle during the compensation stage is added to the planning. The reverse retraction planning model does not allow the target chasing distance TargetL to exceed the G33 tapping start point G33StartPoint. After entering the avoidance distance, it no longer moves in follow mode, but calculates the planned deceleration based on the distance from the tapping start point, and plans with the minimum system speed as the final speed until it decelerates and stops at the tapping start point G33StartPoint.

[0166] like Figure 11 As shown, when the follow-up tool retracts into the clearance distance, the distance from the current point to the tapping start point, DisToStartPoint, is less than the clearance distance. It is important to note that the target chasing distance, TargetL, cannot exceed the actual tapping length L′ of G33. At this point, dynamic programming no longer uses the maximum acceleration / deceleration of the system parameters (5 times the system parameters during follow-up). Instead, it uses the distance from the current point to the tapping start point, DisToStartPoint, to inversely calculate the deceleration using a deceleration model according to Equation 11. This deceleration is used as the planning parameter, and the system minimum speed is used as the final speed for planning, until the tapping start point is reached. Where V... min This is the system's minimum final velocity. When the distance DisToStartPoint from the current point to the tapping start point is 0, it indicates that the tool has retracted to the G33 start point, and at this point, the process proceeds to step 7, the spindle deceleration and stop phase.

[0167]

[0168] S7, spindle deceleration stop;

[0169] In the first interpolation cycle of this stage, the spindle deceleration and stop motion planning is performed. In the remaining cycles, the tapping axis remains stationary. When the status ucInpStatus of the spindle single-axis structure is identified as INP_FINISHED, it indicates that the spindle deceleration and stop are complete. At this time, the number of processed heads ucAlreadlyL is incremented by 1. When ucAlreadlyL equals the number of heads to be processed by G33 ucL, the tapping of G33 is completed, and the system no longer enters S8. The system directly executes the next line of G code instructions in the next cycle. When ucAlreadlyL < ucL, the system enters S8.

[0170] S8, Multi-start Thread Tapping Spindle Acceleration Before Feed:

[0171] This step is used for multi-start thread machining. In the first interpolation cycle of this stage, the spindle is accelerated in the forward tapping direction. In the remaining cycles, the tapping axis remains stationary. When the spindle single-axis structure's status ucInpStatus is identified as INP_FINISHED, it indicates that the spindle acceleration is complete, and the process returns to S2.

[0172] S9, tapping direction follows throughout the entire process.

[0173] S9 is not an independent operating stage in the tapping process, but rather an explanation of how the encoder direction follows the entire process in the G33 tapping process.

[0174] The tap shaft must constantly determine the direction of the spindle encoder throughout the tapping and retraction process. Figure 1 For the entire tapping process, only the four taps that move after the G33 command starts (tapping spindle acceleration before follow-up, tapping with follow-up, spindle deceleration and stop, spindle reversal and retraction) need to determine the encoder direction. Identifying the encoder direction can reverse the spindle to remove the tap if it breaks during tap processing.

[0175] The tapping structure stores the spindle rotation direction information during forward tapping, with the variable `cTappingSpindleDir`. The encoder's orientation (forward or reverse) can be determined by comparing the encoder structure member `cEncoderDir` with the tapping structure member `cTappingSpindleDir`. The tapping structure also stores the direction information corresponding to forward tapping, with the variable `G33StartVector`. The direction planned in the previous cycle can be determined by comparing the interpolation vector information `SStartVector` in the tapping structure with `G33StartVector`. If the encoder direction does not match the planned motion direction, the planned direction must be adjusted accordingly. Figure 5 The corresponding tapping dynamic speed planning model is used for planning. The following section explains how to follow the encoder direction in stages.

[0176] (1) Acceleration stage before tapping spindle follows movement

[0177] This stage requires overtaking and catching up within the clearance distance for alignment. Under normal circumstances, the spindle will rotate in the direction recorded by member cTappingSpindleDir in the tapping structure. If it rotates in the opposite direction, the following steps will be taken:

[0178] Scenario 1: If the capture start point is not obtained and the virtual run is not completed, the virtual run phase is invalidated and the virtual run restarts.

[0179] Scenario 2: The startup point has not been captured but virtual operation has been completed. In this case, the startup will not start even if the startup conditions are met.

[0180] Scenario 3: It has already started, and now it directly enters the follow-up phase.

[0181] (2) Follow-up tapping, spindle deceleration and stop, and spindle reversal and tool retraction stages

[0182] The encoder direction and motion planning direction during the follow-up phase can be divided into the following four cases:

[0183]

[0184] (a) In cases 1 and 2, the encoder direction and the motion planning direction are consistent. The newly added displacement ΔL can be directly calculated according to Equation 2 and included in the dynamic programming model.

[0185] (b) Case 3: The encoder is in reverse and the previous cycle was planned in the forward direction.

[0186] At this point, we first determine the relationship between the positive remaining distance CurLeftL and the corresponding displacement ΔL fed back by the encoder.

[0187] If CurLeftL ≥ ΔL, then remove the newly added reverse distance ΔL from CurLeftL and TargetL, and still perform forward distance planning. Figure 5 (a) Dynamic speed planning model for forward tapping.

[0188] If CurLeftL < ΔL, then the motion planning direction needs to be changed. The process is as follows:

[0189] ① Set the displacement PreL to 0; update the target catch-up distance TargetL and the remaining catch-up distance CurLeftL to ΔL-CurLeftL;

[0190] ② Set the current speed CurrentSpeed ​​to 0;

[0191] ③ Starting from the current point and ending at the G33 tapping start point, recalculate the interpolation vector information SStartVector in the G33 structure. Figure 5 (b) Reverse retraction dynamic speed planning model.

[0192] (c) Case 4: The encoder is moving in the forward direction, and the previous cycle's motion plan was in the reverse direction.

[0193] At this point, we first determine the relationship between the remaining reverse catching distance CurLeftL and the corresponding positive displacement ΔL fed back by the encoder.

[0194] If CurLeftL ≥ ΔL, then remove the newly added forward distance ΔL from CurLeftL and TargetL, and continue planning for the reverse distance. Figure 5 (b) Dynamic speed planning model for tool retraction.

[0195] If CurLeftL < ΔL, then the planning direction needs to be changed to positive. The process is as follows:

[0196] ① Set the already caught distance PreL to 0; update the target catch distance TargetL and the remaining catch distance CurLeftL to ΔL-CurLeftL;

[0197] ② Set the current speed CurrentSpeed ​​to 0;

[0198] ③ Since the planning needs to be reversed in the tapping direction, the endpoint of the plan must be redefined based on the current position, which involves two scenarios. For example... Figure 12 As shown in (a), the current point has not exceeded the theoretical endpoint of tapping. Therefore, the current point and the theoretical endpoint of tapping can be directly used as the planning interval. Figure 5 (a) Dynamic speed planning model motion for forward tapping; such as Figure 12 As shown in (b), the current point has already crossed the endpoint of the tapping theory. At this point, a new planning endpoint needs to be recalculated. Figure 5 (a) Dynamic velocity planning model for forward tapping.

[0199] To verify the performance of the algorithm mentioned in this paper, a single-start thread tapping simulation was performed with a starting point (0, 0), an ending point (0, -10), a Z-axis acceleration of 0.002 mm / ms², a Z-axis deceleration of 0.002 mm / ms², a spindle speed of 800 r / min, a thread lead of 1.5 mm, and 1 thread start. The spindle was subjected to a cubic S-curve acceleration / deceleration, with both maximum acceleration and maximum deceleration set to 0.0001 * 360° / ms². The results are as follows. Figure 13 As shown, Figure 13 (b) The triangular mark on the encoder numerical curve in the tap Z-axis coordinate diagram is the starting point. The theoretical starting value is 0, the actual absolute starting value of the encoder is 19968, and the starting deviation is -32. The small starting deviation can capture the encoder starting point within one spindle revolution. The actual displacement required to complete the catch-up is 0.495mm, which meets the requirement of 1mm clearance distance.

[0200] Simulations of two-ended thread machining were performed using the same parameters. The simulation curve for single-ended internal thread tapping is shown below. Figure 14 As shown.

[0201] The theoretical starting value of the first thread is 0, the actual absolute starting value of the encoder is 9974, the starting deviation is -26, the small starting deviation can capture the encoder starting point within one spindle revolution; the actual displacement required to complete the catch-up is 0.495mm, which meets the requirement of 1mm clearance distance.

[0202] The theoretical starting value of the second thread is 5000, and the actual absolute starting value of the encoder is 15028, with a starting deviation of 28. The small starting deviation allows the encoder starting point to be captured within one spindle revolution. The actual displacement required to complete the catch-up is 0.543mm, which meets the requirement of a clearance distance of 1mm.

[0203] Simulation results show that the algorithm can achieve rapid start-up capture with low start-up error, can enter the follow-up state for tapping within the avoidance distance, and can maintain the follow-up state until deceleration and stopping at the tapping start point.

[0204] Figure 15 This is a photograph of a 6061 aluminum alloy material being tapped using an M10F1.5 tap at a spindle speed of 800 rpm. Figure 16 This is a photograph of a 6061 aluminum alloy material being repeatedly tapped using an M6F16 tap at a spindle speed of 800 rpm. Figure 17 The images show actual workpieces of 45 steel being tapped using an M6F16 tap at a spindle speed of 500 rpm, with no broken threads.

[0205] The above-described embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Therefore, any changes made in accordance with the shape and principle of the present invention should be covered within the protection scope of the present invention.

Claims

1. A method for internal thread tapping based on spindle encoder feedback, characterized in that, Implementation of G33 tapping commands based on CNC systems, including: S1. Pre-processing for tapping and interpolation motion; S2. The overtaking algorithm, which performs dynamic speed planning based on feedback from the main spindle encoder, enables the tapping spindle to accelerate to the follow-up state within the clearance distance. S3. The tapping spindle performs follow-up tapping according to dynamic speed planning. When the target chasing distance exceeds the theoretical tapping length, it proceeds to the next step. S4. After the tapping reaches the target endpoint, the spindle decelerates and stops. In the first interpolation cycle of this stage, the spindle deceleration and stop motion planning is performed. During the remaining cycles, the tapping spindle remains in a follow-up state until the state of the single-axis structure of the spindle is detected. This is for The time indicates that the spindle deceleration and stop are complete. At this point, the G33 pause time before spindle reversal in the system parameter structure g_SSystemPara is checked. The system determines whether to pause. If the pause time is not zero, it enters the S5 spindle reversal pre-pause phase. If the pause time is zero, it directly enters the S6 spindle reversal phase. S5. Decrease the pause time before G33 spindle reverses cycle by cycle. When the change is 0, enter the S6 spindle reverse planning stage. S6, spindle reverses, tapping spindle retracts and decelerates to stop at the starting point; After the spindle encoder direction is detected to be reversed in this stage, the reverse tapping compensation function is completed according to the tapping reverse compensation distance parameter that can be set by the user. During the compensation period, the corresponding displacement fed back by the encoder is accumulated and added to the displacement of the dynamic speed planning after compensation. In the tapping spindle retraction stage, it is in the follow-up stage before the avoidance distance. After entering the avoidance distance, the deceleration used for speed planning is calculated according to the distance from the tapping start point. It no longer completely follows the encoder, but decelerates and stops at the tapping start point, and then enters S7. S7, Spindle deceleration stop; During this stage, spindle deceleration and stop motion planning is performed in the first interpolation cycle. The tapping spindle remains stationary during the remaining cycles. This process continues until the state of the single-axis spindle structure is identified. for The time indicates that the spindle deceleration and stop are complete. At this point, the number of processed heads is recorded. Perform an update with +1, when Equals the number of heads required for G33 processing When G33 tapping is completed, the system will not enter S8 again, and will directly execute the next line of G code instructions in the next cycle; when < At that time, enter S8; S8, Multi-start thread tapping spindle acceleration before feed; In the first interpolation cycle of this stage, acceleration planning is performed in the positive tapping direction of the spindle. During the remaining cycles, the tapping axis remains stationary until the state of the single-axis structure of the spindle is identified. for This indicates that the spindle acceleration is complete, and the program returns to S2.

2. The method for internal thread tapping based on spindle encoder feedback according to claim 1, characterized in that, Pre-treatment before tapping and interpolation includes: The spindle speed and lead of the tapping command input by the user are judged. When the spindle speed and lead exceed the maximum tapping speed limit, an alarm is triggered and the tapping motion is stopped. Determine if the length of the start and end points in the G33 code is zero. If the length is zero, directly change the running status of the G33 tapping command to complete. Determine whether the spindle has completed acceleration before starting tapping; only proceed to the next step after acceleration is complete. Initialize the current velocity and velocity planning structure in the tapping structure; Determine the number of machined threads in the tapping structure If the value is zero, then only the driving point and simulation time point in the tapping structure are initialized as real-time points. Initialize the member variables in the tapping structure; Enable spindle speed measurement.

3. The method for internal thread tapping based on spindle encoder feedback according to claim 1, characterized in that, The overtaking and catching-up algorithm, which performs dynamic speed planning based on feedback from the spindle encoder, enables the tapping spindle to accelerate to a follow-up state within the clearance distance, including: A dynamic velocity planning model is constructed for tapping interpolation motion planning; Perform tapping start judgment and start-up error compensation; By using virtual operation to correct the acceleration and deceleration of the catch-up plan, the tapping spindle can complete the catch-up within the avoidance distance and enter the follow-up state.

4. The method for internal thread tapping based on spindle encoder feedback according to claim 3, characterized in that, The constructed dynamic velocity planning model calculates the target chasing distance. Divided into the distance already caught up and remaining chasing distance Two parts: after startup, the displacement increment is calculated based on encoder feedback for each interpolation cycle. ,Will Simultaneously accumulated and Dynamic speed planning uses the remaining catch-up distance that changes periodically. As the planning object, at the current speed Initial velocity, G33 chasing maximum speed Dynamic speed planning is performed to plan the maximum speed and the theoretical follow-up speed as the final speed.

5. The method for internal thread tapping based on spindle encoder feedback according to claim 4, characterized in that, The dynamic velocity planning model adopts a trapezoidal acceleration / deceleration model, which specifically includes: The formula for speed-time is as follows: ; The displacement-time formula is as follows: ; The formulas for calculating accelerated displacement, uniform displacement, and decelerated displacement are as follows: ; The formulas for calculating acceleration time, constant velocity time node, and total time are as follows: ; In the above formula, and These are the acceleration and deceleration of the trapezoidal acceleration and deceleration, respectively. The target maximum speed of the trapezoidal acceleration / deceleration curve and The initial and final velocities are for planning purposes; and , These are acceleration displacement, uniform displacement, and deceleration displacement, respectively. and , These represent acceleration time, constant speed time node, and total time, respectively.

6. The method for internal thread tapping based on spindle encoder feedback according to claim 3, characterized in that, The tapping start judgment and start error compensation include: The tapping spindle starts with the encoder value as a reference. The increment of the encoder for one revolution of the spindle is the absolute value of the spindle encoder. right The modulo and positive operations can establish a mapping relationship between the encoder value and the spindle position. For the number of heads already processed, To process the number of heads, The encoder value is the relative value when the tapping spindle starts, and the calculation formula is as follows: ; Calculated relative value of the encoder when the tapping spindle starts It is a double-precision variable, and the absolute value of the encoder. As a long integer variable, to avoid the influence of the encoder feedback value constantly changing in increments of the spindle speed, a capture range is set for startup, and the error of early or late movement is compensated during the catch-up process.

7. The method for internal thread tapping based on spindle encoder feedback according to claim 6, characterized in that, Methods of starting by setting a capture range include: Method 1: Maintain the absolute value of the encoder from the previous cycle in the encoder's structure. The absolute value of the encoder in the current cycle A capture range is formed, and the encoder is activated based on the relative value of the tapping spindle. Whether to start can be determined by whether it falls within this range; Method 2: The encoder is started based on the calculated relative value of the tapping spindle. The starting point is captured by defining a left and right interval with a width of 1.1 times the encoder increment width corresponding to the spindle speed for the center point; After capturing the start point, calculate the start deviation using the following formula. Corresponding compensation displacement : ; When the start deviation is negative, it means that the start point is earlier than the target start point, and the target chasing distance is within a certain range. and remaining chasing distance Subtract the catch-up distance corresponding to an early start When the start deviation is positive, it means that the start is later than the target start point, and the target chasing distance is within a certain range. and remaining chasing distance The corresponding catch-up distance is added in the middle and late stages. .

8. The method for internal thread tapping based on spindle encoder feedback according to claim 5, characterized in that, The formulas for correcting the acceleration and deceleration of the catch-up plan through virtual operation are as follows: ; ; in, These represent acceleration and deceleration in catching up with the planning. This is the original alignment distance. To ensure adequate clearance, the system requires a clearance of no less than 1 mm.

9. The method for internal thread tapping based on spindle encoder feedback according to claim 1, characterized in that, Step S6 includes: The first cycle in this stage involves reversing the spindle at the same speed but in different directions. After the spindle reverses, the tapping spindle has a reverse distance compensation function; this distance is a system parameter. Unlike backlash compensation in linear modules, when this distance is 0, no compensation is needed; when the compensation distance is not 0, the compensation stage no longer uses dynamic velocity planning functions, but instead plans the entire compensation distance once, using trapezoidal acceleration and deceleration by default. During the compensation stage, the cumulative spindle rotation angle corresponds to the displacement that the tapping axis should travel, which is stored in the tapping structure member. In the middle; the tapping spindle only compensates once during the reverse retraction phase when the encoder reverses for the first time, and will not compensate again if there are subsequent abnormal reverses; The spindle reverse recognition relies on the encoder direction. and G33 forward tapping spindle direction Determine whether the signs are different; The first cycle of spindle reversal relies on the spindle reversal start flag of the G33 structure member. Make a judgment and reverse the first cycle of the reverse compensation plan to TRUE; Reverse compensation completion judgment: When the remaining displacement of the motion plan is 0, it indicates that the reverse compensation is complete. At this time, the reverse compensation completion flag of the tapping structure member G33 is set. Set to TRUE; During the reverse compensation phase, the corresponding displacement of the encoder feedback is accumulated and recorded in the tapping structure variable. In the process, the encoder's positive and negative directions are identified; the retraction direction is a positive value, and the tapping direction is a negative value. After compensation, the dynamic velocity planning method is still used for movement. At this time, reverse planning is performed with the current real-time point as the starting point and the G33 tapping start point as the final endpoint. In the first cycle of planning, the displacement that the tapping axis should move corresponding to the cumulative spindle rotation angle during the compensation stage is added to the planning. The reverse retraction planning model does not allow the target chasing distance. Exceeding the starting point of G33 tapping After entering the clearance distance, it no longer moves in follow-up mode, but instead calculates the planned deceleration based on the distance from the tapping start point, using the system's minimum speed as the final velocity, until it decelerates and stops at the tapping start point. ; When the follow-up retraction tool enters the avoidance distance, the distance from the current point to the tapping start point. If the distance is less than the evasive distance, be aware of the target's pursuit distance. Cannot exceed the actual tapping length of G33 At this point, dynamic programming no longer uses the maximum acceleration or deceleration of the system parameters (5 times the maximum acceleration or deceleration during follow-up), but instead uses the distance between the current point and the tapping start point. The deceleration is inversely calculated using the following formula based on the deceleration model: ; Using this deceleration as a planning parameter and the system's minimum speed as the final speed, the planning continues until the tapping start point is reached. The minimum final velocity of the system; the distance from the current point to the tapping start point. A value of 0 indicates that the tool has been retracted to the starting point of G33, at which point the spindle deceleration and stop phase S7 begins.

Citation Information

Patent Citations

  • Machining method of spiral groove

    CN107900379A

  • Linear acceleration and deceleration control method based on segmented filtering and limited jerk and acceleration

    CN113885443A