Arduino 的 GRBL 库 – 使用 Arduino 的 IDE 直接烧写 GRBL 到您的 Arduino

GRBL Arduino Library – Use the Arduino IDE to flash GRBL directly to your Arduino

We have created an Arduino Library of the popular GRBL g-code Interpreter. A great little application that turns your Arduino into a very capable CNC machine.

GRBL,是广受欢迎的  G 代码解释器型 Arduino 库。一个很棒的小应用程序,借助它,可以把你的 Arduino 变成一个非常能干的 CNC 控制器。

This library makes it so much easier to install GRBL onto your Arduino. No more issues with making HEX files or trying to find a way to upload the Hex file to your board. Simply install the library and open the right example sketch for your Arduino.

这个库使得安装 GRBL 到您的 Arduino 容易得多。无需生成 HEX 文件,也无需努力寻找将 HEX 文件上传到你的主板的方法了。只需安装这个库文件,然后打开 Arduino 相应的 sketch 示例文件。


  • 从 GitHub 下载库文件:GRBL Arduino Library
  • 解压缩库文件,然后将解压缩后的文件夹复制到你的 Arduino 软件安装目录下的 Libraries 文件夹内。例如 C:\arduino-1.0.3\libraries\;
  • 将该文件夹重命名为“GRBL”;
  • 打开 Arduino IDE;
  • 点击以下菜单:文件 -> 实例 -> GRBL -> Arduino Uno
  • 将 sketch 上传到你 Arduino Uno 板。


配置 Grbl

Grbl has a system ‘$’-command to tweak the settings and trigger runtime commands. Connect to Grbl using the serial terminal of your choice (baud rate 9600 unless you changed that in config.h) as 8-N-1 (8-bits, no parity, and 1-stop bit.) Once connected you should get the Grbl-prompt, which looks like this:

Grbl 有一个系统“$” – 命令来调整设置和触发运行命令。使用您所选择的串行终端连接 Grbl(默认 波特率 9600 除非你在 config.h 更改过)8-N-1(8 位,无奇偶校验,1 停止位)一旦连接你会收到 Grbl 提示,就像这样:

Grbl 0.8c ['$' for help]

Type $ and press enter. You should not see any local echo of the $ and enter, but Grbl should respond with a help message:

输入 $ 并按回车键。Grbl 会返回一些帮助信息: 继续阅读“配置 Grbl”

关于 Grbl

Grbl is a free, open source, high performance software for controlling the motion of machines that move, that make things, or that make things move, and will run on a straight Arduino. If the maker movement was an industry, Grbl would be the industry standard.

Grbl 是一个免费,开源的,用于控制机器移动的高性能运动软件,让事物,或使物体运动,并将直接在 Arduino 上运行。如果创客运动是一个产业,那么 Grbl 将成为行业标准。

Most open source 3D printers have Grbl in their hearts. It has been adapted for use in hundreds of projects including laser cutters, automatic hand writers, hole drillers, graffiti painters and oddball drawing machines. Due to its performance, simplicity and frugal hardware requirements Grbl has grown into a little open source phenomenon.

大多数开源 3D 打印机是基于 Grbl 为核心。其已经适用于成百上千的项目包括激光切割机,自动手作家、钻孔机,涂鸦画家和怪异的绘图机。由于其高效,简单和极低的硬件要求 Grbl 已经成为一个小的开源事迹。

In 2009, Simen Svale Skogsrud graced the open-source community by writing and releasing the early versions of Grbl to everyone (inspired by the Arduino GCode Interpreter by Mike Ellery). Since 2011, Grbl is pushing ahead as a community-driven open-source project under the pragmatic leadership of Sungeun K. Jeon Ph.D.

2009 年,Simen Svale Skogsrud  受惠于开源社区的贡献编写并向所有人发布了 Grbl 的早期版本(灵感来自于 Mike Ellery 的 Arduino G 代码解释器)。2011 年以来,Grbl 在 Sungeun K. Jeon 博士务实的领导下作为一个社区驱动的开源项目在推进。

连接 Grbl

This wiki is intended to provide various instructions on how to connect to grbl in various ways. Please feel free to contribute more up-to-date or alternative methods.

这个维基旨在提供如何以不同的方式连接 Grbl 的各种说明。请随时提供更多最新的或替代的方法。

Grbl 的针脚

Pin diagram for Grbl v0.8 and v0.9 with the traditional layout: (NOTE: The probe A5 pin is only available in Grbl v0.9.)

Grbl V0.8 和 V0.9 与传统的布局引脚图(注:探头 A5 引脚仅在 Grbl v0.9 提供。)


For Grbl v0.9 with variable spindle PWM ENABLED: (NOTE: The Z-limit and the spindle enable pin are swapped, because we had to access the hardware PWM on D11 for variable spindle PWM output to work.) We are still updating this pin configuration at the moment by weighing future options. We’d like to only change the pins once. Stay tuned!


First, to connect your stepper motors to Grbl, you’ll need some stepper motor drivers to power the steppers and connect your driver inputs to the Arduino controller pins. There are a number of drivers that can do this, available as fully pre-built, partially pre-built, or completely DIY. There are some examples farther down the page. The stepper drivers will need to share the stepper enable pin (D8) to their respective enable pins, while the direction and step pulse pins (D2-D7) will need to be connected to their respective pins on the drivers. Just make sure that all of your drivers and the Arduino share a common ground (star grounded with your motor driver power). This is about all you’ll need to get started.

Afterwards, once you decide that you’re ready or would like to enable homing and/or hard limits, you’ll need to connect a normally-open limit switch to each of the limit pins (D9-D11). Homing and hard limits use the same switches. These limit pins are already held high with an internal pull-up resistor, so all you have to do is wire them to ground. So when you close a switch, the switch will pull the limit pin to ground. If you’d like to have hard limit switches on both ends of travel of an axis, just wire two limit switches in parallel to the axis limit pin and ground. Make sure you have the switches installed before attempting to perform a homing cycle, and make sure you practice good wiring methods to minimize external electric noise on the input pins.


In Grbl v0.8 and later, there are pin-outs of the cycle start, feed hold, and reset runtime commands, so you can have physical control buttons are your machine. Just like the limit pins, these pins are held high with an internal pull-up resistor, so all you have to do is connect a normally-open switch to each pin and to ground. Again make sure you practice good wiring methods to minimize external electric noise on the input pins.

在 Grbl V0.8 及更高版本,有循环启动的引脚,进给保持,和复位运行命令,这样你可以为你的机器添加物理控制按键。就像限位引脚,这些引脚具有内部上拉电阻高高举起,因此,你所要做的就是将一个常开开关连接到每个引脚并接地。再次确保你已养成良好的布线方式,以尽量减少输入引脚上的外部电噪声。

If you have a desire or need for spindle or coolant control, Grbl will toggle these output pins (D12, D13, A3) high or low, depending on the G-code commands you send to Grbl. With v0.9 and variable spindle PWM enabled, the D11 pin will output a range of voltages from 0V to 5V depending the spindle speed G-code command. 0V indicates spindle off in this case. Since these pins are all application dependent in how they are used, we’ll leave it to you to determine how to control and use these for your machine. You can also hack the spindle and coolant control source files to easily alter how they work and then compile and upload your modified Grbl through the Arduino IDE.

如果你需要主轴或冷却液控制的要求,Grbl 将切换这些输出引脚(D12,D13,A3)的高低状态,根据 G 代码指令发送到 Grbl。随着 V0.9 版本可变速主轴 PWM 的启用,根据主轴转速G代码指令 D11 引脚将输出从 0V 到 5V 的电压范围。在这种情况下 0V 表示主轴关闭。以后这些引脚,如何使用它们都取决于所有应用程序,如何使用这些控制你的机器由你决定。

Arduino 的开源 CNC 控制器 GRBL (G 代码解释器)

Opensource CNC controller written for Arduino’s (G-code interpreter GRBL)
Arduino 的开源 CNC 控制器 GRBL (G 代码解释器)

Traditional CNC machines used old-fashioned printer / parallel ports to connect to a computer.The computer then sends the signals to the motor’s over individual cables.
传统的数控机床使用老式打印机 / 并行端口连接到计算机。然后计算机通过单独的连线将信号发送到马达端。

So why would you want to use a Arduino powered CNC controller?
那么 为什么你会选择 Arduino 驱动的 CNC 控制器呢?

Well the team from Dank that developed the software called Grbl have a few good reason for doing so. Here are their reasons..
好的,来自 Dank 的软件开发团队称 Grbl 有充份的理由让你这样做。这是他们给出的理由…

Who should use Grbl
谁会使用 Grbl

  • Makers who do milling and need a nice, simple controller for their system
    制造商的铣削系统需要一个友好的、 简单的控制器
  • People who loathe to clutter their space with legacy PC-towers just for the parallel-port
    那些讨厌杂乱的旧的塔式 PC 并行端口的人
  • Tinkerers who need a controller written in tidy, modular C as a basis for their project.
    超级玩家需要一个可写入的控制器,为他们以 C 作为基础的模块化项目

I can actually think of a lot more than just those.With a bit of tinkering you can actually make your CNC machine run in headless mode where you just upload your design to the Arduino and the machine will do the rest without the need of a PC.
事实上,我能想到的不仅仅是这些还有更多,稍微改造下,你可以让你的数控机床在无上位机的模式运行,只要上传你的 Arduino 设计,机器无需再连接计算机就会工作。

You could also add a Wireless connection to the Arduino allowing you to remotely control your CNC machine from a mobile device.
你还可以为 Arduino 添加一个无线连接,以允许你从移动设备远程控制您的数控机床。