Class Notes CAD CAM
Class Notes CAD CAM
• apply computer drawing skills to develop complex engineering drawing and design
Expected Outcomes
• use the basic functions of a solid modeller within the CAD system to draw 3-
dimensional objects
• use CAD system to make electrical circuit drawings and piping drawings
Course Outline
History and evolutions of CAD and CAM. Architecture of CAD: CAD hardware sys-
tems. CAD software systems: Types such as AutoCAD and Design CAD. 3-D computer
aided draughting. Mathematical elements of computer graphics: Derivatives, chain rule,
curves and fractals, curve generation, interpolation, B-splines, Bezier curves, fractal -
fractal lines. Computer graphics: Transformations, translations, rotations. Geometric
modeling: Wireframe, surface and solid modelling. Finite elements as a CAD tool:
Draughting, modelling and analysis. Advantages and disadvantages of CAD. Introduc-
tion to the types and applications of numerically controlled machine tools: Structure
of numerical control programs and programming for numerical control. Introduction to
a Computer Aided Part Programming system: Structure and elements of a program,
the creation of a programme for a given component, examination of post processors,
production of a component from a post processed file.
Reference Textbooks
1. Encanacao J. L., Linder R. & Schechtendahl E. G. (1990) Computer Aided Design:
Fundamentals and System Architectures, Springer-Verlag, Berlin
2. Tien-Chien Chang, Richard A. Wysk, Hsu-Pin Wang (2006) Computer Aided Man-
ufacturing Prentice Hall international 3rd Ed
i
Contents
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Expected Outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Course Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Reference Textbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
2 Computer Graphics 8
2.1 Two-Dimensional Transformation . . . . . . . . . . . . . . . . . . . . . . 8
2.1.1 Basic modeling transformations . . . . . . . . . . . . . . . . . . . 8
2.2 Three-Dimensional Transformation . . . . . . . . . . . . . . . . . . . . . 18
2.2.1 Rotation Transformation . . . . . . . . . . . . . . . . . . . . . . . 18
3 Geometric modelling 20
3.1 Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1.1 Role of Curves in Geometric Modeling . . . . . . . . . . . . . . . 22
3.1.2 Parametric and Non-parametric Equations of a Curve . . . . . . . 23
ii
3.1.3 Fixed-Form or Analytical Curves . . . . . . . . . . . . . . . . . . 24
3.1.4 Interpolated Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.5 Approximated Synthetic Curves . . . . . . . . . . . . . . . . . . . 33
3.2 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.1 Analytical surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2.2 Free-form surfaces: . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3 Solid models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4 Finite Element as CAD tool . . . . . . . . . . . . . . . . . . . . . . . . . 41
iii
Chapter 1
Fundamentals of CAD-CAM
systems
1.1 Introduction
1970
• Application of CAM in government, industry and academia
1
• National organization formed
• Beginning of usage of computer graphics
• Turnkey system available for drafting
• Wireframe and surface modeling software became available
• Mass property calculation and FEA software became available
• NC tape generating, verification, and integrated circuit software became available-
Beginning of usage of computer graphics
• Turnkey system available for drafting
1980
• CAD/CAM used for engineering research and development
• New CAD/CAM theories and algorithms developed
• Integration of CAD/CAM
• Solid modeling software became available
• Use of PCs and workstation began
1990
• Concept of concurrent engineering developed
• Increased use of CAD/CAM on PCs and worksations
• Improvements in hardware and software
Advantages of CAD
• A faster rate of producing drawing.
• Great accuracy in drawing-enhanced by zooming feature.
• Neat drawings.
• No repetitions of drawing.
• CAD system contain draughting features.
• They are faster in design calculations and analysis.
• Produce superior design forms which also allows for quick modifications.
• There is less development required in the design process (shortened by eliminating
prototype)
• Design in CAD can also be integrated with other disciplines (Computer aided
engineering, CAM, CIM FMS etc)
2
1.3 Brief history in CAM
Advantages of CAM
• A higher production rate with low work force
• Superior products
The term CAD/CAM refers to the complete integration of CAD and CAM into one
complete process.
3
A wide range of hardware is used to support the software functions in CAD systems.
The operating system software is the interface between the CAD application software
and the hardware. It supervises the operation of the hardware and provide basic func-
tions, including creating and removing operating tasks, and providing access to software
resources such as files, editors, compilers, and utility programs. The operating system is
important not only for CAD software, but also for non-CAD software.
The application software is the heart of a CAD system. It consists of programs that do
2-D and 3-D modelling, drafting, and engineering analysis. The functionality of a CAD
system is built into the application software. It is the application software that makes
one CAD package different from another. Application software is usually operating sys-
tem dependent.
The general architecture of a CAD system is shown in Figure 1.1. The application
software is at the top level and is used to manipulate the CAD model database.
Application
Software
CAD
User Graphics Utility Model
Interface (GUI) Databas
Device Drivers
Printer
The graphic utility system performs coordinate transformation, windowing, and display
control. Because several different I/O devices may be used, device drivers translate the
data into and out of the specific data format utilized by each device. Device drivers also
control the physical devices. The operating system is run in the background to coordinate
the entire operation. Finally, a user interface links the human with the system.
These are the devices that we use for communicating with computer, and providing our
input in the form of text and graphics. The text input is mainly provided through key-
board. For graphic input, there are several devices available and used according to the
4
work environment. A brief description of these devices is given here.
Mouse: This is a potentiometric device, which contains several variable resistors that
send signals to the computer. The functions of a mouse include locating a point on the
screen, sketching, dragging an object, entering values, accepting a software command,
etc. Joystick and trackballs are analogous to a mouse device, and operate on the same
principle.
Digitizers: Digitizers are used to trace a sketch or other 2-D entities by moving a cursor
over a flat surface (which contains the sketch). The position of the cursor provides a
feedback to the computer connected with the device. There are electrical wires embed-
ded in orthogonal directions that receive and pass signals between the device and the
computer. The device is basically a free moving puck or pen shaped stylus, connected
to a tablet.
Light Pens: Lockheeds CADAM software utilized this device to carry out the graphic
input. A light pen looks like a pen and contains a photocell, which emits an electronic
signal. When the pen is pointed at the monitor screen, it senses light, which is converted
to a signal. The signal is sent to the computer, for determination of the exact location
of the pen on the monitor screen.
Touch Sensitive Screens: This device is embedded in the monitor screens, usually,
in the form of an overlay. The screen senses the physical contact of the user. The new
generation of the Laptop computers is a good example of this device.
Other Graphic Input Devices: In addition to the devices described above, some CAD
software will accept input via Image Scanners, which can copy a drawing or schematic
with a camera and light beam assembly and convert it into a pictorial database. The
devices just described are, in general, independent of the CAD package being used. All
commercial CAD software packages contain the device drivers for the most commonly
used input devices. The device drivers facilitate a smooth interaction between our in-
put, the software, and the computer. An input device is evaluated on the basis of the
following factors:
• Resolution
• Accuracy
• Repeatability
• Linearity
After creating a CAD model, we often need a hard copy, using an output device. Plotters
and printers are used for this purpose. A plotter is often used to produce large size
drawings and assemblies, where as, a laser jet printer is adequate to provide a 3-D view
of a model. Most CAD software require a plotter for producing a shaded or a rendered
view.
5
1.6 CAD software systems
CAD software are written in FORTRAN and C languages. FORTRAN provides the
number crunching, where as, C language provides the visual images. Early CAD pack-
ages were turnkey systems, i.e., the CAD packages were sold as an integrated software
and hardware package, with no flexibility for using second vendor hardware (1970s and
80s). These systems were based on 16-bit word, and were incapable of networking. The
modern CAD software utilizes the open architecture system, i.e., software vendors do
not design and manufacture their own hardware. Third party software can be used to
augment the basic CAD package. Most popular CAD package will facilitate integration
of the Finite Element Analysis and other CAD software from more than one vendor. For
example, IDEAS preprocessor can work with almost all the FEA packages for pre and
post analyses.
Networking is an important consideration in applications of CAD software. A model
created by one engineer must be readily accessible to others in an organization, which
is linked by a LAN or other means. The designer, analyst, management, marketing,
vendor, and others generally share a model. This is the concurrent engineering in action,
mentioned earlier.
A good CAD package includes good software, as well as, a compatible hardware. Fol-
lowing is a brief description of the general criteria for evaluating a CAD package.
Hardware: Most desirable features in a good hardware are:
• Open architecture
• Compact size
• Inexpensive components
• Inexpensive upgrading
Software: In general, the most comprehensive software are written to satisfy almost all
the modeling needs of a modeler, consequently, the software tend to be very complex
and hard to learn. To create a simple model, we go through several unnecessary steps,
and lack the intuitiveness of a simple, straightforward program. ProE is a good example,
where we have to go through several layers of menus to create a simple solid. On the
other hand, if we were to use a simpler CAD program, the same solid can be created by
only a few simple commands. There are several other factors that we should consider
when evaluating software. Following is a brief description of these factors.
• Operating System: Unix or Windows/NT. PCs in general use Microsoft Win-
dows, where as, operating system for Workstations is Unix. For a large organiza-
tion, Workstations are preferable.
• User Interface: Most popular CAD software have menu driven commands, which
is preferable to the old system of non-menu driven, where user interface was com-
pletely by responding to software commands. The most popular CAD programs
work with menu driven interface, with some input/action required through com-
mand prompts.
6
• Documentation and Support: Learning a software can be very difficult if the
software lacks good documentation. Documentation usually comes in the form
of a users manual, a tutorial book, commands manual, and on-line help. The
recent trend is to provide access to the above-mentioned documentation through
the Internet, or provide the manuals on a CD ROM. Some CAD vendors provide
additional technical support help through phone ProE is a very good example of
this type of support.
• Maintenance: Cost of the hardware and software upgrades can significantly im-
pact the small and medium size companies decision to choose one software over
the others. Most CAD vendors go through an upgrade, on the average, every two
years. Usually, hardware upgrade is not as frequent.
7
Chapter 2
Computer Graphics
2.1 Two-Dimensional Transformation
Geometric transformations have numerous applications in geometric modeling, e.g., ma-
nipulation of size, shape, and location of an object. In CAD, transformation is also used
to generate surfaces and solids by sweeping curves and surfaces, respectively. The term
sweeping refers to parametric transformations, which are utilized to generate surfaces
and solids. When we sweep a curve, it is transformed through several positions along or
around an axis, generating a surface. The appearance of the generated surface depends
on the number of instances of the transformation. A parameter t or s is varied from
0 to 1, with the interval value equal to the fraction of the parameter. For example, to
generate 10 instances, the parameter will have a value t/10 or s/10. To develop an easier
understanding of transformations, we will first study the two-dimensional transforma-
tions and then extend it to the study of three-dimensional transformations. Until we get
to the discussion of surfaces and solids, we will limit our discussion of transformation
to only the simple cases of scaling, translation, rotation, and the combinations of these.
Applications of transformations will become apparent when we discuss the surface and
solid modeling.
There are two types of transformations:
• Modeling Transformation: this transformation alters the coordinate values of
the object. Basic operations are scaling, translation, rotation and, combination of
one or more of these basic transformations. Examples of these transformations can
be easily found in any commercial CAD software. For instance, AutoCAD uses
SCALE, MOVE, and ROTATE commands for scaling, translation, and rotation
transformations, respectively.
There are three basic modeling transformations: Scaling, Translation, and Rotation.
Other transformations, which are modification or combination of any of the basic trans-
formations, are Shearing, Mirroring, copy, etc. Let us look at the procedure for carrying
8
out basic transformations, which are based on matrix operation. A transformation can
be expressed as
[P ∗] = [P ][T ]
where, [P ∗] is the new coordinates matrix
[P ] is the original coordinates matrix, or points matrix
[T ] is the transformation matrix With the z-terms set to zero, the P matrix can be
written as,
x 1 y1 0
x 2 y2 0
x 3 y3 0
[P ] = (2.1)
.. .. ..
. . .
xy xy 0
The size of this matrix depends on the geometry of the object, e.g., a point is defined
by a single set of coordinates (x1 , y1 , z1 ), a line is defined by two sets of coordinates
(x1 , y1 , z1 ) and (x2 , y2 , z2 ), etc. Thus a point matrix will have the size 1x3, line will be
2x3, etc.
A transformation matrix is always written as a 4x4 matrix, with a basic shape shown
below,
1 0 0 0
0 1 0 0
[T ] =
0
(2.2)
0 1 0
0 0 0 1
Values of the elements in the matrix will change according to the type of transformation
being used, as we will see shortly. The transformation matrix changes the size, position,
and orientation of an object, by mathematically adding, or multiplying its coordinate
values. We will now discuss the mathematical procedure for scaling, translation, and
rotation transformations.
Scaling
9
• Non-Uniform Scaling:
Matrix equation of a non-uniform scaling has the form:
sx 0 0 0
0 sy 0 0
[T ] =
0 0 sz 0
(2.4)
0 0 0 1
where, sx , sx , sx are the scale factors for the x, y, and z coordinates of the object.
Homogeneous coordinates
Example
If the triangle A(1,1), B(2,1), C(1,3) is scaled by a factor 2, find the new coordinates of
the triangle.
Solution: Writing the points matrix in homogeneous coordinates, we have
1 1 0 1
[P ] = 2 1 0 1
1 3 0 1
10
The new points matrix can be evaluated by the equation
Transformed by scaling
Original
Translation transformation
In translation, every point on an object translates exactly the same distance. The effect
of a translation transformation is that the original coordinate values increase or decrease
by the amount of the translation along the x, y, and z-axes. For example, if line A(2, 4),
B(5, 6) is translated 2 units along the positive x-axis and 3 units along the positive y-
axis, then the new coordinates of the line would be
A0 (2 + 2, 4 + 3), B 0 (5 + 2, 6 + 3) or
Lecture Notes © by R. B. Agarwal Computer Aided Design in Mechanical Engineering 2-6
0 0
A (4, 7), B (7, 9).
where, x and y are the values of translation in the x and y direction, respectively. For
translation transformation, the matrix equation is
[P ∗] = [P ][Tt ] (2.7)
11
Example
Translate the rectangle (2, 2), (2, 8), (10, 8), (10, 2) 2 units along x-axis and 3 units along
y-axis.
2 2 0 1 1 0 0 0 4 5 0 1
2 8 0 1 0 1 0 0 Chapter 2 – Two Dimensional Transformation
= 4 11 0 1
[P ∗] =
10 8 0 1 0 0 1 0 12 11 0 1
10 2 0 1 2 3 0 1 12 5 0 1
Note that the resultant coordinates are equal to the original x and y values plus the 2
2.73 Rotation
and units added to these values, respectively.
We will first consider rotation about the z-axis, which passes through the origin (0,0,0), since it
Rotation
is the simplest transformation for understanding the rotation transformation. Rotation about an
arbitrary axis, other than an axis passing through the origin, requires a combination of three or
Wemorewilltransformations, as we will
first consider rotation see later.
about the z-axis, which passes through the origin (0, 0, 0),
since it is the simplest transformation for understanding the rotation transformation.
When anabout
Rotation objectan
is rotated
arbitrary about theother
axis, z-axis, all the
than points
an axis on thethrough
passing object rotate in a circular
the origin, arc, and
requires
a the center of the
combination of arc liesorat more
three the origin. Similarly, rotation
transformations, as we of an see
will object about an arbitrary axis has
later.
the same relationship with the axis, i.e., all the points on the object rotate in a circular arc, and
When an object is rotated about the z-axis, all the points on the object rotate in a
the center of rotation lies at the given point through which the axis is passing.
circular arc, and the center of the arc lies at the origin. Similarly, rotation of an object
about an arbitrary axis has the same relationship with the axis, i.e., all the points on the
object rotate in a circular arc, and the center of rotation lies at the given point through
2.7.1 Derivation of the Rotation Transformation Matrix
which the axis is passing.
Using trigonometric relations, as given below, we can derive the rotation transformation
• Derivation
matrix. of P(x,
Let the point the y) Rotation
be on the Transformation
circle, located at an Matrix:
angle α, as shown. If the point
Using trigonometric
P is rotated relations,
an additional angle θ, the as
new given
pointbelow, we can
will have derive the rotation
the coordinates (x*, y*). transfor-
The
mation matrix. Let the point P (x, y) be on the
angle and the original coordinate relationship is found as follows. circle, located at an angle α, as
shown. If the point P is rotated an additional angle α, the new point will have the
coordinates (x∗ , y ∗ ). The angle and the original coordinate relationship is found as
follows.
x = r cos α
Original coordinates of point P.
y = r sin α
x* = rcos(α + θ)
The new coordinates.
*
y = rsin(α + θ)
Thus, a point or any object can be rotated about the z-axis (in 2-D) and the
new coordinates of the object found by the product of the points matrix and the
rotation matrix, derived here.
• Rotation of an Object about an Arbitrary Axis: Rotation of a geometric
model about an arbitrary axis, other than any of the coordinate axes, involves sev-
eral rotational and translation transformations. When we rotate an object about
the origin (in 2-D), we in fact rotate it about the z-axis. Every point on the object
rotates along a circular path, with the center of rotation at the origin. If we wish
to rotate an object about an arbitrary axis, which is perpendicular to the xy-plane,
we will have to first translate the axis to the origin and then rotate the model, and
finally, translate so that the axis of rotation is restored to its initial position. If we
erroneously use the equation (2.9) directly, to rotate the object about a fixed axis,
and skip the translation of this point to the origin, we will in fact end up rotating
the object about the z-axis, and not about the fixed axis.
Thus, the rotation of an object about an arbitrary axis, involves three steps:
Step 1: Translate the fixed axis so that it coincides with the z-axis
Step 2: Rotate the object about the axis
Step 3: Translate the fixed axis back to the original position.
Note: When the fixed axis is translated, the object is also translated. The axis
and the object go through all the transformations simultaneously.
Example
Rotate the rectangle (0, 0), (2, 0), (2, 2), (0, 2) shown below, 300 ccw about its
centroid and find the new coordinates of the rectangle.
Solution: Centroid of the rectangle is at point (1, 1). We will first translate the
centroid to the origin, then rotate the rectangle, and finally, translate the rectangle
13
Example 3: Rotate the rectangle (0,0), (2,0), (2, 2), (0, 2) shown below, 30 ccw about
its centroid and find the new coordinates of the rectangle.
(0,2) (2,2)
(0,0) (2,0)
1. Translate the centroid to the origin: The matrix equation for this step is
Solution: Centroid of the rectangle is at point(1, 1). We willfirst translate the centroid to th
0 0 the
origin, then rotate the rectangle, and finally, translate 0 rectangle
1 so that the centroid is rest
to its original 2 0 0 1
[P ∗position.
]1 = [P ][Tt ], where [P ] = 2 2 0 1
and
1 0 0 0
0
01 0 0 00 1
[Tt ] =
[P*]1 = [P] [Tt], where [P] = 0 20 0 1 00 1
−1 2−1 2 0 01 1
0 2 0 1
2. Rotate the Rectangle 300 ccw About the z-axis: The matrix equation for
this step is given as
[P ∗ ]2 = [P ∗ ]1 [Tr ], where, [P∗ ]1 is the resultant points matrix obtained in step 1,
and [Tr ] is the rotation transformation, where θ = 300 ccw. The transformation
matrix is, 1 0 0 0
0 1 0 0
and cos θ [Ttsin
] θ= 0 0 0 0 1 00.866 0.5 0 0
− sin θ cos θ 0 -10 -1 0 1−0.5 0.866 0 0
[Tr ]θ = =
0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1
Lecture Notes © by R. B. Agarwal Computer Aided Design in Mechanical Engineering 2-11
3. Translate the Rectangle so that the Centroid Lies at its Original Po-
sition: The matrix equation for this step is
Now we can write the entire matrix equation that combines all the three steps
outlined above. The equation is,
14
Substituting the values given earlier, we get,
0 0 0 1 1 0 0 0 0.866 0.5 0 0 1 0 0 0
2 0 0 1 0 1 0 0 −0.5 0.866 0 0 0 1 0 0
[P ∗ ] =
2 2 0 1 0 0 1 0 0 0 1 0 0 0 1 0
0 2 0 1 −1 −1 0 1 0 0 0 1 1 1 0 1
0.6340 −0.3660 0 1
−0.3660 1.3660 0 1
[P ∗ ] =
1.3660
2.3660 0 1
−0.3660 1.3660 0 1
The first two columns represent the new coordinates of the rotated rectangle.
Combined transformations
Most applications require the use of more than one basic transformation to achieve de-
sired results. As stated earlier, scaling with an arbitrarily fixed point involves both
scaling and translation. And rotation around a given point, other than the origin, in-
volves rotation and translation. We will now consider these combined transformations.
• Scaling With an Arbitrary Point
In uniform scaling, all points and their coordinates are scaled by a factor s. There-
fore, unless the fixed point is located at (0, 0), it will be moved to a new location
with coordinates s-times x and s-times y. To scale an object about a fixed point,
the fixed point is first moved to the origin and then the object is scaled. Finally,
the object is translated or moved so that the fixed point is restored to its original
position. The transformation sequence is,
Where,
[Tt ] is the translation transformation matrix, for translation of the fixed point to
the origin,
[Ts ] is the scaling transformation matrix, and
[T − t] is the reverse translation matrix, to restore the fixed point to its original
position.
Note: The order of matrix multiplication progresses from left to right and the
order should not be changed.
The three transformation matrices [Tt ][Ts ][T − t] can be concatenated to produce
a single transformation matrix, which uniformly scales an object while keeping
the pivot point fixed. Thus, the resultant, concatenated transformation matrix for
scaling is,
1 0 0 0 s 0 0 0 1 0 0 0 s 0 0 0
0 1 0 0 0 s 0 0 0 1 0 0
0 s 0 0
[Ts ]R =
0 =
0 1 0 0 0 s 0 0 0 1 0 0 0 s 0
−x −y 0 1 0 0 0 1 x y 0 1 x − sx y − sy 0 1
15
The concatenated equation can be used directly instead of the step-by-step matrix
solution. This form is preferable when writing a CAD program.
D(1,3) C C (2,3)
. . (3,2)
x
A(1,1) B(2,1)
Mirroring
Solution: We will first translate the point (3,2) to the origin, then rotate the rectangle about th
origin, and finally, translate the rectangle back so that the original point is restores to its origi
In modeling position
operations,
(3,2).one
Thefrequently used operation
new coordinates is mirroring
of the rectangle an object.
are found Mirroring
as follows.
is a convenient method used for copying an object while preserving its features. The
mirror transformation is a special case of a negative scaling, as will be explained below.
[P*] = [P] [Tt] [Tr] [T-t]
Let us say, we want to mirror the point A(2, 2) about the x-axis(i.e., xz-plane), as shown
in the figure.
1 1 0 1 1 0 0 0 .866 .5 0 0 1 0 0
2 1 0 1 0 1 0 0 -.5 .866 0 0 0 1 0
= 2 3 0 1 0 0 1 0 0 0 1 0 0 0 1
1 3 0 1 -3 16-2 0 1 0 0 0 1 3 2 0
ng operations, one frequently used operation is mirroring an object. Mirroring is a
nt method used for copying an object while preserving its features. The mirror
ation is a special case of a negative scaling, as will be explained below.
y, we want to mirror the point A(2,2) about the x-axis(i.e., xz-plane), as shown in the
The new location of the point, when reflected about the x-axis, will be at (2, −2). The
point matrix [P ∗ ] = [2 − 2] can be obtained with the matrix transformation given below.
location of the point, when reflected about the x-axis, willbe at (2, -2). The point
P*] = [2 -2] can be obtained with the matrix transformation 1given 0 below.
0 0
0 −1 0 0
[P ∗ ] = [2201]
0 0 1 0 = [2 − 201]
0 0 0 1
y
1 0 0 0
0 -1 0 0 A(2, 2)
2 0 1] 0 0 1 0
0 0 0 1
x
A’(2, -2)
[2 -2 0 1]
The new points matrix, in terms of the original points matrix and the five trans-
formation matrices is given as,
17
nly about a plane, and not about a line.
Translate the line AB (i.e., the plane) such that it passes through the origin, as shown by
hed line.
Next, rotate the line about the origin (or the z-axis) such that it coincides with x or y
Where, the subscripts t, r, and m represent the translation, rotation, and mirror
axes (we will use the x-axis).
operations, respectively. Lecture
Mirror the rectangle about the x-axis.
(Note: A negative sign is used in the subscripts to indicate a reverse transfor-
Rotate the line back to itsmation).
original orientation.
18
subscript z indicates rotation about the z-axis. Similarly, rotation about the x and y-
axes are denoted as [Trx ], and [Try ], respectively. The transformation matrices are given
below.
cos θ sin θ 0 0
− sin θ cos θ 0 0
[T rz] = (2.12)
0 0 1 0
0 0 0 1
1 0 0 0
0 cos θ sin θ 0
[T rx] =
0 − sin θ cos θ 0 (2.13)
0 0 0 1
cos θ 0 − sin θ 0
0 1 0 0
[T ry] =
sin θ
(2.14)
0 cos θ 0
0 0 0 1
19
CHAPTER 4
CURVES
Chapter 3
Geometric modelling
4.1 Introduction
3.1 Curves
In order to understand the significance of curves, we should look into the types of model
representations that are used in geometric modeling. Curves play a very significant role in CAD
In order to understand the significance
modeling, especially, of curves,
for generating we should
a wireframe look which
model, into the types
is the of model
simplest form for
representations that are aused
representing in geometric modeling. Curves play a very significant role
model.
in CAD modeling, especially, for generating a wireframe model, which is the simplest
form for representing a model.
We can display We on
an object cana monitor
display screen
an object on different
in three a monitor screen in three
computer-model forms:
x Wireframe forms:
different computer-model model
x Surface
• Wireframe model Model
x Solid model
• Surface Model
• Solid model
Wireframe model: A wireframe model consist of points and curves only, and looks as if its
made up with a bunch of wires. This is the simplest CAD model of an object. Advantages of th
Wireframe typemodel: A wireframe
of model include easemodel consist
of creation andoflow
points
level and curves
hardware andonly, and requirements.
software looks
as if its made up with a bunch
Additionally, the dataofstorage
wires.requirement
This is theis simplest
low. The CAD model of anofobject.
main disadvantage a wireframe model
Advantages isof that
thisittype
can beofvery
model includeto ease
confusing of creation
visualize. and low
For example, levelhole
a blind hardware
in a box and
may look like a
software requirements.
solid cylinder,Additionally, thefigure.
as shown in the data storage requirement is low. The main
disadvantage of a wireframe model is that it can be very confusing to visualize. For
example, a blind hole in a box may look like a solid cylinder, as shown in the figure 3.1.
In spite of its ambiguity, a wireframe model is still the most preferred form, because
it can be created quickly and easily to verifyComputer
ME 165 Lecture Notes © by R. B. Agarwal
a concept of an object. The wireframe
Aided Design in Mechanical Engineering 4-1
model creation is somewhat similar to drawing a sketch by hand to communicate or
conceptualize an object. As stated earlier, a wireframe model is created using points and
curves only.The disadvantages of wireframe models are manifold.
• These models are usually ambiguous representations of real objects and rely heavily
on human interpretation. Models of complex designs having many edges become
very confusing and perhaps even impossible to interpret.
20
• The lack of visual coherence and information to determine the object profile. In
most systems, the holes are displayed as two parallel circles separated by the hole
length.
• Representations of the intersection of plane faces with cylinders and that of cylin-
ders with cylinders, or tangent surfaces in general is usually a problem in wireframe
modelling and requires user manipulations.
Despite its many disadvantages, the major advantages of wireframe modelling is its sim-
plicity to construct. Therefore, it does not require as much computerChapter time and memory
4 - Curves
as does surface or solid modelling. However, the user or terminal time needed to prepare
and/or input data is substantial and increases rapidly with the complexity of the object
In spite
being of its ambiguity,
modelled. a wireframe
Wireframe modellingmodel
is is still the most
considered preferredextension
a natural form, because it can be
of traditional
created quickly
methods of drafting.and easily to verify a concept of an object. The wireframe model creation is
somewhat similar to drawing a sketch by hand to communicate or conceptualize an object. As
Surface Model:In
stated earlier, an attempt
a wireframe model istocreated
solve the
usingdrawback
points andofcurves
wireframe
only. models, some mod-
elling schemes add information about the surfaces in the part. In these systems, the
user enters
Surface the vertices
Model: sweepingand edgesaround
a curve as inorwireframe models,
along an axis but in
can create an ordered
a surface model.manner,
The
outlining or bounding one face at a time. For example
figures below show two instances of generating a surface model. sweeping a curve around or along
an axis can create a surface model. The figures below show two instances of generating
a surface model.
Theappearance
The appearance ororresolution
resolution of of
a surface model
a surface depends
model on the on
depends number of sweeping
the number instances
of sweeping
we select.we
instances Forselect.
a realistic
Forlooking model,looking
a realistic we needmodel,
to selectwea large
neednumber of instances,
to select requiring
a large number
a large computer memory, or, opt for a not-so realistic model by selecting a
of instances, requiring a large computer memory, or, opt for a not-so realistic model small number of
instances, and save memory. In some commercial CAD packages we have the option of selecting
by selecting a small number of instances, and save memory. In some commercial CAD
the resolution of a model, other packages have a fixed value for resolution that cannot be
packages we have the option of selecting the resolution of a model, other packages have
changed by users.
a fixed value for resolution that cannot be changed by users.
Surfacemodels
Surface models are useful
usefulforforrepresenting
representingsurfaces such
surfaces as aas
such soft-drink bottle,bottle,
a soft-drink automobile
automo-
fender, aircraft wing, and in general, any complicated curved surface. One of
bile fender, aircraft wing, and in general, any complicated curved surface. One of the the limitations of a
surface model
limitations of aissurface
that there is no is
model geometric definition
that there of points that
is no geometric lie insideoforpoints
definition outsidethat
the lie
surface.
inside or outside the surface. There are many surface entities provided by CAD/CAM
such as Plane surface, Ruled surface, Surface of revolution, Tabulated cylinder, B-spline
surface among others.
Solid Model: Representation of an object by a solid model is
Surface models have considerable advantages over wireframe models. -6mm
relatively a new concept. There were only a couple of solids
modeling CAD programs available in late 1980s, and they
• They
required are less ambiguous.
mainframe computers to run on. However, in 1990s,
due to the low cost and high speed, PCs have become the
• They
most popularprovide hidden line
solid modeling and platform,
software surface algorithms
prompting to add realism to the displayed
geometry.
almost all the CAD vendors to introduce their 3-D solid
modeling software that will run on a PC.
21
Solid models represent objects in a very realistic and
unambiguous form; however, they require a large amount of
storage memory and high-end computer hardware. A solid
Chapter 4 - Curves
s ambiguity, a wireframe model is still the most preferred form, because it can be
kly and easily to verify a concept of an object. The wireframe model creation is
milar to drawing a sketch by hand to communicate or conceptualize an object. As
• Shading algorithms are only available for surface and solid models.
r, a wireframe model is created using points and curves only.
• From an application point of view, surface models can be utilised in volume and
del: sweeping a curve around
massorproperty
along an axis can create finite
calculations, a surface model.modelling,
element The NC path generation, cross
w show two instances of generating a surface model.
sectioning, and interference detections.
Curves are used to draw a wireframe model, which consists of points and curves; the
curves are utilized to generate surfaces by performing parametric transformations on
them. A curve can be as simple as a line or as complex as a B-spline. In general, curves
can be classified as follows:
22
• Analytical Curves: This type of curve can be represented by a simple mathe-
matical equation, such as, a circle or an ellipse. They have a fixed form and cannot
be modified to achieve a shape that violates the mathematical equations.
• Free-form curves: These curves provide the most flexibility in drawing curves
of very complex shapes. The model of a curved automobile fender can be easily
created with the help of approximated curves and surfaces.
In this equation, no distinction is made between the dependent and the independent
variables. Implicit curves have some convenient features. For example, it is simple to
determine whether a point P (x1 , y1 ) inside or outside of the region formed by the curve.
Thus, for the curve f (x, y) = 0, a point (x1 , y1 ) is inside the curve if f (x1 , y1 ) < 0 and
outside of the curve if f (x1 , y1 ) > 0. The tangent and normal of the curve are also easy
to find. The tangent line at P (x2 , y2 ) on the curve is
Example
Find the tangent and normal lines of the following curve at P (1, 2)
f (x, y) = y 2 − 4x = 0
23
(0 < t < 1); since curves are usually bounded in computer graphics, this characteristic
is of considerable importance. Therefore, parametric form is the most common form of
curve representation in geometric modeling. Examples of parametric and non-parametric
equations follow.
Non-Parametric Parametric
Circle: x2 + y 2 = r 2 x = r cos θ, y = r sin θ
1+ (y2 - y1) t
. P (x, y)
e, 0 d t d 1
A (x1, y1)
P Q
A A
Figure 3.4:
Conic curves are used to create simple wireframe models of objects, which have edges
that can be represented by these analytical curves. The fixed-form or analytical curves
do not have inflection points, i.e., curves have slopes that are either positive or negative
and do not change their sign (positive slope will remain positive and negative slope
will remain
ME 165 negative). All
Lecture Notes © by R. B.conic
Agarwalcurves can be represented
Computer by a quadratic
Aided Design in Mechanical Engineering equation, for 4-5
example, circular and elliptical curves have quadratic polynomial equations.
Circular Curve:
(x − xc )2 + (y − yc )2 = r2 (3.4)
where, xc , and yc are coordinates of the center, and r is radius of the circle.
If we were to use this form of the equation for plotting a circle or a circular curve, we
will first calculate several values of x and y along the circumference of the circle, and
then plot them. The curve thus generated will be of a poor quality, unless we plot a
very large number of data points, which will result in a significant demand for storage of
these data points. Therefore, as stated earlier, in CAD programs, we use a parametric
equation, which avoids the need for storage of the data points, and provides a smooth
curve. The parametric equation of the above circle can be written as,
xi = xc + r cos θ
yi = yc + r sin θ
This equation is converted into a matrix form so that a computer can solve it. We will
now convert this equation into a matrix form.
Let us assume that the plot starts at the point (xi , yi ), and the center lies at the origin.
We increment θ to (θ + ∆θ), giving us the new point on the circle (xi+1 , yi+1 ), or
25
Chapter 4 - Curves
(xi+1, yi+1)
T (xi, yi)
T
Equation (3.5) is valid for a circle that has center at the origin. To find the equation of
a circle that has center located at an arbitrary point (xc , yc ), we can use the translation
quation (4.4) is validtransformation.
for a circle that has
Notecenter
thatat the
the origin.
equationTo (3.5)
find the
canequation of a circleas rotational transfor-
be interpreted
at has center locatedmation
at an arbitrary
of pointspoint
xi (xc, yy
and c), we can the
i about use origin.
the translation transformation.
Now, instead of rotation about the origin,
ote that the equationwe (4.4) can be interpreted as rotational transformation of points
wish to rotate the point about the fixed point (xc , yc ). i and yix
out the origin. Now, instead of rotation about the origin, we wish to rotate the point about the
xed point (xc, yc). This can be accomplished by the three-step approach, discussed 1 in chapter
0 0 2,0
., first translate the fixed point to the origin, rotate the object, and finally translate
0 it so1that0the0
xi+1 yUsing
i+1 0 this0 procedure
] = [ xi ywe 0 0get: ×
xed point is restored to its original [position. i will ]
0 0 1 0
−xc −yc 0 1
(3.6)
cos ∆θ sin ∆θ 0 0 1 0 0 0
− sin ∆θ cos ∆θ 0 0 0 1 0 0
×
0 0 1 0 0 0 1 0
0 0 0 1 xc yc 0 1
Simplifying theComputer
165 Lecture Notes © by R. B. Agarwal
equation we get,
Aided Design in Mechanical Engineering 4-7
xi+1 = xc + (xi − xc ) cos ∆θ − (yi − yc ) sin ∆θ
(3.7)
yi+1 = yc + (xi − xc ) sin ∆θ + (yi − yc ) cos ∆θ
26
Even though, equations (3.7) can be used as an iterative formula to plot a circle or a
circular curve, using the EXCEL or MATLAB, or any other plot routines, the matrix
equation (3.6) is the preferred form for a CAD program. The original CAD programs
used iterative formulas to generate curves.
Chapter 4 - Curves
Ellipse
Following the procedure outlined in the previous section, we can derive the parametric
lipse
equations
g the procedure outlined in the of an ellipse.
previous Parametric
section, equation
we can derive of an ellipse
the parametric is given by the equation
equations
pse. Parametric equation of an ellipse is given by
xi = a cos θ
ion (3.8)
yi = b sin θ
T
2b
27
Interpolation method can be applied to draw curves that pass through a set of the given
data points. The resulting curve can be a straight line, quadratic, cubic, or higher order
curve. We are quite familiar, and have used, the linear interpolation of a straight line,
given by the formula
Now, we will discuss the higher order curves, which are represented by higher order poly-
nomials. Lagrange polynomial is a popular polynomial function used for interpolation
of high order polynomials.
Lagrange Polynomial
When a sequence of planar points (x0 , y0 ), (x1 , y1 ), (x2 , y2 ), . . . (xn , yn ) is given, the
nth degree of interpolated polynomial can be calculated by the Lagrange Polynomial
equation, X
fn (x) = yi Li,n (x) (3.12)
where
[(x − x0 ) . . . (x − xi−1 )(x − xi+1 ) . . . (x − xn )]
Li,n (x) =
[(xi − x0 ) . . . (xi − xi−1 )(xi − xi+1 ) . . . (xi − xn )]
To understand the above expression better, note that
• The term (x − xi ) is skipped in the numerator, and
• The denominator starts with the term (xi − x0 ) and skips the term (xi − xi−1 ),
which will make the expression equal to infinity.
Example
Using the Lagrange polynomial, find the expression of the curve containing the points,
P0 (1, 1), P1 (2, 2), P2 (3, 1)
Solution
28
Here, n = 2 and x0 = 1, y0 = 1, x1 = 2, y1 = 2, etc. The polynomial
Chapter 4 is of a second
- Curves
degree. Expanding the Lagrange equation, we get,
f2 (x)==(1) [(x −
y0 [(x – 2) (x –−
x1 )(x 3)]x2/ )]/[(x
[(1 – 2) (1 – 3)] + (2) [(x-1) (x – 3)] / [(2 – 1) (2 – 3)] +
0 − x1 )(x0 − x2 )] + y1 [(x − x0 )(x − x2 )]/[(x1 − x0 )(x1 − x2 )]+
(1) [(x – 1) (x - 2)] / [(3 – 1) (3- 2)]
y2 [(x − x0 )(x − x1 )]/[(x2 − x0 )(x2 − x1)]
= ½ (x2 – 5x + 6) – 2 (x2 – 4 x + 3) + ½ (x2 – 3 x + 2) or
= (1)[(x − 2)(x − 3)]/[(1 − 2)(1 − 3)] + (2)[(x − 1)(x − 3)]/[(2 − 1)(2 − 3)] +
f2 (x) = - x2 + 4 x – 2
(1)[(x1)(x − 2)]/[(31)(3 − 2)]
1 1
= (x2 − 5x + 6) − 2(x2 − 4x + 3) + (x2 − 3x + 2) or
This is the explicit
2 non-parametric equation of a circle;
2 the given points lie on the circumference.
2
f2 (x) = −x + 4x − 2
A cubic polynomial is the lowest degree polynomial that can guarantee a C2 curve. Higher2 order
A cubic polynomial
polynomials are not used isin theCAD, lowest degree
because polynomial
they tend to oscillatethat cantheguarantee
about a Candcurve.
control points
Higher order polynomials are not used in CAD, because they
require large data storage. Major CAD/CAM systems provide three types of synthetic curves:tend to oscillate about the
controlCubic
Hermite points and require
Spline, large data
Bezier Curves, storage. Curves.
and B-Spline Major CAD/CAM systems provide three
types of synthetic curves: Hermite Cubic Spline, Bezier Curves, and B-Spline Curves.
ME 165 Lecture Notes © by R. B. Agarwal Computer Aided Design in Mechanical Engineering 4-11
Cubic Spline curves pass through all the data points and therefore they can be called as
29
Chapter 4 - Curves
interpolated
Cubic curves.pass
Spline curves Bezier andallB-Spline
through the data curves do not
points and pass they
therefore through allcalled
can be the data
as points,
instead, they pass through the vicinity of these data points. Both the cubic
interpolated curves. Bezier and B-Spline curves do not pass through all the data points, spline and
instead,
Bezier
they passcurve have
through thefirst-order
vicinity of continuity, whereBoth
these data points. as, the
B-Spline curvesand
cubic spline have a second-order
Bezier curve have
continuity.
first-order continuity, where as, B-Spline curves have a second-order continuity.
Hermite
4.5.3 Cubic
Hermite Spline
Cubic Spline
Hermite cubic curve is also known as parametric cubic curve, and cubic spline. This
Hermite
curve cubic
is used curve is also
to interpolate givenknown as parametric
data points cubic
that result in curve,curve,
a synthetic and cubic
but notspline.
a free This
form,
curveunlike
is usedthetoBezier and B-spline
interpolate given curves. The most
data points thatcommonly
result in aused cubic spline
synthetic curve,is but
a not a
three-dimensional
free form, unlike planar curve and
the Bezier (not B-spline
twisted). The curveThe
curves. is defined by two dataused
most commonly points that spline
cubic
lie
is at
a the beginning and at planar
three-dimensional the end curve
of the curve, along with The
(not twisted). the slopes
curveatisthese points.
defined byIttwo
is data
represented
points thatbyliea cubic
at thepolynomial.
beginningWhen and attwothe
endend
points and their
of the slopes
curve, alongdefine
witha the
curve,
slopes at
the curve is called a Hermite cubic curve. Several cubic splines can
these points. It is represented by a cubic polynomial. When two end points and be joined together by their
imposing the slope continuity at the common points. In design applications, cubic splines
slopes define a curve, the curve is called a Hermite cubic curve. Several cubic splines can
are not as popular as the Bezier and B-spline curves. There are two reasons for this:
be joined together by imposing the slope continuity at the common points. In design
applications, cubic splines are not as popular as the Bezier and B-spline curves. There
x The curve cannot be modified locally, i.e., when a data point is moved, the
are two reasons for curve
entire this: is affected, resulting in a global control, as shown in the
• The curve cannot be modified locally, i.e., when a data point is moved, the entire
figure.
curvex The order of
is affected, resulting
the curveinisaalways
globalconstant
control,(cubic),
as shown in the figure.
regardless of the number
of data points. Increase in the number of data points increases shape
• The order of the curve
flexibility, is always
However, constant
this requires (cubic),
more regardless
data points, of the
creating more number
splines,of data
points. that
Increase in the
are joined number
together of data
(only points
two data increases
points shape
and slopes are flexibility,
utilized for However,
this requires more data points, creating more splines, that are joined together (only
each spline).
two data points and slopes are utilized for each spline).
If 165
ME (x,Lecture
y, z) Notes
are ©the
by R.coordinates
B. Agarwal of point
ComputerPAided
, the equation
Design (3.14)
in Mechanical can be written as, 4-12
Engineering
30
There are 12 unknown coefficients, aij , known as the algebraic coefficients. These coef-
ficients can be evaluated by applying the boundary conditions at the end points. From
the coordinates of the end points of each segment, six of the twelve needed equations
are obtained. The other six equations are found by using the tangent vectors at the two
ends of each segment. Substituting the boundary conditions at t = 0, and t = 1, we get,
Solving for the coefficients in terms of the P (t) and P 0 (t) values in equations (a) through
(d), we get,
a0 = P (0)
a1 = P 0 (0) (3.17)
a2 = −3P (0) + 3P (1) − 2P 0 (0) − P 0 (1)
a3 = 2P (0) − 2P (1) + P 0 (0) + P 0 (1)
The equation
P (t) = a3 t3 + a2 t2 + a1 t + a0 (3.18)
can be written, with coefficients aij replaced by the P (t) and P 0 (t) values in equations
(3.17), resulting,
P (t) = [2P (0)−2P (1)+P 0 (0)+P 0 (1)]t3 +[−3P (0)+3P (1)−2P 0 (0)−P 0 (1)]t2 +P 0 (0)t+P (0)
P (t) = [(2t3 − 3t2 + 1)]P (0) + [(−2t3 + 3t2 )]P (1) + [(t3 − 2t2 + t)]p0 (0) + [(t3 − t2 )]P 0 (1)
The equation in short form can be written as: P (t) = [t][M ]H [G]
Where, the terms [t], [M ]H , and [G] correspond to the terms on the right hand side of
the equation (3.19). [M ]H is called Hermite matrix of a cubic spline, and represents the
constant matrix. The term [G] is called geometric coefficient matrix. Let us consider an
example to understand how the equation (3.19) works.
31
Example
A parametric cubic curve passes through the points (0, 0), (2, 4), (4, 3), (5, −2) which
are parametrized at t = 0, 41 , 43 , and 1, respectively. Determine the geometric coefficient
matrix and the slope of the curve Chapter
when4 -t Curves
= 0.5.
¾ Solution
1 The points on the curve are
(0, 0) at t = 0
(2, 4) at t = 41
ation (4.15), we get,(4, 3) at t = 34
(5, −2) at t = 1
Solving we get
P (0) 0 0
P (1) 5 −2
P (0) = 10.33 22 (3.21)
0
p0 (1) 4.99 −26
The slope at t = 0.5 is found by taking the first derivative of the equation (3.19), as
0 follows,
-2
22 2 −2 1 1 0 0
-26 −3 3 −2 −1 5 −2
P 0 (t) = [ 3t3 2t 1 0 ] 0
(3.22)
0 1 0 10.33 22
1 0 0 0 4.99 −26
is found by taking the first derivative of the equation (4.15), as follows,
Therefore,
2 -2 1 1 0 0 P 0 (0.5) = [ 3.67 −2.0 ], or
-3 3 -2 -1 5 -2
2t 1 0] 0 Slope
0 1= ∆x/∆y
0 −2.0/3.67
=10.33 22 = −0.545 Note: coinciding the end points, and imposing
1 equal
0 values
0 0 of the4.99
slopes,
-26as shown, can create closed shape of a cubic spline.
2.0], or
.0/3.67 = - 0.545
e end points, and imposing equal values of the slopes, as shown, can create
ubic spline.
32
R. B. Agarwal Computer Aided Design in Mechanical Engineering 4-15
3.1.5 Approximated Synthetic Curves
In the previous sections, we have studied the analytical and interpolated curves, now
we will focus on the approximated curves. Bezier and B-spline curves represent the
approximated curves, these curves are synthetic, and can be joined together to form a
very smooth curve. For data fitting, interpolated curves work best, where as, for free
form geometry, interpolation cannot be used, and approximation becomes necessary. In
many engineering applications, smoothness of a curve is preferred over the quality of
interpolation. These curves are flexible, local changes in the shape do not affect the
entire shape of the curve. Let us study the Bezier curve first, followed by the B-spline.
Bezier Curves
Equation of the Bezier curve provides an approximate polynomial that passes near the
given control points and through the first and last points. In 1960s, the French engineer
P. Bezier, while working for the Renault automobile manufacturer, developed a system of
curves that combine the features of both interpolating and approximating polynomials.
In this curve, the control points influence the path of the curve and the first two and
last two control points define lines which are tangent to the beginning and the end of
the curve. Several curves can be combined and blended together. In engineering, only
the quadratic, cubic and quartic curves are frequently used.
Here, Vi represents the n + 1 control points, and Bi,n (t) is the blending function
for the Bezier representation and is given as
n
Bi,n (t) = (ti )(1 − t)n−i (3.24)
i
The equations (3.25) force the curve to lie entirely within the convex figure (or
envelop) set by the extreme points of the polygon formed by the control points.
The envelope represents the figure created by stretching a rubber band around all
the control points.
The figure 3.1.5 shows that the first two points and the last two points form lines
that are tangent to the curve. Also, as we move point v1 , the curve changes shape,
33
v1
v2 v1’
v0 v3
such that the tangent lines always remain tangent to the curve. Beziers blending
Bezier’s blending
function function an
produces nth degree
produces an nth polynomial
degree polynomial
for n for
+ 1n+1 control
control pointsand
points and forces
the Bezier curve to interpolate the first and last control points. The intermediate control
the Bezier curve to interpolate the first and last control points. The intermediate points
pull thecontrol
curve toward
points them, andcurve
pull the can betoward
used tothem,
adjust and
the curve
can beto the
useddesired shape.
to adjust the curve to
the desired shape.
3! 0
B0,3 = t (1 − t)3 = (1 − t)3
0!3!
3! 1
B1,3 = t (1 − t)2 = 3t(1 − t)2
1!3!
3! 2
B2,3 = t (1 − t)1 = 3t2 (1 − t)
2!3!
3! 3
B3,3 = t (1 − t)0 = t3
3!3!
34
By substituting the above values in the equation (3.26) we get
Figure 3.6: Point V3 is the middle point of the common points V2,, V3,, and V4 of
curves A and B.
Point V3 is the middle point of the common points V2,, V3,, and V4 of curves A and B.
NOTE: Using the Bezier curves, we can create closed curves by making the first
and last points of the control points coincide.
NOTE: Using the Bezier curves, we can create closed curves by making the first and last points
of the control points coincide.
Example
A cubic Bezier curve is described by the four control points: (0, 0), (2, 1), (5, 2),
(6, 1). Find the tangent to the curve at t = 0.5.
Example: A cubic Bezier curve is described by the four control points: (0,0), (2,1), (5,2), (6,1).
FindSolution
the tangent to the curve at t = 0.5.
We will use the Bezier cubic polynomial, given in equation (3.27), which is,
Solution: We will use the Bezier cubic polynomial,
−1 given
3 in−3
equation
1
(4.20),
V0 which is,
3 −6 3 0 V1
P 0 (t) = [ t3 t2 t 1 ]
−3 3
0 0 V2
-1 3 -3 11 0V 0 0 V3
0
P(t) = [t3 t2 t 1] 3 -6 3 0 V1
Where, -3 3 0 0 V2
1
V = (0, 0) V
0 00 0 3
V1 = (2, 1)
V2 = (5, 2)
V3 = (6, 1)
35
ME 165 Lecture Notes © by R. B. Agarwal Computer Aided Design in Mechanical Engineering 4-19
The tangent is given by the derivative of the general equation above,
−1 3 −3 1 V0
3 −6 3 0 V1
P 0 (t) = [ 3t2 2t 1 0 ]
−3 3
(3.28)
0 0 V2
1 0 0 0 V3
At t = 0.5, we get,
−1 3 −3 1 V0
3 −6 3 0 V1
P 0 (t) = [ 3(0.5)2
2(0.5) 1 0 ]
−3 3
= [ 6.75 1.5 0 1 ]
0 0 V2
1 0 0 0 V3
B-Spline Curve
B-spline curves use a blending function, which generates a smooth, single parametric
polynomial curve through any number of points. To generate a Bezier curve of the same
quality of smoothness, we will have to use several pieces of Bezier curves. Unlike the
Bezier curve, the degree of the polynomial can be selected independently of the number
of control points. The degree of the blending function controls the degree of the resulting
B-spline curve. The curve has good local control, i.e., if one vertex is moved, only some
curve segments are affected, and the rest of the curve remains unchanged.
The mathematical derivation of the B-spline curve is complex and beyond the scope
of this course. The equation is of the form:
X
P (t) = Ni,k (t)Vi (3.29)
Where, P (t) is a point on the curve. i indicates the position of control point i, k is order
of curve Ni,k (t) are blending functions Vi are control points
3.2 Surfaces
Like curves, surfaces can be classified into analytical and free-form surfaces. Analyti-
cal surfaces include two groups. The first group is defined by nonparametric equations;
examples are the plane, cylinder, sphere, cone, and torus. The second group is defined
by parametric equations; examples are a surface of revolution, ruled surface, and tabu-
lated cylinder. Free-form surfaces are defined by control points, as are free-form curves.
Displaying a surface, however, is not a straight forward as displaying a curve. Drawing
36
a curve basically involves connecting n equally spaced (either in Cartesian space or in
parameter space) points on the curve. The value of n determines how precise the curve
is interpolated. If the same strategy is used in drawing surface n × m points are needed.
When both n and m are large, the surface will be fully covered by curves and thus not
discernible in shape. If n and m are small, then each curve will be course.
(a) Nonparametric surfaces: The simplest surface is a planar surface (see Fig. 3.7),
the equation has the general form
ax + by + cz = 1 (3.30)
Section 5.4 Curves and Curved Surfaces 163
ol
ur
(y +
(X -+a)'
V'(x - XO)' (y -+b)'37
- YO)' (z =-r2
20)' = r2 (5.51) '
The parametricinform
Alternatively, is
parametric form with height h, we have
r cos 8
h
h-z
r sin 8
h
p
(c + r cos t) sin s
c − (x − xo ) + (y − yo ) + (z − zo )2 = r2
2 2
1
distance c from the center of meridian to center of the torus (see Fig. 3.9)
0 s t , s < 27r
(3.34)
b. Parametric
The parametric formsugaces
of the torus is cylinder. A tabulated cylinder is a surfacc cre
Tabulated
ated with the useof a curve
r(t) and a vector V. (See
Figure 5.30.) The equation is
x (c + r cos t) cos s
y = (c + r cos t) sin s 0 ≤ t, s < 2π (3.35)
z r sin t
5.3
The curve r(t) can be any parametric curve, even a line segment. A line segment
ca be written as r(t) = tP1 + (1 − t)Po . For example, to create a planar surface,
one may sweep a line:
r(t, s) = [tP1 + (1 − t)Po ] + sV 0 ≤ t, s ≤ 1
Ruled surface: A ruled surface is the result of blending two curves ro (t) and
r1 (t). (See Fig. 3.11). This kind of surface is defined as
r(t, s) = ro + s[r1 (t) − ro (t)] 0 ≤ t, s ≤ 1 (3.37)
38
Figure 3.10: A tabulated cylinder
M
f
r1
39
$:34,1e ~Icl'ilicdby 4 X 4 = 16 control points. Each point on the surface is the result of
~ ( s ~ ~ ill
~ lill1l of
~ ~the
W control points.Thus, the surface equation has 16 terms. Each term
ha II i~wlhcspondingcontrol point Pi;and combination of blending functions Bi(t)B;(s).
z
I" '.
I!,
I
. ,, .
3 ',
Free-form surfaces are based on free-form curves. The Bezier, and B-spline surfaces are
formed from Bezier, and B-spline curves, respectively. To blend points together to form
a surface, two parameters t and s are needed:
XX
r(t, s) = Bi (t)Bj (s)Pij 0 ≤ t, s ≤ 1 (3.41)
i j
where, Pij represent control points, Bi (t) and Bj (t) are blending functions. A bicubic
Bezier surface, as shown in Fig. 3.13, is defined by 4 × 4 = 16 control points. Each
point on the surface is the result of blending in all of the control points. Thus, the
surface equation has 16 terms. Each term has a corresponding control point Pij and
a combination of blending functions Bi (t)Bj (s). The i and j values run from 0 to 3.
The four corners of the surface are located at P0,0 , P0,3 , P3,0 and P3,3 . Continuity and
smoothness conditions must be satisfied. The tangent plane (instead of line) at any given
point r(t, s) is defined by two principal tangent vectors, on in the t direction and one
in the s direction. The following Equations are used to find the principal tangents:
The tangent plane is formed by these two vectors. The surface normal is
∂r(t, s) ∂r(t, s)
N(t, s) = × (3.44)
∂t ∂s
Note that the normal vector could point either up or down. To change the vector from
pointing in one direction to another, just multiply it by -1. Figure 3.14 shows the
principal tangent and surface normal of a bicubic Bezier surface.
40
Figure 5.33 A surface
ar(t,patch
S)
on a larger surface.
dBi(t)
at = i j
CC, Bj(s)Pii (5.60)
ar(t, S ) dB,(s)
= Ci C j
. ~ i ( t )Pij~ - (5.61)
PI'II
Np~
I ~ model, its internal representation is usually used. The internal rep-
(11 V I I I S N ~ I ' ~ a~ Isolid , ('ell
fgse~~lr~lioll is how a computer stores the model. It is different from the external repre- , Con
S ~ I I I H I I ~ Iwhich
I, is how the picture or image is displayed. There are six different types , Bo~
I I h~r ~ l l t lilllcrnal representation schemes (see Figure 5.36):
I I'~*irnilive
, instancing
! S l ~ ~ l ioccupancy
i~l enumeration (SOE)
i, ( 'c l l clccomposition
4, ( 'ollslructive solid geometry (CSG)
'1. Iloundary representation (B-rep)
The i and j values run from 0 to 3. The four corners of the surface are locnlr*
po,o,
tang
zier surf
are 1
e sati
y two p Figure 5.35 Principal tangents and surface normal.
Figure 3.14: Principal tangents and surface normal
41
Chapter 4
• Position-control loop hardware for all the axes of motion where each axis has a
separate control loop
42
• Acceleration, deceleration, and backlash take-up circuits
• Auxiliary function control, such as a coolant on-off, gear changes and spindle on-off
control
The most important function of any CNC machine tool is to control motion precisely
and consistently. CNC systems use a dedicated program to perform NC functions in
accordance with the control commands stored in a computer memory. If the host com-
puter is external to the machine tool and commands several machines as well as other
NC devices, the system is referred to as Direct Numerical Control (DNC) system. If
the microprocessor that interacts with the host computer is used as a resident controller
in the machine tool, the system is referred to as Distributed Numerical Control system.
The distributed numerical control system may also comprise a management information
retrieval package, where information is returned to the central computer and a variety
of reports are presented for management.
Bulk Memory
Master computer
Numerical control has been applied in many machine operations, both in machine tools
as well as in non machine tools.
43
4.1.1 Machine tool applications
Numerical Control has been implemented for the control, of most of machine tools,
mainly for operations such as turning, milling, drilling and grinding. The machines in
which NC has been successfully incorporated include the common conventional and non
conventional machines, some of which are the following:
3. NC drill press - This uses point to point control of the workhead. Some drill presses
have turrets containing several drill bits to enable them drill holes of different sizes
by automatically changing the tools.
5. NC cylindrical grinder - This is similar to a turning center, except that the tool in
this case is a grinding wheel. It has a 2-axis continuous path control similar to an
NC lathe.
7. NC Wire EDM - The electrode in form of a wire is passed through a small hole
drilled into the workpiece. The movement of the work table through the computer
numerical control in x and y directions enables cutting the components to the
required shapes.
8. NC Laser beam machining (LBM)- A high power laser beam is directed to the
workpiece either by use of fibre optics or by use of mirrors. The beam is focused
onto the workpiece, and causes the material to vaporize, hence the cutting action.
A CNC system is used to move the workpiece or the beam or both, in order to
achieve the desired shape.
It has also been applied in material processing machines such as punch presses, nibbling
machines, presses, welding and tube bending.
44
• Drafting machines, such as x-y plotters
Just as for any form of automation there are several advantages of CNC machine tools.
These include:
2. Fewer and simpler jigs and fixtures required, thanks to the highly accurate posi-
tioning systems.
3. Complex components may be machined with ease, allowing for more functional
features, hence fewer components. Surfaces to be generated can also be defined
mathematically.
9. Less floor space required - owing to increased output rates, fewer NC machines
are required to perform the same amount of work, compared to the number of
conventional machines required.
10. Reduction of operator’s skill level requirements - after programming, the work
required is only that of machine tending, the main tasks being loading/unloading
the work and changing tools, which do not call for highly specialized skills.
11. Reduced parts inventory - smaller lot sizes are still economical, and hence the
average inventory is reduced.
12. Lower scrap rates, mainly due to the reduction of human errors.
45
Disadvantages
1. Very high initial investment cost due to the high costs of software development,
CNC controls and electronic hardware, the more reliable mechanical components
and additional features such as tool changers, which are not found in conventional
machines.
2. Maintenance cost is generally high due to the sophistication of the control systems
5. CNC systems have to be highly utilized in order to realize economic benefits. They
are not economical for low production levels.
46
Parameters used in specification and rating of CNC
machine tools
Accuracy: This is the ability to position the machine table / spindle at a desired
location. It is usually a combination of control resolution and hardware accuracy.
The control resolution is the minimum length distinguishable by the control unit,
and is normally governed by the type of actuator used. Hardware accuracy is as
a result of tolerances on the machine elements such as screws and bearings. Note:
There are other sources of errors such as force-induced tool deflections, thermal
errors due to cutting process. The manufacturer-rated machine accuracy does not
include machining process-related errors. The actual accuracy varies from the rated
accuracy.
Repeatability: This is the ability of the control system to return to a given location
that was previously programmed into the controller, under identical conditions.
It is a statistical term indicating how closely a machine repeats a given position
command. If a the slide of a machine always moves to a fixed position, then it is
said to be highly repeatable, even if the position is far from the command position.
Repeatability is measured by the standard deviation of the errors. Accuracy is
measured as the diameter of the circle enclosing a target area produced by many
repeated experiments. The actual accuracy of a CNC Machine can be estimated
as:
A = X̄ ± R (4.1)
where, A= Accuracy of the CNC Machine
R = Repeatability and
X̄= Average error from the programmed point.
Spindle power and axes power: These are very important as they dictate the type
of material that can be machined/handled and the maximum rate of machin-
ing/processing.
Number of axes: This is analogous to the degrees of freedom. The number of axes of
a machine determines the complexity of the part geometry that can be machined.
The most common machines are 3- and 5-axes machines.
Axes limits: These determine the maximum work size that can be machined.
In addition to the machine frame and other features found in conventional machines, a
typical Numerical control machine has the following components.
47
System Controller: This consists of a mechanism for reading the software and convert-
ing the coding into machine instructions. The controller is the heart of the NC
operation. Types of control programs include
Operator’s Console: This contains the necessary control for operating the machine
manually. It could be a swinging cabinet, a rolling cabinet or an overhanging
pendant. It offers the facility for setting up workpieces.
Magnetic controls cabinet: Contains starting switches and magnetic relays for control-
ling the flow of electrical power to the pumps, spindle motor, etc. The relays and
switches are controlled by the signals from the controller.
Hydraulic pump: This supplies fluid power for operating hydraulic motors attached to
the lead screws for table movements. Note: Lead screws are, in some machines
driven by electric motors.
In addition to the main functions of machine tools, such as holding the workpiece and
cutting tool securely and displacing them relative to one another, the CNC machine tool
must have provision for performing functions such as automatically altering the spindle
48
speed and feed rates, tool changing, coolant application etc.
These extra functions are normally included in the programme for execution.
Some of the major functions performed by the control systems include:
• change of tools
Note: Not all machines are equipped with automatic operation for all the above listed
functions.
CNC systems require motor drives to control both the position and the velocity of the
machine axes. Each axis must be driven independently and follow the command signal
generated by the NC control. There are two ways to activate the motor drives: the
open-loop system and the closed-loop system. The following sections will describe these
two systems.
In general, an open loop control is a system where the output variables have no effect
on the control of the input. In an open loop system, a device is instructed to move to
a certain location in a certain manner, say at a specified speed, but the control unit
does not ascertain that the device reaches the predetermined location or moves at the
commanded speed.
Open-loop principles are sometimes employed in manipulating electric or electro-hydraulic
stepper motors for machine tool control using computers. Discrete signals from the com-
puter are fed into the control unit, and instructions move to the stepper motor drive
unit. One pulse input to the motor drives turns it through one step.
The main variables in the open-loop control deal with the stepping motor. These vari-
ables are the step angle, angle of rotation and rotational speed of the motor. The drive
to the machine element may be a leadscrew, ball-bearing screw, or rack and pinion.
49
Workpiece
Fixture
Stepper Table
Pulses motor Lead screw
Numerical ∆x, v Electric
control logic pulse generator
Programmed instructions are fed into the controller through an input device. These
instructions are then converted to electrical pulses (signals) by the controller and sent
to the servo amplifier to energize the servo motors. The cumulative number of electrical
pulses determines the distance each drive will move, and the pulse frequency determines
the velocity.
In general, the control resolution Rm due to the mechanical factors is given by
p
Rm = , (4.2)
ns rg
where p is the pitch of the lead screw, ns is the number of steps per revolution of a motor,
and rg is the gear ratio.
Note: Each machine movement to be controlled has its own stepping motor and drive as
shown in Fig. 4.3.
Y
X
Numerical
Controller
50
Example:
The motor shaft is directly connected to the leadscrew for driving an NC machine table.
The leadscrew has a step angle of 1.80 . If the pitch of the leadscrew is 2.5mm, determine
how closely the table’s position can be controlled. Suppose we want to move the table at
120 mm/min. What would be the rotational speed of the motor and the pulse frequency?
Soln.
One complete revolution of motor = 360/1.8 = 200 steps. (This corresponds to 200
pulses) One revolution of leadscrew moves the table = 2.5 mm. Therefore, the table can
be controlled up to 2.5/200 mm increments = 0.0125mm To achieve the table speed of
120 mm/min, the leadscrew speed (and hence the motor speed) ought to be 120/2.5 = 48
rpm. The pulse frequency,
Np
fp = (4.3)
60
where p is the number of pulses per revolution and N is the motor speed. Thus,
48 × 200
fp =
60
= 160 pulses/sec
The open-loop system has a drawback in that there is no feedback system to check
whether the program position and velocity have been achieved. If the system perfor-
mance is affected by say load or temperature, then the actual output could deviate from
the desired output. For these reasons, the open-loop system is normally used in point-
to-point systems where the accuracy requirements are not critical.
51
Position Speed
comparator comparator Servo motor Machine tool
Input command
(position, speed)
Amp. Amp.
In the case of position control, the command signal is fed through an amplifier to actuate
the drive motor until the difference between the command signal(position) and the actual
slide position reaches zero. When the error signal is zero, the machine movements are
at the exact or very close to the positions commanded. Most modern NC systems have
closed loop control with a resolution of up to 2.5 µm.
Actual devices used in feedback control will be discussed in Unit 4.
From the design drawings and specifications, the part programmer identifies the various
operations required to manufacture the part taking into consideration the materials to
be used, the dimensions, the required tolerances, etc, and selects the necessary tools and
other parameters for the operation. In most cases, the part programmer will need to
52
Design drawing
refer back to the designer for clarification and sometimes to suggest design modifications
for more efficient machining.
After identification of the operations, the programmer prepares the program (Part pro-
gramming), which is a sequence of symbolic codes that specifies the desired machine
actions.
The program may be prepared manually or generated by use of a computer - either by
computational or direct from design drawing (Computer assisted part programming).
The next step is the input translation. In older machines, the process involved punch-
ing of tapes using a special printer to translate the code to machine language. Modern
systems use disks or direct computer inputs. After coding, it is important to check for
errors. This can be done by simulating the operations. This is the verification stage. A
plotter simulates the movements of the tool and graphically displays the final part in 2D
on paper.
Alternatively, the tools are offset, and the actions observed without cutting (this is a
post-processing action). Any errors detected are then corrected at this stage. The fi-
nal step is the post-processing step, whereby the coded instructions are converted into
machine tool action, and the actual machining takes place.
Numerical control programming can be classified into two categories. These are point to
point (PTP) and continuous path. In a PTP system, accurate positional control is re-
quired only to place the spindle, workpiece or other machine members in fixed positions
for such operations as spot welding, drilling, boring, reaming or tapping. In between
these positions, the only requirement is that the machine members move from one point
53
G
9
Actual 7
8
Specified 5
6
y
3 4
x
F1 2
to another without regard to the path taken. Since this movement from one point to the
next is non-machining, it is made as rapidly as possible to reduce idle time.
Movements in more than one axis may take place simultaneously (with separate controls)
or sequentially (which consumes more time). Though the path G taken between the two
points is generally not important, care must be taken 9 collision with workpiece
to avoid
Actual 7
or fixture. 8
In order to avoid errors due to backlash, it is advisable to approach a point always from
the same direction along Specified
any axis. 5
6
PTP is extensively used on machines that can move in oneydirection only, such as in
drilling or punching. In some cases,
3 PTP method is used to machine a straight line and
a contour. In such cases, the number of 4steps determines
x how close the actual profile is
to the specified profile. In order to get much closer to the specified line, much smaller
step sizes will be neededFand 2 a much longer program.
1 hence,
For a continuous path system, the motion is controlled on more than one axis con-
N
Actual and specified
y
30°
x
M
tinuously and simultaneously. The machine controls not only the destinations, but also
Designed by Checked Date Date
the paths through which thebytool reaches
Approvedthese
by destinations. The cutting tool contacts
Githu 1/12/2011
the workpiece as coordinate movements take place. This system, which is also known
as contouring system, is typically used in milling, grinding, turning, flame cutting and
pocketing operations.
Edition Sheet
point_to_point 1/1
54
The main difference between continuous path programming (CPP) and PTP is the in-
terpolation routine. The problem is that of providing control for the tool continuously,
which requires changes in two or more axes simultaneously, as the machining progresses.
Suppose, in Fig. 4.8, the length of the segment MN is 120 mm, and the movement to be
made is from M to N. The displacement in x -direction is
4x
vx = √ vf
(4x2 + 4y 2 )
(4.4)
4y
vy = √ vf
(4x2 + 4y 2 )
where 4x and 4y are the displacements along the x and y axes, respectively.
In linear interpolation for a circular surface, several thousand discrete points connected
by straight lines would be required. Most machine control units, however have a circular
interpolator, in which the programming for a circular path is the end points of the arc,
the radius, the arc center and the direction of the cutter.
Example:
G02G17x56.5z70.0R65.5
The circular interpolator breaks up the span into the smallest straight line resolution
units (Basic Length Units(BLU)) available in the control. The control computes and
generates the controlling signal to achieve the required movements.
Other types of interpolation include:
• parabolic
• helical
• logarithmic
• exponential interpolations
These types of interpolation allow for machining of free-form surfaces. They usually
require generation of points for cutter paths, through a computer programme.
55
4.9 Circular interpolation
If an NC controller does not have built-in functions for complicated geometries such as
circles, parabolas etc, these geometries can be approximated using an offline interpolation
procedure. The main task in this case would be to determine the number of interpolation
points that would guarantee the desired results in terms of tolerances. Most computer as-
sisted part programming languages have subroutines for automatically calculating these
points. Interpolation can be used to produce curves and circular or parabolic arcs to
very close tolerances.
Circular interpolation can be performed using the specified an inner, outer or total toler-
ance, each of which is the maximum allowable deviation between the desired ideal curve
and the actual linear paths. These are illustrated in Fig. 4.9
to
ti
R
R
δθ tt δθ
tt
δθ
The minimum number of chords necessary to achieve the specified tolerances are com-
puted based on the radius of the circular arc and the angle subtended by the arc at the
center.
It can be shown that for the case of inner tolerance, the angle δθ, subtended by a an arc,
whose chord approximates the arc is given by
R − ti
δθ = 2 cos−1 (4.5)
R
while for the outer tolerance,
R
δθ = 2 cos−1 (4.6)
R − to
In the case of total tolerance,
R − tt
δθ = 2 cos−1 (4.7)
R + tt
The total number of chords N necessary to approximate the circular arc is determined
as
θ
N= (4.8)
δθ
56
where θ is the angle subtended by the arc at the centre.
Note: If N is not a whole number, the next higher integer should be used in order to
ensure that the specified tolerance is achieved.
The position of various vertices of the polygon approximating the arc can be determined
by incrementing δθ and working out the coordinates.
For example, the nth vertex of a polygon approximating a circle of radius R and whose
center is (xc , yc ) can be determined as
xn = xc + R cos(nδθ)
yn = yc + R sin(nδθ) (4.9)
57
4.10 CNC Part programming
CNC part program is a detailed list of instructions that are to be executed by the machine
control unit to drive the machine tool in order achieve the final component shape. CNC
programming refers to the generation of the part program.
There are 4 different techniques used to generate the CNC part programs. These are:
1. Manual programming
2. Computer assisted part programming
3. Graphic numerical control programming
4. CNC programming based on solid modelling.
Almost all modern CNC controls use the word address format, whereby each command
consists of a CNC word containing a letter address and a numerical value. The letter
address tells the control the kind of word, and the numerical value tells it the value of
the word. The following general format is used, but the order of words within the same
block does not really matter.
N....G....X....Y....Z....A....B....C....F....S....T....M....
An ISO standard for coding exists in which all the 26 letters of the English alphabets
have been assigned meanings in the word addresses format. The meaning of some of
these words are shown in Table 4.1.
58
4.10.2 Manual programming
Manual programming involves writing part program using the word address directly into
a computer or through the keyboard into the CNC console (this is normally referred to
as manual data input or MDI).
Manual programming is used for workpieces of relatively simple geometries, where the
program needs not be very long. It begins with a careful study of component drawing.
The tools to be used are then identified, and the tool path of the CNC machine is then
described in the standard codes, which are then keyed in for processing.
A part program consists of a number of blocks, each representing an operation to be
carried out in machining of a part. Ordinarily, each block starts with a block number,
but this is not a rule. Each block can have one or more of the word addresses in a
sequence. For example:
N35 G01 G91 X55.6 Y70.3 Z40.0 F100;
Within the block, the word address can occur in any sequence, as was mentioned earlier.
The end of the block (EOB) is indicated by a semicolon.
Important Note:
Programming formats for various control systems are not always identical and may some-
times differ from ISO recommendations. It is therefore important that the relevant pro-
gramming manual should be referred to when preparing the program. Such manuals are
normally supplied by the machine tool or controls manufacturers.
Preparatory functions
Preparatory functions are pre-set functions associated with the movement of the machine
axes and geometry. They are denoted by the letter G, followed by appropriate address,
e.g., G43. The preparatory functions are for this reason, often referred to as G codes.
Below is a list of G codes that are generally present in all machining centers, and uni-
formly followed by all controller manufacturers.
1) Motion group
59
• G41 - Cutter compensation left
• G42 - Cutter compensation right
4) Units group
Some of the G codes are modal, meaning that they remain functional until they are
canceled by another G code. Others are non modal, meaning that they remain functional
only in the block in which they are programmed.
Miscellaneous functions
Miscellaneous functions operate some controls on the machine, such as tool change,
coolant supply or cut, stopping of machines and giving direction of rotation of spindle.
Some of the most common miscellaneous functions are:
• M00 - (program stop) for terminating auto operation of the machine, eg. when an
inspection is to be done before going on with the work.
• M02, M30 - End of program. It causes the stopping of the machine and clearing
of all the control registers.
• M05 - Stopping of the machine spindle. When it is given in a block, it will be the
last the last code to be executed.
Exercises
60
4.10.3 List of G and M codes
Preparatory functions
61
G69* ROTATION G68 CANCEL (SETTING 56)
G70 BOLT HOLE CIRCLE with a CANNED CYCLE (I,J,L)
DEFAULT *
OPTIONAL **
G71 BOLT HOLE ARC with a CANNED CYCLE (I,J,K,L)
G72 BOLT HOLES ALONG AN ANGLE with a CANNED CYCLE (I,J,L)
G73 HIGH SPEED PECK DRILL CANNED CYCLE (X,Y,A,B,Z,I,J,K,Q,P,R,L,F) (SET-
TING 22, 52)
G74 REVERSE TAPPING CANNED CYCLE (X,Y,A,B,Z,J,R,L,F) (SETTING 130)
G76 FINE BORING CANNED CYCLE (X,Y,A,B,Z,I,J,P,Q,R,L,F) (SETTING 27)
G77 BACK BORE CANNED CYCLE (X,Y,A,B,Z,I,J,Q,R,L,F) (SETTING 27)
G80* CANCEL CANNED CYCLE (SETTING 56)
G81 DRILL CANNED CYCLE (X,Y,A,B,Z,R,L,F)
G82 SPOT DRILL / COUNTERBORE CANNED CYCLE (X,Y,A,B,Z,P,R,L,F)
G83 PECK DRILL CANNED CYCLE (X,Y,A,B,Z,I,J,K,Q,P,R,L,F) (SETTING 22, 52)
G84 TAPPING CANNED CYCLE (X,Y,A,B,Z,J,R,L,F) (SETTING 130)
G85 BORE IN, BORE OUT CANNED CYCLE (X,Y,A,B,Z,R,L,F)
G86 BORE IN, STOP, RAPID OUT CANNED CYCLE (X,Y,A,B,Z,R,L,F)
G87 BORE IN AND MANUAL RETRACT CANNED CYCLE (X,Y,A,B,Z,R,L,F)
G88 BORE IN, DWELL, MANUAL RETRACT CANNED CYCLE (X,Y,A,B,Z,P,R,L,F)
G89 BORE IN, DWELL, BORE OUT (X,Y,A,B,Z,P,R,L,F)
G90* ABSOLUTE POSITIONING COMMAND
G91 INCREMENTAL POSITIONING COMMAND (SETTING 29)
G92 GLOBAL WORK COORDINATE SYSTEM SHIFT (FANUC) (HAAS) (SETTING
33)
G92 SET WORK COORDINATE VALUE (YASNAC) (SETTING 33)
G93 INVERSE TIME FEED MODE ON
G94* INVERSE TIME FEED MODE OFF / FEED PER MINUTE ON (SETTING 56)
G98* CANNED CYCLE INITIAL POINT RETURN (SETTING 56)
G99 CANNED CYCLE ”R” PLANE RETURN
G100 MIRROR IMAGE G101 CANCEL (X,Y,Z,A,B)
G101 MIRROR IMAGE (X,Y,Z,A,B) (SETTING 45, 46, 47, 48, 80)
G102 PROGRAMMABLE OUTPUT TO RS-232 (X,Y,Z,A,B)
G103 LIMIT BLOCK LOOKAHEAD (P0-P15 for number control looks ahead)
G107 CYLINDRICAL MAPPING (X,Y,Z,A,Q,R,)
G110-G129 WORK OFFSET COORDINATE POSITIONING #7-26
G136** AUTOMATIC WORK OFFSET CENTER MEASUREMENT
G141 3D+ CUTTER COMPENSATION (X,Y,Z,I,J,K,D,F)
G143** 5-AXIS TOOL LENGTH COMPENSATION+ (X,Y,Z,A,B,H) (SETTING 15,
117)
G150 GENERAL PURPOSE POCKET MILLING (X,Y,P,Z,I,J,K,Q,D,R,L,S,F)
G153** 5-AXIS HIGH SPEED PECK DRILL CANNED CYCLE (X,Y,A,B,Z,I,J,K,Q,P,E,L,F)
(SETTING 22)
G154** 5-AXIS REVERSE TAPPING CANNED CYCLE (X,Y,A,B,Z,J,E,L,F)
G161** 5-AXIS DRILL CANNED CYCLE (X,Y,A,B,Z,E,L,F)
G162** 5-AXIS SPOT DRILL / COUNTERBORE CANNED CYCLE (X,Y,A,B,Z,P,E,L,F)
G163** 5-AXIS PECK DRILL CANNED CYCLE (X,Y,A,B,Z,I,J,K,Q,P,E,L,F) (SET-
TING 22)
62
G164** 5-AXIS TAPPING CANNED CYCLE (X,Y,A,B,Z,J,E,L,F)
G165** 5-AXIS BORE IN, BORE OUT CANNED CYCLE (X,Y,A,B,Z,E,L,F)
G166** 5-AXIS BORE IN, STOP, RAPID OUT CANNED CYCLE (X,Y,A,B,Z,E,L,F)
G169** 5-AXIS BORE IN, DWELL, BORE OUT (X,Y,A,B,Z,P,E,L,F)
G174 SPECIAL PURPOSE NON-VERTICAL RIGID TAPPING CCW (X,Y,Z,F)
G184 SPECIAL PURPOSE NON-VERTICAL RIGID TAPPING CW (X,Y,Z,F)
G187 ACCURACY CONTROL FOR HIGH SPEED MACHINING (E) (SETTING 85)
MISCELLANEOUS FUNCTIONS
63
M80** AUTOMATIC DOOR OPEN (SETTING 131)
M81** AUTOMATIC DOOR CLOSE (SETTING 131)
M82 TOOL UNCLAMP
M83** AUTO AIR JET ON
M84** AUTO AIR JET OFF
M86 TOOL CLAMP
M88** COOLANT THROUGH SPINDLE ON (SETTING 32)
M89** COOLANT THROUGH SPINDLE OFF
M93 AXIS POS CAPTURE START (P,Q)
M94 AXIS POS CAPTURE STOP
M95 SLEEP MODE
M96 JUMP IF NO SIGNAL (P,Q)
M97 LOCAL SUB-PROGRAM CALL (P,L)
M98 SUB-PROGRAM CALL (P,L)
M99 SUB-PROGRAM/ROUTINE RETURN OR LOOP (SETTING 118)
M109** INTERACTIVE USER INPUT (P)
64
4.10.4 Computer assisted part programming using high level
languages
There are several high-level processing languages that can be used for numerical control.
Some of the most commonly used NC languages include the following
In all these languages, a postprocessor is required to convert the program into the specific
language that a particular CNC machine tool can understand. The final program used
by the machine tool will be identical, whether it is prepared in machine language, by a
CAM system or by the computer in a high-level programming languages. Note: Differ-
ent machine tools require their information differently, and therefore there are different
postprocessors. Of all the above languages, APT is the most widely used.
This language is easy to understand as it uses simple statements to command the cutting
tool through its sequence of machining operations. Like any other high-level language,
APT allows arithmetic operations, subroutines, macros, looping logic, et cetera. More-
over, it allows parametric representations of geometric entities ranging from a single
point in space to very complex 3-D sculptured surfaces. Though currently APT is being
replaced by graphics-based user-friendly interactive CAD/CAM software systems, it is
important to understand the very basic structure of APT programming system since
most CAD/CAM systems use APT standards in processing NC tool path data.
APT statements
There are 4 types of statements and over 400 words in APT vocabulary. These statements
are
Geometry statements These are also called definition statements. They define the
geometric elements that comprise the workpiece.
Motion statements These are used to describe the path taken by the tool
Post processor statements These apply to specific machine tool and control system.
They are used to specify feeds and speeds and actuate other features of the machine.
Auxiliary statements These are used to identify the workpiece, tool, tolerances, etc.
65
Table 4.2: Typical APT geometry words
Geometric Type APT Vocabulary word
Point POINT
Line LINE
Spline SPLINE
Plane PLANE
Circle CIRCLE
Cylinder CYLNDR
Pattern PATERN
Geometry statements
The geometry of a workpiece is defined using points, lines, arcs, space curves and surfaces.
Each geometric entity is mathematically represented and stored as variables by APT.
Each geometry is defined according to the following format:
(Geometry’s symbol)=Geometry/Dimension and parameters of the geometry
For example, to define a point P1, we write
P1=POINT/3.0,2.1,8.5
The geometry symbol is P1, and the geometry statement is POINT, and the descriptive
data are the coordinates of the point. Some typical APT geometry vocabulary words
are given in the Table 4.2.
APT allows the use of parabolas, hyperbolas, ellipses and parametric curves. Splines
are the most common parametric curves that allow flexible and smooth curve fit passing
through a given set of points.
Note: There are many ways of defining some of the geometry types. Refer to the recom-
mended textbooks [1] and [5]for details.
66
It is important to note the following points for geometry statements;
(2) Any symbol used as descriptive data or definitional modifier must have been pre-
viously defined.
(4) Only one symbol can be used to define any given element
(5) Lines defined by APT are considered to be of infinite length in both directions.
The same applies to planes.
There are two types of tool motion commands in APT, namely, Point to Point and con-
tinuous tool motion command. The general form of motion statement is:
Motion command/descrtiptive data
If the requirement is to move the tool to a specified point from its current position, the
PTP commands are used. There are two types of PTP motion commands. These are
GOTO/Point, Feedrate
and
GODLTA/Point,Feedrate
Both commands take the tool to the point indicated to the right of the forward slash
with an optional feed rate provided. The part coordinates are absolute for GOTO state-
ment and incremental for GODLTA statement. Such statements are especially useful for
drilling and punching operations.
For continuous potion commands, the controlled path is defined by the part, drive and
check surfaces.
Drive surface This is the surface that guides the side of the cutter. It is parallel to the
tool axis.
Part surface This is the surface on which the bottom of the tool rides. It doesn’t have
to be an actual surface of the workpiece.
Check surface This is the surface that bounds the tool motion
Modifier words are used within the descriptive data of the motion statement. The main
modifier words are TO, ON and PAST. They define the position of the tool with respect
to the surface. If the drive surface is tangent to a circular check surface, a fourth modifier
word TANTO is used.
The APT continuous motion statement commands the tool to move along the ’drive’
and ’part’ surfaces and the movement ends when the tool is at the ’check’ surface. The
general format for motion command is
67
Numerical Control and Computer Numerical Control Technology 335
Check surface
Drive surface
Tool
Part
surface
• GOFWD
For continuous motions as shown in Figure 8.61, the tool motion is guided by the following
three surfaces:
• GOBACK
• Drive surface. Guides the sides of the cutter
• Part surface. The bottom of the cutter rides
• GOUP
• Check surface. Stops the movements of the tool (TO, ON, PAST, TANTO), as shown in
• GODOWN Figure 8.62.
Figure 8.63 shows the motion command that include GOLFT, GORGT, GOFWD,
• GORGT GOBACK, GOUP, and GODOWN
3. Postprocessing statements. These statements contain the machine instructions that are
• GOLFT passed unchanged into the cutter location data (CLDATA) file to be dealt with by the post-
processor. It operates the spindle speed, feed rate and other features of the machine tool,
such as adding coolant and stopping the program. Some common postprocessor statements
Note: The check surfacewhere
are as follows, andthetheslash
drive surface
indicates that must be re-defined
some descriptive inneeded:
data are each new command.
COOLNT, Turns the coolant on, off and actuates other coolant options.
68
Auxiliary statements
These are used for cutter size specifications, part identifications etc.
CAM utilizes computers in the manufacturing stage. Such a modern technique has the
following features:
• Allows the programmer to develop a model that represents the part and the ma-
chining operations.
• The programmer can interact with the model graphically to make the necessary
adjustments and modifications before the CNC code is generated.
• CAM software reads the DXF that contains the part geometry and the levels or
layers that the geometry exists on.
• CAM software utilizes a job plan to assign the correct tool path to each layer.
• The job plan knows the work material that will be used so that it can calculate
speeds and feeds for each tool.
The integrated CAD/CAM approach prepares the part program directly from the CAD
part geometry, either by using NC programming commands called in the CAD/CAM sys-
tem or by passing the CAD geometry into a dedicated CAM program. Using CAD/CAM
systems, the CAD drawings can therefore be changed to CNC programs. The CAD/CAM
approach has the following advantages:
(1) No need to encode the part geometry and the tool motion
(2) Allows the use of interactive graphics for program editing and verification
(3) Displays the programmed motions of the cutter with respect to the WP, which
allows visual verification of the program
(4) Allows interactive editing of the tool path with the addition of the tool moves and
standard cycles
(5) Incorporates the most sophisticated algorithms for part programming generation
(1) The aspects of the part geometry that are important for machining purposes are
identified (and perhaps isolated on a separate level or layer); geometry may be
edited or additional geometry added to define boundaries for the tool motion.
(2) Tool geometry is defined; for instance, by selecting tools from a library.
(3) The desired sequence of machining operations is identified and tool paths are de-
fined interactively for the main machining operations.
69
(4) The tool motion is displayed and may be edited to refine the tool motion, or other
details may be added for particular machining cycles or operations.
(6) The CLDATA file is postprocessed to MCD, which is then transmitted to the
machine.
Postprocessor
The postprocessor takes the part geometry and job plan and writes the code that the
specific machine will understand.
Simulation
The program can be written and tested before it is actually run, and jigs, fixtures, and
clamping can be shown during simulation to determine whether there are any potential
problems. The simulation shows the machining time. Operations can then be adjusted
to optimize production off-line, which keeps the machine operating.
The program is sent to the machine manually, using a tape or disk, or electronically,
using a communication cable.
70