I’ve been using SuperPID for manual speed control, but really want to take advantage of the gcode controlled on/off and speed control. This way I can walk away from cnc and have the spindle shut down automatically when it’s time for a tool change. There are some older posts on this with helpful, but outdated or incomplete material. Here’s how I implemented.
First, important to know my setup
- My controller board is 2.4e
- I’m using cncjs, I’m running the Windows Electron app most of the time (also have it on a Linux Mint machine)
- I’m using SuperPID for my speed controller
The Hardware - Shapeoko Controller 2.4e
Let’s start with the wiring. On the 2.4e board there are 4 empty holes in the top right that look to be labeled “SPID”. Interesting, right? These are even labeled with the 4 pins you need for controlling the SuperPID: GND - PWM - D13 - 5V. Make note of the “PROG” button, we’ll need that later.
EDIT: some 2.4e boards come with the header pins in place (lucky you if so!), see this post.
First step is soldering 4 pins to this SPID part of the board. (Side note, I’ve seen some other boards with mappings to the black 6 prong jack that is sticking out the front. I couldn’t validate that on this board, so went with what was labled.) To do this, you’ll need to pull the board from the controller box. Unfortunately, the heat sink is really glued on there, warm the back of the box with a heat gun or hair dryer to soften it up. I had to use a shim to start separating it, you can see I messed up the glue a little.
Not too stressed about that, plenty of contact with the back to dissipate heat, which must be minimal since it is a passive heat sink with no fan. Next I soldered on the pins. I picked up a bulk set of JST pins and a crimper for $30.
You’ll need a 4 strand wire that’s about 28g and long enough to reach from your controller to your SuperPID. I used an older USB cable (the newer ones, the wires are too fine to work with). Using a 4 pin female connector, crimp these wires in. Note that this style connector is easily reversed, there are not directional pins. I followed red as 5V and black as GND to keep it simple. For PWM and D13, just make a note when you’re ready to connect to your SuperPID.
The Hardware - SuperPID
This is the wiring from the controller and how you route to the SuperPID. The SuperPID instructions are well documented, but they don’t show this particular case, so I modified their diagram.
Edit: Note that you must use the same ground as the controller, you cannot only use ground from another source (like a USB plug) or the D13 pin and PWM pin will not work correctly. I tried to use the +5V power source and ground from the controller, but it was not enough amps to power the SuperPID and fan, it was behaving erratically. Switched back to independent power source for SuperPID and fan and linked the ground wires to the Shapeoko controller. All works as expected now. Updated diagram:
My one issue with this setup is the 5V from the board would not power the small fan I have in the SuperPID box and turn on SuperPID. The fan is only 0.2A, so need to investigate that more. Edit: Gave up on this and went back to independent power source with a common ground.
Next up, I want to be able to flip back to manual mode, so I needed two switches. First, unsolder the jumper on the back of the board and attach three leads.
Connect the wires to a SPDT (single pole, double throw) switch in the same order. Middle wire on the board goes to middle wire on the switch.
This will allow you to switch between non-linear (knob) mode and linear (computer) mode. This is explained in detail on page 27 in the SuperPID manual. Next, I added a switch to go back and forth from manual speed control to computer speed control. This is different than the linear/non-linear - that is how SuperPID interprets the signal - this is where the signal is coming from - computer or knob. Using another SPDT switch, I wired exactly like the diagram on page 27:
I would have preferred this as one switch, a DPDT (double pole, double throw), but I had these on hand. Flipping both up goes to manual mode and I can use the knob to control speed. Both down and the computer is in charge, the knob does nothing.
Now were in business - power on your CNC and your SuperPID and you’ll discover… failure…
The signal from the router board turns on the spindle as soon as you start up. The D13 pin is reversed from what SuperPID is expecting.
Software - Update Shapeoko Controller
Ready to make some updates to the grbl on the controller board? There are three line changes you need to make. I was pretty nervous about this, but turned out to not be a big deal once I figured it out.
-
First, head to this directory and download the latest Carbide Updater and grbl.hex file. This is your fail safe in case you make an oops and want to go back to the Carbide file
-
Download Arduino IDE and install. (note - I had to download the beta version after Win10 updated last night, the stable version would not open).
-
Go to GitHub - gnea/grbl: An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino and click “Clone or Download” and select “Download ZIP”. This downloads the latest version of grbl (for me, it was 1.1h)
-
Unzip the directory
-
Open “grbl-master” folder then “grbl” folder and you’ll see a file “config.h”. Right click and open with your favorite text editor (notepad, notepad++, etc.)
-
Near the top, change:
#define DEFAULTS_GENERIC
Change to
#define DEFAULTS_SHAPEOKO_3
Then find these two lines and “uncomment” - delete the two // in front (credit to this site and this post for the code and explanations).
// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
// #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
becomes
#define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
#define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
-
Go to this post and download the config.h file @robgrz posted. This has all the Shapeoko modifications. Review your file and uncomment all the additional lines so it matches with the exception of the three modifications above and then save. (Why not just use this file from Rob and make the above change? My theory was the one I downloaded from grbl matched 1.1h, the one posted matched a different version). My version is here: config.h (49.2 KB). This may work for you, I matched the Shapeoko version and updated the three lines above. Remember, this was the 1.1h version, you can use it as a reference.
-
Time to upload to your board! This is the most nerve wracking part for me, but it’s not hard. Go to the grbl compiler site and follow the directions EXACTLY using Arduino IDE. Every step is thoroughly documented, even if you are not a programmer, just read carefully and follow along every single line. The one piece not included - remember that “PROG” button on your board in the photo above? Now is the time to use it. In the last step, uploading the to board, press and hold the program button, then select “Upload” in Arduino IDE. When you get the message “upload complete”, release the button.
Software - Update with cncjs
Now for the last change - we need to tell the board the min and max RPM. In the links above, the older version of grbl has “#define SPINDLE_MAX_RPM” in the config.h file. I tried using those commands on this version and it didn’t work. Here’s what I discovered.
Open cncjs, power on your CNC, and connect. In the Console widget you’ll see a list of parameters:
Your parameter $30 is probably =1000. Scroll to the input > and enter
$30=30000
Hit enter to update the Maximum Spindle Speed. If the Minimum is not = 0, then update that as well. SuperPID is expecting a MIN = 0 and a MAX = 30000
$31=0
While you’re there, enable soft limits and enter the max travel for your machine. You’ll thank me when you don’t crash into the rails anymore when you’re jogging:
Those are my machines parameters, determine your max travel in mm and upate:
$20=1
$130=XXXX
$131=YYYY
$132=ZZZZ
And the test…
Are you ready for it? Here we go!
- Flip your switches on SuperPID to Linear Mode and Computer Controlled
- Power on your CNC and SuperPID
- Power on your spindle mains to SuperPID
- Connect with cncjs and home your machine
- Go to the Spindle Widget
- Enter 10000 RPM and click the M3 button (make sure your spindle is in a safe location)
- In the Console Widget, you’ll see “M3 S10000” and your spindle turns on!
- Back to the Spindle Widget, click M5, your spindle shuts down
- Success!!
- Go eat some tacos, it’s been a long day!
How to use this
Carbide Create automatically includes the M3 S##### and M5 commands. Now as you run your gcode, the spindle will start and stop automatically at tool changes and the start and end of your file. Also, the Feed/Speed/Rapid toggles will work while your job is running.
A few notes now that you’ve read all this.
I have not tested the CNC with Carbide Motion since I’ve made these changes. I exclusively use cncjs as my interface.
You’re taking apart your controller board and soldering it - probably not good from a warranty perspective. You break it… well, you already bought it. Don’t blame the nice folks at Carbide 3D or me. Same thing for flashing the new grbl. You probably won’t brick your board, but you could screw up some settings and make your router behave erratically. It’s your fault, not mine or Carbide’s.
You’re modifying and soldering on your SuperPID, same as above. The liability is on you.
These changes are detailed, but not hard. I’ve done my best to compile these instructions from multiple resources and annotate where the information came from to make it easier for you. These worked for me, with my setup, noted above. Your setup may be different and require different steps. Lucky you! When you figure it out, document it for others.
and finally…
Hope this helps you if you’ve been wondering how to implement but nervous to try since there aren’t any comprehensive resources. I know enough to be dangerous, by no means an expert. If you find something inaccurate or missing, please comment for others.