Limit switches (also referred to as end stops or homing switches) are sensors that sit at one or both ends of each movement axis of a CNC to provide a few different functions. There are many different limit switch designs which broadly fall under being either mechanical or non-mechanical (ex. inductive).
In order to use limit switches, you will need to make modifications to both the electronics and firmware of the machine. For more in-depth information on the firmware, specifically the settings required to enable limit switch capability, visit the GRBL v1.1 Configuration Guide.
Do I Need Limit Switches?
The LongMill does NOT need limit switches to operate and doesn’t include them by default. Many individuals are drawn to having switches by convention, but most times a limit switch exists to either:
- Define soft or hard limits* in order to prevent a CNC from damaging itself if it travels past its movement limits
- Repeatably locate the machine (homing) for jogging / work offsets, saving a job that’s gone bad, or to resume existing work done for a multi-part job
The LongMill design addresses these functions by way of:
- Being designed so that hitting the ends of its travel area causes zero damage to the machine
- In larger, more powerful machines such as VMCs and industrial CNC routers, crashing a machine can very well mean costly damage to your machine so limit switches are cheap insurance to prevent that. However, on hobby machines like the LongMill, the machine is not powerful enough to cause damage to itself, and so are not really necessary. In fact, in some cases, it can be more of a hassle as accidental triggers can ruin a project.
- Locating the machine can easily be done via the use of a touch plate
- ‘Homing’ is just the act of calibrating a CNC to a particular spot repeatably so that if, for example, you lose your CNC position due to a power outage or for a tool-change then you can find that position again using the offset distance from the calibrated point. This calibrated point can be set using limit switches but can just as easily be a touch plate or conductive geometry that a tool can touch off
With this being said, some users may still choose to integrate switches into their machine if they start to find themselves running longer and longer jobs, performing more complex cuts, or they’re looking for easier job relocation without having to keep their touch plate in mind.
*A soft limit is when there is a single switch on one side of the movement and the movement limit is defined in software, whereas a hard limit has two switches on either movement end which signal a ‘Stop’ to the controller if triggered.
Already the LongMill controller comes with two different input spaces (a JST-XH connector for each axis and a screw terminal connector) that allows easy connection of any kind of switch. If you are intent on installing switches yourself, here are some points we’d like to ensure you’re aware of:
- For limit switches on a CNC what matters most is that the sensing happens precisely and that the accuracy deviates very little with changes in the surrounding environment, otherwise the switch might activate 2mm away when you’ve got your shed heater on but 3mm away if you open the door. Each manufacturer should provide theses sorts of details in their sensor documentation.
- It’s very important to shield and filter noise along the lines with the limit switches, as interference can cause the limits to trigger erratically. We have found that placing a 0.1uF capacitor across the input and ground for each limit helps to prevent errant triggers.
- If you are wiring limits to both ends of the axis, you can put them parallel to each other.
- All of the switches share the same ground.
Installing the Sienci Labs Inductive Sensor Kit
The inductive sensor kit is a plug-and-play add-on kit for your LongMill, which adds three inductive sensors to your machine to act as limit and homing switches. Please note that this part of the resources is still in development and the kit is not available yet. The kit is expected to be available for sale around mid to end of September.
Step 1 – Unpacking
Each kit comes with
- M3-10mm or M3-12mm socket head cap screws for mounting the brackets
- An X, Y, and Z mounting bracket
- 3 inductive sensors
- 3 0.1uF – (104) Ceramic Capacitors*
*These capacitors are only needed for LongBoards Rev 1.1 and Rev 1.2. If your LongBoard is Rev 1.3 and above, you will not need these and they can be set aside.
You will need for installation:
- A 2.5mm Allen key
- 17mm wrench or adjustable wrench*
**All kits will have the inductive sensors pre-installed and a wrench is only needed if you wish to make tweaks to the placement of the sensors themselves.
Ensure that you have all of your parts before installing the sensors.
Before you begin, you will have to decide where you want to place your sensors and which direction you want your homing sequence to go. You can either have your machine home to the lower-left corner, upper left corner, lower right corner, and upper right corner of your machine. We recommend homing to the lower-left corner or your upper left corner for reasons that will be discussed below.
Homing to the bottom left corner (recommended)
It is a fairly common practice to use the bottom left corner of your stock as your origin point when creating gcode. With this regard, using the bottom left corner of your machine offers a couple of advantages. First, if the majority of your projects use the lower-left corner of the machine, you can use the home position of your machine as the zero position of your project. Some users may want to create some sort of jig or stop to butt the material against it to create a repeatable starting point for their jobs. Secondly, if you followed our instructions when mounting your LongMill when squaring your machine by running the machine to the back, you will not run into the sensors as you may when having your sensors installed at the back.
Homing to the upper left corner
Homing to the upper left corner is also a common homing location. Some folks may prefer this sequence as it allows the machine to move out of the way of the workspace to make it easier to place and remove the workpiece. However, additional consideration may need to be made to prevent the machine from damaging the rear sensor when squaring the machine.
Step 2 – Attaching to the machine
Each bracket uses a pair of M3 screws to mount to the machine. Simply slide the bracket onto the recommended location and tighten the M3 screws using a 2.5mm Allen key into the brass heatset nuts until snug. Do not over tighten, as this could damage the bracket, but ensure that the bracket cannot move easily.
The Z-axis sensor mount slides directly on the top end of the left-side Z-axis rail, ensuring the mount is pressed onto the rail as far as it can go. Depending on your model, you may need to loosen the nut on the sensor and adjust how far it extends down. For older models (V1) with the flat top Z-axis gantry plate, the sensor will need to be moved upwards as shown in the right photo. For newer models (V2, V3) with the notch at the top of the z-axis gantry plate, the sensor sits at the upper position as shown in the left photo. Step 3 contains additional information on adjusting the sensors on the brackets.
Although the Z-axis sensor mount is self-aligning, the X and Y-axis sensor mounts are not, as they are designed to allow use in multiple configurations. Firstly, the X-axis sensor mount is attached to the machine by sliding it onto the top of the left steel gantry plate, so it is touching the aluminum rail as shown in the photo below. If you’d like to home the machine to the right side, install the X-axis sensor mount on the right steel gantry plate, mirrored to what is shown in the photo.
Next, the Y-axis sensor slides onto the front left 3D-printed plastic foot. It must be aligned so the mounting tab of the sensor mount lines up with the edge of the extrusion. Alternatively, you can move the X-axis gantry forward and align this sensor by eye. Unscrew and remove the sensor from the mount and look through the hole of the sensor to line up the gantry plate with the hole center. These methods are illustrated below.
The Y-axis sensor mount is designed so it can be used on any of the four corners/feet of the machine, should you wish to home the machine to the back or mount the sensor on the right side, the same installation applies, but you must flip the sensor inside the mount if installing in on the left-back or front right foot.
Step 3 – Adjusting the sensors on the brackets
All three inductive sensors are identical and are mounted to the brackets to allow for installation onto the machine. In most cases, you should be able to use this position to set up your machine. However, you can adjust them if you want to tweak the location of the sensors. Instructions on adjusting the sensors are as follows.
Start by removing one nut and washer from each sensor and set it aside. Then slide the sensor through the hole of each mount.
Next, reinstall the nut and washer to secure the sensor in place on the bracket. Note that the Z-axis sensor does not use a washer on the lower nut.
We recommend a certain amount of stick out for each sensor. You may choose to adjust the stick out based on your machine’s configuration and if you have any accessories attached. To adjust, simply loosen and retighten the nuts and washers on your sensor using a 17mm wrench to place the sensor in your ideal location. Each sensor is assembled as shown below for reference.
Step 4 – Connecting the sensors to the LongBoard controller
Unclip the tabs that hold the wires in each drag chain and route the cables from the inductive sensors. The Z-axis sensor will get routed through the drag chains against the X and Y rail, and the X-axis sensor gets routed through the drag chain against the Y-axis only. The Y-axis sensor does not need to be routed through a drag chain. Ensure that there are no sharp bends or tears in the cables as a failed limit sensor could cause a false alarm and halt the machine during use.
The three cables plug into the three white JST connectors labeled as XLim, YLim, ZLim. To make sure each of the sensors is plugged into the correct port for its axis, it is recommended to label the cable with tape and marker before routing the cables, or plug-in each cable as they are routed through the machine individually.
Once installed, you can verify that each sensor is working and is plugged into the correct port for its axis by using the console within UGS, gSender, or other machine interface software. Type the following command into the console: $10=19 and press enter. This will enable reporting of the current status of each of the sensors. After you’ve finished checking that each sensor is reporting correctly, you can set disable sensor status reporting by setting the default value: $10=3
You can either jog the machine to a position where a sensor is triggered (shown by a red light on the sensor), or hold anything made of steel in front of the sensor. While the sensor is triggered, enter the following command into the console: ?
The console will now report back to you which limit sensor is triggered, indicated by an X, Y, or Z. Check this for each of the three sensors/axis to make sure the axis sensor reported matches the axis of the sensor you’re manually triggering. If the reported triggered sensor does not match the sensor you are triggering, swap the cable plugs at the board as necessary so they all match. This can also be very useful for diagnosing issues with your sensors, should you have any.
Step 5 – Changing your settings for limit switches
If you received your machine before September 2021, you may need to update your LongMill’s firmware to the latest version to have access to all of the updates to make your limit switches work. You can check what version of the firmware you are using by checking the console output of the LongMill when you first connect it to the gcode sender. At the time of writing, the latest version of the LongMill firmware is Sept 8, 2021.
Your LongMill firmware can be updated with just a couple of clicks. Simply connect your machine to gSender, click on “Firmware”, and click on the “Flash GRBL” button. Follow the prompts to install the latest version of the firmware onto your LongBoard.
Next, import our default EEPROM settings for your machine with limit switches. Use the “Import Settings” tool and update your EEPROM settings to the new defaults (link to download file coming soon). If you wish to make changes or adjustments, additional info about changing your EEPROM settings can be found further down on this page.
Step 6 – Using your sensors
At this stage, you’re ready to start using your sensors. Below is a further guide on using your sensors.
Hard limits and soft limits
Hitting the limit of the movement on your machine isn’t always pleasant. Limits are useful in preventing this from ever happening, and come in two forms; hard and soft limits. Hard limits are hardware-based, and stop movement in a direction when a physical switch or sensor is triggered. Soft limits are software-based, and stop movement in a direction when the machine believes it has moved outside its predefined limit in a direction. While hard limits will always prevent your machine from extending past its limits and crashing, soft limits will not if they are not set up right or the machine has an incorrect relative position.
In the use case of this sensor kit, if you wish to have limits in all directions of your machine to prevent crashing, it is possible to use hard and soft limits in conjunction to reliably limit the movement of your machine. For a machine setup to home in the bottom left corner, the physical limit switches can act as hard limits, while the soft limits can act to prevent movement in the opposite direction (towards the upper right corner). Because the machine is able to home very easily and accurately using sensors, the soft limits can now work reliably as the machine can know a reliable position relative to the homing location at all times and avoid movements. If any command to move beyond the set soft limits is sent, an error will be returned and the machine will need to be reset and homed again.
If you wish to use soft limits on your machine, there are some firmware changes that must be made. From within gSender, open the ‘Firmware’ window again, where we previously set up the homing cycle. Here, we will need to enable ‘Soft limits’, as well as specify the maximum travel of the machine is the X, Y and Z direction.
For the 30×30 LongMill, a maximum travel of 750mm in the X-direction, and 810mm in the Y-direction is suitable, however, these will, of course, be different for smaller machines, or if you have any modifications or accessories. The best way to set these limits is to home your machine, zero all axes, then jog each axis to where you feel comfortable limiting it. Use the shown coordinates to set your maximum travel for each axis as necessary.
The Z-axis maximum travel should be set to prevent the router from crashing into the work surface, not the bit. Having your Z-axis maximum travel too low could cause errors during cutting and a failed job if you don’t permit the Z-axis to travel low enough.
Homing the machine
With the new firmware settings applied as discussed in step 5, the machine will now enter an alarm state upon powering up. This alarm state will activate whenever the homing cycle is enabled, and the machine does not know its current position. We must now home the machine to get out of this alarm state or unlock the machine to perform other functions.
To do so, press the ‘Home’ button if you’re using gSender, or ‘Home Machine’ if you’re using UGS. Alternatively, you can home the machine by sending the command $H in the console of whichever machine interface you’re using. If you’re homing the machine for the very first time, it is recommended to be ready to press the emergency stop button at any time if you see the machine homing in the wrong direction, or not stopping once any sensor is triggered. Once the homing cycle is complete, the machine will stop at its home position and set it’s own machine coordinate system relative to this position.
With GRBL, the machine coordinate system is set with the origin at the back right corner with the tool raised to the maximum height as illustrated below. This may be unintuitive, as the machine is ‘homed’ to the opposite front left corner. Regardless, this does not affect how work offsets can be used. After homing, the machine coordinates will read out as the negative maximum travel set in the X and Y direction, while the Z will be -1.00, as the Z-axis moves down by 1 mm after homing.
With CNC, work offsets can be thought of as bookmarks. They are saved origin positions on your machine that allow you to always return later to a known location. Having one or more known locations you can repeatedly return to is extremely useful for many reasons such as restarting a failed job, recovering from a power outage during a job, repeating a job in a fixture or multiple fixtures, returning to an exact work XY origin after performing a tool change. The repeatability of the inductive limit switches has been tested to be less than 0.001”, meaning that you will always be able to return to your original work origin within 0.001” accuracy, and can confidently repeat jobs without worries of toolpath misalignment or crashes.
To change work offsets or workspaces, simply select one of the 6 workspaces from the drop-down list in the top right corner of gSender as shown in the photo below. Alternatively, entering the command G54, G55, G56.. etc. into the console of gSender or UGS will tell the machine to switch into that workspace. You will notice the work coordinates (blue numbers) will change upon switching workspaces to whatever the coordinates are within the new workspace. The machine coordinates (grey numbers) will always remain the same regardless, as these are of course relative to your machine’s home position.
All 6 of these workspaces are modal settings, meaning they will be saved by the controller even after powering off the machine. For this reason, work offsets with the ability to home the machine give you the confidence to know your job’s relative position no matter what.
Wiring you own limit switches
In order to attach limit switches to your setup, you will need the following:
- Soldering iron
- Heat shrink
- 4-pin JST connectors (optional)
- 20-24 AWG copper stranded wire
- Limit switches, either mechanical or inductive
- 3x 10 kΩ resistor (for Rev 1.2 and Rev 1.3)
- 3x 0.1 mF ceramic non-polarized capacitors (for Rev 1.2)
You can check the version of your Longboard on top of your control box.
The first step is to figure out where to wire your limit switches. Each limit switch will come with 3 wires, signal, GND and 5V. They will either be bare wires or come with connectors. For switches that come with 4-pin JST connectors, you can simply plug the switches into the white connectors on the side of your control board, making sure the wiring is correct based on the type of switch you have (NO, NC, NPN, PNP). If you have just the switch and wires, use the green connectors because you can fasten down wires with these connectors.
For mechanical switches, each switch must be wired to a different signal line, then to GND, as indicated in the “x3” label on the diagram. For inductive switches, each switch must be wired to a different signal line, then to GND and 5V, as indicated in the “x3” label on the diagram.
Next, you will need to extend or attach the wiring for your limit switches, and find an appropriate place to mount them on the LongMill. If you are using a different limit switch, you can create your own limit switch mounts by designing and cutting them out on the machine or 3D printing them as well. Make sure the wire is long enough to reach the control board from the machine.
The type of switch used must be considered for proper wiring. For NO and NC mechanical switches, refer to the diagrams below for proper wiring. The blue lines indicate the signal line (XLim, YLim and ZLim) and the green lines indicate the ground line (GND). If you are using two switches per axis, the wiring between the them is indicated below as well.
If you have a Rev 1.2 or 1.3 Longboard, it is necessary to attach the resistors and/or capacitors as specified. Refer to the diagrams below for the additional wiring. The red 5V line is used to produce the noise filtering effects via capacitor and to establish the correct voltage via resistor.
The limit switches must also be included as described in the previous diagrams, making connections between their respective signal line and ground. In Rev 1.2, you wire the limit switch between the resistor and the capacitor. In Rev 1.3, you wire the limit switch between the resistor and the signal pin.
Before you solder anything, make a plan and dry fit all these components into their approximate locations. Once you have settled on their placements, you can solder your circuit together.
Once you’ve assembled all the electrical connections to the Longboard, you can enable limit switches, in which you will need to change a couple of settings on your LongMill’s firmware. Settings can be changed by sending the command to update the EEPROM settings manually through the console, or using the “Firmware Tool” on gSender. Below, we have listed the settings that you may want to enable.
$5 – Limit pins invert, boolean
For NO or NPN, this setting should be $5=0, so that the input and output pins are set to the proper voltage level to function properly. For NC or PNP, this setting should be set to $5=1.
$20 and $21 – Soft limits and hard limits enable
If you have two switches per axis, use $20=0 and $21=1 to enable hard limits. If you have one switch per axis, use $20=1 and $21=0 to enable soft limits.
$22 – Homing cycle, boolean
By default, your LongMill is set to $22=0, disabling the ability to use the homing cycle. Activate homing by sending the command $22=1. When homing is activated, every time your machine is connected, your machine will ask you to home the machine as a safety feature. You can home your machine by sending the command $H through the console, or use the “Home” button on your gcode sender.
$23 – Homing direction invert, mask
By default, your LongMill is set to $23=0. This setting is used to select the direction that the machine moves to home each axis. By default, when $23=0, the machine will move home up in the Z direction, and then to the upper left corner (moving towards the left on the X axis and moving up to the top on the Y axis).
In some cases you may want to change the direction that you want to home, either based on the location of your limit switch and the way you want to set up your workflow. For example, if you have a square at the bottom left corner of your machine where you can set a corner you can set rectangular material on so that you can repeat the same job over and over again, you may want to invert the Y axis homing direction so that your machine homes to the bottom left corner of the machine.
|Setting Value||Mask||Invert X||Invert Y||Invert Z|
When looking at the table on inverting each axis, setting value 2 inverts the direction of the Y motor only. So by sending command $23=2, the Y axis homing direction will be reversed.
On gSender, you can use the toggles instead to change the direction of each axis.
$24 – Homing locate feedrate, mm/min
By default, this speed is set to $24=25, which sets the homing locate feedrate to 25mm/min. When homing your machine, the machine will first move at a preset speed (see $25 – Homing Seek) to more rapidly reach the limit switch, move away from the switch to deactivate it, then move towards the limit switch at a slower speed for a more accurate reading.
We recommend keeping this value at 25mm/min as it works for most limit switches.
$25 – Homing seek, mm/min
By default, this speed is set to $25=500, which sets the homing search seek rate to 500mm/min. This is the speed of which the machine will move to locate each limit switch.
$26 Homing switch debounce delay, ms
By default, this time is set to $26=250, which controls the delay before the controller measuring if the signal is on or off. Some switches can take a few moments before a on or off signal is defined. We recommend keeping this at its default setting. However, if you find that your switch randomly triggers for no reason, you may want to increase the debounce delay.
$27 Homing pull-off distance, mm
By default, this distance is set to $27=1. This distance determines the distance that the machine needs to move away from the switch to un-trigger it. For some sensors, such as mechanical switches, this can be a few millimetres, while inductive proximity sensors may only need a fraction of a millimetre. For inductive sensors, we recommend keeping your default homing pull-off distance at 1mm, while if you are using mechanical switches, use about 2-4mm to ensure that your switch is completely untriggered after your homing sequence.
Endstop Controls in gSender
In order to conduct a homing cycle and other endstop functionality, go to gSender’s Firmware tool and enable homing cycle ($22). After saving this, you should see the “Home” button and the 4 ‘corner’ buttons. The “Home” button will initiate the homing cycle, meaning the machine will use the limit switches to position itself. Once the homing cycle has been completed successfully, the ‘corner’ buttons will be available, and you can use them to move the machine to the corner positions. Below is an explanation on how the homing cycle works.
Testing Limit Switches
Once the firmware and program changes have been made, test the limit switches you have installed. When you connect to the machine, look for a red button to unlock the machine. This is the reminder for you to home your machine before starting a job.
Then press the “Home” button on the right side to begin the limit switch homing cycle.
On gSender, the process for limit switch homing is very similar to touch plate probing. This is what happens on the LongMill when you run the homing cycle with the soft limits enabled:
- Machine moves up quickly in the Z-axis, until the switch gets triggered
- Machine retracts slightly, moves up slowly in the Z-axis, until switch gets triggered again
- Machine quickly moves diagonally across table to upper right corner, until the switch gets triggered
- Machine retracts slightly, slowly moves diagonally across table to upper right corner, until switch gets triggered again
If this process completes without any errors, you have successfully homed your machine!