3D Simulation of Tool Machining
3D Simulation of Tool Machining
3D Simulation of Tool Machining
Technical section
3D simulation of tool machining
Anna Puig, Llu!ıs Perez-Vidal, Dani Tost
Software Department, Departamento de Lenguajes y Sistemas Informatica Grafica, Universitat Politecnica de Catalunya,
Edifici H Av. Diagonal 647, planta 8a, Barcelona 08028, Spain
Accepted 18 October 2002
Abstract
This paper describes a 3D tool machining simulation system. The initial tool and the grinding wheels are integrated
with the machine tool. The application reads and interprets the CNC program code that controls the machine, it
computes the positions and the motion of components and it translates the sequence of machining operations into
Boolean operations. The machining is computed for 2D sections and, later, a 3D model of the tool is reconstructed. The
application is ready to yield tool visualization, it gives measurements on sections and it can show an interactive
animation of the whole process. A novel aspect of the simulation is that it is able to deal with 6-axes machines, whereas
most of previous work is limited to 3- and 4-axes machines. In addition, it allows to interrupt the machining process and
to show partially machined tools. A major contribution is the fact that the Boolean operations are performed in 2D and
the 3D model is reconstructed from the cross sections, which provides user control on the resolution of the operations at
a low cost.
r 2002 Elsevier Science Ltd. All rights reserved.
Keywords: Application packages; Industrial machining; Simulation; Boolean operations; Graphics data structures and data types
1. Introduction grinding wheels and the rest of the machine tool, (ii)
to check visually the efficiency of the trajectories; (iii) to
In mechanical industry, CNC (numerical control) verify that the surface of the resulting tool is effectively
machines have been in use for more than 20 years. the desired surface. Using a simulation system decreases
Metal-cutting machines move according to the instruc- considerably the tool production cost because it avoids
tions of programs that command step-by-step linear or the trial-and-error process on the real machine with
rotating servomotors and they yield better precision costly materials that is otherwise necessary.
than that obtained with the old manual analogic Conventional CAD systems do not offer the function
machines. of simulating the mechanization of tools, for which
There is a wide variety of papers on CNC in CAD, specific applications are needed. This paper deals with a
mainly centered on the automatic computation of tool particular type of machine tools: bore and cutter
paths, [7]. An integrated CAD/CAM system starts from grinders. Most of the existing simulation applications
a final tool design and yields the optimal trajectories of for these types of machines deal only with the machining
the tool and the grinding wheel, giving the CNC code as of 2D cross sections of the tools and they are restricted
a final result. Machining simulation and verification to the main fluting operation [1]. 3D applications are
wants to do exactly the opposite: to calculate the tool rather recent [2,13]. They provide a machining simula-
starting from the path with a triple goal, [3]: (i) to detect tion for specific 5-axes machines and they are not
possible collisions between the tool or any of the applicable to general movements. The goal of this paper
is to describe a novel application able to deal with any
E-mail addresses: anna@lsi.upc.es (A. Puig), lpv@lsi.upc.es combination of movements up to 6 axes (Fig. 1). A
(L. Perez-Vidal), dani@lsi.upc.es (D. Tost). major feature of the application is that, by opposition to
0097-8493/03/$ - see front matter r 2002 Elsevier Science Ltd. All rights reserved.
PII: S 0 0 9 7 - 8 4 9 3 ( 0 2 ) 0 0 2 4 8 - 0
100 A. Puig et al. / Computers & Graphics 27 (2003) 99–106
Tool
Visualization
Wheel Parser Mecanization Model
CNC Filter
Movements Measurements
Animation
the definition of the representation model for both tools Therefore, the filter consists mainly of removing from
and grinding wheels. the sequence all the registers, substituting them by actual
Interactive visualizations of the tools are based on a values, and suppressing the loops and alternative
representation model, which can be efficiently queried structures. Removing registers is feasible because in
for the geometry of the surface of objects. The CNC, registers do not act as input variables but play the
complexity of these surfaces is so high that, not only role of parametering design values. In order to remove
must we optimize the model, but also adopt optimiza- them, they must be evaluated, which implies the
tion strategies for the visualization using the resources treatment of parenthesis (square brackets, really) nested
offered by state-of-the-art graphics cards. to any depth in the arithmetic expressions. The removal
To produce partial or total animations of the of loops is a recursive procedure, since loops can be
simulation process, a list of motions of all the solids in nested one inside another. The treatment of a simple
the workshop must be stored and the ability to query loop must handle the following cases:
and visualize at any time the corresponding positions
and geometry of the objects must be provided. * Loops that do not contain any machining operation
The steps in the process are illustrated in Fig. 2. and are used only to perform computations on the
contents of registers. In this case, the computations
will be done and, no new lines will be added on the
3. Steps final result.
* Loops that repeat exactly the same operations, because
3.1. Filter the real machine needs several passes to actually
remove all the material. Those are also suppressed.
The filtering module receives as input a tool machin- * Loops corresponding to several flutes. The set of
ing program written following the CNC rules and machining operations that are the same are grouped
regulations, and produces a sequence of lines that into a block, the number of loops is counted and the
simplifies maximally the input sequence. The input angle between flutes is computed, and these two
CNC sequence is divided into blocks that correspond numbers are written at the beginning of the block in
to each one of the logical machining operations (fluting, the output sequence.
gashing, etc.). In each operation a single wheel and the * Complex loops that depend one from the previous
tool are involved. Each instruction can be either a one. Those are evaluated and written as a full list of
command controlling parameters of the machine, instructions, resulting in sequence.
(rotation speed, rebalancing, etc.) or the coding of a
translating or rotating motion, relative to the previous After considering the possibility of implementing this
motion or absolute, according to the initial positions of part of the application in C, or in C++, the Perl
the tool and the wheel. Instructions are grouped into language has been chosen. The biggest advantage of
sequential or iterative compositions and movements are Perl, in this case, is that it lends itself very well to the
specified in terms of register (variable) values. treatment of lists of CNC command lines. Besides, it
The output sequence contains only movement in- caters for the treatment of regular expressions, together
struction lines with numerical values, code lines indicat- with recursive calls to procedures. Finally, a Perl
ing if the movement values are relative or absolute and program can be easily embedded in a C program.
control lines indicating that a set of instructions should
be repeated a given number of times applying to the tool 3.2. Compilation
an axis rotation. These later instructions are very useful
to replicate the result of Boolean operations for the At the compilation stage, the entire tool and the
different flutes of the tools. grinding wheel set motions are processed to build a list
102 A. Puig et al. / Computers & Graphics 27 (2003) 99–106
of motions for the animation process. This structure lets may determine the end of a block is the end of an
the program determine, at any step, the tool undergoing iteration block.
machining, its position and the orientation and position
of the grinding wheels. The spindle moves together with 3.3. Machining
the grinding wheel set, and the tool support and the
collet move together with the tool. The calls to 3.3.1. Machining strategies
machining that will compute the new tool are made at Machining is the operation that creates a new tool
this stage. The compilation module has to define the resulting from the grinding of an initial tool with a
blocks to group the numerical code instructions that will grinding wheel with a sequence of operations. It is a
give way to a new tool. The overall efficiency of the dynamic Boolean operation of difference between the
process and the number of intermediate tools that will grinding wheel and the tool along time. The most
be candidates for visualization and query will depend referenced numerical control simulation method is the
upon this grouping into blocks. Several alternatives so-called Vector Cut [4,9]. It is an approximate
have to be taken into account. At one end, we can solution that represents the frontier as a set of points
group all the motions of the process into a single block. and normal vectors that will be cut along the path of
This means, that the machining process would perform the grinding wheel. This method is effective for
all checks of possible interference between the objects the simulation of sculptured surface polishing, but it is
at each Boolean operation and the creation of a single not extensible to complex motions of the tool and/or
tool at the end of the process and, therefore, only the grinding wheels. It is mainly useful to detect
the first and last tools could be visualized. Sometimes mistakes in the path that means a cut of the vectors
the validity of a single machining operation has to too big or too small, but, apart from the extension
be checked, and this would not be possible with this of [8], it does not yield directly a model of the bit to
option. machine.
A second strategy consists of defining as a machining Another option consists of discretizing the times
block the whole set of instructions of a machining dimension and implement a sequence of Boolean static
operation (all those of gashing, for instance). The operations between the solids at every time slice. This
advantage of this strategy is that one tool per operation operation shows its biggest drawback in its very high
is built and this can be independently queried and computational cost. According to [6], this is propor-
visualized, improving the realism of the simulation. A tional to the number of discrete positions to the fourth.
possible refinement of this strategy would be the This puts it out of question, in practical terms. Another
definition as a block of the group of instructions of problem it shows is the granularity of the temporal
one machining operation from the beginning of a discretization: it must be very fine if precision in the final
collision to the end of the collision. That is, a block tool is required. This means that very little material is
embraces the movements from the moment the grinding cut off in each Boolean operation, and that may entail
wheels touch the tool to the moment that contact is lost. robustness problems in the computations. A possible
Thus the computational cost of the machining process is method to avoid both problems is to discretize the initial
reduced, avoiding Boolean operations where there is no tool model into a voxel or an octree model [11], to
real subtraction of materials. This means that an perform all the succession of Boolean operations on the
approximate control of possible interference has to be discrete model and then reconstruct the machined
implemented inside the compilation process and that the surface, at the end. Like this, we benefit from the fact
tool has to be generated when a solid with a consistent that the cost of discrete Boolean operations is much
machining is obtained. lower and the reconstruction phase at the end of the
There are several defined cases where that control is process is done as late as possible. This option requires
not enough. In some machining operations, like flute, a the sequence of movements to be specified in terms of
grinding wheel machines the tool by translating and relative motion of the grinding wheel, while the tool and
rotating the tool, and returns to the initial position with its discretization remain fixed. This prerequisite is not
the opposite movements. In this case, the procedure will always valid and, in particular, does not hold for the
detect interference both in the real machining motions general case of 6-axes machines.
and in the opposite (‘‘reverse’’) motions. Consequently, The third option taken into account is that of the
the end of a block is determined by a motion that does computation of the volume swept by the tool and
not produce interference and also by the beginning of a the grinding wheel in their motions to perform a
reverse motion. This is the alternative actually imple- single Boolean difference operation between the two
mented with the aim of performing efficient Boolean volumes. The main difficulty of this option is the
operations without decreasing the number and quality computation of swept volumes. There are several
of possible queries and visualizations in the middle of references [5,10] on this subject, that contain methods
the machining process. Finally, the last situation that generally applied in CAD for extrusions, collision
A. Puig et al. / Computers & Graphics 27 (2003) 99–106 103
detection, and other problems but none of them can be procedure Machining(tool: tTool, wh: tWheel, ml: tMov-
applied to the non-trivial case of simultaneous motion of List)
the two solids in play. var
sw, st: tSection
3.3.2. 2D sections machining seglist: tSegmentList
The novel proposal we develop here is sketched in fvar
Fig. 3. It consists of discretizing the tool in axial st:=FirstSectTool(tool)
sections, performing the machining operations on these while ValidSection(st) do
sections and finally reconstructing the surface of the tool sw:=FirstSectWheel (wh)
stitching the sections. This solution has the main while ValidSection(sw) do
advantage of reducing the computational complexity endofmov:=FALSE
and thus the computational cost of Boolean operations Init SegList(&seglist)
from 3D to 2D and, as the second option examined [11], while endofmov do
to postpone the reconstruction to the end of the InterSect(st, sw, &seglist)
sequence. It also allows for the adaptive adjustment of UpdateGeom(ml,&st, &
both the resolution of the machining in one single sw,&seglist,&endofmov)
section and the thickness between successive cuts. It also endwhile
enables the fulfillment of the requirements of the query sw:=NextSectWheel(wh, sw)
of axial cuts described in Section 2. The main difficulty ResetToolPosition(&st)
of this operation is the choice of the resolution for the endwhile
reconstruction phase. However, we will show in Section ReconstructCrossSection(&st, seglist)
4 that satisfactory solutions can be given to this st:=NextSectTool (tool, st)
problem, and it has been selected because it seems the endwhile
best compromise overall. fprocedure
2D sections machining is based on a triple discretization:
the tool into 2D sections, the grinding wheel into This process is optimized with several acceleration
infinitesimal thickness discs, and the motion in successive techniques:
positions. Thus, the general geometric problem is reduced
to that of the intersection between two discs. The algorithm
simulates the path of a circular section of the tool and the * The intervals of probability of intersection between
disc of the grinding wheel. For every instant, it computes discs are computed to reduce the number of tests
the segment of intersection between those two and it, between discs.
applies to the preceding segments the axial rotation motion * The intersection segments are computed incremen-
of the tool. At the end of the path, the ends of the segments tally using temporal coherence of motion.
inside the section define a polygonal approximation of the * Finally, in operations like ‘‘flute’’, in which the shape
dynamic Boolean operation. This process is repeated for of the section is the same for a good stretch of the
each differential section of the wheel. Then, the envolvent tool, a profile of cut in one maximum diameter
of the intersection polygonals is computed, and a new section is first computed, next replicated applying an
profile of the section is computed. And finally, if the axial rotation and clipped against the actual cross
section was already machined, the new profile is cut over sections. This replication is only possible on cross
the initial profile. The algorithm below sketches the sections that are cut by the same wheel cross sections
structure of the machining operation. The implementation along the same movements. In practical terms, this
is based on this algorithm and it does not use any means that this speed-up is only applicable for the
comercial package. ‘‘flute’’ operation.
Boolean Surface
operation reconstruction
4. Geometric model from the same previous shell are allowed. The labeled
segments of the shells indicate the connectivity between
The tools have a tubular shape, which makes them them. At the branching, the contour with fewer shells is
suitable to be represented with a generalized cylinder stuck to the other and planar tiles between branches are
based model. Each geometric model is defined as a set of built (see Fig. 4). The correspondences between vertices
planar contour curves centered in a sweeping axis. The of adjacent irregular contours are established taking into
contour curves are originally circular but they may account the segment to which they belong. This ensures
acquire an irregular shape after machining. Evermore, that, except at the segment extremes, points of a segment
during machining a contour can be broken into different can only form triangles with points of the same segment.
connected contours, called shells. The representation of In addition, triangles belonging to different segments
circular contours is parametric. They are stored at can be painted with different colors.
points where the radius derivative changes. Irregular In order to speed up the visualization, the topological
shaped cross sections are sampled at the highest information generated during tiling can be stored in the
resolution during machining, so that no interpolation model by associating to each explicit contour point its
between explicit curves should be done during rendering. list of adjacent vertices in the previous and the next
These sections are represented explicitly as sets of contour along with its averaged normal vector.
labeled shells composed of labeled connected segments This model has low memory requirements, its render-
of 2D polar contour points. The segments correspond ing is fast and, above all, it is well adapted to the tool
to the machining operations that have generated machining process. In addition, as the other objects of
the cut. the workshop, wheels and holders, have also a tubular
During the rendering, the tool surface is tiled into shape, they are represented with the same model.
triangles between successive contours. A detailed de-
scription of this process can be found in [12]. It handles 4.1. Visualization and animations
three tiling configurations: two circular cross sections,
an irregular one with a circular one and two irregular The visualization of several parts implies the recon-
cross sections. The former case is straightforward. struction of the boundary of the model, exposed in the
Sticking a circular cross section to the irregular one following section. It requires information on the
solves the second case. This strategy removes eventual geometry and the lighting properties of the tool material
folds of the surface and the union between the two along with the eventual colors associated to the different
stuck sections is almost unnoticeable. Finally, the operations (see Fig. 5).
tiling between irregular adjacent contours is based OpenGL graphical library primitive calls have been
on the establishment of a double correspondence: used to exploit the possibilities of the projective Z-Buffer
between shells and within shells, between contour and shading techniques it offers. A blank bit machined
points. with a flute and a gash, consisting of 4724 triangles
The correspondences between shells is based on their is visualized in 3–4 s, with a Pentium III at 700 MHz
label: when a connected shell is cut into pieces during a having a Diamond Viper graphics card. We have
machining operation, the new shells are tagged with a used OpenGL display-lists to optimize the visualization
label that indicates that they were formerly pieces of the delay for the whole workshop. To post 30 frames
initial one. Only correspondences between shells coming that include the whole workshop (see Fig. 6), the
process time has been 47 s. The time to visualize industrial interest. The main contributions of the
each frame is 1 s. Although the preprocess of all the package are:
display lists before the visualization proper is very
time consuming, the animation process accelerates
* A flexible and versatile architecture that allows
a 65%. simulation directly from CNC code, through a
The graphical interface of the application is aimed at a filtering and compilation preprocess, that minimizes
user who is a machining expert. It is a single-user and geometric computations.
single-process application. It is based on multi-window * A geometric model of the workshop that evolves with
control automata with independent and interruptible time to facilitate real-time animations and high-
interactions, implemented in Tcl/Tk and C. Here is an quality visualizations.
example of the interface where an angle in a section of * A novel and efficient method to perform Boolean
the machined tool is examined (see Fig. 7). operations.
In addition, the simulation has also a commercial appeal [6] Lee K. Principles of CAD/CAM/CAE systems. Reading,
for the clients of CNC software and it makes the MA: Addison-Wesley, 1999.
communication between programers and operators easier. [7] Lin Y, Lee TS. An adaptive tool path generation algorithm
for precision surface machining. Computer Aided Design
Acknowledgements 1999;31:237–47.
[8] O’Connell JM, Jablokow A. Construction of solid models
from NC machining programs. Proceedings of ASME on
We gratefully acknowledge the decisive help of Albert Manufacturing Science and Engineering. PED-VOL
Mercade in the implementation of software for the 64. ASM Manufacturing Science Engineering 1993.
application. p. 157–66.
[9] Jerard R, Drysdale R, Hauck K, Schaudt B. Methods
References for detecting errors in numerically controlled machining
of sculptured surfaces. IEEE Computer Graphics and
[1] Amsys. WinEMC CNJ2-30, Advanced Machining Sys- Applications 1989;1:29–39.
tems, 1998. [10] Roth D, Bedi S, Ismail F, Mann D. Surface swept by a
[2] ANCA. Cimulator 3D User Manual, ANCA, 2000. toroidal cutter during 5-axis machining. Computer Aided
[3] Han Z, Yang CCH. Interference detection and optimal Design 2001;33:57–63.
tool selection in 3-axis nc machining of free-form surfaces. [11] Roy U, Xu Y. Computation of a geometric model of a
Computer Aided Design 1999;31:303–15. machined part from its nc machining programs. Computer
[4] Chappel I. The use of vectors to simulate material removed Aided Design 1999;31:401–11.
by numerically controlled milling. Computer Aided Design [12] Tost D, Puig A. Visualization of labeled segment cross-
1983;15:156–8. contour surfaces. Volum Graphics 2001, New York, June
[5] Abdel-Malek K, Yeh H, Othman S. Swept volumes: void 2001.
and boundary identification. Computer Aided Design .
[13] Walter AG. Cyber grinding software. Tubingen: Walter
1999;30:1009–18. AG, 2000.