This is a RaspberryPi Zero-compatible add-on board that can be used to control up to 2 stepper motors using GCode commands. The board works with the non-Wifi (Pi Zero) and the Wifi version (Pi Zero W). It should also work with a standard Raspberrypi, although I have not tested this.
The hat has an on-board AVR Mega328P micro-controller that runs the GRBL firmware, 2 sockets for Pololu-compatible Stepper boards (e.g. DRV8825 and compatible) and connectors for the stepper motors, limit switches, stepper motor power and an extra I2C connector that is wired to the Pi Zero I2C contacts.
The big benefit of this arrangement is that the AVR takes care of all the timing-sensitive tasks, so that the Raspberry Pi can do other things.
See the bill of materials below.
Use the brilliant interactive HTML-BOM generated by the brilliant BOM KICAD plugin from openscopeproject to populate the board.
Make sure the populated board is not connected to the Raspberrypi. Use the ICSP connector on the front of the board to upload the GRBL firmware using e.g. avrdude and a compatible programmer.
With the Raspberrypi turned off, plug the GRBL hat board into the Pi header, so that the 2 boards are aligned to each other. Do not connect anything to the GRBL hat yet.
In order for the communication to work, the on-board serial board of the Raspberrypi has to be enabled with raspi-config: run raspi-config in a terminal, go to Interfacing Options -> Serial -> No to login shell -> Yes to enable serial port hardware. After rebooting, you should have a new serial port accessible as /dev/ttyS0.
Connect to Grbl using the serial terminal of your choice. Set the port to /dev/ttyS0 and the the baud rate to 115200, 8 bits, no parity, 1 stop bit (8N1). One possibility is to use miniterm:
miniterm /dev/ttyS0 115200
Once connected, you will not see anything (GRBL started when the Pi was plugged into power).
Type $ and press enter to have GRBL print a help message. You should not see any local echo of the $ and enter. Grbl should respond with:
[HLP:$$ $# $G $I $N $x=val $Nx=line $J=line $SLP $C $X $H ~ ! ? ctrl-x] ok
Congratulations, you have a working GRBL controller connected to your Pi Zero!
Shut down the Pi and disconnect power. Next, connect two stepper driver boards (e.g. 2x Pololu DRV8825 driver board). Make sure you get the orientation correct.
Then connect the motor power supply and set the current using the trimpot on the driver boards. Disconnect motor power, plug in 2 stepper motors (e.g. NEMA17 form factor) and apply motor power again.
Turn on power to the Pi and log in via ssh. Run the following commands from a terminal to test the motors:
stty -F /dev/ttyS0 115200 # set baud rate to 115200 baud cat testing/test.gcode > /dev/ttyS0
This should move first the x-axis to 45 degrees and back, followed by the y-axis. If there is jerky motion or no motion at all, make sure that the wire connections to the steppers are good.
The Raspberrypi board communicates with the GRBL controller over the on-board serial port /dev/ttyS0. The serial port needs to be configured to 115200 baud, 8 databits, 1 stopbit, no parity (8N1).
The stepper resolution is set to 32 microsteps in hardware, this cannot be changed. For a standard stepper with 200 steps per revolution this gives 200*32/360 = 17.778 steps per degree.
Look at the GRBL wiki for any GRBL related questions.
Ref | Qty | Value | Part | Mouser part |
---|---|---|---|---|
A1 | 1 | AXIS_X | Pololu DRV8825 module | |
A2 | 1 | AXIS_Y | Pololu DRV8825 module | |
C1 C2 | 2 | 100n 0805 | ||
C4 C5 | 2 | 33p 0805 | ||
C8 C9 | 2 | 100u dia 6.3 25V | ||
J1 | 1 | GPIO_CONNECTOR | pin header 2x20 | |
J2 | 1 | ISP | pin header 2x03 | |
J3 | 1 | LIMIT_X | JST PH B2B 1x02 vert | |
J4 | 1 | LIMIT_Y | JST PH B2B 1x02 vert | |
J5 | 1 | VMOT | JST PH B2B 1x02 vert | |
J6 | 1 | MOTOR_X | JST PH B2B 1x04 vert | |
J7 | 1 | MOTOR_Y | JST PH B2B 1x04 vert | |
J8 | 1 | I2C | JST PH B2B 1x04 vert | |
R1 | 1 | 1M 0805 | ||
R2 | 1 | 10K 0805 | ||
U1 | 1 | uC TQFP-32 | Microchip ATmega328P-AU | 556-ATMEGA328P-AU |
Y1 | 1 | 16MHz ABM3 | Abracon ABM3-16.000MHZ-B2-T | 815-ABM3-16-D2Y-T |
- [ ] use less pins on the Raspi connector + cutout in PCB
- [ ] add photos of the finished board