📷 IMAGE AREA — X, Y, Z axis directions and positive/negative motion on a CNC vertical machining centre
Suggested alt text: CNC milling machine X Y Z axes and positive negative motion directions
The coordinate system is the foundation of programming in CNC milling. The machine cannot understand spoken expressions like “go a little to the right” or “come to the hole centre”; the position the tool will reach must be stated with axis letters and numerical values. Before learning G codes, the student must understand four topics well: the directions of the X/Y/Z axes, the machine and workpiece coordinate systems, the roles of the zero points, and the difference between absolute and incremental programming. This lesson is the basis of G00, G01, G02, G03, the drilling cycles and tool compensations.
1. Aim of the lesson
By the end of this lesson the student will be able to interpret the X/Y/Z axes and their positive/negative directions correctly; distinguish machine zero, reference point and workpiece zero; understand the difference between machine and workpiece coordinates; explain the purpose of the G54–G59 workpiece coordinate systems; use the G90 absolute and G91 incremental programming logic; and understand why coordinate and sign errors are dangerous.
2. Why is a coordinate system needed?
On a drawing, the locations of holes, the corners of pockets, the starts of slots and the centres of radii are defined with dimensions. In the CNC program the tool must reach these points, so each point is stated numerically relative to a reference. For example, X40. Y25. sends the tool to 40 mm in X and 25 mm in Y according to the selected coordinate system. But for these values to be meaningful, the question “relative to which zero point are these measured?” must be answered. The coordinate system provides a common start point from which all positions are measured.
3. The Cartesian coordinate system
The most used system in CNC milling programs is the Cartesian coordinate system, with the mutually perpendicular X, Y and Z axes. For example X50. Y30. Z10. means the tool is at 50 in X, 30 in Y and 10 mm in Z relative to the selected zero. The basic axes are X, Y, Z; the auxiliary linear axes are U, V, W; the auxiliary rotary axes are A, B, C.
4. X, Y and Z axis directions
The X axis is usually left-right (right X+, left X-). The Y axis is front-back; what matters is not memorising the physical table motion but understanding the programming direction (the workpiece is assumed fixed, the tool moving). The Z axis is along the spindle: Z+ moves the tool away from the part, Z- toward it. If the top face is taken as Z0, Z5. can be 5 mm above the surface and Z-3. 3 mm into it. A wrong negative Z can cause a collision with the part, vise, fixture or table.
5. Physical motion vs programming motion
On a VMC the table may physically move in X/Y and the spindle group in Z; on another machine the structure may differ. The programmer always treats the workpiece as fixed and the tool as moving relative to it. If the table physically goes left, the tool is considered to move right relative to the part. This way the same coordinate logic is used on machines with different mechanical structures.
6. The right-hand rule
The right-hand rule helps understand axis directions: the thumb points X+, the index finger Y+, the middle finger Z+. On a real machine, however, the directions must be verified from the axis labels, the direction marks on the operator panel and the builder manual.
7. Zero points in CNC milling
There is no single zero in CNC milling; several references exist for different tasks: machine zero, reference point, workpiece zero, tool-change/park point and local zero.
- Machine zero: the fixed start point set by the builder; the basis of the machine coordinate system, stroke limits and reference positions; not changed by the operator and usually not on the part.
- Reference point: a machine-specific position used so the control recognises the axis positions (Zero/Reference/Home Return). FANUC states a manual reference return may be needed after power-on and that the stroke-limit check may not work fully before it is done. (On some machines with absolute encoders it may not be needed at every power-on; follow the builder manual.)
- Workpiece zero: the start point of the program dimensions; can be a corner, the part centre, a hole centre or a fixture locating point. A well-chosen zero reduces calculations and lets drawing dimensions be used directly.
8. How to choose the workpiece zero
The zero is not chosen randomly; consider where the drawing dimensions start from, the part symmetry, reliable locating faces, repeatability in series production and ease of measurement. Corner zeroing: a corner of the top face on a rectangular part (e.g. bottom-left corner X0 Y0 Z0) — useful when the dimensions come from the same corner. Centre zeroing: the centre of a symmetric part (on a 100×60 part: right edge X+50, left X-50, top Y+30, bottom Y-30) — easier for circular pockets and mirrored geometries. Fixture reference: in series production a fixture pin/locating face increases repeatability.
9. Choosing the Z zero
The Z zero can be taken from different surfaces: the part top face, the fixture top, the table surface or a fixed tool-measuring plane. If the part top face is Z0: the surface is Z0, inside the part is negative Z, and the safe zone above is positive Z (e.g. Z5. 5 mm above, Z0. top face, Z-2. 2 mm in). If the table/fixture face is Z0, the part top becomes a positive Z value. In this series, unless stated otherwise, the part top face is taken as Z0.
10. Machine coordinate vs workpiece coordinate
The machine coordinate is the fixed system set by the builder; it belongs to the machine, is fixed and related to the reference return. The workpiece coordinate is the system the programmer sets for the part; it belongs to the part/fixture, can change per job and is the basis of the program dimensions. As a simple analogy, the machine coordinate is like the factory’s position on the city map, while the workpiece coordinate is like the layout plan of a department inside the factory.
11. FANUC workpiece coordinate systems: G54–G59
On FANUC, G54, G55, G56, G57, G58, G59 can each store a separate workpiece zero. G54 does not store the part itself but the X/Y/Z distances between the machine zero and the chosen workpiece zero (e.g. G54: X-520 Y-245 Z-430 — real values vary by machine/setup). Why several zeros? With two parts on the same table, the left part can be G54 and the right G55; the same program geometry runs on both parts by selecting a different coordinate system. G90 G54 G00 X0. Y0. means: select absolute programming, go rapidly to X0 Y0 relative to the G54 zero.
12. Entering the workpiece zero wrongly
A correctly written program can become dangerous due to a wrong workpiece zero. If there is a 20 mm error between the real part top and the entered Z zero, a programmed Z-2. can go much deeper into the part. A wrong X/Y drills a hole in the wrong place or drives the cutter into the vise. Therefore, before Cycle Start, the selected G54–G59 system, the X/Y/Z zero values, the active program, the tool length and the real clamping position of the part must be checked together.
13. Absolute programming – G90
In absolute programming all target points are defined relative to a single fixed zero and selected with G90. Wherever the tool is, the X/Y values are interpreted relative to the workpiece zero. Example rectangle path:
G90
G00 X20. Y10.
G01 X60. Y10. F200.
Y40.
X20.
Y10.Each target is given relative to the part zero. On the Y40. line X is not written because X does not change and the previous X60 remains. G90 advantages: each point is read against a fixed zero, the program is easy to check, an error on one line does not corrupt later targets cumulatively, and drawing coordinates can be used directly. This is why G90 is the basic method in most CNC milling programs. Note: with G90 active, X50. does not mean “move 50 mm” but “go to X50 relative to the zero”; if the tool is at X30 it moves +20, if at X70 it moves -20.
14. Incremental programming – G91
In incremental programming the target is stated relative to the tool’s current position, not a fixed zero, and selected with G91. Every command asks “in which direction and how far should I move from where I am?” The same rectangle path (start X20 Y10):
G91
G01 X40. F200.
Y30.
X-40.
Y-30.Here the values are move amounts, not point coordinates. G91 is useful for equally spaced holes, repeating moves, grid patterns and subprograms. Risk: if one move is wrong, all later points shift (X45 instead of X40 shifts the whole contour by 5 mm). Forgetting a negative sign is very dangerous: writing X40. instead of X-40. can take the tool to a position 80 mm off in the opposite direction. So the direction and the minus sign must be checked carefully.
15. The key difference between G90 and G91
With the tool at X20 Y10 and a target of X50 Y30: G90 X50. Y30. means “go to X50 Y30 relative to the zero” (actual move +30 X, +20 Y). G91 X30. Y20. means “from where you are, move X+30, Y+20.” Both reach the same end point, but the meaning of the numbers differs.
16. G90 and G91 are modal codes
G90 and G91 are modal: they stay active after their line until the opposite command is given. Once G90 is selected it need not be rewritten on every line; G90 is valid until G91 appears. Both can be switched within the same program:
G90 G54 G00 X0. Y0.
G91 G01 X20. F200.
Y20.
G90 G00 X0. Y0.Safe habit: after a special incremental move, G90 should be written explicitly again; otherwise the programmer may write a coordinate thinking G90 is active while the system is still in G91. FANUC notes that running an absolute program in incremental mode (or vice versa) can cause unexpected machine motion.
17. Combined/separate axis values and interpolation
Only the axes to move can be written in a block; after G90 G00 X20. Y10., X50. changes only the X target while Y10 remains. In G01 X50. Y30. F200. X and Y do not move separately in turn but simultaneously, and the tool follows a straight path between start and end; this is called linear interpolation. In G91, if an axis does not move it need not be written (G91 X30.).
18. Interpreting positive and negative signs
In G90 the sign shows which side of the zero the target is on (X-20. on the negative X side of the zero). In G91 the sign shows the direction of motion (X-20. move 20 mm in negative X from the current position). These two meanings must not be confused.
19. Preparing a coordinate table
Preparing a coordinate table for each important point reduces sign errors and eases program checking. For the same rectangle path:
| Point (G90) | X | Y |
|---|---|---|
| P1 | 10 | 10 |
| P2 | 60 | 10 |
| P3 | 60 | 40 |
| P4 | 10 | 40 |
| Move (G91) | X change | Y change |
|---|---|---|
| P1 → P2 | +50 | 0 |
| P2 → P3 | 0 | +30 |
| P3 → P4 | -50 | 0 |
| P4 → P1 | 0 | -30 |
20. Simple G90 and G91 application
A rectangular contour with corners P1=X10 Y10, P2=X70 Y10, P3=X70 Y40, P4=X10 Y40. With G90:
G90 G54
G00 X10. Y10.
G01 X70. Y10. F250.
Y40.
X10.
Y10.The same path with G91:
G90 G54 G00 X10. Y10.
G91
G01 X60. F250.
Y30.
X-60.
Y-30.
G90These examples show only the coordinate logic; a real program also defines the safe Z height, tool length compensation, spindle speed, coolant, tool diameter and the approach/retract moves.
21. G90 and G91 in hole positions
Four equally spaced holes (X20/50/80/110, Y20): in absolute X20. Y20. / X50. / X80. / X110.; in incremental, go absolute to the first hole then G91 X30. X30. X30. This shows why G91 is useful for equally spaced holes; however, in real drilling, canned cycles such as G81 are used (in later lessons).
22. G28 combined with G91
The common G91 G28 Z0. does not mean “go to Z zero.” G28 sends the axis to the reference position; the stated coordinate is treated as an intermediate point. G91 G28 Z0. → incremental system, a zero-increment intermediate move in Z, then the axis returns to the machine reference. Safety: sending several axes to reference on the same line (G91 G28 X0. Y0. Z0.) can create an unwanted path; usually Z is retracted to the safe zone first, then X/Y: G91 G28 Z0. then G28 X0. Y0. then G90. The exact method is set by the builder procedure.
Moving in machine coordinates with G53
Like G28, G53 works independently of the workpiece zero. G53 makes the movement follow the machine coordinate system directly instead of the selected G54–G59 system.
G53 G0 Z0This line is typically used to send the Z axis to its upper position in machine coordinates. Its key properties:
- It is independent of the G54–G59 selection.
- On most controls it is non-modal; it is effective only in the block where it is written.
- It moves according to machine coordinate values and is generally used in G90 mode.
- Used wrongly, it can create a collision risk.
Do not assume that G53 Z0 is the safe upper position on every machine; check the machine’s coordinate directions and the builder’s manual. The most commonly confused point is this: G53 uses machine coordinates, G54 uses workpiece coordinates. The same Z0 value is a completely different physical point in the two systems.
23. A brief introduction to plane selection
There are three basic working planes: G17 XY, G18 XZ, G19 YZ. On a three-axis VMC most contours are programmed in the XY plane, so the most common choice is G17. Plane selection matters especially in circular/helical moves and drilling cycles; a wrong plane can cause unexpected motion (covered in detail in a later lesson).
24. Common coordinate-system mistakes
- Selecting the wrong G54: the program is prepared for G54 but G55 stays active; the correct program runs in the wrong place. Write
G90 G54explicitly at the program start. - Forgetting G91 is still active: X100 is assumed absolute but the system is in G91; the tool moves 100 mm — a serious crash. Fix: after the incremental move,
G90. - Forgetting a negative sign (X40 instead of X-40): the tool goes the wrong way.
- Confusing machine and workpiece coordinates: the Machine, Absolute, Relative and Distance to Go displays give different information.
- Taking the Z zero from the wrong surface and moving the part without updating the zero: the cutter goes to the wrong depth; re-check the zero after removing/refitting.
- Forgetting the decimal point: on some systems
X10andX10.may be interpreted differently; this series uses explicit notation (X10.). Verify the decimal-input setting on the real machine.
25. Safe coordinate checking
Before running a new program: check where G90/G91 is selected; verify the active workpiece coordinate and the G54–G59 values on screen; check the real tool position and which surface the Z zero was taken from; verify the tool length compensation; examine the rapid-move targets; run the program in single block; lower the rapid override; watch the Distance to Go display on the first approach; use Feed Hold if in doubt and Emergency Stop in danger.
26. Basic position information on the operator screen
- Absolute: position relative to the active workpiece coordinate system (relative to the G54 zero if G54 is active).
- Machine: position relative to the machine coordinate system (related to machine zero).
- Relative: a relative display the operator can zero temporarily; not the same as the workpiece offset.
- Distance to Go: how much further the axes must move to complete the active command; very useful in first-part checking.
27. The student’s working method
When a drawing is given, do not start writing the program directly. First: determine the workpiece zero; draw the X/Y positive directions; name the important points P1, P2…; prepare a G90 coordinate table and a G91 table from the differences between points; mark the negative moves; and write the safe start point and the Z planes (safe Z, approach Z, part surface, machining depth) separately. This method significantly reduces program errors.
28. Lesson summary
- Positions are defined with X/Y/Z; in programming the workpiece is fixed and the tool moves. Z+ moves away, Z- toward the part.
- Machine zero and workpiece zero have different roles; G54–G59 store different workpiece coordinates.
- G90 defines targets relative to a fixed zero, G91 defines moves relative to the current point; both are modal.
- In incremental, sign errors affect later positions too; reselecting G90 after G91 is a safe habit.
- Do not run the program without checking the coordinate system and the Z zero.