Why Connect Your CNC Router to an AI Agent?
If you're running a CNC machine with GRBL or Marlin firmware, you already know the drill: you send G-code, the machine cuts, and you hope nothing jams. But what if your machine could talk to an AI agent that monitors conditions, predicts failures, and even adjusts parameters in real time? That's exactly what ASI Biont does. It's an AI agent that connects to virtually any device—including your CNC controller—through a conversation. No dashboards, no custom panels, just chat.
In this guide, I'll walk you through how ASI Biont integrates with GRBL and Marlin machines, how you can set it up with the Hardware Bridge, and how to automate monitoring and control using plain English. Whether you're a hobbyist with an Arduino-based GRBL shield or a shop floor operator with a Marlin-based 3D printer converted to CNC, this approach works.
How ASI Biont Connects to CNC Controllers
ASI Biont supports multiple connection protocols, but for GRBL and Marlin the most practical is serial over COM port (RS-232/RS-485 via the Hardware Bridge). The bridge is a small Python application you download from your ASI Biont dashboard. It opens the COM port and exposes it to the AI agent using a simple command interface. Once the bridge is running, you can send G-code, read status, and receive responses directly through chat.
Why serial? Because GRBL and Marlin are designed to communicate over a serial UART interface. The bridge handles the low-level serialization, so you don't need to write a line of protocol handling. If you have a more advanced industrial controller that speaks Modbus or MQTT, ASI Biont can also connect via paho-mqtt, pymodbus, or even OPC-UA. For this article, we'll focus on the typical GRBL/Marlin setup.
Setting Up the Hardware Bridge
First, download bridge.py from the ASI Biont dashboard. Don't fetch it from GitHub—the version from the dashboard is guaranteed to work with the agent. Connect your CNC controller (e.g., Arduino Uno with GRBL) via USB and find the correct COM port. On Windows it might be COM3, on Linux /dev/ttyACM0. Then run:
python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=115200 --rate=10
This opens COM3 at 115200 baud and refreshes state messages 10 times per second. The bridge will detect the GRBL startup banner (e.g., Grbl 1.1h) and let the AI agent know the machine is ready.
Interacting with the CNC via Chat
Once the bridge is running, you can open the ASI Biont chat and say something like:
"Check the current position of the CNC and run a home cycle."
The AI agent will interpret this, call industrial_command with the appropriate serial command, and send the result back. For the bridge, the Python call looks like this:
industrial_command(protocol='serial', command='?', port='COM3', baud=115200)
This returns the GRBL status string, e.g., `<Idle
|MPos:0.000,0.000,0.000|FS:0,0>`. The AI parses it and tells you the machine is idle at the origin.
Practical Example: Monitoring a Job and Getting Alerts
Let's say you're running a long engraving job and want to know when it finishes, plus catch any spindle overload. You can tell the agent:
"Start sending me a Telegram message when the machine goes idle, and also if the feed rate drops below 50% for more than 5 seconds."
The AI writes a Python script that uses pyserial to read GRBL status periodically (you can do this in an execute_python call with a 30-second timeout, or better, use the bridge's continuous stream). The script might look like this:
import serial, time, requests
ser = serial.Serial('COM3', 115200, timeout=1)
while True:
ser.write(b'?')
resp = ser.readline().decode().strip()
if '<Idle' in resp:
requests.post('https://api.telegram.org/bot<YOUR_BOT>/sendMessage', data={'chat_id': '<chat>', 'text': 'CNC job finished'})
break
# parse feed rate and logic here
time.sleep(1)
In reality, inside execute_python you'd avoid an infinite loop because of the 30-second timeout. Instead, the AI agent uses the bridge's --rate option to sample the machine, or it triggers a longer job monitoring script via execute_python that runs one check per invocation. The point is: you don't write this code yourself. You describe the desired behavior, and AI writes it.
Going Further: Predictive Maintenance with Marlin
Marlin firmware (often used on 3D printers converted to CNC) provides detailed temperature and step-loss telemetry. ASI Biont can read those values over the same serial connection. You can ask:
"Monitor the stepper current and temperature. If the hotend temperature deviates by more than 5 degrees, warn me in the chat."
The AI agent will generate a script using serial to send M105 (read temperatures) and M122 (diagnostics) commands, parse the responses, and set up alerts. This is where the real value kicks in—you get predictive maintenance without touching a single sensor.
The Power of execute_python for Anything Else
What if your CNC isn't directly serial-compatible or you want to integrate with a tool changer over Modbus? No problem. ASI Biont's execute_python lets the AI write and run any Python script in a sandbox. You just describe your device's protocol, and the AI produces code using pyserial, pymodbus, paramiko, or aiohttp. For example:
"Connect to the Modbus TCP on 192.168.1.50 and read holding register 100 for the tool changer position."
The AI will generate a script like:
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.1.50')
client.connect()
rr = client.read_holding_registers(100, 1)
print(rr.registers[0])
client.close()
This means you're not locked into a single protocol. If your controller runs Linux and speaks SSH, the AI can use paramiko. If it exposes a WebSocket API, it'll use aiohttp. There's no need to wait for the ASI Biont team to add a
Comments