You are on page 1of 76

Corso IFTS

Tecnico Progettista Programmatore di sistemi per l'industria 4.0

ARCHITETTURA E
PROGRAMMAZIONE SISTEMI PER
MOTION CONTROL

MARCO
SILVESTRI

LEZIONE 08
NC and CNC machines and
Control Programming
History of CNC (Computer Numerical Control)

1949
US Air Force asks MIT to develop a "numerically controlled"
machine.

1952
Prototype NC machine demonstrated (punched tape input)

1980-
CNC machines (computer used to link directly to controller)

1990-
DNC: external computer “drip feeds” control programmer
to machine tool controller
(Distributed Numerical Control)
Motivation and uses

To manufacture complex curved geometries in 2D or 3D


was extremely expensive by mechanical means (which
usually would require complex jigs to control the cutter
motions)

Machining components with repeatable accuracy

Unmanned machining operations


Advantages of CNC

- Easier to program;
- Easy storage of existing programs;
- Easy to change a program
- Avoids human errors
- NC machines are safer to operate
- Complex geometry is produced as cheaply as simple ones
- Usually generates closer tolerances than manual machines
NC machines
Motion control is done by: servo-controlled motors

Table
Leadscrew
Encoder A/C Motor
~

Servo Controller

Counter Comparator

Input (converted from analog to digital value)


CNC terminology

BLU: basic length unit ➔


smallest programmable move of each axis.

Controller: (Machine Control Unit, MCU) ➔


Electronic and computerized interface between operator and m/c

Controller components:
1. Data Processing Unit (DPU)
2. Control-Loops Unit (CLU)
Controller components
Data Processing Unit:
Input device [RS-232 port/ Tape Reader/ Punched Tape Reader]
Data Reading Circuits and Parity Checking Circuits
Decoders to distribute data to the axes controllers.

Control Loops Unit:


Interpolator to supply machine-motion commands between data points
Position control loop hardware for each axis of motion
Types of CNC machines
Based on Motion Type:
Point-to-Point or Continuous path

Based on Control Loops:


Open loop or Closed loop

Based on Power Supply:


Electric or Hydraulic or Pneumatic

Based on Positioning System


Incremental or Absolute
Basic Machine Axes: 3 axis
• Milling Machines: 3 axis
X – axis (table left and right)
Y – axis (table in and out)
Z – axis (usually the spindle
axis)
Additional Axes
• A – axis (angular axis about X - axis)
• B – axis (angular axis about Y – axis)
• C – axis (angular axis about Z – axis)

• U – axis (secondary axis parallel to X)


• V – axis (secondary axis parallel to Y)
• W – axis (secondary axis parallel to Z)
Milling Machines: 4 axis
Manual NC programming
Part program: A computer program to specify

- Which tool should be loaded on the machine spindle;

- What are the cutting conditions (speed, feed, coolant ON/OFF etc)

- The start point and end point of a motion segment

- how to move the tool with respect to the machine.

Standard Part programming language: RS 274-D (G-code)


G - Code Programming
• G – Code Programming
• Originally called the “Word Address”
programming format.

• Processed one line at a time sequentially.


FORMAT
The RS274-D is a word address format

Each line of program == 1 block

Each block is composed of several instructions, or (words)

Sequence and format of words:

N3 G2 X+1.4 Y+1.4 Z+1.4 I1.4 J1.4 K1.4 F3.2 S4 T4 M2

sequence no destination coordinates dist to center of circle tool

feed rate spindle speed


preparatory function
miscellaneous function
Word Address 1
Reserved Code Words Worksheet
N – Sequence or line number
G – Preparatory function

Dimension Words:
X–
Y–
Z–
Word Address 1
• N – Sequence or line number
• A tag that identifies the beginning of a block of
code. It is used by operators to locate specific lines of a
program when entering data or verifying the program
operation.

• G – Preparatory function
• G words specify the mode in which the milling
machine is to move along its programmed axes.
Word Address 2
• Dimension Words
X – Distance or position in X direction
Y – Distance or position in Y direction
Z – Distance or position in Z direction

• M – Miscellaneous functions
• M words specify CNC machine functions not
related to dimensions or axial movements.
Word Address 3
• F – Feed rate (inches per minute or millimeters per
minute)
• Rate at which cutting tool moves along an axis.

• S – Spindle speed (rpm – revolutions per minute)


• Controls spindle rotation speed.

• T – Tool number
• Specifies tool to be selected.
Word Address 4
• I – Circular cutting reference for x axis

• J – Circular cutting reference for y axis

• K – Circular cutting reference for z axis


G Word
• G words or codes tell the machine to perform
certain functions. Most G words are modal
which means they remain in effect until
replaced by another modal G code.
Common G Codes
• G00 – Rapid positioning mode
• Tool is moved along the shortest route to
programmed X,Y,Z position. Usually NOT used
for cutting.
• G01 – Linear Interpolation mode
• Tool is moved along a straight-line path at
programmed rate of speed.

• G02 – Circular motion clockwise (cw)


• G03 – Circular motion counter clockwise (ccw)
Common G Codes, con.,
• G17 – XY plane
• G18 – XZ plane
• G19 – YZ plane
• G20 – Inch Mode
• G21 – Metric Mode
• G28 – Return to axis machine Zero (Home)
G Codes: G90, G91
G90 – Absolute Coordinate Reference
References the next position from an absolute
zero point which is set once for the entire
program.

G91 – Incremental Coordinate Reference


References the next position from the previous
position.
G Codes: Canned Cycles
• G80 – Cancel canned cycle
• G81 – Drilling cycle
• G83 – Peck drilling cycle (elimina truciolo)
• G84 – Tapping cycle (maschiatura)
• G85 – Boring cycle (alesatura)
• G86 – Boring cycle

• NOTE: A canned cycle stays in effect until cancelled


by a G80.
Canned Cycles: G81
• G81 – Drilling Cycle
• Feed to depth, rapid return

• Example of program code:


• N35 G81 X.500Y.500Z-1.000 R.100 F1.50
• N36 X1.000Y1.500
• N37 X1.500Y2.000
• N38 G80
Canned Cycles: G83, G84
• G83 – Peck Drilling Cycle
• Feed to an intermediate depth, rapid out, rapid
back to just above previous depth, feed to next depth,
rapid out, repeat until reaching full depth.

• G84 – Tapping Cycle


• This cycle creates internal threads in an existing
hole.
• NOTE: One cannot over-ride the feed rate.
Canned Cycles: G85, G86
• G85 - Boring Cycle
• Feed to depth, feed back out.

• G86 – Boring Cycle


• Feed to depth, rapid out.
G Codes: Cutter Compensation
• G40 – Cancel cutter diameter compensation.

• G41 – Cutter compensation left.

• G42 – Cutter compensation right.


M Word
• M words tell the machine to perform certain
machine related functions, such as: turn
spindle on/off, coolant on/off, or stop/end
program.

Professional Development ID Code: 6006


Common M words
• M00 – Programmed pause
• Automatically stops machine until operator pushes a button
to resume program.

• M01 – Optional stop


• A stop acted upon by the machine when operator has
signaled this command by pushing a button.

• M02 – End of program


• Stops program when all lines of code are completed. Must
be last command in program.
Common M words
• M03 – Turn spindle on
• In clockwise direction

• M04 – Turn spindle on


• In counter clockwise direction

• M05 – Stop spindle


• Usually used prior to tool change or at end of program.

• M06 – Tool change


• Stops program and calls for a tool change, either
automatically or manually.
Common M words
• M08 – Turns Accessory 1 on.
• M09 – Turns Accessory 1 off.

• M10 – Turns Accessory 2 on.


• M11 – Turns Accessory 2 off.

• M30 – End of program


• Similar to M02 but M30 will also “rewind” the
program. Must be last statement in program. If used, DO
NOT use M02.
Zero Points
• Part Zero
– Used for absolute programming mode.
– Usually a position on the part that all absolute
coordinates are referenced to.
– Changes with different parts and programs.

• Machine Zero or Machine Home Position


– Fixed for each machine from the manufacturer.
– Not changeable.
Interpolation
• Method of determining intermediate points
along a cutting path.

• Two methods:
• Linear interpolation – cut a path along a
specified angle at a specified feed rate.
• Circular interpolation – cut a path along an arc
or circle at a specified feed rate.
Manual Part Programming Example
5”
2.5”
p4
p2 p3 p5

1”

Tool size = 0.25 inch,


5” Feed rate = 6 inch per minute,
Cutting speed = 300 rpm,
Tool start position: 2.0, 2.0
45°
Programming in inches

(4, 4)
p1 Motion of tool:
p0 → p1 → p2 → p3 → p4 → p5 → p1 → p0
p0 (2, 2)
1. Set up the programming paramete
5”
2.5”
p4
p2 p3 p5

1”

Programming in inches
5”
Use absolute coordinates

Feed in ipm
45°
N010 G70 G90 G94 G97 M04
(4, 4)
p1
Spindle speed in rpm
p0 (2, 2)
Spindle CCW
2. Set up the machining conditions
5”
2.5”
p4
p2 p3 p5

1”
Machine moves in XY-plane

Use full-circle interpolation


5”
Feed rate

Spindle speed
45°
N020 G17 G75 F6.0 S300 T1001 M08
(4, 4)
p1
Tool no.
p0 (2, 2)
Flood coolant ON
3. Move tool from p0 to p1 in straigh
5”
2.5”
p4
p2 p3 p5

Linear interpolation
1”
target coordinates

5” N030 G01 X3.875 Y3.698

45°

(4, 4)
p1

p0 (2, 2)
4. Cut profile from p1 to p2
5”
2.5”
p4
p2 p3 p5

1”

Linear interpolation
5” target coordinates

N040 G01 X3.875 Y9.125


45°
or
(4, 4)
p1 N040 G01 Y9.125

p0 (2, 2)

X-coordinate does not change ➔ no need to program it


5. Cut profile from p2 to p3
5”
2.5”
p4 Linear interpolation
p2 p3 p5

target coordinates
1”

N050 G01 X5.634 Y9.125

5”

y = 9 + 0.125 = 9.125
(6.5 - x)2 + 0.1252 = (1 - 0.125)2
x = 5.634
45° p3
(x, y)
(4, 4)
p1 (6.5, 9)
.125

p0 (2, 2)

1”
6. Cut along circle from p3 to p4
5”
2.5”
p4
p2 p3 p5

1”

circular interpolation, CCW motion

5”
target coordinates

45° N060 G03 X7.366 Y9.125 I6.5 J9.0

(4, 4) coordinates of center of circle


p1

p0 (2, 2)
7. Cut from p4 to p5
5”
2.5”
p4
p2 p3 p5

1”

5”

Linear interpolation

45° target coordinates (Y is unchanged)

(4, 4)
N070 G01 X9.302
p1

p0 (2, 2)
8. Cut from p5 to p1
5”
2.5”
p4
p2 p3 p5

1”

5”
Linear interpolation

target coordinates (see step 3)


45°
N080 G01 X3.875 Y3.698
(4, 4)
p1

p0 (2, 2)
9. Return to home position,
stop program
5”
2.5”
p4
p2 p3 p5

1”
Linear interpolation

target coordinates (see step 3)

5” N090 G01 X2.0 Y2.0 M30

end of data
45°
N100 M00
(4, 4)
p1 program stop

p0 (2, 2)
Axis movements: Caution!
Multiple axis movements are possible.
“Best Practice” is NOT to make a 3-axis
movement using one line of code.
Move to position using two axes, X,Y;
then move the Z with an additional
line of code.
PROGRAM ANALYSIS
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
G0 X0
G0 Z0
G1 X5 Y5 Z-5
G1 X10 Y0 Z0
G0 Z1
G0 X5
G0 Z0
G1 Y5 Z-5
G1 Y10 Z0
G0 Z1
G0 X0 Y5
G0 Z0
G1 X5 Z-5
G1 X10 Z0
G0 Z0
PROGRAM ANALYSIS
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
PROGRAM ANALYSIS
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
G0 X0
G0 Z0
PROGRAM ANALYSIS
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
G0 X0
G0 Z0
G1 X5 Y5 Z-5
G1 X10 Y0 Z0
PROGRAM ANALYSIS
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
G0 X0
G0 Z0
G1 X5 Y5 Z-5
G1 X10 Y0 Z0
G0 Z1
G0 X5
G0 Z0
G1 Y5 Z-5
G1 Y10 Z0
G0 Z1
G0 X0 Y5
G0 Z0
G1 X5 Z-5
G1 X10 Z0
G0 Z0
EXERCISE
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
Modify the program to
G0 X0
G0 Z0
obtain:
G1 X5 Y5 Z-5
G1 X10 Y0 Z0
G0 Z1
G0 X5
G0 Z0
G1 Y5 Z-5
G1 Y10 Z0
G0 Z1
G0 X0 Y5
G0 Z0
G1 X5 Z-5
G1 X10 Z0
G0 Z0
EXERCISE
G21 T3 F5
G0 X0 Y0 Z0
G1 X5 Y5 Z-5
G1 X10 Y10 Z0
G0 Z1
Modify the program to
G0 X0
G0 Z0
obtain:
G1 X5 Y5 Z-5
G1 X10 Y0 Z0
G0 Z1
G0 X5
G0 Z0
G1 Y5 Z-5
G1 Y10 Z0 G0 X0 Y0 Z0
G0 Z1 G1 Z-1
G0 X0 Y5 G1 X10
G0 Z0 G1 Y10
G1 X5 Z-5 G1 X0
G1 X10 Z0 G1 Y0
G0 Z0 G0 Z0
EXERCISE
Create the path with:
▪ Absolute coordinates
▪ Incremental coordinates
EXERCISE
Create the path with:
▪ Absolute coordinates

G90 G01 X0 Y0
X50.0
X70.0 Y35.0
X45.0
X0 Y80.0
Y0
M30
EXERCISE
Create the path with:
▪ Incremental coordinates

G91 G01 X0 Y0
X50.0
X20.0 Y35.0
X-25.0
X-45.0 Y45.0
Y-80.0
M30
EXERCISE
CNC milling program. Use G-code G02 circular interpolation milling
programming.
EXERCISE
CNC milling program. Use G-code G02 circular interpolation milling
programming.

G90 G00 X-2.0 Y-1.0


G01 X0 Y0 F8.0 ; point A
Y4.0 ; point B
G02 X2.0 Y6.0 R2.0 ; point C
G01 X8.0 ; point D
G02 X9.0 Y2.268 R2.0 ; point E
G01 X0 Y0 ; point A
G00 X-2.0 Y-1.0
Example 1: NC Block
.125 GRID
Top View NC Block SPACES

Origin
(0,0)
.125 GRID
Worksheet Problem 1 SPACES

D( , ) I( , ) J( , )
B( , ) K( , )

L( , )

E( , )
A( , )

F( , )

C( , )
H( , ) G( , )
Origin
(0,0)
Example 1: Program NC
N01 G90 G80 T00
N02 G00 X0 Y3.000 Z1.000
N03 M03 S1000
Example 1: Program NC
N01 G90 G80 T00
N02 G00 X0 Y3.000 Z1.000
N03 M03 S1000
N04 X.375 Y.250 Z1.000
N05 Z.100
N06 G01 Z-.100 F5.00
N07 Y1.750
Example 1: Program cont’d
N08 X1.250 Y.250
N09 Y1.750
N10 G00 Z.100
N11 X2.625 Y.500
N12 GO1 Z-.100
N13 X2.375 Y2.50
N14 X2.000
Example 1: Program cont’d
N15 X1.750 Y.500
N16 Y1.500
N17 X2.000 Y1.750
N18 X2.375
N19 X2.625 Y1.500
Example 1, con.,
N20 G00 Z1.000

N21 X0 Y3.000
N22 M05
N23 M30
Example 2: PLTW Block
.250 GRID
Worksheet Problem 2 SPACE

Origin
Example 2: Top View M( ,
)
F( , K( ,
J( , ) I( , )
C( , ) ) O( ,
) )

B( ,
) Q( ,
E( , )
)
A( ,
)

L( , P( ,
D( , ) )
G( , ) N( ,
) H( ,
)
Origin )

.250 Grid Space


Example 2: PLTW
N01 G90 G80 T01
N02 G00 X0 Y0 Z1.000
N03 M03 S1000
N04 X.750 Y.500 Z1.000
N05 Z.100
N06 G01 Z-.250 F5.00
N07 Y2.500
Example 2: PLTW cont’d
N08 X1.250
N09 G02 X1.250 Y1.500 I1.250 J2.000
N10 G01 X.750
N11 G00 Z.100
N12 X2.250 Y2.500
N13 G01 Z-.250
N14 Y.500
Example 2: Program cont’d
N15 X3.250
N16 G00 Z.100
N17 X4.000
N18 G01 Z-.250
N19 Y2.500
N20 X3.500
N21 X4.500
Example 2: PLTW cont’d
N22 G00 Z.100
N23 X5.000 Y2.500
N24 G01 Z-.250
N25 X5.500 Y.500
N26 X5.750 Y1.500
N27 X6.000 Y.500
N28 X6.500 Y2.500
Example 2: PLTW cont’d
N29 G00 Z1.000
N30 X0 Y0
N31 M05
N32 M30
Automatic Part Programming
Software programs can automatic generation of CNC data

Define Tool

CNC data

Make 3D model
Simulate
cutting
Automatic part programming and DNC
Very complex part shapes ➔ very large NC program

NC controller memory may not handle HUGE part program

computer feeds few blocks of


NC program to controller

When almost all blocks executed,


controller requests more blocks

You might also like