GRBL HotWire Mega 5X for CNC Foam Cutters

posted in: CNC, Hot Wire, Software | 28
GRBL Hotwire Mega 5X application

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. Initially, it used software and firmware adapted by Daniel Rascio from GRBL-Panel and GRBL 0.8c2 but since then I have modified it extensively to use GRBL 1.1. 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.

The software will run on the MKS Gen L board as well. I’ve made a separate post here if you wish to use that board.

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 my builds as well. But I’m aware that not everyone can afford this. So I decided during the first coronavirus lockdown in the UK 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 many long hours I managed 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 issues 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.
  • GUI has been better suited 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.

Arduino Mega 2560 4 axis

Installing the new software and firmware.

First, we install the firmware on the Arduino or MKS 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 follow on from Installing Software.

Firmware – Compiling

I have created a separate post for compiling and uploading the firmware here

It’s not recommended to use this option unless you need to change the firmware source code. This is not necessary unless you have some specific need. Please check with me first, it may not be required.

Installing the GRBL-HotWire Mega 5X Software

I’ve only tested this software on Windows 10, I don’t have older versions anymore.

Download the software from here

Icon

GRBL HotWire Mega 5X Windows Application v5.02 472.23 KB 1385 downloads

A Windows application that works with the Arduino Mega using customized firmware…

Unzip the download and click setup.exe to run it. It should open the new application if all is well. I have modified the original application extensively developed by Daniel and Gerrit Visser If you have problems I’ll do my best to help but always run lots of tests 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.

Configuration

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! Disconnect the motors first because turning the motors by hand induces a current and voltage in the wire, damaging the controller.

To change any setting click on the setting tab and you’ll see a table with all the settings. Each of the $ settings represents a value we can change on the Arduino. Plugin the USB, select Connect on the Interface page, go to the Setting tab, and ensure $22 is set to zero. This disables homing. Even if you are going to use homing we need to disable this first and get the axis directions correct. Do a Disconnect and Reconnect to make sure the change is taken. The Homing button should be greyed out.

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

SettingValueDescriptionNotes
$010Step pulse, microseconds
$1255Step idle delay, milliseconds
$20Step port invert, mask
$36Direction port invert, mask
$40Step enable invert, boolean
$50Limit pins invert, boolean
$60Probe pin invert, boolean
$103Status report, mask
$110.02Junction deviation, mm
$120.002Urc tolerance, mm
$130Report inches, boolean
$200Soft limits, booleanDon’t enable only use when homing
otherwise, this will cause a jogging error
$210Hard limits, boolean
$220Homing cycle, boolean
$231Homing dir invert, mask
$24200Homing feed, mm/min
$25100Homing seek, mm/min
$26250Homing debounce, milliseconds
$275Homing pull-off, mm
$301000Max spindle speed, RPM
$310Min spindle speed, RPM
$320Laser mode, boolean
$1001066Axis 1 (X) steps/unit (mm or deg)
$1011066Axis 2 (Y) steps/unit
$1021066Axis 3 (Z) steps/unit
$1031066Axis 4 (U) steps/unit
$110400Axis 1 (X) Max rate, unit/min
$111400Axis 2 (Y) Max rate, unit/min
$112400Axis 3 (Z) Max rate, unit/min
$113400Axis 4 (U) Max rate, unit/min
$12016Axis 1 (X) Acceleration, unit/sec^2
$12116Axis 2 (Y) Acceleration, unit/sec^2
$12216Axis 3 (Z) Acceleration, unit/sec^2
$12316Axis 4 (U) Acceleration, unit/sec^2
$1300Axis 1 (X) Max travel, unit
$1310Axis 2 (Y) Max travel, unit
$1320Axis 3 (Z) Max travel, unit
$1330Axis 4 (U) Max travel, unit

Checking Axis direction

If you find the axis going the wrong way, a simple option is just to reverse the 4 pin connector on the RAMPS board. Many thanks to Jim H from Halifax, Nova Scotia for pointing this one out.

If an axis is going in the wrong direction and you can’t reverse the connector then we need to change the $3 value.

The simplest way to do this is first set $3=0 disconnect and reconnect. Then try each axis to see which one is moving in the wrong direction.

So for example, if Y and Z were going the wrong way. Using the table below we need to InvertY and Invert Z setting to Y like this N Y Y N.

The X and U axes are OK but we need to invert Y and Z. Look down the table below to see which value corresponds to NYYN which is 6. Now set $3 to 6 and disconnect and reconnect. Your axes should all work in the correct direction

Setting ValueMaskInvert XInvert YInvert ZInvert U
000000000NNNN
100000001YNNN
200000010NYNN
300000011YYNN
400000100NNYN
500000101YNYN
600000110NYYN
700000111YYYN
800001000NNNY
900001001YNNY
1000001010NYNY
1100001011YYNY
1200001100NNYY
1300001101YNYY
1400001110NYYY
1500001111YYYY
1600010000NNNN
Values for $3 Axis invert mask and $23 Homing invert mask

Steps/MM

$100-103 are the values for each axis in 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 having trouble getting the 10 x 1.5mm threaded rod then you can use 3/8-16 TPI and set the Steps/MM to 1007 for 1/8 micro-stepping. I’ve had a few builders in the USA that says 10 x 1.5mm threaded rods are quite expensive.

Some builders have used T8 lead screws which can come in many forms. The example below is for a T8 lead screw with a 2mm pitch. Please check the specifications as some lead screws can have multiple starts which alter the steps per mm. If you are unsure just measure how far the drive nut moves in one revolution of the lead screw and use the value in the Prusa Calculator. We can check it later in the calibration and adjust it if needed.

Lead Screw/Threaded RodSteps per MM 1/8 micro-stepping
10mm x 1.5 mm pitch Threaded Rod1066
T8 Lead Screws 2mm pitch800
3/8-16 TPI Threaded Rod1007

If you are not using homing limit switches/end-stops then that should be enough to get your machine working. Do check the calibration afterwards. The new Updated Part 2 video includes the calibration checks

Homing/Limit Switches Configuration

X Limit Switch

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 to 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 maximum 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 a spare negative next to the Z min negative.

AxePin minSoft Limit
(X)D3$130
(Y)D14$131
(Z)D18$132
(U)D42$133
I used some servo connectors on X, Y and Z and the same wire but removed them from the plug for the U signal and ground

Here’s a quick summary of my settings to enable homing

Please read the full description below as well

SettingValueComment
$51NC(normally closed)
$221Enable Homing
$26 5-25 milliseconds Debounce setting see below
$272-10mmAxis pull off
$201Soft Limits (if using 4 switches. Leave at 0 if you use 8 switches)
$211Hard Limits using 8 switches
$23See table aboveHoming in the wrong direction
$130-$133Max 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.

Enable Homing

To enable homing the $22 setting needs to change 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.

Debounce

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. Use the same procedure as the Axis Direction check above to get home working in the correct direction

Soft and Hard Limits

Soft and Hard Limits

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 settings if you have Homing enabled with limit switches.

I only have 4 switches and have set soft limits to the max travel of vertical and horizontal axes. Less wiring and I very rarely come anywhere near the maximum travel.

On my old machine I had 8 switches and I never once triggered the maximum travel switches. But I did have some connection breaks which took some finding.

$130, $131, $132, $133 – [X, Y, Z, U] Max travel This sets the maximum travel for each axis in mm. This is only useful if you have soft limits (and homing) enabled.

For Soft Limits using 4 switches set $20=1 and $21=1 and then $130-133 to your maximum travel.

For Hard Limits using 8 switches Set $20=0 and $21=1 leave $130-133 set to 0.

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

G93 feed mode is fully supported in this firmware version. It’s 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.

usb cnc foam cutter running g93 inverse time feed mode
Running G93 inverse time feed mode

Finally

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 extensive modifications on the good work of Gauthier Brière, Gerrit Visser and Daniel Rascio. Please use at your own risk and please test, test and test before committing any foam.

You will probably want to generate your own g-code now so check out my post on G-code generation software here G-code generation software to make foam wings and fuselages with CNC foam cutter

Happy foam cutting

YouTube player
YouTube player

Version 3.2 Update

This video explains the software updates from the original release. The major improvement is the hot wire control.

YouTube player

28 Responses

  1. Ian

    Hi Keith,

    When I compiled the GRBL and checked it in the Arduino serial monitor area and entered $i, I get axis XYZAB instead of XYZU. I have never used or programmed before, please help!

    Regards
    Ian

  2. Erez

    Hi Keith,
    I’m using the firmware GRBL-HotWire Mega 5X.
    In my system I have the makerbot endstop, the are N.O switches. (MIN position)

    I change the $5 to invert but the firmware doesn’t like it.

    I guess the system work best with N.C (also for the cable safe reason).

    Any advice?

    • Keith

      Hi Erez
      Best if you can use N.C switches. Just doing a quick search on the Internet there seem to be a lot of issues using these switches. Sorry, that’s not much help but micro switches are so cheap 20 for about $8 on Amazon it would save you a lot of time.

      Keith

  3. Alessandro

    Hello, what about using a mks gen l board instead of Arduino mega + ramps?
    Does it work?
    Another question, if I want to use the cutter only for cutting some text, so as a 3 axis machine, does it work also if it’s a 4 axis?
    Many thanks in advance.

    • Keith

      Hi Alessandro
      I’m testing the MKS Gen L board right now and it works. But I’ve had to modify the Windows Controller program because there was an issue on some laptops during the initial connection. I’m about to release an updated version of the software with a new video which should be ready in a couple of weeks. So yes it does work but the software on the website may not work on your PC/Laptop.

      The foam cutter will work on any shape as long as you can generate 4 axis g-code for it. So it depends on how you generate the g-code.

      Hope that answers your questions
      Keith

  4. Alessandro

    Good morning, and thanks for the replay. What about if I add a fifth axis to work cilynder cuts, is the software able to manage it?
    Regards, Alessandro.

    • Keith

      Hi Alessandro
      The software only works with 4 axes. I didn’t write the original software I have only modified it to work with the later firmware. If you really need a fifth axis then DevCNC Foam supports it. But first, check with Stefano at DevCad because I’ve no experience of 5th axis.

      Keith

  5. Fedor

    Hi Keith!
    I have built a 4 axis CNC machine. All movements have the correct dimensions, but the speed is lower than indicated in the g-code: 160 mm/min instead of 200 mm/min. $110-114: 400 mm/min so it is not limiting speed.

    The second problem is that the actual Jog Both carriage movement is 2 or 3 times bigger than the selected in the box. However, single-axis jogging also works correctly.
    What can be wrong in my settings?

    Thank you!

    • Keith

      Hi Fedor
      The speed in the g-code is quite high it should be 120mm/min. I have uploaded another test file recently so give that one a try. https://rckeith.co.uk/download/clark-y-wing-g-code-for-250mm-root-and-tip-with-4mm-round-spar/

      The jogging moving more than the requested is caused the mouse clicks. If you hold it down just a bit too long it takes it as 2 or 3 clicks and moves too much. On the setting page you can enable keyboard arrows and use PgUp/PgDn for moving both carriages. Works much better.
      Keith

  6. Martijn

    Hi Keith,
    First of all thank you for all the information and the software you are providing. It was instrumental in getting me started.

    I unfortunately do have an issuewith the sw where the Q runs dry. At that point the UI stops drawing. Pressing the play button continues the program. I updated to the latest versions but it still happens.
    I do have a video of it happening if that would help.

    Kind regards,
    Martijn

    • Keith

      Hi Martijn
      I have noticed this on some profiles but others it seems OK. The g-code does work ok on the controller it’s just the UI doesn’t always show it completed. Can you send the g-code you are using to hotwire.cnc@gmail.com. I think its to do with the way GRBL buffers commands and then sends an update back.

      Keith

  7. demerson

    thanks for the beautiful work but ask me why the grbl hotwire5x does not execute the cut files generated by devfoan?

  8. Keith

    Hi
    It will execute DevFoam files perfectly, you must have incorrect settings. Send me your cut file and I’ll take a look to hotwire.cnc@gmail.com
    I use DevWing Foam all the time so you must have an incorrect setting. Send a screenshot of your machine axis. The usual cause is incorrect axis names. The GRBL software uses XYUZ

    Keith

  9. Nihal Mankar

    when I click on the UP button in jogging both carriages, the vertical arm from the left side moves, and the horizontal arm from the right side starts moving. Please give me some suggestionns

    • Keith

      Hi Nihal
      Which firmware are you using? You should be using the one from this website. If you are then it seems you have some connection mixed up. Send a picture of your setup to hotwire.cnc@gmail.com
      Keith

  10. carlos augusto

    can i use this for a 2-axis foam letter cutter ?

    • Keith

      Hi Carlos
      You could and just ignore the U and Z axis. Homing wouldn’t work but it isn’t required for the foam cutter to work. When you connect it set the zero for the X and Y without homing.

      Keith

      • carlos augusto juncks ramos

        great! i will use defoam le 2 to generate the gcode!

  11. leon huynh

    Sir,

    I did exactly the same with you. But when I run GRBL HOTWIRE MEGA 5X, I hit the button “Connect”, the HOME CYCLE, UNLOCK and ALARM turn into red. What is the problem?
    Pls help

    Thanks

    • Keith

      There is no problem. It looks like you have homing enabled. Follow the instructions on this page https://rckeith.co.uk/grbl-hotwire-mega-5x-for-cnc-foam-cutters/ and set it up without homing. Even if you intend to use homing the first step is to disable it with $22=0. Then you can check all the calibration and axis directions. After that, you can enable homing if you intended to use endstops. All the details are in the link above.
      Keith

  12. Leon

    Dear Sir,

    I am stuck in the wiring endstop.
    My endstop has C , NO, NC. So, which is Signal, Negative, and Ground?

    Could you pls advise

    Thanks

    • leon

      Hi Sir,

      I just understood how to do endstop and found the answer for my own question

      Thanks Sir

      • Keith

        OK, I use normally closed so NC on the switch.

  13. Leon

    Hi Sir,

    The title says 5X Mega. Is that mean this grbl can control 5 Axis?
    I know how to do 4 axis by following your excellent instructions. But can I enable for the 5th Axis?

    Thanks

    • Keith

      Hi Leon
      The firmware can support 5 axis but for the foam cutter, it’s configured for 4 axis. It would need the source code reconfiguring and recompiling. The Windows software will only work with 4 so it’s been configured for that. So enabling the 5th axis will not work. It’s based on this https://github.com/fra589/grbl-Mega-5X so that’s why it’s named after it. I think the latest version will even support 6 axis.
      Keith

  14. JOZE

    Hello Keith!

    it is possible to connect a laser module on Mega 5x (hot wire variant) I use Arduino mega 2560 + ramps 1.4
    How?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.