A simple example used in macro programming will now be used to illustrate the similarities and differences between macro programs and NC programs.
A company mainly performs medium-volume processing of 10 types of parts similar to those shown in Figure 1-1.
picture
Picture 1-1
Parts are made of precision castings. These parts have a total of six processing elements: inner hole, inner chamfer, end face, outer fillet, small outer circle, and taper surface between the small outer circle and the large outer circle. These 10 types of parts are processed in turn from time to time.
Figure 1-1 shows a schematic diagram of one of the parts. When processing this part, the first step is to use an end face turning tool to turn the end face and outer contour, and the second step is to use an internal turning tool to turn the inner hole and chamfer the inner corner. Only the first step is discussed here.
The NC program for the first step is as follows:
picture
Each part needs to compile a similar NC program, but in fact only the data in the N12~N17 segments among these 10 programs are different.
Therefore, replace the 8 size data shown in Figure 1-1 with 8 variables (#1~#7, #18), and assign values to them before executing the program section (macro program section) containing these variables.
(Among them, #1 represents the chamfer size of the inner hole, which will be used in the next step).
At this time, executing this macro block that replaces constants with variable values has the same effect as executing the NC block.
The result is the same.
The following is a macro program for turning the part shown in Figure 1-1:
Executing this macro program is the same as executing the 0001NC program.
This macro program can also be used for the processing of several other parts. Just reassign the first seven variables according to the actual size of the parts to be processed (that is, change the values). This macro program also has other formats, which will be introduced in detail later.





