Learn VMC Programming: Format or Skeleton of VMC programming




INTRODUCTION:

Every professional VMC program looks different on the surface – different tools, different cuts, different parts. But underneath, they all share the same skeleton. Today, I am not going to teach you how to write a specific VMC program for face milling, contouring, or drilling. Those are individual operations important, yes, but they come later. Instead, I am going to teach you something far more fundamental: the programming format or template that every single VMC program follows – the structure, the order of commands, and the safety blocks that make a program reliable and machine-ready, regardless of the part or the tool.

I am not teaching you how to write a face milling cycle or a drilling canned cycle. Those are recipes. Instead, I am teaching you the kitchen layout – the universal format that every safe and functional program follows. You will learn why we always start with cancellation codes like G90 G80 G40, why we send the Z-axis home before a tool change, and why M30 is the only proper way to end. Once you memorise this template, you can read any program from any machine and write your own without crashing. The specific cuts will come later – first, master the structure.”


Think of it like writing a formal letter. The content changes depending on who you write to, but the structure – the address, the salutation, the body, the closing – always stays the same. A VMC program works exactly like that. Every safe and machine-ready program begins with a safety block like this (G90G80G40G49G21G17), that cancels all active commands – G90 for absolute positioning, G80 to cancel canned cycles, G40 to cancel cutter compensation, G49 to cancel tool length offset, and so on. Then we send the Z‑axis home with G28G91Z0.0, followed by X and Y home. Only then do we call a tool (T01M06), start the spindle (M03S1000), select a work offset like G54, and apply tool length compensation with G43.

Now comes the middle section – and this is where the program changes completely depending on what you are machining. The middle section contains your cutting moves but even there, the format remains predictable. For face milling, you will see G01 linear moves with step‑over patterns. For contouring, G01 and G02/G03 arcs will trace the profile. For drilling, a single canned cycle like G81 or G83 replaces many lines of code. For pocketing, you might use subprograms or helical entries. This middle block can be short or hundreds of lines long – but the format around it never changes. You always finish cutting, then retract Z, turn off coolant with M09, return to reference positions (G91G28Z0), cancel all commands again, stop the spindle (M05), and end with M30.

So remember: the skeleton is fixed - safety, homing, tool, offset, cutting, retract, cleanup, stop. Only the middle changes. Learn the skeleton first. Once you master this template, you can read any program and write your own without crashing. The specific cutting operations will come naturally later. First, learn the skeleton.




EXAMPLE:


O0001 (PROGRAM NUMBER) ;
N1 (SEQUENCE NUMBER) ;

(--- SAFETY HEADER ---)
G90 G80 G40 G49 G21 G17 G15 ; (ALL COMMAND CANCELATION)
G28 G91 Z0.0 ; (Z-AXIS REFERENCE / HOME)
G28 G91 X0.0 Y0.0 ; (X & Y AXIS REFERENCE / HOME)

(--- TOOL CALL ---)
T01 M06 ; (TOOL CALL)
M03 S1000 ; (SPINDLE ON CLOCKWISE AT 1000 RPM)
G0 G90 G54 X0.0 Y0.0 ; (RAPID TO WORK COORDINATE X0 Y0)
G43 Z100. H01 ; (TOOL LENGTH COMP ON / SAFE HEIGHT)
G0 Z10. M08 ; (RAPID TO APPROACH POINT / COOLANT ON)

(--- MAIN CUTTING BLOCK ---)
G01 X... Y... F... ; (LINEAR CUT)
G02 X... Y... R... ; (CW ARC)
G03 X... Y... R... ; (CCW ARC)
G01 X... Y... ; (LINEAR CUT)

(--- FOOTER / PROGRAM END ---)
G0 Z100. M09 ; (RETRACT TO SAFE Z / COOLANT OFF)
G91 G28 Z0.0 ; (Z-AXIS HOME)
G91 G28 Y0.0 ; (Y-AXIS HOME TO LOAD/UNLOAD)
G90 G80 G49 G40 G15 G17 ; (RESET MODAL CODES)
M05 ; (SPINDLE OFF)
M01 ; (OPTIONAL STOP)
M30 ; (PROGRAM END AND REWIND)



(--- SAFETY HEADER ---)
G90 G80 G40 G49 G21 G17 G15 ;
G28 G91 Z0.0 ;
T01 M06 ;
M03 S1000 ;
G0 G90 G54 X0.0 Y0.0 ;
G43 Z100. H01 ;
G0 Z10. M08 ;

(--- MAIN CUTTING BLOCK ---)

(--- SECTION A: POLAR COORDINATE DRILLING ---)
G16 ; (START POLAR COORDINATES - X=Radius, Y=Angle)
G81 G98 X50. Y45. Z-10. R3. F100 ; (G81: Spot Drill at 50mm Radius, 45 degrees)
Y135. ; (Drill next hole at 135 degrees)
Y225. ; (Drill next hole at 225 degrees)
Y315. ; (Drill next hole at 315 degrees)
G80 G15 ; (CANCEL CYCLE AND POLAR MODE)

(--- SECTION B: PECK DRILLING ---)
G83 G99 X100. Y0. Z-30. Q5. R3. F120 ; (G83: Deep Hole Pecking, Q=5mm Peck)
X200. ; (Drill next hole at X200)
G80 ; (CANCEL CYCLE)

(--- SECTION C: RIGID TAPPING ---)
M29 S500 ; (ENABLE RIGID TAPPING MODE - Crucial for Fanuc)
G84 G98 X100. Y0. Z-20. R5. F750 ; (G84: Tapping - Feed = Pitch x RPM)
G80 ; (CANCEL CYCLE)

(--- FOOTER ---)
G0 Z100. M09 ;
G91 G28 Z0.0 ;
G91 G28 Y0.0 ;
M30 ;



Breakdown of the format:

​The program is divided into three main sections:

1. The safety header:


These lines prepare the machine to ensure it doesn't carry over settings from a previous job.
G90 G80 G40 G49 G21 G17 G15: This is a "cancelation" block. It sets the machine to Absolute programming (G90), cancels canned cycles (G80), cancels cutter compensation (G40), and sets the units to Millimeters (G21), cancels polar coordinates (G15) and set up machine to XY axis (G17).
• G28 G91 Z0.0: Sends the Z-axis (the spindle) to its home position to avoid crashing into the workpiece.
• T01 M06: Calls Tool #1 and performs an automatic tool change.
• M03 S1000: Starts the spindle clockwise at 1,000 RPM.
• G43 Z100 H01: Activates Tool Length Compensation using the value stored in offset H01 and moves to a safe height of 100mm.
• G54: Selects work offset coordinate system #1. This tells the control: use the saved values for X, Y, and Z offsets that define where this particular part’s zero point is located on the table. X0.0 Y0.0 then commands a rapid move to the part zero as defined by that G54 offset. So the machine moves to wherever you previously set G54’s X and Y, typically the lower-left corner, center of the part, or a fixture reference point.

2. The Cutting Block:

​This is the "meat" of the program where the actual machining happens.
• G01 / G02 / G03: These are motion commands. G01 is a straight linear cut, G02 is a clockwise arc, and G03 is a counter-clockwise arc.

3. The exit:

​These lines safely shut down the machine.
• M09 / M05: Turns off the coolant and stops the spindle rotation.
• G91 G28 Z0.0 / Y0.0: Returns the Z-axis and Y-axis to their home positions (often used to move the table toward the operator for easy part unloading).
M30: End of program and reset to the beginning.

While this is a very standard "safety format" for Fanuc-style controllers, it isn't identical for every program. Most shops use a template like this to prevent crashes, but the specific codes change based on the machine's setup, the material, and the specific job requirements. Here is how the format varies and what you should look out for:

1. Variations in the safety header:

​The header is designed to reset the machine. Depending on the shop, you might see these changes:
• Units (G20 vs. G21): If you are working in inches instead of millimeters, you would use G20 instead of G21.
• Plane Selection: While G17 (XY plane) is standard for most milling, you would use G18 or G19 if you were doing specialized side-milling or polar coordinate work.
• Work Offsets: While G54 is the most common work coordinate. However, if you have multiple parts on the table, you might see G55, G56, or even extended offsets like G54.1 P1.

2. Tool change logic:

​The sequence T01 M06 works for machines with an Automatic Tool Changer (ATC). On machines without an ATC, you might just see a M00 (Program Stop) to let the operator change the tool by hand. High-speed machines often pre-stage the next tool. You might see T02 on a line by itself immediately after a tool change to get the next tool ready in the carousel.

3. Circular Interpolation:

​The image shows G02 and G03 for arcs. There are two ways these are written:
• R-Programming: G02 X20. Y20. R10. F150. (Uses a radius value).
• IJK-Programming: G02 X20. Y20. I10. J0. F150. (Uses incremental distances to the arc center). Most professional templates prefer IJK because it is more mathematically precise for full circles.

4. The footer:

​The way a program ends usually depends on the size of the machine:

• M01 (Optional Stop): 

This is a safety valve. If the operator has the "Optional Stop" button pressed on the control panel, the machine will pause here. This is great for checking the tool or the finish before the next operation.

• Comments in Brackets: 

The text in parentheses (LIKE THIS) is ignored by the machine. It is there only for the programmer or operator to read.


The Semicolon ( ; ): 

This represents the "End of Block" (EOB) character, telling the controller to move to the next line of code.




Post a Comment

0 Comments