Controller Software for 4 axis CNC Foam Cutters
This is the GRBL HotWire Mega5X firmware and software update for USB Foam Cutter build on this website. It was originally designed to use software and firmware adapted by Daniel Rascio from GRBL-Panel and GRBL 0.8c2. Daniel did a fine job and many builders have used it with great success. It requires an Arduino Mega 2560 with a RAMPS board, part list here if you’d like to build one.
As this is an upgrade to the original electronics build please follow the video series, Part 2 as well. This article details the hardware changes and configuration for the new firmware and software.
GRBL firmware is now at version 1.1 and there are a few limitations with the old software/firmware. Limit switches were not supported so you can’t home the machine. The G93 inverse time feed mode didn’t work so DevWing Foam and DevFus Foam can’t use its best option for generating g-code.
Daniel posted the source code for the GRBL HotWire Controller software on RC Groups. Which is a Windows-based application adapted from GRBL-Panel originally for 3 axis CNC routers
GRBL HotWire Mega 5X
One question that I get quite often is can I use limit switches or end stops. On the old firmware, you couldn’t. The only option was to purchase DevFoam CNC at 60 Euros. This is a very good program and I highly recommend it. I use it for all my builds now. But I’m aware that not everyone can afford this so I decided during the corona virus lockdown to see if I could modify the Windows application to work with the GRBL-Mega-5X firmware. Many thanks to Gauthier Brière for the excellent work on grbl-Mega-5X. This update wouldn’t have been possible without it.
I’m glad to say after some long hours I managed to to get it to work with the newer firmware and it addresses a few issues as well. So I’ll list the main feature and issued fixed
- Limit Switches/End-Stops now supported
- G93 Inverse Time Feed Mode supported
- Running a customized version of GRBL firmware adapted by Gauthier Brière
- Connect/Rescan buttons issue fixed on older laptops
- G-code developed in Jedicut now displays correctly
- Bad Number format error message fixed.
- GUI has been reworked slightly for CNC foam cutting
Hardware changes required for GRBL HotWire Mega 5X
The driver module and jumpers need to be configured as below. If you are using the older firmware then move E1 driver and jumpers to the X-axis socket on the RAMPS board. The newer firmware uses XYZ and E0.
Installing the new software and firmware.
First, we install the firmware on the Arduino. This can be compiled and upload to the Arduino Mega or you can upload pre-compiled firmware. Secondly, the new Windows application needs to be installed. I’ve only tested the software on Windows 10 as I don’t have any older versions now. But I think it should work on Windows 7 and 8.
Firmware – Uploading Pre-Compiled
This is a much simpler option and less error-prone if you are not used to this. I’ve created a separate posting for this link below.
Once you have done that then goto to Installing Software
Firmware – Compiling and Uploading
Download the firmware form here
Unzip the files to a location of your choice. You will need the Arduino IDE to compile and upload the firmware which is a free download from here
Install the Arduino IDE like any other application once downloaded. The firmware you’ve downloaded from the link above needs to be uploaded to the Arduino IDE as a library. This is different from the older firmware if you have done that previously
From the Sketch menu click Include Library and then Add Zip Library We still use this option even though we have unzipped already. Navigate to where you have downloaded the firmware and then select the folder grbl.
You should now see the grbl listed in Libraies as a Contributed Library
Before compiling and uploading make a note of your old setting if you are upgrading from the old firmware. The old setting will probably be lost. You only really need your steps/mm for the axes, but it’s worth noting the others.
Make sure you have the correct port and board selected in the Arduino IDE and then select File->Open and navigate to where you have the firmware downloaded too. In the grbl folder navigate to \examples\grblUpload and select grblUpload.ino
Now select the upload icon and the firmware will compile and upload.
If you get any errors then check you have the correct board selected and COM port. If you are having issues connecting to the Arduino check my troubleshooting video which has some suggestions. Quite often on cloned Arduino boards from China its the CH340 driver for Windows that needs installing. This mainly happens on older versions of Windows.
Installing the GRBL-HotWire Mega 5X Software
I’ve only tested this software on Windows 10, I don’t have older version anymore. If you do find issues please use the older GRBL HotWire Controller program and the GRBL8c2mega2560RAMPS firmware on these older operating systems.
Download the software from here
Unzip the download and click the setup.exe to run it. It should open the new application if all is well. I have adapted the original application made by Daniel and Gerrit Visser I didn’t write the original code so please use this application with that in mind. If you have problems I’ll do my best to help but always run lots of test before committing to cut any foam. I usually run the g-code through the application without any foam and the hot wire switched off just to make sure it does as I expect.
After installing the software we need to configure the settings. The default settings will set the foam cutter up as the build on this website. But before you start testing any movement move each axis away from the physical stops of the machine. If an axis goes in the wrong direction it could ruin a flexible coupler, trust me I’ve done it a few times!
To change any setting click on the setting tab and you’ll see a table with all the setting. Each of the $ settings represents a value we can change on the Arduino. A full list can be found here on the Github page. Make sure you are connected to the Arduino before trying to change a setting and press the return key after otherwise the settings are not applied.
Default Settings – No Homing or Limit Switches
|$0||10||Step pulse, microseconds|
|$1||255||Step idle delay, milliseconds|
|$2||0||Step port invert, mask|
|$3||6||Direction port invert, mask|
|$4||0||Step enable invert, boolean|
|$5||0||Limit pins invert, boolean|
|$6||0||Probe pin invert, boolean|
|$10||3||Status report, mask|
|$11||0.02||Junction deviation, mm|
|$12||0.002||Urc tolerance, mm|
|$13||0||Report inches, boolean|
|$20||0||Soft limits, boolean||Don’t enable only use when homing |
otherwise, this will cause a jogging error
|$21||0||Hard limits, boolean|
|$22||0||Homing cycle, boolean|
|$23||1||Homing dir invert, mask|
|$24||200||Homing feed, mm/min|
|$25||100||Homing seek, mm/min|
|$26||250||Homing debounce, milliseconds|
|$27||5||Homing pull-off, mm|
|$30||1000||Max spindle speed, RPM|
|$31||0||Min spindle speed, RPM|
|$32||0||Laser mode, boolean|
|$100||1066||Axis 1 (X) steps/unit (mm or deg)|
|$101||1066||Axis 2 (Y) steps/unit|
|$102||1066||Axis 3 (Z) steps/unit|
|$103||1066||Axis 4 (U) steps/unit|
|$110||400||Axis 1 (X) Max rate, unit/min|
|$111||400||Axis 2 (Y) Max rate, unit/min|
|$112||400||Axis 3 (Z) Max rate, unit/min|
|$113||400||Axis 4 (U) Max rate, unit/min|
|$120||16||Axis 1 (X) Ucceleration, unit/sec^2|
|$121||16||Axis 2 (Y) Ucceleration, unit/sec^2|
|$122||16||Axis 3 (Z) Ucceleration, unit/sec^2|
|$123||16||Axis 4 (U) Ucceleration, unit/sec^2|
|$130||0||Axis 1 (X) Max travel, unit|
|$131||0||Axis 2 (Y) Max travel, unit|
|$132||0||Axis 3 (Z) Max travel, unit|
|$133||0||Axis 4 (U) Max travel, unit|
Checking Axis direction
If an axis is going in the wrong direction then we need to change the $3 value. The table below shows what value to enter to reverse the direction of an axis. So if we need to reverse Y and Z then enter 6 in the $3 row and press Enter. Disconnect and reconnect to the Arduino to make sure the setting are applied. I found sometimes you didn’t need to do this but on occasions it needed a disconnect/reconnect.
|Setting Value||Mask||Invert X||Invert Y||Invert Z||Invert U|
$100-103 are the values for each axis steps per millimetre. The default value is 1066 for 1/8 micro stepping with 10mm x 1.5mm pitch thread. If you are using different leadscrews/threaded rods then this will need recalculating. A good resource is here which has a Steps per millimetre – leadscrew driven systems, calculator.
If you are not using limit switches then that should be enough to get your machine working. Do check the calibration afterwards. The video I made Part 4 has the details on how to do this at 11:32 in.
Homing/Limit Switches Configuration
Before starting this configuration make sure you have completed the section above and have installed the GRBL HotWire Mega 5X firmware and software from this website. There are changes specific for the foam cutter. Don’t use grbl-Mega-5X from GitHub version or you will have errors.
Many problems with limit switches or end-stops can be attributed to not using screened cables or providing some form of electrical isolation. Opto switches do this but are a bit more involved as they need a separate power supply.
Limit Switches Pins on the RAMPS board
I’ve only used the MIN switches on my foam cutter using the pin listed below with soft limits enabled for the MAX travel. I had limit switches on my old machine for the maximum travel but I never actually triggered them while cutting any foam. It also adds extra wiring. So using MIN switches with soft limits gives the same result with less wiring.
By default, the limit switches must be wired between ground and the following pins on the Arduino board:
Connect the switch between Signal(S) and negative(-). The U min D42 is the signal(S) pin. You will need to connect the other wire from the switch to a negative(-). I just used spare negative next to the Z min negative.
|Axe||Pin min||Soft Limit|
Here’s a quick summary of my settings to enable homing
Please read the full desciptions below as well
|$26||5-25 milliseconds||Debounce setting see below|
|$27||2-10mm||Axis pull off|
|$21||0||Hard Limit (Mechanical switches for max travel)|
|$23||See table above||Homing in the wrong direction|
|$130-$133||Max Travel(mm)||How far each axis can move. Only use with Soft Limits. If you leave at 0 axes won’t move|
Normally Closed Switches
The general consensus of opinion is to wire switches as NC(normally closed) and the triggering breaks the connection. So we need to set $5 = 1, the limit switches operate in “Normally closed” (NC) mode.
To enable homing the $22 setting needs changing from 0 to 1 and it’s a good idea to set $27 to a small value say 5 or 10mm. This pulls the axis off the switch after it has triggered. If you leave it at 0 then you may get a false trigger.
Sometimes you may need to change $26 the debounce setting. If you find you are getting strange results then increasing this value may help. I had this problem when I first used Mach3 with limit switches. Increasing this value fixed it. It’s because the switches are not triggered cleanly and this can cause problems.
Homing in the wrong direction
If you find the axis homes in the wrong direction then change $23. It uses the same table as the axis direction invert mask above. So if you found X and U going the wrong way then enter 9 in $23
Soft and Hard Limits
Make sure you don’t have both enabled. It will cause errors in the application
Soft limits is a safety feature to help prevent your machine from travelling too far and beyond the limits of travel, crashing or breaking something. It works by knowing the maximum travel limits for each axis and where Grbl is in machine coordinates.
Hard Limits is basically the same except we use a physical switch at the end of the axis
Only use these setting if you have Homing enabled with limit switches.
I only have MIN switches or end-stops to home each axis and the set soft limits to the max travel of vertical and horizontal axes.
$130, $131, $132, $133 – [X, Y, Z, U] Max travel This sets the maximum travel from end to end for each axis in mm. This is only useful if you have soft limits (and homing) enabled.
Set $20 to 1 for soft limits or $21 if you have switches to set at the max travel. Do not enable both.
That should get your homing with limit switches working. There are a few other settings that can be adjusted for speed and acceleration. The default setting in the firmware works well in my machine and are very similar to DevCNC Foam. If you need to change them do so with caution as trying to run too fast can caused missed steps.
Gauthier has produced a very detailed wiki page on homing and limit switches so if you are having issues not covered here please check his wiki page https://github.com/fra589/grbl-Mega-5X/wiki/Limit-switches-and-homing
G93 Inverse Time Feed Mode
This is a feed mode used to calculate the feed between each movement sent to the axes. If you have G93 enabled in your software e.g. DevWing Foam2 then you will see a feed rate on every line starting with G1.
This mode is most useful when cutting wings or fuselages with a big difference between the root and tip.
On the older firmware 0.8, this mode never worked properly. If you enabled it then the foam cutting would move very slow once it received a G1 command with a feed rate. On the new firmware, this now works correctly and I’ve tested it several times without any issues
Jedicut Files Display Correctly
On the old GRBL HotWire Controller g-code files created in relative or incremental mode didn’t display correctly. This just is now fixed. The firmware worked fine with them it was just the display didn’t understand the mode.
Jedicut needs some setting changed to work with this software. Please follow this post before contacting me. How to use Jedicut G-Code with GRBL 4 Axis CNC Foam Cutter
error grbl: Bad number format
The old firmware displayed this error sometimes but it never caused any issues. I believe it was a problem with GRBL 0.8. Now we are running on GRBL 1.1 this error message has gone.
GUI has been reworked slightly for CNC foam cutting
Some of the dialogue boxes were not really relevant to foam cutting like coolant and tool number. So I modified the GUI to better fit CNC foam cutting. The software has been developed and compiled in Visual Studio 2019 Community Edition and requires .Net Framework 4.5 or higher. The installation should take care of that and download the correct version.
I haven’t tested this on older versions of Windows so I can’t say if it will work OK. I suspect it will but if you can run the program on Windows 10.
Planned updates coming soon
The user feedback has been very positive for this application. This has highligthed few areas for improvement. So in the next release here are the changes planned
- Some g-code files when loaded wouldn’t display the profile in XY and UZ views. This was caused by the application expecting a the g-code line with spaces between each instruction. The update will work with or without spaces and display correctly.
- HotWire control works much better. The latest firmware changed the way the PWM signal to the D8 connector on the RAMPS board was calculated. The next release will give much better control of current to the wire.
- The keyboard repeat rate for the U-axis was missing in Settings.
I hope this version works well for you and if you have any issues drop me a line. Please be aware I’m not a developer and have based these modifications on the good work of Gauthier Brière, Gerrit Visser and Daniel Rascio. So I won’t be able to make any major changes to the code. Please use at your own risk and please test, test and test before committing any foam.
Happy foam cutting