Part Program Manual (Autosaved)
Part Program Manual (Autosaved)
1
Numerical Control - History
N G X Y Z I J K F S T M
Every X and Y movement command takes the dimensions from the datum position on the bottom left of the part.
Programming with G91 incremental
(G91 EXAMPLE);
N010 G21 G54 G98 G40 G80 G49 G90;
N020 T1 M6;(15MM DRILL);
G90 G21 (MOVING TO POSITION 1 IN ABSOLUTE);
S600 M03;
G00 X15.0 Y15.0 (POSITION 1);
G91 (INCREMENTAL MODE); X20.0 (POSITION 2);
X20.0 (POSITION 3);
X20.0 (POSITION 4);
Y20.0 (POSITION 5);
X-20.0 (POSITION 6);
X-20.0 (POSITION 7);
X-20.0 (POSITION 8);
Y20.0 (POSITION 9);
X20.0 (POSITION 10);
X20.0 (POSITION 11);
X20.0 (POSITION 12);
G90 (ABSOLUTE MODE);
G00 Z50.0; I have used G90 absolute to move the cutter to the first position since the spindle position is unknown
G28 X0.0 Y0.0 M05; at this time, once the tool is at the first hole, G91 is activated for the duration of the movements
M00;
Symbols Used in G-Code
Semicolon (;): In CNC programming, each line of code typically represents
a specific action or instruction for the machine to follow. The semicolon
helps to indicate the end of one command and the beginning of another.
Full Stop (.) It acts as a delimiter to separate different commands or
functions within the program. When the CNC machine reads a full stop, it
knows that it has reached the end of a particular instruction and should
move on to the next one.
Plus (+) and Minus (-): These symbols are commonly used to indicate
positive and negative values, such as feed rates, tool offsets, or coordinate
positions.
Percent Sign (%): In some CNC systems, the percent sign is used to mark
the start and end of a program or subprogram.
Example
Basic manual part programming sequence to drill a 10 mm diameter hole with a depth of 5 mm at
the center of a workpiece with dimensions of 100 x 100 x 20 mm using Fixed Sequential Format.
N10 G21 G54 G98 G40 G80 G49 G90;
N20 T01 M06 (Select tool and perform tool change)
N30 S1000 M03 (Spindle speed and direction)
N40 G0 G43 Z5 H01: move to a safe height above the workpiece.
N50 G0 X50 Y50 (Move to safe position above workpiece center)
N60 G01 Z-5 F50 M7 (Begin drilling to depth of 5mm)
N70 G00 Z5 (Retract drill bit)
N80 M05 (Stop spindle)
N90 M09 (Stop coolant)
N100 G91 G28 X0. Y0. Z0.;
N110 M30; (End program)
Example of G code from CNC VMC Simulator
N010 G21 G54 G98 G40 G80 G49 G90;
N020 T1 M6; N180 G0 Y100.; N340 G0 Y100.; N490 G0 Z100.;
N190 G1 Z-2.; N350 G1 Z-15.; N500 M5;
N030 S2800 M3; N360 G0 Z2.;
N200 G0 Z2.; N510 M9;
N040 G0 G43 Z50. H1; N370 G0 Y140.; N520 G91 G28 X0. Y0. Z0.;
N210 G0 Y60.;
N050 G0 X60. Y60.; N380 G1 Z-15.; N530 M30;
N220 G1 Z-2.;
N230 G0 Z2.; N390 G0 Z2.;
N060 G0 Z2.;
N070 G1 Z-2. F280 M7; N240 G0 Z100.; N400 G0 X140.;
N080 G0 Z2.; N250 M5; N410 G1 Z-15.;
N260 M9; N420 G0 Z2.;
N090 G0 Y100.; N270 T2 M6;
N100 G1 Z-2.; N430 G0 Y100.;
N280 S1800 M3; N440 G1 Z-15.;
N110 G0 Z2.;
N290 G0 G43 Z50. H2; N450 G0 Z2.;
N120 G0 Y140.; N300 G0 X60.;
N460 G0 Y60.;
N130 G1 Z-2.; N310 G0 Z2.;
N470 G1 Z-15.;
N140 G0 Z2.; N320 G1 Z-15. F360 M7;
N480 G0 Z2.;
N330 G0 Z2.;
N150 G0 X140.;
N160 G1 Z-2.;
N170 G0 Z2.;
The meaning of provided on CNC program
N010 G21 G54 G98 G40 G80 G49 G90;
G21: Sets the machine to operate in metric units.
G54: Establishes the coordinate system for the part.
G98: Indicates that the tool will return to the initial Z-plane after each drilling operation.
G40: Cancels cutter radius compensation.
G80: Cancels any canned cycle mode.
G49: Cancels tool length compensation.
G90: Sets absolute programming mode.
N020 T1 M6;
T1: Selects tool number 1.
M6: Changes the tool to the selected one.
N030 S2800 M3;
S2800: Sets spindle speed to 2800 RPM.
M3: Starts the spindle in a clockwise direction.
N040 G0 G43 Z50. H1;
G0: Rapid positioning movement command.
G43 Z50.: Initiates tool length offset with an offset value of 50mm on the Z-axis.
H1: Selects tool length offset number 1.
N050 G0 X60. Y60.;
Moves the tool rapidly to position X=60 and Y=60
Part Program With Cam Software
A part program are generated using Computer-aided manufacturing
(CAM) software and are then translated into G-code and M-code
commands for execution by the CNC machine.
The program controls various functions such as tool movements,
spindle rotation, coolant usage, and other auxiliary functions necessary
for machining operations.
These instructions are typically generated in Computer-Aided
Manufacturing (CAM) software and fed into Computer Numerical
Control (CNC) machines, such as drills, lathes, mills, grinders, and
routers. The CNC computer translates these instructions into
standardized G-code and M-code commands and follows them in the
Automatic Part Programming
Define Tool
CNC data
Make 3D model
Simulate
cutting
Procedures to Develop G-Code Using SolidWorks CAM:
Design Your Part: Create a 3D model of the part in SolidWorks with accurate dimensions and features.
Activate CAM Functionality: Open the CAMWorks or SolidWorks CAM tab in SolidWorks to enable
CAM features.
Specify Machine Type: Define the type of CNC machine (e.g., milling machine, lathe) for which you
are generating G-code.
Set Up Stock Material: Specify the material type, dimensions, and placement of the stock material for
machining.
Feature Recognition: Utilize Automatic Feature Recognition (AFR) to identify machinable features
like holes, pockets, and bosses from the 3D model.
Assign Machining Operations: Assign appropriate operations (drilling, milling, turning) to each
recognized feature and customize parameters.
Simulation and Validation: Run a simulation within SolidWorks to visualize the machining process,
check for collisions, and make adjustments if needed.
Generate G-Code: Once satisfied with the setup, generate the G-code that will guide the CNC machine
in producing the part.
Post-Processing: Select the correct post-processor for your CNC machine to convert G-code into a
format compatible with its controls.
Export and Execute: Export the G-code file, transfer it to your CNC machine’s control software, and
begin the machining process while monitoring its progress.
Exercises 1
Exercises 2
Develop The G Code for the drawing given below
Exercise 3
F 25
Raw Material
70
F 22.5
F 17.5
Finished Part
20
30
Exercise
• Write the part program to drill the holes in the part shown in Figure 1.
The part is 12.0 mm thick. Cutting speed = 100 m/min and feed = 0.06
mm/rev. Use the lower left corner of the part as the origin in the x-y
axis system. Write the part program in the word address format using
absolute positioning.
• Hint: you will need to calculate the N.
Exercise 4