Author's): Rajesh Swamy
Originally published in Towards Artificial Intelligence.
CNC construction
Since the AI brain was ready to make machining decisions, it was time to help it body – the CNC machine itself.
This phase focused on making it fully functional three-axis dental CNC prototypeable to interpret toolpaths generated by artificial intelligence and execute them precisely.
The goal was clear:
Build a stable, compact and intelligent CNC that can cut, measure and learn – all under local control.
CNC equipment overview
The CNC system was built from the ground up as a prototype, from the mechanical frame to the firmware.
Mechanical design
- Axles: 3-axis gantry system (X, Y, Z) using linear rails and ball screws.
- Draft Envelope: 800 mm × 1800 mm × 300 mm – large enough for dental frameworks and precision prototypes.
- Spindle: ER20 collet, 24,000 rpm, 2.2 kW high-speed, air-cooled spindle, ideal for precise dental machining.
- Drive system: DM860H stepper drivers with NEMA 34 motors, micro-stepping configured for smooth movement.
- Frame: Rigid extruded aluminum construction for vibration stability and dimensional accuracy.
- Sensors: Limit switches on all axes, emergency stop, spindle current sensor and IMU vibration sensor for tool status telemetry.
Electronics and control
- Controller: Based on Arduino GRBL version 1.1 firmware on ATmega 328P.
- Power electronics: Power supply 48V for motors, 24V for control logic and relays.
- Interface: USB serial (115,200 bps) connected to the host computer running the GRBL streamer.
- Telemetry sensors:
- Spindle Feedback – RPM (Hall sensor)
- Current feedback (Hall effect transducer)
- Vibration data of the 3-axis IMU


GRBL firmware and motion control
At its heart is traffic control GRBL version 1.1lightweight, open-source G-code interpreter.
Why GRBL:
- Runs on inexpensive 8-bit hardware.
- It offers precise motion planning with acceleration control.
- Supports PWM-based spindle control and probing.
- Easily integrates with Python streaming libraries.
Configured parameters for our 3-axis configuration:
$100=160.000 (X steps/mm)
$101=160.000 (Y steps/mm)
$102=200.000 (Z steps/mm)
$110=3000.000 (X max rate)
$111=3000.000 (Y max rate)
$112=1000.000 (Z max rate)
$120=100.000 (X accel)
$121=100.000 (Y accel)
$122=50.000 (Z accel)
$30=24000 (Max spindle RPM)
$32=0 (Laser mode off)


GRBL Streaming and Control Pipeline
For a task to be automated, the AI-generated G-code must be sent line-by-line to GRBL.
We evaluated several open source streamers:
A selection of G-code streaming and control tools
During development, we explored several G-code streaming and CNC communication tools – each serving a different purpose in our workflow.
We started with bCNC AND OpenCNCPilot.
OpenCNCPilot was particularly useful in the early stages of research and development. It provided visual feedback, height probing, and tool path simulation – all of which helped us solve surface movement and consistency issues.
bCNCon the other hand, it has proven valuable for interactive testing and calibration. Its macro system and probing support were essential in verifying tool offsets and machine accuracy.
We chose the production pipeline grbl-streamer – a lightweight Python-based streamer that integrates perfectly with our AI inference workflow. It allows you to send G-code files directly from the Python automation layer to GRBL, supporting line-by-line commands with precise synchronization and error handling.
This approach allows AI to generate a toolpath and send it directly to the CNC without human intervention, effectively closing the gap between prediction, execution and feedback.
import serial, timedef stream_gcode(port, filename):
with serial.Serial(port, 115200, timeout=1) as cnc:
time.sleep(2)
cnc.write(b"rnrn") # wake up GRBL
cnc.flushInput()
for line in open(filename):
cmd = line.strip()
if cmd:
cnc.write((cmd + "n").encode())
resp = cnc.readline().decode().strip()
print(f"{cmd} -> {resp}")
cnc.write(b"M30n") # program end
# Example
stream_gcode("/dev/ttyUSB0", "rough_pass.gcode")
This Python script supports queuing, flow control, and real-time status reporting.
G-code files are created automatically FreeCAD command-line interface using AI-predicted meta-processing.

Integration of AI and GRBL control
The control pipeline connects AI decision engine With CNC executive system: :
- AI Output: Machining meta (chamfer, tool, feed, step, depth).
- CAM Generation: FreeCAD CLI builds toolpaths.
- Execution: G code streamed by Python to GRBL.
- Monitoring: RPM, vibration and current streamed via MQTT for feedback.
- Completion: The finished detail is sent for 3D scanning and inspection.
This creates real time closed loop — the machine performs learning based on its own telemetry.
Abstract
The CNC prototype based on the ER20 spindle with a power of 2.2 kW implements the decisions of the AI system, turning predicted machining parameters into motion.
This physical execution closes the gap between data and material – allowing the machine to operate, sense, and feed information back to improve subsequent cycles.
Then we move on to Implementationwhere every component – AI, CAM, GRBL and 3-D inspection – combines into one automated workflow.
Published via Towards AI


















