Raspberry Pi CNC

From Protoneer - Wiki
Jump to: navigation, search


RPI-CNC-V260 - Top - Pololu.JPG

The RPI CNC Board combines a real-time CNC controller(Micro-controller running GRBL) with a powerful credit card size computer(Raspberry Pi).

By combining the two systems we have created an eco-system where the Raspberry Pi provides benefits like: Processing power, connectivity(IOT) and a well supported community.

The board plugs directly into the Raspberry Pi General Purpose Input/Output pins, with the micro-controller and Raspberry Pi communicating via serial. (/dev/ttyAMA0)

Availability, Update Notifications and Forums

Available online:

caption Protoneer Shop

200pxcaption Zyltech - North American distributor

caption www.BuyaPi.ca - Canadian Distributor caption www.piShop.us - USA Distributor

caption MyBotShop.de - Germany - info@mybotshop.de

Newsletter and Forum

Raspberry Pi CNC Board News-Letter
Raspberry Pi CNC board forum section


This products main objective is to provide an affordable Do-it-yourself CNC solution to hobbyists. We can't guarantee that this product will function as intended in industrial environments. We don't take responsibility of damages,injuries or deaths caused directly or indirectly by this product. CNC products are inherently dangerous and we urge user to take care and mind your health and safety first.

Installation and configuration

IMPORTANT: None of the components should be powered while installing or configuring.

Quick Start Guide

WARNING: Do not power up the board with stepper drivers installed if they are not connected to stepper motors. The stepper drivers are current limiting and will overheat if they are not connected.

WARNING: Make sure to plug in the Stepper driver in the right way round. EN of each axis should align with the "Enable" pin of the stepper driver. (Some Chinese stepper drivers have the printed pin names up side down.)

Raspberry Pi CNC - Quick Start Guide


Raspberry Pi CNC Hat Schematics

Wiring Diagram

Dimensions: PCB is 55x89mm and with green connectors 59x93mm


RPI-CNC-260-LeftPinout.jpg Click image to enlarge

  • Pin 1 - 2 : Spindle Direction Pins
  • Pin 3 - 4 : PWM Spindle Pins
  • Pin 5 - 8 : End-stop pins and Probe pin
  • Pin 9 - 10 : Coolant Pin
  • Pin 11 - 12 : Main Power Pins - 12-36V (Check polarity!!!)

RPI-CNC-260-StepperConfig.jpg Click image to enlarge

  • Micro Stepping Pins with pin 3 at the top.
  • Stepper Coils indicated with A and B.

Powering the Hat

The MCU is powered by the Raspberry Pi and runs at 5V(Level shifters are in place to allow the MCU and Pi to communicate at diverant logic level voltages).

The external power supply connectors power the Pololu compatible stepper drivers. External driver setup's don't need the external power to be hooked up.

Micro Stepping Jumpers

Jumpers number are indicated as follow:


In the tables below High indicates that a Jumper is inserted and Low indicates that no jumper is inserted.

Pololu A4988 Link
Jumper 1 Jumper 2 Jumper 3 Microstep Resolution
Low Low Low Full step
High Low Low 1/2 step
Low High Low 1/4 step
High High Low 1/8 step
High High High 1/16 step
Pololu DRV8825 Link
Jumper 1 Jumper 2 Jumper 3 Microstep Resolution
Low Low Low Full step
High Low Low 1/2 step
Low High Low 1/4 step
High High Low 1/8 step
Low Low High 1/16 step
High Low High 1/32 step
Low High High 1/32 step
High High High 1/32 step

End Stops

End Stops use normally-open push-button type switches. The End-stop socket shares a common ground that connects to each axis end-stop. The pins are pulled high by the micro controller's internal pull-ups and will activate the end-stop when the pin is connected to ground.


GRBL v0.9 setting $21 needs to be set to 1 to activate hard-limits. Setting $22 also activated the Homing functionality.

V2.51 Introduces End-stop and Probe line filters to prevent noise on the lines.

Endstops can also be doubled up in parallel. 2xEndstops.png

Clone Drive (Introduced with V2.51)

The 4th Stepper Driver Socket can be configured to clone any of the other Axes. Configuration is done with the two rows of solder-able jumpers situated under the board.


In the images above the green sections indicates a jumper positions to configure the 4th Stepper Motor Socket.

!!! The A3 / A4 jumpers are for custom software and allows control of Socket 4 with the A3/A4 pins. !!!

External Driver Boards

External driver boards are great for use with larger external driver like Gecko drivers and TB660 drivers.

The external driver board redirect signals through the green screw connectors on the Raspberry Pi CNC hat and makes it super easy to hook up.

Pin-outs below:

Current version and wiring of the External driver...


The above image has been corrected as the pin names was inverted.

Old Raspberry Pi CNC Hats before V2.6 are orientated this way... PreVersion2.6.png

Button Controls

The buttons : RESET,ABORT,HOLD,RESUME work with normally open buttons and gets activated when grounded. All buttons are pulled high.

Reset restart the board completely. (Hardware reset and homing needed.)

Abort cancels the current movement but keeps the state of the current machine. (Homing not needed, all done via GRBL)

Coolant, Spindle Direction, Spindle Speed

GCode Commands:

  • S0 - S1000 - This command set the spindle speed. (0-1000 with 1000 being 100% speed.)
  • M3 / M4 - Enables the spindle clockwise or anti-clockwise. The Spindle Direction pin is set accordingly(Anti-clockwise turns direction pin high). Sets the Spindle speed pin accordingly.
  • M5 - Disables and pulls spindle pin low.

Examples: M3 S500 -> Enables spindle in clockwise direction at 50% speed.

Keep in mind that the direction pin does not reset when the M5 command is used.


GCode Commands:

  • M8 - Enables the coolant and pulls the pin high.
  • M9 - Disables and pulls the pin low.


The probe pin and ground can be connected to a Normally-open switch. Software like bCNC has probe functions and can be used with this board.

Connection To Raspberry Pi

Pinout of the Atmel Atmega328 pins connected to the Raspberry Pi. RPI-CNC-Pins-Connected-To-Pi.png

Grove Connector

This is great for connecting I2C devices directly to the Raspberry Pi. This only works at the Raspberry Pi's 3.3V voltage levels.

Software (Firmware)

In order for the GRBL to communicate with the Raspberry Pi, the hardware serial port on the Raspberry Pi needs to be enabled and working. HobbyTronics has a good tutorial on how to set it up and test it. Raspberry Pi Serial Port setup

Uploading new firmware

Version 2.58+

As of this version firmware can directly be upload from the Raspberry Pi.

Upload procedure

The Raspberry Pi V4.00 image includes script to update the firmware on the Raspberry Pi CNC HAt.

Upgrade Procedure

  1. Firstly make sure no software is connected to the Hat's serial port.(A clean V4 image will start of in that state) (Only one app can connect at a time and if its being used the firmware will not update.)
  2. On the desktop there is a folder called "Update Firmware" that contains 3 shortcuts for changing the firmware
    1. GRBL 0.9
    2. GRBL 1.1
    3. Latest GRBL (Experimental)
  3. By double clicking one , it will execute a script that uploads the firmware.

Before shipping each board we test the firmware and we use the same script to upload the initial firmware before automated testing starts.

The upload script uses Python GPIO libs and sometimes does not upload the first time while the pins gets configured.(Bootloader timing issue that happens rarely) If so try a second time.

Older version

Firmware gets uploaded from the Nano's usb port.

GRBL Firmware

GRBL is the magic that does the actual control of the CNC machines.

For more details : GRBL

The Raspberry CNC board comes pre-loaded with GRBL but can be updated as follows : Flashing Grbl to an Arduino


Will be added soon.


Raspberry Pi Serial TroubleShooting


Version 2.60

  • Added a Grove Connector to allow I2C connections directly to the Raspberry Pi.
  • Green Screw connectors changed from 3.5mm pitch to 3.81mm pitch.
  • Moved Stepper Drivers inline.

Version 2.58

  • Replaced the Arduino Nano with a embedded micro-controller(ATMEGA328 - Arduino UNO compatible)
  • Add reset circuitry to enable programming directly from the Raspberry Pi. ISP pins added and preloaded with the Opti-Boot bootloader. This opens the door for other firmwares like Firmata.
  • Replaced clone jumpers with solder-able jumpers.
  • Later batches might have dip-switches instead of Jumper headers.
  • First Protoneer board to be mode on our Pick and Place machine.

Version 2.51

  • Extra Stepper Drivers Socket that can clone one of the other Axes.
  • End-stop + Probe line noise filters. Allows end stops to work with normal un-shielded cable.
  • Breakout pins allowing external Stepper drivers to be hooked up.
  • Wiki Page - http://wiki.protoneer.co.nz/Raspberry_Pi_CNC_v2.51

Version 2.11

  • Initial Version
  • 3-Axis (XYZ)
  • End Stop for each Axis (XYZ)
  • Variable Speed Spindle / Laser Intensity control (PWM Spindle pin and Direction pin)
  • Coolant control pin. (Extra output pin)