After being familiar with CNC programming for a period of time, we have mastered the basic functions and usage of the corresponding instructions. But this is only the beginning. As a CNC programmer, instructions are tools, just like martial arts-based moves. How to play against the enemy is the fundamental. We need to apply flexibly, by analogy. For complex parts, we need several instructions to give consideration to the use, and there should be no contradictions and conflicts between each other. Let's study the keyway machining of the next plum-shaped coupling.
Three evenly distributed keyways are machined on a hollow cylinder. Because it resembles a plum blossom, Gu is called a plum spline keyway. This structure is generally used for quincunx couplings. It is a more commonly used structure, and learning its programming has practical value.

The picture shows a tubular workpiece with an outer circle of 80 and an inner hole of 50. According to requirements, three uniformly distributed umbrella-shaped grooves with an angle of 60 shall be processed. The tool uses a 20 milling cutter.
Key points of analysis:
1. The slope of the umbrella structure intersects the center, and the tool radius compensation should be used to eliminate it during processing;
2. The processing angle needs to be realized by polar coordinate commands;
3. Cycle depth milling must use macro program instructions;
The programming procedure is as follows:
G54G90G0X0Y0; (Establish a coordinate system)
G43H1Z20; (tool length compensation)
M03S1000; (spindle start)
G17G16; (Establish polar coordinates)
#1=0; (assignment)
WHILE[#1LE20]DO1; (start of macro program)
#1=#1+0.5; (Depth increment 0.5)
G42G0X60Y0D1; (right offset polar coordinate)
G0Z-#1; (cutting depth)
G01X0F80; (milling the first slot)
X60Y60;
G0Z20; (knife lift)
G0X60Y120; (Move to the second keyway)
Z-#1; (cutting depth)
G01X0F80; (milling the second slot)
X60Y180;
G0Z20; (knife lift)
G0X60Y240; (the third keyway of the moving knife)
Z-#1; (Depth of cutting)
G01X0F80; (milling the third slot)
X60Y300;
G0Z20; (knife lift)
END1; (Cycle introduction)
G40X0Y0; (cancel tool offset)
G15; (Cancel polar coordinates)
M05; (Spindle stop)
M30; (program stop)
be careful:
There are a few knowledge points to add.
1. When using polar coordinates, some students will use G52 to establish the origin of the temporary coordinate system. But it is not applicable in the above program, because the tool offset commands G41 and G42 are invalid in G52, so please pay attention to it. Of course, the programming of the program is changeable, you can use the graphics rotation command G68 to write a try.
2. From this program, we can see that in the use of the tool offset command, the judgment of G41 and G42 is not simply to say whether it is on the left or right of the workpiece. In other words, how to determine the upper and lower sides of the workpiece. We also need to look at the feed direction of the tool. If you find it difficult to understand, everyone remembers a formula: G41 mills the shape clockwise, milling the cavity counterclockwise; G42 mills the shape counterclockwise, milling the cavity clockwise.
3. It is inevitable that there will be errors in learning CNC programming. Before we do the actual processing, it is best to verify the operation in the simulation software to avoid unnecessary losses. Please leave a message for the instructions of polar coordinates in the simulation software. If the angle of two points exceeds 180 degrees, there will be an error, which may be different from the actual use, so personal advice should not be too dependent. Inspection is only a means, and technology is the fundamental.





