By mastering these machining techniques, you will have a solid foundation in programming

The programming of CNC machining programs is the process of writing program sheets according to the programming format, which includes the process of machining parts, process parameters, workpiece dimensions, the direction of tool displacement, and other auxiliary actions (such as tool changing, cooling, workpiece loading and unloading, etc.) in the sequence of motion instructions.

The determination of the machine tool coordinate system and the direction of motion

The linear motion X, Y, and Z coordinate systems of the machine tool adopt the right-handed Cartesian coordinate system, as shown in Figure 11-6. The order of defining the coordinate axes is to first determine the Z-axis, then the X-axis, and finally the Y-axis. For machine tools that rotate the workpiece (such as lathes), the direction away from the workpiece is taken as the positive direction of the X-axis; for machine tools that rotate the tool (such as vertical milling machines), when the tool is on the Z-axis, facing the column from the spindle direction, the right direction is taken as the positive direction of the X-axis. The three rotation axis coordinate systems are parallel to the X, Y, and Z coordinate axes, and the forward direction is taken as the positive direction according to the right-hand screw.

Basic instructions for CNC lathes

1) Program format

The machining program usually consists of three parts: program start, program content, and program end.

The beginning of the program is the program number, used as the start identifier of the machining program. The program number is usually represented by the character “%” followed by four digits.

The program end can be represented by auxiliary functions M02 (program end) and M30 (program end, return to the starting point), etc.

The main content of the program consists of several program blocks (BLOCK), and a program block is composed of one or several information words, and each information word is composed of an address character and a data character. The information word is the smallest unit of instruction.

2) Program block format

The commonly used format is the word address program block format, and the application standard is JB3832-85.

Here is a typical word address program block format:

N001 G01 X60.0 Z-20.0 F150 S200 T0101 M03 LF

Where,

N001 – indicates the first program block

G01 – indicates linear interpolation

X60.0 Z-20.0 – respectively indicate the displacement in the X and Z coordinate directions

F, S, T – respectively indicate the feed speed, spindle speed, tool number

M03 – indicates the spindle rotation clockwise

LF – indicates the end of the program block

3) Basic function codes in CNC systems

(1) Program segment number: N10, N20…

(2) Preparation function: G00-G99 are functions that make the CNC device perform certain operations.

G codes are divided into modal codes and non-modal codes. The so-called modal code means that once a G code (G01) is specified, it remains effective until a later program block uses the same group of G codes (G03) to replace it. Non-modal codes are only valid in the specified program block and must be rewritten when needed in the next program block (such as G04). Follow us on WeChat for metal processing, worth your attention.

a. Rapid point positioning command G00

The G00 command is a modal code. It commands the tool to move rapidly from its current position to the next target position using point positioning control. It is only for rapid positioning without trajectory requirements.

Its command writing format is: G00 X_Z_; The actual motion path of the tool is not a straight line but a polyline, so when using the G00 command, you should pay attention to whether the tool will collide with the workpiece or fixture. Ignoring this point can easily lead to collisions, which are more dangerous in rapid states.

b. Linear interpolation command G01

The linear interpolation command is a linear motion command and is also a modal code. It commands the tool to move in a linear manner between two or three coordinates at any specified slope at the specified feed rate (unit: mm/min).

Its command writing format is: G01 X_Z_F_; The F command is also a modal command, and it can be canceled using the G00 command. If there is no F command in the program block before the G01 program block, the machine will not move. Therefore, there must be an F command in the G01 program block.

c. Circular interpolation command G02/G03 (using Cartesian coordinates for judgment)

The circular interpolation command commands the tool to move in a circular motion at the specified feed rate within a specified plane, cutting out a circular contour. When machining arcs on a lathe, not only the clockwise or counterclockwise direction of the arc is specified using G02/G03, and the endpoint coordinates of the arc are specified using XZ, but also the radius of the arc is specified.

Its command writing format is: G02/G03 X_Z_R_;

(3) Auxiliary functions: Used to specify auxiliary actions of the machine tool (such as start, stop, direction reversal of the machine tool, switching of cutting fluid, spindle direction, tool clamping and releasing, etc.)

M00 – Program pause

M01 – Optional stop

M02 – Program end

M03 – Spindle clockwise rotation (CW)

M04 – Spindle counterclockwise rotation (CCW)

M05 – Spindle stop

M06 – Tool change in machining center

M07, M08 – Coolant on

M09 – Coolant off

M10 – Workpiece clamping

M11 – Workpiece releasing

M30 – Program end, return to the starting point

The M05 command must be used between the M03 and M04 commands to stop the spindle before operation.

(4) Feed function F

If the direct specification method is adopted, the required feed rate is directly written after F, such as F1000, indicating a feed rate of 1000 mm/min); when threading, tapping, and thread milling, the feed rate is related to the spindle speed, and the number after F specifies the lead.

(5) Spindle function S

S specifies the spindle speed, such as S800, indicating a spindle speed of 800 rpm.