copied from https://www.thingiverse.com/thing:3960187
thanks to Nick Renolds for sharing this
These are simple holders I designed to use common 10mm normally open barrel switches as end stops on the widely sold Eleksmaker Elekslaser diode laser engravers. I have included the OpenSCAD file if you would like to modify it for a different diameter switch.
More importantly though, this thing includes a how-to for automatic homing, including a pre-compiled GRBL image that works with 2-axis homing. By default, GRBL expects to home the Z-axis first and this does not work, even in ‘laser mode’ for a laser engraver.
As ever, be careful with laser engravers, they can blind you and/or start fires. This is a special risk with the EleksLaser as by default it is not enclosed.
You’re doing this at your own risk, I’m assuming a certain degree of competence in soldering, flashing firmware on Arduinos and so on. Don’t continue if you’re uncomfortable with making modifications to hardware.
Print out the four switch holders and slide them into the aluminium channel on the X and Y axis, as shown in the photos. The X axis holders are slightly longer than the Y axis holders.
The tolerance is quite tight so they hold snugly in place, they may need tapping in to the aluminium channel with the back of a screwdriver or drift. The holders are just the right length to sit hard against the acrylic end pieces and keep the switch in the right place.
The EleksMana SE controller of the EleksLaser does not expose any end stop pins, even though GRBL supports them, so you have to solder directly to the underneath of the board. Look at the Arduino nano clone and count the pins to find out where they appear on the bottom of the controller board.
Connect the two X end stop switches in parallel between pin 9 of the Arduino and Gnd
Connect the two Y end stop switches in parallel between pin 10 of the Arduino and Gnd.
To make this work, GRBL also needs to be configured, both with compile time options and machine settings.
You need to specifically compile GRBL for 2-axis homing, seehttps://github.com/gnea/grbl/wiki/Frequently-Asked-Questions#how-do-i-configure-my-homing-cycle-to-just-do-2-axes-or-i-have-a-pen-plotter-and-dont-have-a-z-axis
I have included a pre-compiled .hex file if you do not wish to do this yourself. Make sure you take a copy of your current GRBL settings by connecting to it over a serial terminal and typing ‘$$’ as flashing your controller will wipe all your settings.
To flash the Arduino clone on the EleksMana controller with the .hex file, use the included XLoader Windows application, setting it for an Arduino Nano 328p. The original XLoader author’s website has disappeared so I include a copy for convenience only, it is not my work.
Please read the documentation on the homing cycle in GRBL once you’ve flashed the controller.https://github.com/gnea/grbl/wiki/Set-up-the-Homing-Cycle
In short, to configure it to enable hard end stops and homing send it the following commands over a serial terminal…
$22=1 ; Enable Homing
$23=1 ; Set Home as top left of the work area
$24=25 ; Slow homing speed, after first finding the limit switch
$25=500 ; Fast homing speed, to get to limit switch
$21=1 ; Enable hard limits
If you would like the engraver to home to the bottom left instead, send $23=3 to the controller over the terminal. The homing speeds are very conservative, feel free to tweak them upwards.
To make the machine find home, send the following over a serial terminal…
$H ; Home now!
Also, now it has hard limits configured, it should never again smash into the end of its travel.
I hope you find this information useful.