Skip to content

Wiring Hookup for CNC with RAMPS 1.4

bdurbrow edited this page Aug 4, 2019 · 9 revisions

Hooking up a RAMPS 1.4 board as a CNC controller

Hooking up a RAMPS 1.4 board as a CNC controller with GRBL is similar to hooking it up as a 3D printer with standard 3D printer firmware (Marlin, etc). However, there are several differences, that this wiki page aims to document.

What's the same:

  • Power Supply
  • Stepper motor setup (with the exception of cloned axis configuration... see below).
  • Arduino Mega 2560 board
  • RepRap Discount Smart Controller LCD, Encoder Wheel, & SD Card interface.

What's different:

  • 4x4 Matrix Keypad
  • Manual Pulse Generator (MPG) Encoder Handwheel for Jogging
  • Rapid, Feed, & Spindle Override Potentiometers
  • Cycle Start, Feed Hold, Safety Door, & Soft Reset Switches
  • Home/Limit Switches
  • Axis Cloning
  • Coolant Pumps
  • Spindle Control
  • Probe Input

Wiring Overview

Details

4x4 Matrix Keypad

Suitable 4x4 matrix keypads are available in a variety of configurations and styles. The lowest cost option commonly found is a self-adhesive membrane keypad with a 0.1" female header attached. That is what is documented here.

The connector on these is usually wired as follows, from left to right, as you are looking down on the keypad with the connector flat:

  • Row 1 (the uppermost)
  • Row 2
  • Row 3
  • Row 4 (the lowermost)
  • Column 1 (the leftmost)
  • Column 2
  • Column 3
  • Column 4 (the rightmost)

To connect this to the RAMPS board, you will need to create a wiring harness with the leftmost pin of the keypad connector (keypad row 1) going to the upper-right connector on RAMPS Aux 2; the next pin on the keypad connector going to the second rightmost pin on Aux 2, etc. See the Wiring Overview image above for the complete pinout of Aux 2 as it is used in the default configuration.

If you have a keypad that is not wired in the same way, you can either revise the wiring harness that you create so that the correct row and column connections are made to Aux 2, or you can edit the cpu_map.h file to reflect the actual pinout of the hardware that you have.

Note that there is a file in the "UI Support" folder called "Keypad.pdf" with the key functions on it that you can print out and use as an overlay for these membrane style keypads.

Manual Pulse Generator (MPG) Encoder Handwheel for Jogging

CNC Manual Pulse Generators are a type of quadrature encoder. As such, they have two primary outputs, Phase A and Phase B. Some also have inverted outputs as well - Phase A' and Phase B'. These inverted outputs will not be used in this setup.

The default configuration maps the MPG inputs to Arduino pins 2 and 3. On the RAMPS board, these are brought out as the end stop inputs for the X axis - consequently, this setup requires connecting the end stop switches differently (see below for more information).

Connect the Phase A output to the input on the RAMPS board labeled for the X- end stop; and connect the Phase B output to the next input over (there is no label on the RAMPS board, but it is between the X- and Y- input). 5v power and ground that the handwheel will need is available on this set of header pins as well.

If turning the handwheel seems to make the machine go backwards from the way you would expect, then flip the wires going to Phase A and Phase B on the handwheel.

Rapid, Feed, & Spindle Override Potentiometers

The RAMPS board is set up for three analog inputs that, on a 3D printer, are used for thermistors for detecting bed and extruder temperature. However, the circuit for these inputs works well with a 5K ohm potentiometer; and the software will read these and map them to overrides for rapid speed, feed, and spindle RPM.

Standard potentiometers have three terminals on them; the two outermost ones connect to the resistor element itself, and the middle one connects to the wiper that moves when you turn the shaft.

To use a potentiometer with the RAMPS board, connect one of the outermost pins on the potentiometer to the ground pin on the thermistor input on the RAMPS board, and the middle (wiper) pin to the input pin on the RAMPS board. If turning the potentiometer seems backwards, use the other outermost pin on the potentiometer (while you are figuring out which way you want it to go, it's helpful to use some alligator clips or mini-grabbers to test the circuit before soldering it in place).

Note that by default, the potentiometers are turned off in config.h. To use a specific potentiometer for an override, you will need to turn the option on in config.h, re-build GRBL, and re-download it to your Arduino Mega. Look around line 664 in config.h for the options to turn on.

Cycle Start, Feed Hold, Safety Door, & Soft Reset Switches

The standard version of grbl for the Arduino Mega had the inputs for these functions mapped to the Aux 2 port on the RAMPS board. However, that port was needed for the matrix keypad... so these had to be moved elsewhere. The configuration as distributed in this repository puts those inputs on unused pins on Aux 4.

Fortunately, these otherwise unused pins are all clustered together; making it relatively easy to either remove the pins from the RAMPS board (if you have suitable desoldering equipment) or bend them 90 degrees outwards to connect 0.100" 'dupont' style jumper wires to. When bending the pins, using needle-nose pliers is helpful. Note that if you choose to bend the pins you will need to cut and remove the plastic spacer from the male header for those pins in order to provide clearance once the adapter PCB for the LCD panel connectors is installed (an X-acto style knife or razor blade seems to work better than 'nippy' style cutters, as the cutters tend to bend the surrounding pins more - just be careful that you don't slip and cut yourself!).

On the Aux 4 connector, these pins can be found towards the bottom of the connector. See the Wiring Overview image above for more details on the exact pin location.

The standard configuration expects these switches to be normally open momentary switches wired with one side of the switch to the input pin, and the other side of the switch connected to ground.

A convenient ground connection can be found on the location marked "12V-AUX" on the RAMPS board. This location is indicated on the Wiring Overview image as "Control Switch Ground". Be careful that you get the ground pad here - the other one is connected directly to the power inputs, and using it will kill your Arduino!

Bent Pin method

Home/Limit Switches

The main grbl wiki has some good information on hooking up your limit switches; and while the general principals do apply, where you will be connecting them will, of course, be different for the RAMPS board.

As the ATMega2560 pins that had been routed to the X axis minimum and maximum switches are needed for the MPG handwheel, the actual location where you will connect your switches will be different than what is printed on the RAMPS board.

From left to right, the first two input pins on the limit switch header are used by the MPG handwheel. Next, marked "Y-" on the RAMPS board, is where you will connect your X axis minimum limit switch. Following that, is the input for the Y axis minimum limit switch. If you have a cloned axis enabled, you will connect it's limit switch to the next pin; otherwise leave this pin disconnected. In the rightmost position of the header is where you will connect the Z axis maximum limit switch.

See the Wiring Overview image above for the exact pinout as actually used by this software in it's default configuration.

Note that when this document refers to a 'minimum' limit switch, it's referring to a limit switch positioned on the machine such that it trips when that axis reaches it's 0.000 position (and likewise, the 'maximum' limit switch is one positioned such that it trips when the axis reaches the most positive position it can - for example, if you have a Z axis that has 300mm of travel, the Z maximum limit switch will trip when the Z axis reaches 300.000mm).

Axis Cloning

Axis Cloning allows you to have the step & direction outputs for the X or Y axis be sent to a second stepper driver. By default it's turned off; but you can enable it in cpu_map.h - look around line 167 for the options to turn it on. The standard configuration in cpu_map.h maps the cloned X axis to the E0 stepper driver on the RAMPS board; and the cloned Y axis to the E1 stepper driver.

At the moment auto-squaring of the machine is not yet implemented, however when it is; to use it you would connect a limit switch on the cloned axis such that when the main motor is in it's 0.0000 position, the cloned axis limit switch will trip when the machine is square (i.e, the cloned axis motor is also in it's proper 0.0000 position).

Coolant Pumps

The RAMPS board includes several MOSFET transistors that can be used to activate flood or mist coolant pumps for your machine.

The output marked D10 on the RAMPS board is by default mapped to the flood coolant output; and the output marked D9 is mapped to mist coolant.

Note that you may need to put a 'snubber' diode across your pump connections, depending on what transistor the specific RAMPS board you have was fitted with. If so, connect the diode reverse-biased; so that under normal circumstances it will not conduct when the pump is turned on.

If you need to use a pump that runs at a voltage different than what you are driving your stepper motors at, or do not want to use the same power supply to power the pump; then use a relay to activate it (preferably a solid-state relay; mechanical relays have the same issue with possibly needing a snubber diode as motors do).

Spindle Control

Spindle control is mapped to the Servo output pins on the RAMPS board. Other than the pin locations on the board, and the presence of a discreet Spindle Enable pin, it functions similarly to a standard grbl setup.

The right three servo outputs are what the standard configuration maps the spindle outputs to. From the right, first is the Spindle Enable output; next is the Spindle Direction output; and on the leftmost position of the group of three pins is the Spindle Speed output (this is the PWM output).

See the Wiring Overview for a graphical illustration of this pinout.

Probe Input

The input for the spindle probe is mapped to the Aux 1 connector on the RAMPS board. Both 5v and ground are available on this pin header. See the Wiring Overview section for the exact pinout of this connector.

Attribution and Resources

The original image used in the Wiring Overview was found on the RepRap.org website:

https://reprap.org/wiki/File:Arduinomega1-4connectors.png

The main page for the RAMPS 1.4 board has lots of useful information on how to hook it up:

https://reprap.org/wiki/RAMPS_1.4

Likewise, their sub-forum for RAMPS is quite nice:

https://reprap.org/forum/list.php?219