This semester I decided to pursue the idea of building a desktop CNC router using BeagleBoard's PocketBeagle as the gcode processing unit. My intial attempt was to use MachineKit, a fork of LinuxCNC, as my gcode processing software, but after exploring the option for a while I determined that it was no longer supported to the extent that I would need to complete the project. I was able to successfully implement BeagleG, a gcode interpreter built by GitHub user Henner Zeller.
The Process:Mechanical-
I started the project with the mechanical side. After ordering the variety of linear motion guides and lead screws, I started printing the necessary PLA fixtures. Using a Prusa i3 MK3 printer, I printed the parts with 40% infill and an increased wall thickness (6 layers) to increase the strength of load bearing parts -- this part takes a minute, about 85 hours of print time with the way I had my parts sliced. I could then assemble, using Nikodem's project as a guide. I ordered longer lead screws and linear motion rods than I needed, so I used a chop saw to cut them to length.
Electrical-
CNC machines are pretty simple electronically; they consist of a GCode interpreter (PocketBeagle), Stepper Motor drivers, and the Stepper Motors themselves. These parts when combined allow you to control X, Y, and Z axis movement by turning lead screws through prescribed angles to achieve linear motion. I chose to use 4 Stepper Motors so that the X axis (the long axis on my machine) could have a lead screw on each side to aid in smooth movement across such a long range.
The Stepper Motor drivers that I chose to use were a4988 motor drivers, which could easily be used with this Arduino motor driver shield. So naturally the first step I took was to plug everything in and test the assembly with a Arduino running GRBL CNC software.
At this point I knew that everything should function if driven correctly, so it was time to pursue driving the project with the PocketBeagle.
MachineKitStruggles-
My initial hope was to use the open source project LinuxCNC, to take advantage of the real time kernel available with the BeagleBoard ecosystem in conjuction with the tiny footprint of the PocketBeagle. I found the MachineKit project, a LinuxCNC fork that was configured for small footprint applications like the BeagleBoard. I was very hopeful about implementing this for my project, and after struggling to build the program, I finally had a working copy of MachineKit on my PocketBeagle! But to my chagrin I had no way of configuring or controlling it, due to the lack of display output on the BeagleBoard. I attempted recreating the image and build on a BeagleBoard Black, in order to take advantage of the micro-HDMI output on the board, but was unable to launch the program GUI.
After some additional research I discovered that I should be able to control and configure the build from my Windows machine through USB serial connection. I just needed a program called MachineKit Client. Unfortunately for me this proved much harder to acquire then it should have been. The Windows and Linux binarys were no longer maintained and had bitrotted. I attempted to build the app from the ground up, but the prescribed processes also ended in corruption both on my Windows machine and on a Linux Jessie VM.
My MachineKit journey came to an end here, I determined that at the time of my project, the support to run and control MachineKit through MachineKit Client has degraded past a functional threshold. So it was onto the next idea.
BeagleG:A Success-
With a little more research, I found Henner Zeller's GCode interpreter, BeagleG. This code is written to run with BeagleBoard Black (BBB), PocketBeagle's larger brother that contains the same 1GHz ARM processing unit. Because of this twin element, I could use the equivalent GPIO pinout that Henner used on the BBB but on the PocketBeagle. I followed the build instructions on the github page and started to configure a hardware configuration for my CNC motor driver setup.
The hardware setup consists of five files:
In order to teach my build how to control my machine I had to first take a look at the pinmapping in the GRBL.pins and beagleg-pin-mapping files. Due to the twin processor pinout between the BBB and PocketBeagle, I was able to leave the beagleg-pin-mapping file alone, with the exception of commenting out the lines for features (like axes 4-8) that I don't need to use. For the GRBL.pins I reassigned the values to the equivalent GPIO pins on the PocketBeagle to the ones that were used on BBB. I then just had to update my Devicetree Source (.dts) in the same way and remake the program declaring my created hardware file as the hardware target.
make BEAGLEG_HARDWARE_TARGET=GRBL
And then I had to overlay the new Devicetree Source that I had created:
sudo start-devicetree-overlay.sh GRBL/BeagleG-GRBL.dts
Finally a quick reboot and I had all my pins assigned!
I then wired my driver shield to my PocketBeagle, making sure to follow the pinning that I had just assigned. I wired 3.3V power to my breadboard and then to my shield, both to the 3.3v input and the 5v input because unlike the Arduino, the PocketBeagle's GPIO is 3.3V. By assigning the 5V input a 3.3V signal, the board then sees the 3.3V signal inputs. I confirmed that the a4988 stepper drivers signal input range was large enough and was able to get around needing to use voltage adjusters.
Lastly I just had to introduce my PocketBeagle to my CNC through the use of a config file. Using a sample config file as a source, I defined my machine size and my axes as well as my machine constraints (feedrate, homing configuration, etc). I was ready to test!
I ran this sample gcode script:
G28
G21G91X200F1600
G90 G21
Which homed the machine to its current location, then jogged the X axis 200 mm at a feedrate of 1600. I used the machine-control command to finally run the device:
sudo ./machine-control -c My.config test.gcode
This worked!
FinalTouches-
My CNC can now parse GCode and run through commands on all three axes. I used Fushion360 to setup GCode to cut various parts, an intially confusing but necessary process.
I then just had to add my 500W Spindle. I screwed it into the mount that I had printed, and soldered longer leads onto its power wires.
The power supply that came with the spindle was intimidating at first, it required connecting 110V supply power. I took a three prong computer power cord and added an inline 6 Amp fuse for safety, and then attached it to the supply and hoped for the best.
The spindle powered right up and I can now control the speed with a potentiometer.
Here's a video of it running with a test gcode file:
FuturePlans:
I plan to do a couple things with this machine, first of which is establishing a home point through limit switches. With this home point I should be able to more accurately develop gcode files for use on it.
Additionally I want to explore replacing the spindle with other toolheads, like a sharpie or pen for instance. As a plotter the device could be used to write out lots of test or create cool patterned drawings.
Comments