Electronics Build Guide Arduino Mega 2560 RAMPS 1.4
Introduction
This guide will walk you through the steps to build the electronics for a CNC foam cutter using the Arduino Mega 2560 with a RAMPS 1.4 board. This a great combination and I’ve made many projects with them.
Thanks to 3d printing the electronics for a foam cutter are quite affordable now and easy to obtain.
Advantages:-
- You can use a genuine Arduino Mega 2560 microcontroller.
- Readily available in most countries
Disadvantages:-
- A hot wire over 39 inches or 1 meter long can be difficult to get hot enough to melt the foam. The RAMPS board only works on 12 Volts the MKS is a better choice running at 24 volts
- Aligning the RAMPS board pins to the Arduino Mega 2560 can be problematic on some cheap cloned boards.
Build Guide
Please make sure you have used the recommended parts from the parts list. If you use alternatives this guide may not work.
Please don’t install the electronics onto the foam cutter until it’s working on the bench. After the bench test, you can do the final calibration and dry run once installed on the foam cutter. The foam cutter will require longer wires than your bench testing which is usually the source of problems if it doesn’t work correctly when installed
Please note Homing can’t be tested on the bench. It’s only possible after installation on the foam cutter with all the switches wired.
Step1 – Connect the board
Connect the board to your computer running Windows 10 or 11. Other users have confirmed it will run on older versions of Windows but I can’t confirm that as I don’t have them anymore.
In Device Manager ensure you can see the board listed. If you see a yellow warning triangle you may need to install the CH340 drivers. Use this link if that’s the case.
Step 2 – Firmware
Download the firmware and software from here and unzip to your computer. In the location you unzipped the download then unzip XLoaderXYZA-Mega2560.zip
GRBL Hot Wire Firmware and Software V2.2 1.77 MB 4146 downloads
This is the latest software and firmware for the CNC Foam Cutter version v2.2 Uploaded…You will have a folder called XLoaderXYZA-Mega2560 locate the XLoader.exe file and run that.
In the Hex File field make sure it ends with firmware-mega2560.hex
If you have used Xloader before it remembers the last hex file used. Which may not be this hex file. A few guys have been tripped up here.
Make sure the Device field says Mega(ATMEGA2560). Your COM port may be different to the picture. Just make sure it’s the same as in Device Manager. Also, ensure the Baud rate is set to 115200. Then click “Upload”
If all is well you will see the number of bytes uploaded. If you do get any errors check your settings as described above.
Default Settings of the Firmware
Setting | Value | Description | Notes |
---|---|---|---|
$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 (A) 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 (A) Max rate, unit/min | |
$120 | 16 | Axis 1 (X) Acceleration, unit/sec^2 | |
$121 | 16 | Axis 2 (Y) Acceleration, unit/sec^2 | |
$122 | 16 | Axis 3 (Z) Acceleration, unit/sec^2 | |
$123 | 16 | Axis 4 (A) Acceleration, unit/sec^2 | |
$130 | 0 | Axis 1 (X) Max travel, unit | Don’t leave at zero. Set to your maximum travel |
$131 | 0 | Axis 2 (Y) Max travel, unit | Don’t leave at zero. Set to your maximum travel |
$132 | 0 | Axis 3 (Z) Max travel, unit | Don’t leave at zero. Set to your maximum travel |
$133 | 0 | Axis 4 (A) Max travel, unit | Don’t leave at zero. Set to your maximum travel |
Step 3 – Software
From the download unzip grblHotwire.zip to a folder. Then run the setup.exe
This will install the software so that we can complete the rest of the bench testing.
You may need to install the Dot Net Framework if you get any errors. Follow this link and select Runtime. Windows 10 is usually fine but sometimes Windows 11 will need the FrameWork installed.
In the software if your COM port is not selected press ReScan and click Connect. You should see the image below.
If you get errors the common one is installing the wrong hex file. The older firmware used XYZU for its axis letters but the latest firmware uses XYZA.
If you see any numbers other than zero in the DRO run the following command in the MDI dialogue box $RST=* This will clear any old settings in the EEPROM.
Step 4 – Power Supply
The RAMPS board need a 12 Volt power supply of at least 150 Watts. Power needs to be applied to both green connectors. You can save some wiring by looping the wire see the diagram below.
One side feeds the motors and Arduino and the other powers the MOSFETs for the hotwire.
Double-check you have looped the wires correctly e.g. positive to positive and negative to negative. Otherwise, the RAMPS board and possibly the Arduino will be destroyed.
Switch on your power supply and make sure the board still works by connecting to the GRBL Hotwire software.
Step 5 – MicroStepping
The foam cutter build on this website uses 1/8th microstepping. This is set by jumpers in the driver socket location. Set them as the diagram.
The firmware is preconfigured to use this setting with a 1.5mm pitch threaded rod. If you use different microstepping you will need to adjust the setting $100-$103 on the settings tab of the software.
If you are using different leadscrews/threaded rods then this will need recalculating. A good resource is here which has Steps per millimetre – leadscrew driven systems, calculator
Step 6 – Driver install
Install the DRV8825 stepper drivers onto the RAMPS board as shown in the diagram below. You can also use the A4988 as well. The most important thing to check here is that the enable pin on the driver is aligned with the enabled socket pin on the board. If you reverse the driver it will be destroyed. Double-check before you apply any power
Step 7 – Setting the driver current
The DRV8825 stepper drivers have a tiny trim pot to adjust the VRef(Voltage reference) which sets the current the stepper motors use. This value depends on your stepper motor current per phase. Use the calculator here to get the correct value. Follow this link https://www.youtube.com/watch?v=flOsxI26Jfw&t=2285s explaining how to do this.
Step 8 – Stepper Motors
Power off the board and connect the stepper motors to the board with the cables/wires from the parts list.
Power on the board and click Connect on GRBL Hotwire. The stepper motors will be difficult to turn by hand. This indicates they are working correctly. Try using the jog buttons to see if the motors turn.
If the motors don’t turn or are erratic the connector wires/cables may be wired incorrectly. This has happened to a few guys. Follow this link of how to check stepper motor wire paring https://www.youtube.com/watch?v=yzCKXei0pLU&t=445s
This video is quite old now and shows the old stepper driver location but the method to check the wire pairing is still the same. So follow this to get your motors working if incorrect cables have been supplied
Step 9 – Cooling Fans
The stepper drivers will warm up when the current is sent to the motors. If you’re using motors rated for less than 1 amp, you might not need a cooling fan, but I recommend using one regardless. Connect a 12-volt fan to the 12-volt power supply.
Step10 – Foam Cutter Build
Now that the electronics have been bench-tested and functioning correctly, you can move on to the mechanical build.
The ebook and videos explain the mechanical build in detail. A final test of your build is to make sure you can turn the threaded rods or lead screws easily by hand. If they are hard to turn or bind you will most likely damage the electronics. If all is well carry on with Step 11
Step11- Foam Cutter Wiring
You will need to extend the stepper motor wires. Ensure that you use a wire gauge that is the same as or thicker than that of the stepper motors. If you plan to use homing, it’s essential to use a shielded or screened cable, as failing to do so may cause issues.
If you are using homing then only connect the micro switch between the NC connection on the switch and ground and signal on the relevant connector socket. There is no need for pull-up resistors because they are internal to the Arduino.
Step 12 – Do not enable homing
Make sure $22=0 in the settings tab. Even if you are using homing it needs to be disabled for testing the correct axis direction.
Step 13 – Test Axis Direction
Ensure the machine is powered off. Manually turn the threaded rods or lead screws to move each axis away from its starting position. Turn them slowly to avoid generating back EMF that could affect the control board. If possible, disconnect the motor before doing this
When you test the axis direction if it goes the wrong direction towards a hard mechanical stop you can ruin your flexible couplers. I’ve done this a couple of times.
If you have disconnected them, reconnect your stepper motors and switch on the power.
Set the jog distance to 1mm and move each axis with the plus button e.g. X+. The axis should move forward or up. If any of them are going in reverse use the check box of the settings page to Invert Axis Direction. After each change disconnect and reconnect to make sure the setting has been saved.
Step 14 – Calibration Check
The firmware is pre-configured with a value of 1066 in settings $100-$103 for the steps/mm. If you are using different thread rods or lead screws that don’t have a pitch of 1.25mm. You will need to calculate a new value. A good resource is here
You need to ensure when the g-code sends a command to move a set distance that the foam cutter moves that distance. For example, if the command was G1 X100 then the X carriage moves that distance.
Check my video here on how to check and adjust the steps/mm.
If you have used the same thread rods as I have then I have found the default values need no adjustment. But check each axis is correct.
Step 15 – Homing (Optional)
The foam cutter works fine without using Homing with Limit Switches. You can jog each axis to your chosen position and click the zero buttons to set your start position.
You can’t test Homing on the bench it must be on the machine
The limit switches will prevent the axis from crashing into the end stops or going past the machine limits. You can use software limits to prevent the machine from exceeding its travel.
The majority of questions people contact me about are problems with homing. If you follow these guidelines you shouldn’t have any issues.
- You are using the latest firmware and software
- You have used shielded/screened cables to connect your switches.
- The switches are wired NC(Normally closed)
- Only connect the Ground and Signal wires on the controller pins. Do not connect 5-volt
- Ground the shield of the limit switch cable at the controller side only
- Before you enable homing with $22=1 check each axis moves in the correct direction when $22=0
I have a separate posting for troubleshooting CNC Homing here
You can now allow homing by setting $22=1 and $130-$133 to your maximum travel.
Once homing is enabled check the limit switch check boxes are not triggered. If one or more is make sure $5=1 in the settings. If it is still triggered you have a wiring fault or used the NO(Normally Open) connector on your switch.
Trigger each switch by hand and ensure you can see the check box with a tick. If you can’t then you have a wiring fault or wired the switches NO(Normally Open)
The Homing Cycle button will be red until a homing cycle is run. So click this button and watch each axis. If the axis starts to move in the wrong direction use the Invert Homing Direction check box to change the direction. Disconnect and Reconnect to ensure the settings are taken.
You can stop the homing cycle instantly by pressing the space bar or clicking the reset button.
I only use the 4 Min Limit pins with switches and soft limits for maximum travel ($130-133). You can use 8 switches but it adds a lot of extra wiring and points of failure. On my first foam cutter running with Mach3 software I had 8 switches, and I spent more time chasing broken or loose connections. I never exceeded the travel limits because I was ready to stop the machine if something went wrong.
Step 16 – Dry Run
Before you cut any foam use the sample g-code on the downloads page to ensure the machine runs as expected. If you have followed this guide then it should. Address any issues before setting the hot wire.
Step 17 – Hot Wire
The hot wire is connected to the D8 plug on the board. I use 0.4mm nichrome wire. My wire is tensioned by a bow which rests on guides. I have used a spring, but the bow puts less strain on the machine if you cut tapered wings.
Set the hot wire slider to around 10% and click the Turn Hotwire ON button. You may just be able to hear a slight buzzing. Keep your fingers away from the wire and try a piece of scrap foam to see if it melts.
To adjust the current to the wire, use the Override Current Setting buttons. Note that the slider will remain fixed while the g-code is running
Getting a good current setting for your wire may take several runs but I have put together a posting which explains a good method https://rckeith.co.uk/how-to-get-a-good-kerf-setting-for-cnc-foam-cutters/
Step 18 – First Cut
Now you are ready to try the sample g-code to check your machine. Home the machine or set all axes to zero.
Secure your foam block with double-sided tape or a weight. Jog the wire to the start of the foam.
Set your hot wire to a value you found in the previous step and click the run button.
Check the hot wire from above to make sure it is straight and not being pulled out of alignment. If the wire is being dragged, increase the current using the Override Current Setting. On the other hand, if the foam is melting much more than the width of the wire, reduce the current.
Step 19 – G-code generation
If you have reached this step then congratulations you can now build some exciting projects.
Now your machine is working you will want to generate some g-code for your projects. Please refer to this posting for the options available to you https://rckeith.co.uk/foam-wing-free-cnc-software/
I use DevWing Foam 2 and DevFus Foam 2 for all my projects. Although these are paid software options, I believe they are worth every penny. The free alternatives are sufficient for simple wings, but if you need advanced features like dihedral, washout, and lightning holes, these software packages are the best choice. Since I no longer purchase RC models, I’ve easily recouped the costs many times over
Summary
I hope this guide has helped you complete your machine. The mechanical build is fully documented in the eBook, and it should be used alongside this guide. If you encounter any issues, feel free to contact me through the website’s contact page.
Happy foam cutting