Flexible support from samples to mass production

phone +86 13163919000email info@xinmeiintelligent.com

logo

Simple Programming Tutorial

Master CNC Programming Basics

This guide will help you understand the fundamentals of CNC programming for Xinmei machining centers. Whether you're a beginner or looking to refresh your knowledge, this tutorial covers essential concepts.

1Understanding G-Code and M-Code

CNC machines use two types of programming codes to control their operations:

G-Code (Geometric Code)

G-codes control the machine's movement and geometry. They tell the machine where to move, how fast, and what path to follow.

  • G00-Rapid positioning (non-cutting movement)
  • G01-Linear interpolation (straight-line cutting)
  • G02-Circular interpolation clockwise
  • G03-Circular interpolation counter-clockwise
  • G17/G18/G19-Plane selection (XY/XZ/YZ)
  • G28-Return to reference point
  • G90-Absolute positioning mode
  • G91-Incremental positioning mode

M-Code (Miscellaneous Code)

M-codes control machine functions that are not related to movement, such as spindle control and coolant.

  • M00-Program stop
  • M03-Spindle ON (clockwise)
  • M04-Spindle ON (counter-clockwise)
  • M05-Spindle OFF
  • M06-Tool change
  • M08-Coolant ON
  • M09-Coolant OFF
  • M30-End of program and reset

2Basic Programming Steps

Follow these steps to create a simple CNC program:

1

Step 1: Program Header

Start with the program number and safety codes. Initialize the machine state.

2

Step 2: Tool Selection

Select the appropriate tool and set spindle speed. Ensure proper tool offset is applied.

3

Step 3: Workpiece Approach

Position the tool at the starting point using rapid movement (G00).

4

Step 4: Machining Operations

Execute cutting operations using appropriate feed rates and cutting parameters.

5

Step 5: Program End

Return to safe position, stop spindle, turn off coolant, and end program.

3Sample Program

Here is a simple example program for drilling operations:

program.nc
O0001 (DRILLING PROGRAM)
G21 (Metric mode)
G17 G90 G40 G49 G80 (Safety line)
T01 M06 (Select tool 1)
G43 H01 (Tool length compensation)
S1200 M03 (Spindle 1200 RPM, CW)
G00 X0 Y0 (Rapid to start position)
G00 Z5.0 (Approach height)
G01 Z-10.0 F100 (Drill to depth)
G00 Z5.0 (Retract)
M05 (Spindle stop)
G28 G91 Z0 (Return to reference)
M30 (End program)

Programming Tips

  • Always verify your program in simulation mode before actual machining
  • Use proper feed rates and spindle speeds based on material and tool specifications
  • Include safety codes at the beginning of every program
  • Comment your code for better readability and maintenance
  • Regularly backup your programs to prevent data loss