⌖ PORTFOLIO — SIMULATION
CNC Machine G-code Interpreter & Controller
CNC controller parsing G-code files and executing linear (G0/G1) and circular (G2/G3) interpolation. Real-time toolpath visualization with feed rate override.
CNC G-code G0/G1/G2/G3 CODESYS Lenze PLC Lenze i750 Interpolation
CNC-2X / G-CODE v1.0 | CNC Motion Controller
● RUNNING
▸ POSITION
X0.000mm
Y0.000mm
▸ MOTION
MODEG0
FEED0mm/min
▸ PROGRAM
BLOCK#0
STATUSRUN
▸ G-CODE
▸ OVERRIDE
FEED OVR100%
▸ AXES
X-AXIS OK
Y-AXIS OK
MODEL:
FEED OVR 100 %
CNC · G0/G1/G2/G3 Interpolation What Does It Do?
- ▸ Parses and executes G-code program line by line
- ▸ G0: rapid positioning, G1: linear interpolation
- ▸ G2/G3: clockwise / counter-clockwise arc interpolation
- ▸ Real-time toolpath display and override control
How Does It Work?
- ▸ G1: Smooth linear motion via Bresenham algorithm
- ▸ G2/G3: Arc computed with I,J center offset
- ▸ Feed rate override: instant speed multiplier (25–200%)
- ▸ EtherCAT cycle 1ms; CODESYS CNC IEC standard
Industrial Use Cases
- ⚙ Metal milling and turning centers
- ⚙ Plasma and laser cutting machines
- ⚙ Router and engraving machines (wood/foam)
- ⚙ Coordinate measuring machines (CMM)
- ⚙ PCB circuit board milling system
// Basic CNC vs. Advanced CNC Controller
| Criterion | ❌ Basic Controller | ✅ Advanced CNC (This Project) |
|---|---|---|
| Contouring accuracy | ±0.5 mm | ±0.005 mm |
| G-code compatibility | G0/G1 only | G0/G1/G2/G3/G4 |
| Feed rate | Fixed | Override 0–400% |
| Toolpath preview | None | Real-time |
| Circular interpolation | None | G2/G3 supported |
// Typical Application Parameters
| Parameter | Value | Unit / Note |
|---|---|---|
| X stroke | 500 | mm |
| Y stroke | 400 | mm |
| Feed rate (max) | 5000 | mm/min |
| Speed override | 0–400 | % |
| Software | PLC Desginer, CODESYS | CNC IEC |
| Servo | Lenze i750 | 3-axis |
| EtherCAT | 1 | ms |
// G-Code Command Set
| Code | Function | Description |
|---|---|---|
| G0 | Rapid Positioning | Tool lifted, rapid move at max speed without cutting |
| G1 | Linear Interpolation | Linear cut at feed rate specified by F parameter |
| G2 | Clockwise Arc | Clockwise circular motion via I, J or R parameters |
| G3 | Counter-Clockwise Arc | CCW circular motion via I, J or R parameters |
| G4 | Dwell | Waits P milliseconds for coolant or spindle stabilization |
| G17 | Select XY Plane | Sets work plane to XY for circular interpolation |
| G21 | Metric Units | All coordinates interpreted in millimeters |
| G28 | Return to Reference | Tool returns to machine zero (home) reference point |
| G40 | Cancel Tool Radius Comp. | Cancels tool radius compensation activated by G41/G42 |
| G41 | Tool Comp. Left | Offsets tool center to the left of the programmed path |
| G90 | Absolute Mode | Coordinates measured from workpiece origin (default) |
| G91 | Incremental Mode | Coordinates given incrementally from current position |
| G94 | Feed Rate mm/min | F parameter defines feed rate in millimeters per minute |
| F | Feed Rate | Cutting speed for G1/G2/G3 (mm/min); higher = faster, lower quality |
| S | Spindle Speed | Spindle rotational speed (RPM); adjusted for material and tool diameter |
| M3 | Spindle CW Start | Starts spindle clockwise (used together with S command) |
| M5 | Spindle Stop | Stops the spindle; for safe stop after cutting operations |
| M6 | Tool Change | Switches to the tool specified by T parameter (T1–T99) |
| M8 | Coolant On | Activates coolant; improves cutting temperature and tool life |
| M9 | Coolant Off | Shuts off coolant; before program end or tool change |
| M30 | Program End & Reset | Ends program, rewinds to start and resets machine to ready state |
// Cycle Phases
READ
Next G-code block is read
CALC
Path length and speed calculated
MOVE
Tool tip moves via interpolation
CUT
G1/G2/G3 generates cut path
NEXT
Block complete, advance to next