Concept Flow - G-code program structure
Start Program
Initialize Settings
Execute Commands
Check for End
Next Command
The G-code program starts, sets up machine parameters, runs commands step-by-step, and ends when the program finishes.
N10 G21 (Set units to mm)
N20 G90 (Absolute positioning)
N30 G01 X50 Y25 F100 (Move linearly to X50 Y25 at feed 100)
N40 M30 (End program)| Line Number | Command | Action | Machine State | Output |
|---|---|---|---|---|
| N10 | G21 | Set units to millimeters | Units=mm | Units set to mm |
| N20 | G90 | Set absolute positioning mode | Positioning=Absolute | Positioning set to absolute |
| N30 | G01 X50 Y25 F100 | Move tool linearly to X=50, Y=25 at feed 100 | Position=(50,25), Feed=100 | Tool moved to X50 Y25 |
| N40 | M30 | End program | Program Ended | Program stopped |
| Variable | Start | After N10 | After N20 | After N30 | After N40 |
|---|---|---|---|---|---|
| Units | Default (inches) | mm | mm | mm | mm |
| Positioning | Default (Incremental) | Incremental | Absolute | Absolute | Absolute |
| Position | (0,0) | (0,0) | (0,0) | (50,25) | (50,25) |
| Feed | Default | Default | Default | 100 | 100 |
| Program State | Not started | Running | Running | Running | Ended |
G-code program structure: - Start with program setup (units, positioning) - Execute movement and machine commands line by line - Use N numbers for line labels - End program with M30 - Commands affect machine state stepwise
O1000 or similar.M30 ends the program, G01 and G90 are motion and positioning commands, not start markers.O1000 -> Option DM30 is used to stop and end a G-code program.G00 moves the tool, G90 sets positioning mode, and O1000 is a program number, not an end command.M30 -> Option CO1000 G90 G00 X10 Y5 G01 X20 Y15 F100 M30
G00 X10 Y5 moves the tool rapidly to X=10, Y=5. Then G01 X20 Y15 F100 moves it linearly to X=20, Y=15.G01 X20 Y15, so the tool ends at X=20, Y=15.O2000 G01 X10 Y10 G90 M30
G90 sets absolute positioning and should be set before any move commands like G01.G01 before setting G90, which can cause unexpected positioning behavior.O3000 and set absolute positioning G90 before moves.G01 X50 Y50 F200 moves the tool at feed rate 200, and M30 ends the program properly.Pass the test and this pattern moves unknown