Wiring Limit Switches

patgadget edited this page Feb 13, 2018 · 13 revisions

The limit switches are used to detect the physical limits of the working area and to position the head in initial position during the homing process. Properly connected limit switches can increase significantly the reliability of the GRBL - the microcontroller pins connected to the switches are very vulnerable to any noise.

Before starting, make sure your coordinate frame is setup properly on your CNC machine and satisfies the right-hand rule. If you're not sure, its explained in the quick setup guide here. Otherwise, you will likely encounter problems with the homing cycle, where it behaves strangely. If you are having issues with the homing cycle, read this FAQ.

There are two types of end switches wiring:

  • Normally Opened end switches (NO) - switches are connected in parallel, if the head hits one of the switches the resistance becomes low (<10 Ohm). The wiring is simple but there is no indication if one of the switches is disconnected (broken wire).

  • Normally Closed end switches (NC) - switches are connected in serial, if the head hits one of the switches the resistance become high (> 1 MOhm). The wiring is more complicated but if any of the switches is disconnected (broken wire) this will be immediately detected. This is the way how all professional CNC machines end switches were wired.

The easiest way to attach limit switches to Arduino UNO is to just connect the switches to the corresponding pins and to rely on the internal weak pull up resistors (~47K) of the ATMega328 chip. The Normal connected (NC) switch wiring is shown below:

Normal Closed switches

The Normal Open (NO) switch wiring is shown below:

Normally Open

One improvement is to connect 1K to 4.7K pull up resistors to 5V and 100nF capacitors to GND. The extra pull ups and capacitors have noticeable noise suppression effect over the GRBL performance.

NC Filtered


Adding shielded cables to the end sensors or at least using twisted pair of two wires reduces further the noises injected from the next door stepper motor cables.

The ultimate solution for noise filtering on end switches is to add optocouplers - they have many benefits compared to the listed above solutions:

  • There is no direct galvanic connection between the end sensor and the microcontroller pin - any ESD discharges will not affect the GRBL controller
  • Optocouplers are inert elements - short glitches will simply not pass at all
  • Optocouplers are current driven elements and they require huge energy from the noises in order to pass - in normal operating conditions they effectively cut all the noises

During the discussion on GRBL forum we came to the following design of GRBL limit switch end sensor break out board - see the images below. The board is single side PCB (1.0mm to 1.6mm FR4) and uses connector with screws for attaching the end sensor wires. We recommend to use crimping of the wires before inserting them into the connectors.

The schematic of the end sensor board which uses optocouplers

The LIMIT SWITCH side and the ARDUINO side should use 2 different isolated power supply to take real advantage of the opto isolation.

BEST opto_limit

OK Schematic

The BOM file of used components and the estimated price of the board BOM

The 3D view of the board - this is how it will look like after assembly. Assembly

The bottom copper layer (viewed from top side of the board) Bottom Copper Layer

The top silkscreen layer (viewed from top side of the board) Silkscreen Layer

The bottom solder resist layer (viewed from top side of the board) Solder Resist Layer

The DXF file of the copper layer (view from bottom - ready for milling) GRBL.DXF.V2.zip

The GCode generated in CopperCam for milling the board - by having some CNC and engraving bit it's possible to mill the board from FR4.


The gerber files and the NC drill files for producing properly the PCB (you can send these files to any PCB factory to get good quality boards).


The schematic/BOM/PCBs and other layer images as single PDF for convenient documentation


For Woodpecker PCB the wiring of end switches should be done in the following way:

Woodpecker PCB

You can use some cable housing and crimp the wires to get more professional look (these housing connectors will fit straight into the board header)


You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.