-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Wiring Limit Switches
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:
The Normal Open (NO) switch wiring is shown below:
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.
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 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 supply to take real advantage of the opto isolation
The BOM file of used components and the estimated price of the board
The 3D view of the board - this is how it will look like after assembly.
The bottom copper layer (viewed from top side of the board)
The top silkscreen layer (viewed from top side of the board)
The bottom solder resist layer (viewed from top side of the board)
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
End.switches.break.out.board.pdf
For Woodpecker PCB the wiring of end switches should be done in the following way:
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)
http://uk.farnell.com/multicomp/2226a-02/crimp-housing-1-row-2-way/dp/1593506