Raspberry Pi CNC (GRBL, CNC.js)

I bought one of these, a really long time ago: http://wiki.protoneer.co.nz/Raspberry_Pi_CNC . It has an arduino running GRBL on it, and it’s connected to the serial port on the raspberry pi. The raspberry pi can run bCNC if you have a monitor connected to it, or you can run CNC.js (https://www.npmjs.com/package/cncjs) and then connect to it from your computer or phone (similar to octoprint).

Pros:

  • Web interface. Very very slick. I was running it on my desk for a few days without any stepper drivers in it, and I was using the preview as a sort of GRBL simulator.
  • No SD cards to mess with.
  • GRBL has the concept of a “machine origin” and a “work origin” and a few “temporary origins”. Nice, if you like that sort of thing.
  • Webcam support, but I haven’t tested that yet.
  • Linux. I love Linux, but you may hate it :slight_smile:
    Cons:
  • Won’t 3D print. I’m not sure how well the laser engraving stuff works with GRBL.
  • Won’t work with the Marlin LCD display.
  • CNC.js supposedly works with a “Contour shuttleXpress”, but it’s $60 on amazon. so, no jog dial for now. There is a breakout for hold/resume/abort buttons though.
  • Costs money.

Setup:
I used the steppers from my RAMPS board. I had to make sure I added all three jumpers under them for 1/32 stepping. Otherwise, I just followed the instructions from prontoneer for the most part, but I’m running it headless, without a keyboard, mouse, or screen. During setup, I also did these things. I did have a monitor connected, although you can do this stuff through ssh, if you know what I mean.

  1. changed the password.
  2. ran raspi-config, and expanded the filesystem, and changed the hostname to mpcnc.

If you have a raspberry pi 3, then there’s also a script that fixes the serial port. I don’t have a pi3, so I can’t tell you how well this works.

Then you can connect to mpcnc.local:8000 from a phone or computer. For the settings, there aren’t many, and you can read about them here:

A simple way to do that is from the “Console” widget in the web server. Some things that slipped my attention the first time:

  • The “step idle delay” will disable the stepper motors all the time if you aren’t moving anywhere. You can set it to 255 to have the steppers always on as long as there is power. I like that because my machine isn’t naturally square, so I turn it on square, and then only make movements with the steppers.
  • The units aren’t the same as marlin. To convert from mm/sec^2 to mm/min^2, you have to multiply by 3600 (60*60).

These are my settings at the moment, but they are definitely on the conservative side:

$0=10 (step pulse, usec)
$1=255 (step idle delay, msec)
$2=0 (step port invert mask:00000000)
$3=0 (dir port invert mask:00000000)
$4=0 (step enable invert, bool)
$5=0 (limit pins invert, bool)
$6=0 (probe pin invert, bool)
$10=3 (status report mask:00000011)
$11=0.010 (junction deviation, mm)
$12=0.002 (arc tolerance, mm)
$13=0 (report inches, bool)
$20=0 (soft limits, bool)
$21=0 (hard limits, bool)
$22=0 (homing cycle, bool)
$23=0 (homing dir invert mask:00000000)
$24=25.000 (homing feed, mm/min)
$25=500.000 (homing seek, mm/min)
$26=250 (homing debounce, msec)
$27=1.000 (homing pull-off, mm)
$100=200.000 (x, step/mm)
$101=200.000 (y, step/mm)
$102=4535.440 (z, step/mm)
$110=1800.000 (x max rate, mm/min)
$111=1800.000 (y max rate, mm/min)
$112=180.000 (z max rate, mm/min)
$120=100.000 (x accel, mm/sec^2)
$121=100.000 (y accel, mm/sec^2)
$122=10.000 (z accel, mm/sec^2)
$130=960.000 (x max travel, mm)
$131=550.000 (y max travel, mm)
$132=200.000 (z max travel, mm)

I also edited the /etc/rc.local and added cnc.js to automatically start up, by adding this line to the end of the file:

su - pi -c /home/pi/.npm/bin/cnc

This script gets ran by root, so this will log in as pi (which has npm installed everywhere) and then starts cnc. You don’t want to run cnc as root, because root doesn’t have the npm environment set up.

If you want to just go to mpcnc.local instead of mpcnc.local:8000, then you have to configure it to forward port 80 to 8000. You can do that with iptables, try googling it.

3 Likes

thanks for the info plan on doing a similar project myself always good to read others notes :slight_smile:
I will be using a pi3 with mine tho since my pi2 is a server lol

Jeff which would you prefer to run on your lowrider? I am getting ready to build a lowrider and have yet to purchase another ramps stack. This sounds like this may be the route to go as I obviously only plan on milling.

 

Neil

I am using grbl on my low rider. But either will work great. Using the web page for gcode upload is great, since the electronics move with the machine. Marlin will support dual endstops soon. Which would be nice.

You can’t really lose. Do what makes you happy.

I was hoping to make you happy :wink:

Sounds good buddy! I just like trying new things. I see a huge benefit in being able to return to multiple set locations (as far as tool change goes). I may have to snag one of these boards and give it a go. Thanks for the info. You have any default settings for the lowrider or do your posted mpcnc settings work just as well as a starting point.

Neil

These are from my Low Rider. I can’t remember why I felt the need to invert the step direction, instead of just flipping the plug…

$$ $0=10 (Step pulse time, microseconds) $1=255 (Step idle delay, milliseconds) $2=0 (Step pulse invert, mask) $3=3 (Step direction invert, mask) $4=0 (Invert step enable pin, boolean) $5=0 (Invert limit pins, boolean) $6=0 (Invert probe pin, boolean) $10=2 (Status report options, mask) $11=0.010 (Junction deviation, millimeters) $12=0.002 (Arc tolerance, millimeters) $13=0 (Report in inches, boolean) $20=0 (Soft limits enable, boolean) $21=0 (Hard limits enable, boolean) $22=0 (Homing cycle enable, boolean) $23=0 (Homing direction invert, mask) $24=25.000 (Homing locate feed rate, mm/min) $25=500.000 (Homing search seek rate, mm/min) $26=250 (Homing switch debounce delay, milliseconds) $27=1.000 (Homing switch pull-off distance, millimeters) $30=1000 (Maximum spindle speed, RPM) $31=0 (Minimum spindle speed, RPM) $32=0 (Laser-mode enable, boolean) $100=200.000 (X-axis travel resolution, step/mm) $101=200.000 (Y-axis travel resolution, step/mm) $102=800.000 (Z-axis travel resolution, step/mm) $110=1800.000 (X-axis maximum rate, mm/min) $111=1800.000 (Y-axis maximum rate, mm/min) $112=180.000 (Z-axis maximum rate, mm/min) $120=100.000 (X-axis acceleration, mm/sec^2) $121=100.000 (Y-axis acceleration, mm/sec^2) $122=10.000 (Z-axis acceleration, mm/sec^2) $130=960.000 (X-axis maximum travel, millimeters) $131=550.000 (Y-axis maximum travel, millimeters) $132=200.000 (Z-axis maximum travel, millimeters)
1 Like

You rock buddy. My board just came in today. I scored a decent deal on it. Zyltech had a 20% off coupon the other week. I got the hat and rpi3 for like 55 bucks. Then dumped another 75 of filament of course (great stuff at a cheap price if you have not tried it. I have put through about 20 rolls of their filament so far. I hope to get this up and running for testing tomorrow. Thanks again Jeff!!

Neil

That’s cool. I bought mine from prontoneer and it took like a month. Shipped from Australia, IIRC. I hope you like it. Let me know if you learn anything awesome it can do. I have half a mind to try klipper on it, but I do like CNC.js.

I just converted mine to use the RPI CNC board. It’s working wonderfully! There seems to be a lot more GRBL compatible software for laser and router use than Marlin based stuff. And a lot more of it is open source free software.

My laser is working a lot better under GRBL than I ever got it working under Marlin. The LaserWeb software works great, and GRBL automatically adjusts laser power while it’s accelerating/decelerating which makes the edges come out a lot better.

The laser is adjust in the firmware of from LaserWeb? That does look like good software, I just rarely use my laser so I haven’t looked into it much.

grbl 1.1 (I think) added a laser mode, which had some neat features, like the aforementioned ability to reduce the power when the firmware is applying acceleration limits. It also does something to reduce buffering as well, I think.

I am also running GRBL, version 1.1 on an official Protoneer shield 3.51. Although i do not run a Pi, i have a cheap desktop PC running CNCjs desktop version. The latest shield from Protoneer allows for PWM spindle speed control on the correct set of arduino pins. I also run the contour shuttle jog wheel, which i really think is a great upgrade if you are willing to spend the money.

My accellerations ended up almost the same as yours, 100 mm/s x and y, but a little faster on Z accel, 50mm/s i think.

I just added limit switches to make tool changes easier. I dont have a laser at the moment but i really like this setup for milling.

It’s the GRBL firmware that does all the heavy lifting, so it doesn’t matter what program you use, as long as you send the command to enable laser mode first. It does a few things when laser mode is enabled:

  • Doesn't stop and wait for spindle to spin up/down anymore
  • Gives the option of constant laser power with M3 (for cutting only), or dynamic laser power with M4
  • When turned on with M4, the laser power gets adjusted relative to the current speed of the machine, so as it slows down the laser gets turned down as well.
  • When not in motion, the laser turns off automatically, so the laser can't accidentally be left on while the machine is at a stop and burn a hole in your table.
  • G0 travel modes will keep the laser off
It requires a laser module that has a 0-5v TTL PWM input for controlling the laser power.

 

I struggled for awhile to find anything that could do raster engraving a picture on the marlin based firmware. I know there are a couple options, but they are either buggy or expensive. With laserweb, I got a recognizable image burned in under 30 minutes. Still plenty of room for tweaking, but its impressive.

 

 

Hi…i am a new user here. In my case i just converted mine to use the RPI CNC board. There seems to be a lot more GRBL compatible software for laser and router use than Marlin based stuff. And a lot more of it is open source free software.My laser is working a lot better under GRBL than I ever got it working under Marlin.

pcb assembly china

Could you put up some links to what you like and use? Lots of users here use GRBL but then tend to be single use cases.

Most stick with marlin because it is easier to be multi-functional, namely 3D printing, also the control board selection. No edits are needed to switch between all the functions show in the gallery with Marlin. Grbl is great but they have not really kept up with all the 3D print specific stuff.

It’s impossible to print with grbl. Hands down, that’s one feature Marlin will never be behind grbl with.

I switched from a RAMPS board to the RPI CNC shield for a couple months now. I love it.

I already have a 3d printer, so my MPCNC is dedicated to routing and lasering stuff. If you don’t need 3d printing, GRBL seems to be the way to go.

For hardware, I’m using:

For software, I've mostly been using Laserweb 4. I don't know if it's made it into the official distribution for the RPI CNC shield yet, but you can manually install it if it hasn't.

Despite the name, Laserweb is also quite capable of basic milling operations. You can load an SVG or DXF file in the web interface, setup all the inside/outside/pocket cuts you want, and it generates the gcode and runs it. No extra software required on your PC. Make sure you backup your settings though - they are all stored in the browser cache, so if you lose them after spending weeks fine tuning everything you’ll be sad (I was very sad).

I setup two machine profiles in Laserweb - one for milling, and one for lasering. They have slightly different start/end gcode to make sure laser mode is set properly in the firmware and has the right tool sizes and everything.

One feature I love having is the outline button - I can set the zero position and have it move the tool in the outline around where it’s going to be cutting/etching to make sure I have everything lined up properly before I waste material. Just be sure you lift the Z axis up first. If you tell it to drag the bit across the material without turning the spindle on, it won’t stop you and you’ll probably break your bit.

So far it’s done a pretty good job milling things out of plywood and 1x6 boards, and doing both raster and vector engraving on wood. Photos come out pretty nice once the settings are fine tuned and you figure out how to adjust the contrast of the picture to make a nice image.

Unfortunately the laser isn’t powerful enough to cut with. It will cut almost all the way through a piece of 1/8" plywood if you don’t mind doing 10-20 passes at 1-2mm/s. Not really practical. For burning into wood though it does great.

2 Likes

That is great info. Thanks for compiling it.

Have you tried an air assist with the laser? I hear it’s necessary for cutting.

I know this is an old thread, but I recently purchased the pi-hat for my build too. Since there are only 4 driver sockets on the pi-hat, how did everybody hookup both the X and the Y with 2 motors each? I know you can use the clone axis pads for 1 of them but for the other did you drive 2 motors off a single stepper driver or wire 2 drivers in parallel on a single socket?

For both X and Y I wired both motors to a single driver. It’s been working just fine that way.