Chapter 6 Tool set optimization to minimize the total ma-
6.2 Defining the order of tool selection
Having generated tool paths for different tools and for different milling layers the problem of connecting them should be addressed. It is known that all the tool paths together do all the necessary milling work and the global goal is to minimize the total milling time. Thus, the tool paths for one tool should be connected in such a way as to minimize the time of motions between tool paths. It can be seen that this problem is similar to the travelling salesman problem (TSP). The TSP asks the following question: given the list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the
original city [36]. There are many varieties of this problem. E.g. the requirement to return to the original city may be omitted or additional constraints may be imposed on the order of path between cities. However, most of the varieties do not affect the complexity of the problem. The problem is NP-hard which means that it is considered impossible to find the exact solution to the problem in polynomial time. Many heuristic methods can be used to solve it, though.
The problem of connecting tool paths is also NP-hard, because it is at least as hard as the TSP problem. Due to the fact that finding the optimal solution for a NP-hard problem is not the goal of this research, only the formulation of the problem and the simple greedy algorithm as a solution are provided. The provided algorithm cannot find the optimal solution for all the cases. However, it can find a good solution fast. Other heuristic algorithms can be used to archive better result.
Considering the above, the input data for the algorithm of connecting all the tool paths are the tool paths for different tools on different milling layers. The output is the tool order to mill and the single tool path for every tool made of straight line segments. For every segment it is known if it is a milling segment or a rapid motion segment. Such information can be easily post-processed into G-code for the used CNC machine. Milling straight line segment motions are converted into “G1” code, while rapid motions are converted into “G0” code. The code to change the tool is also trivial to build. With the output data it is also easy to calculate the total machining time as stated in Section 6.1. It is worth noting that this algorithm is used during tool set optimization. If the machining time need to be calculated for one milling layer, the special case of the algorithm is used: all the tool paths are independent. In general case, different milling layers are considered, which means that there are dependencies between tool paths. The algorithm of connecting tool paths from different layers has two parts: tool order building and connecting tool path segments for every tool in order.
First, the proper tool order should be built. It is assumed that every tool can be used only once, i.e. after using one tool a CNC machine never switch to this tool again. If the tool order is wrong, e.g. if smaller tools used before the bigger ones, it can lead to tool or part damaging. In traditional approaches to tool path planning, operators are responsible to select the tools in the right order, but in this research, the tool order must be built automatically. The best approach to build the proper tool order is to find all the dependencies between tool paths from different tools on different layers and build the dependencies graph. Then, using this graph it is possible to build the proper tool order, starting from the tool that does not depend on any other tools and finishing with the one that depends on all the other tools. It is assumed here, that it is always possible to build such an order, i.e. the dependencies graph has no cycles. A dependence between two tool paths on different milling layers means that without milling the one from the outer layer, the one from the inner layer cannot be milled. All the tool paths on the same milling layer are considered independent. In addition, only a tool path from the inner layer can depend on the tool path from outer layer, not vice versa. Below, the exact algorithm for how dependencies are detected is shown.
In this work, however, the dependencies graph for different tools is not built. Recall, that tools to mill every layer are not random, for every layer, the optimal tool set is created and the milling zones are defined based on tool performances. That means that if a tool is already used for some point, on some layer, the same or bigger tools will be used for outer layers. And the tool order can be simply built from the bigger tools to smaller ones. The exact proof that the bigger tool must always be used before the smaller one is not addressed in this work, but seems quite reasonable. If there are any doubts, the proper tool dependencies graph should be built to define the proper tool order. If two tools have the same size but different shape it is trickier to select the one that should be used first. In this work, the tool with the highest
depth of cut is selected first. Thus, the algorithm to build the tool order can be stated as: build the set of all the used tools by uniting tool sets from every milling layer and sort the resultant tool set from the biggest depth of cut to smallest. The order of tools in the sorted set is the order to change the tools in CNC Machine and the order to build a single tool path for every used tool. The next step is to connect all the tool paths from every milling layer for every used tool.