OBJECTIVE
After completing this unit, you should be able to:
- Identify the program’s list instructions.
- Understand the Program Format
- Understand the G & M Codes.
CNC Program Language and Structure
CNC programs list instructions to be performed in the order they are written. They read like a book, left to right and top-down. Each sentence in a CNC program is written on a separate line, called a Block. Blocks are arranged in a specific sequence that promotes safety, predictability and readability, so it is important to follow a standard program structure. In this course, a basic CNC program is separated into three sections: the header, the body, and the footer.
The blocks (lines of code) are arranged in the following order:
The Header:
- Program Start
- Load Tool
- Spindle On
- Coolant On
- Rapid to position above part
The Body:
6. Machining operation
The Footer:
7. Coolant Off
8. Spindle Off
9. Move to safe position
10. End program
The steps listed above represent the simplest type of CNC program, where only one tool is used and one operation performed. Programs that use multiple tools repeat steps two through nine for each.
Table 1 and Table 2 below show the most common G and M codes that should be memorized if possible. CNC codes also use letters. Table 3 offers definitions for different letters.
Like any language, the G-code language has rules. For example, some codes are modal, meaning they do not have to be repeated if they do not change between blocks. Some codes have different meanings depending on how and where there are used.
While these rules are covered in this chapter, do not concern yourself with learning every nuance of the language. It is the job of the CNC Programmer to properly format and write the CNC program. A CNC Operator follows the program. It is good for an operator to understand the format of the program.
Practice
G & M CODES
G & M Codes are the most common commands for a CNC program. The definition of each class of code and specific meanings of the most important codes are covered next.
Codes that begin with G are called preparatory words because they prepare the machine for a certain type of motion.
Table 1: G-Code
|
Code |
Description |
|
G00 |
Rapid motion.Used to position the machine for non-milling moves. |
|
G01 |
Line motion at a specified feed rate. |
|
G02 |
Clockwise arc. |
|
G03 |
Counterclockwise arc. |
|
G04 |
Dwell. |
|
G28 |
Return to machine home position. |
|
G40 |
Cutter Diameter Compensation (CDC) off. |
|
G41 |
Cutter Diameter Compensation (CDC) left. |
|
G42 |
Cutter Diameter Compensation (CDC) right. |
|
G43 |
Tool length offset (TLO). |
|
G54 |
Work Offset #1. a.k.a. Fixture Offset |
|
G55 |
Work Offset #2. a.k.a. Fixture Offset |
|
G56 |
Work Offset #3. a.k.a. Fixture Offset |
|
G57 |
Work Offset #4. a.k.a. Fixture Offset |
|
G58 |
Work Offset #5. a.k.a. Fixture Offset |
|
G59 |
Work Offset #6. a.k.a. Fixture Offset |
|
G80 |
Cancel drill cycle. |
|
G81 |
Simple drill cycle. |
|
G82 |
Simple drill cycle with dwell. |
|
G83 |
Peck drill cycle. |
|
G84 |
Tap cycle. |
|
G90 |
Absolute coordinate programming mode. |
|
G91 |
Incremental coordinate programming mode. |
|
G98 |
Drill cycle return to Initial point (R). |
|
G99 |
Drill cycle return to Reference plane (last Z Height) |
M-CODES
Codes that begin with M are called miscellaneous words. They control machine auxiliary options like coolant and spindle direction. Only one M-code can appear in each block of code.
Table 2: M-Codes
|
Code |
Description |
|
M00 |
Program stop.Press Cycle Start button to continue. |
|
M01 |
Optional stop. |
|
M02 |
End of program. |
|
M03 |
Spindle on Clockwise. |
|
M04 |
Spindle on Counterclockwise. |
|
M05 |
Spindle stop. |
|
M06 |
Change tool. |
|
M08 |
Coolant on. |
|
M09 |
Coolant off. |
|
M30 |
End program and press Cycle Start to run it again. |