Threading
Macro for cutting external or internal threads. Thread entry and exit are performed at the angle of the thread profile, which means that the cycle cuts into the diametric part of the workpiece, and not from the end, which allows processing parts without a thread groove.
Supported cutting methods:
- Lateral single-sided cutting
- Lateral double-sided cutting
- Radial cutting
Supported thread cutting methods:
- Sectional
- Sectional alternating (only odd passes are performed with a rebound)
- Standard (full length)
You can make it as a custom G-code on your machine, see other macros.
[!NOTE] Specify the G-coda number for the simplified form of the cycle call. For example G276.
Call Format
G65 P_ [A_] [C_] D_ F_ [H_] [I_] [J_] [K_] [M_] [S_] [U_] [V_] [W_] X_ Z_
G276 [A_] [C_] D_ F_ [H_] [I_] [J_] [K_] [M_] [S_] [U_] [V_] [W_] X_ Z_
Attributes
- P – Subroutine name
- *A - Thread profile angle. From 25° to 65°. Default 60°
- *C - Cone height. Increases the thread diameter at the end (diametric)
- D - Thread profile height (radial)
- F - Thread pitch
- *H - Finishing pass allowance
- *I - Number of thread turns. Default 1
-
*J - Minimum number of revolutions for one tool plunge. The parameter
changes the thread cutting method:
- Default – thread is cut along the entire length
- When specifying the number of revolutions – sectional thread cutting. Minimum section length is J*F*I.
- *K - Number of finishing passes
-
*M - Type of rebound in sectional threading
- 0 – rebound on all passes (default)
- 1 – rebound on odd passes only
-
*S Type of thread start and end positioning:
- 0 – thread length corresponds to nominal value (default)
- 1 – start position corresponds to tool approach position
- 2 – end position corresponds to tool retraction position
- 3 – start and end position correspond to tool approach and retraction position
- *U - Removal per side in one pass (radial). By default, the thread is cut across the entire height of the thread profile
- *V - Width of the final layout along the Z axis
-
*W - Width of the rough layout along the Z axis. The parameter changes the
thread cutting method:
- By default – one-sided lateral cutting
- When specifying the width – two-sided lateral cutting
- When specifying a small width – radial cutting
- X - Thread diameter
-
Z - End of thread along the Z axis
* – optional attributes
all parameters are specified with a sign (with a dot), except for P, I, J, K, M, S
Description:
J – minimum number of revolutions per cut. When this parameter is specified, the thread will be cut in sections. Odd sections are processed first, then even ones. The length of the last section can be increased depending on the length of the thread.
S – type of positioning of the start and end point of the thread. This parameter should be used if there is a possibility of collision with the end surface of the part at the beginning or end of the thread.

W – roughing width. Should be used for cutting large-profile threads, as well as trapezoidal threads. This method increases the wear resistance of the tool, since both cutting edges of the plate are used. Recommended range: 0.2 – 0.8 mm.

V – finishing width. Should be used if it is necessary to clean up the crushing on the walls of the thread profile. It is advisable not to leave a diametrical allowance, or use this method. Recommended range: 0.01 – 0.05 mm.


Examples
Example 1: External metric thread M12x1.75. Parameters: Allowance for finishing passes 0.05 mm. Removal per pass 0.1 mm. Number of finishing passes – 3
% <THREADING> N10(THREAD M12X1.75) G54 G99G97G80G40G18 G28U0 G28W0 T0202 M3S100 G0Z10. G0X14. (diameter of transition between passes) M1 M8 S700 G0Z2. (beginning of carving) G276 D1.7 F1.75 H0.05 K3 U0.1 X9.853 Z-10. (cycle start) G0Z10. M9 M5 G28U0W0 G28W0 M1 M30 %
Example 2: External metric thread M12x1.75. Thread start – Z-2., end – Z10. Taper correction 0.02 mm.
G0X14. G0Z-2. G276 C0.02 D1.7 F1.75 H0.05 K3 U0.1 X9.853 Z-10.
Example 3: Finishing passes for external metric thread M12x1.75. Thread start – Z-2., end – Z10. Taper correction 0.02 mm.
G0X14. G0Z-2. G276 C0.02 D1.7 F1.75 K3 X9.853 Z-10.
Example 4: Internal metric thread M12x1.75. Thread start – Z-2., end – Z10.
G0X8. G0Z-2. G276 D1.7 F1.75 H0.05 K3 U0.1 X12. Z-10.
Example 5: External metric thread M12x1.75 without thread groove. We cut the thread in the direction from the spindle. The beginning of the thread is Z-15., the end is Z2.
G0X14. G0Z-15. G276 D1.7 F1.75 H0.05 K3 U0.1 X9.853 Z2.
Example 6: External metric thread M12x1.75 without thread groove. We cut the thread in the direction from the spindle. The beginning of the thread is Z-15., the end is Z2. The starting position corresponds to the position of the tool feed.
G0X14. G0Z-15. G276 D1.7 F1.75 H0.05 K3 S1 U0.1 X9.853 Z2.
Example 7: External trapezoidal thread Tr14x2. Thread start – Z-2., end – Z10.
G0X16. G0Z2. G276 A30. D2. F2. H0.05 K3 U0.1 X11.5 Z-10.
Example 8: External trapezoidal thread Tr14x2. With lateral two-sided cutting with a width of 0.3 mm.
G0X16. G0Z2. G276 A30. D2. F2. H0.05 K3 U0.1 W0.3 X11.5 Z-10.
Example 9: External trapezoidal thread Tr14x2. With lateral two-sided cutting with a width of 0.3 mm. Width of final breakdown 0.02 mm
G0X16. G0Z2. G276 A30. D2. F2. H0.05 K3 U0.1 V0.02 W0.3 X11.5 Z-10.
Example 10: Internal trapezoidal thread Tr14x2. With lateral two-sided cutting with a width of 0.3 mm. The width of the final breakdown is 0.02 mm.
G0X10. G0Z2. G276 A30. D2. F2. H0.05 K3 U0.1 V0.02 W0.3 X14.5 Z-10.
Example 11: External metric thread M12x1.75. Thread start – Z2, thread end – Z10. Radial penetration into the workpiece (indicate small rough layout width).
G0X12.5 G0Z2. G276 D0.5 F0.5 H0.05 K3 U0.1 W0.01 X11.387 Z-10.
Example 12: External trapezoidal thread Tr42x6. Sectional cutting method. 4 turns per cut, therefore, the minimum length of one section is F*I*J = 24mm
G0X44. G0Z2. G276 A30. D3.5 F6. H0.05 K7 J4 U0.2 X35. Z-120.
Example 13: External trapezoidal thread Tr42x6. Sectional cutting method with lateral two-sided cutting with a width of 0.4 mm. The width of the final breakdown is 0.02 mm. 4 turns per cutting, therefore, the minimum length of one section is F _ I _ J = 24 mm
G0X44. G0Z2. G276 A30. D3.5 F6. H0.05 K7 J4 U0.2 V0.02 W0.4 X35. Z-120.
Example 14: External trapezoidal thread Tr42x6. Sectional cutting method. Rebound only on odd passes.
G0X44. G0Z2. G276 A30. D3.5 F6. H0.05 K7 J4 U0.2 X35. Z-120.
Example 15: Double-turn external trapezoidal thread Tr20x4(p2)
G0X22. G0Z2. G276 A30. D1.3 F2. K4 I2 U0.1 X17.5 Z-20.
Exceptions
- 3001 - -X- Thread diameter missing
- 3002 - -Z- Thread end missing
- 3003 - -F- Thread pitch missing
- 3004 - -F- Thread pitch must be positive
- 3005 - -A- Thread angle missing
- 3006 - -A- Thread angle out of range
- 3007 - -D- Thread depth missing
- 3008 - -D- Thread depth incorrect
- 3009 - -D- Thread depth must be positive
- 3010 - -U- Single cut depth missing
- 3011 - -U- Single cut depth must be positive
- 3012 - -H- Stock value out of range
- 3013 - -C- Taper values out of range
- 3014 - -K- Number of finishing passes out of range
- 3015 - -K- Number of finishing passes must be integer
- 3016 - -W- Rough split width out of range
- 3017 - -V- Finish split width out of range
- 3018 - Invalid starting diameter
- 3019 - -I- Invalid number of thread starts
- 3020 - -J- Invalid number of revolutions per tool plunge
- 3021 - -M- Incorrect rebound type in sectional threading
-
3022 - -S- Incorrect positioning type of
thread start and end
Defined Variables
The macro uses user variables #100 - #199, dynamic parameters are passed along with attributes, and static ones are set in the program itself:
- #121 - MAX WIDTH HARD CYCLES
- #122 - MAX WIDTH FINISHING CYCLES
- #123 - MIN THREAD ANGLE
- #124 - MAX THREAD ANGLE
- #125 - MAX ALLOWANCE FOR X AXIS
- #126 - MAX CONE HEIGHT
- #127 - MAX NUMBER OF FINISHING CYCLES
- #128 - MAX NUMBER OF THREADS
- #129 - FULL TURN IN G32
System Variables Used
- #3000 - Macro alarm
- #5001 - End point position of the previous block (workpiece coordinate system). X-axis
- #5002 - End point position of the previous block (workpiece coordinate system) . Z-axis
- #4000 - Subroutine name
[!WARNING] First, you need to check the Q attribute (the starting angle of rotation of the spindle) in the G32 cycle, namely, you need to check in what units of measurement it works. Next, in the macro, you need to adjust the static variable #129=360000(FULL TURN IN G32), which is responsible for the full revolution of the spindle. It is necessary to check each machine, since they can have different configurations. Checking procedure:
- Write #129=360.
- Cut a shallow double-start
- If the threads intersect, then #129=360.*10
- Cut a shallow double-start
- And so on until you get a double-start thread
- Or just read the documentation for your equipment
[!WARNING] Before starting the makras, do not forget to check all the system variables used; they may differ on some machines.














