Fitting End Stop Limit Switches to a CNC Machine
A guide to fitting micro-switches to a CNC machine to act as End Stop Limit Switches. Also covers electromagnetic interference (EMI) issues and how these can be addressed.
Introduction
This guide will show you how to fit end stop limit switches to your CNC machine. A small CNC 1610 machine is used as an example, but the same procedures can be followed for any CNC machine. Simple low-cost micro switches have been used with DuPont style headers suitable for direct connection to many CNC controller boards including the Woodpecker boards or the Arduino CNC Shield shown here.
Also described are problems that can be encountered with electromagnetic interference (EMI) which are likely to occur with a machine such as this. These EMI problems will manifest themselves as the machine stopping randomly and going in to an alarm state, caused by a false triggering of the end stops. Methods that can be used to eliminate these problems are described here.
All the procedures described in this guide have been used in practice and found to work successfully.
Fitting the End Stop Limit Switches
The micro switches used in this project were chosen for their small size, low cost and the hinge lever which actuates the switch. They are a single pole double throw (SPDT) switch which means they have both normally open (NO) and normally closed (NC) contacts. It is the normally open (NO) contact that is used here in conjunction with the common (C) contact.
Although the micro switches chosen here have proven reliable and capable of good repeatability in terms of the CNC machine homing cycle, alternatives could be used which may give some improvement. You might like try variants with a roller lever arm, which might give a smoother and more repeatable switching action if the friction between the lever arm and the body of the CNC machine is reduced. Some careful experimentation would be required to establish if these give any improvement in practice. The procedures for fitting the micro switches to the CNC machine do not change regardless of the switch chosen, although it is advised that the physical size of the micro switch is checked before purchasing.
Parts Required
The following parts will be required to fit the end stop limit switches. Please note that there are alternatives available for many of the parts on the list and so you may need to buy equivalent parts that may be more easily available in your locality. Also, the information links provided are intended to show examples of products that meet the requirements of the project and are not a recommendation of any particular supplier or product.
Part | Description | Manufacturer | Part Number | Quantity | Information Link |
---|---|---|---|---|---|
Micro Switch | SPDT Lever Momentary Action Micro Switch3 | Various | - | 6 | Amazon |
Ribbon Cable | Ribbon Cable for 2.54mm Connectors1 | Various | - | - | Amazon |
Two Core Screened Cable | Lightweight Lapped Screen Braid Cable1 | RS Components | 749-2541 | 1 | RS Components |
DuPont Connector Header Kit | DuPont connector header kit with terminals and crimper3 | Various | - | 1 | Amazon |
Heatshrink Tubing | Heatshrink tubing kit - various sizes3 | Various | - | 1 | Amazon |
Epoxy Adhesive | Two Part Epoxy Adhesive Fast Setting2 | Various | - | 1 | Amazon |
1 The ribbon cable was used in this project, but the two core lapped screened cable can be used as an alternative if required.
2 Any suitable alternative such as Super Glue can be used.
3 Given as an example only. Many alternative manufacturers and suppliers exist - choose suitable parts that are available to you locally.
Step by Step Guide
Step 1 - Connecting Cables
Start by soldering your connecting wires on to the normally open (NO) and common (C) connections on your micro switches. Ensure that you have sufficient cable to run back to the appropriate header connection on your CNC Shield (or other CNC controller). The soldered connections should be insulated using short lengths of suitable diameter heatshrink tubing so as to prevent accidental shorting to the frame of the CNC machine. This project used the slots in the 2020 aluminium extrusion of the CNC 1610 machine as cable routes in an attempt to neaten the overall appearance of the cabling, so allow for this in the cable length that you leave. Note that ribbon cable was used here, although this could be replaced with the two core shield cable if required (see EMI discussion later).
Once all the cables have been soldered on to the micro switches, the opposite ends of the cables should have two way DuPont style female headers crimped on them, in preparation for connecting to the CNC controller.
Step 2 - Fix the Micro Switches to the CNC Machine's Frame
The positive and negative end stop limit switches should now be fixed in place using a strong epoxy adhesive at a suitable position on the frame of your CNC machine. The positions shown in the series of photographs below have been found to work very well.
Ensure that you position each micro switch and operate it a few times before gluing them in place in order to gauge it's exact position, so that the switch will operate just before a mechanical collision occurs between the frame of your machine and it's table or spindle assembly.
Step 3 - Route the Cables and Connect to the CNC Controller
Carefully route your limit switch cables around your CNC machine so that they will not get caught easily or get trapped when the machine is in motion. Use cable ties or insulating tape to fix them in position. You may find that the slots in the 2020 profile aluminium extrusion (or similar) can prove useful here.
Once all the cables have been routed back to the CNC controller, plug each of the cables in to the appropriate header which will be clearly marked on your CNC controller board.
Step 4 - Enable Hard Limits and Homing in Grbl Settings
Use your Grbl control software to enable both Hard limits (setting $21) and the Homing Cycle (setting $22) in the Grbl settings of your CNC controller.
Note that when you first power up your CNC machine after having done this it will automatically start in an Alarm Lock state. This is a safety feature to stop your machine making a positioning mistake. You will need to run a homing cycle in order for your machine to establish it's positioning information and for the lock to be disabled.
Problems with Electromagnetic Interference
The limit switches that are now attached to the CNC machine are designed to trigger an interrupt on the micro controller integrated circuit controlling it, instantly locking the machine's motion so that it cannot cause damage to itself or the workpiece. This normally happens when the switch is operated, pulling the interrupt pin on the micro controller from a high state to a low state by connecting it to ground. Unfortunately once you have enabled hard limits on your CNC controller, this interrupt can be triggered unintentionally in a few different ways through electromagnetic interference (EMI). In order to stop this happening it is necessary to understand the nature of the EMI, how it propagates and how it can be reduced to levels where it no longer causes a problem.
Electromagnetic interference is caused by electrical circuits that have a varying voltage or current. This voltage can vary intentionally, as in the case of the PWM signals used to control motors or unintentionally, as in the case of the current being switched rapidly on and off by the brushes of an electric motor rapidly making and breaking contact with the commutator. In the development of the CNC Shield Machine Controller and the PWM Spindle Motor Driver, the spindle motor of the CNC 1610 machine alongside many of the MOSFET driver circuits that were tested caused numerous EMI issues leading to the locking of the CNC controller. This lead to the inclusion of filtering circuitry within the design of the PWM Spindle Motor Driver that greatly reduces the interference that is transmitted to the micro controller via the power supply leads. This interference arises from both the PWM signal itself and the inherent interference generated by brushed DC motors and the use of a properly designed PWM motor driver circuit is the best way of avoiding the problems associated with this.
There is a second way in which the interference generated by the spindle DC motor and it's driver circuit can be transmitted to the microcontroller and that is as radio emissions. The power leads leading to the motor act as transmitting aerials and the signal leads that connect the end stop limit switches act as receiving aerials. This mode of transmission was found to particularly affect the CNC Shield based controller as originally designed and so solutions to this problem were found as part of the development of the CNC Shield Machine Controller.
Ideally, the power leads of the DC motor would use a shielded cable and this would be advisable on a larger CNC machine with a more powerful spindle motor. On a small CNC 1610 or CNC 3018 machine this may not be realistic and the full benefits are unlikely to be realised unless the machine is properly grounded to earth via the mains supply. If you do choose to do this ensure that the cable shield is connected to ground and not the negative lead of the motor or the negative power output of the motor driver or at best you will increase the interference levels produced and at worst damage the motor driver circuit.
If the motor power leads are not to be shielded, then another approach would be to shield the signal cables connecting the end stop limit switches to the CNC Shield. This is a possibility and can be fairly easily achieved using the two core screened cable suggested in the Parts Required section. Again, ensure that you connect the cable shield to a good earth point.
As was shown earlier in this guide, this project used ribbon cable to connect the end stop limit switches to the CNC Shield and in an unmodified form this created a situation where the end stop alarm lock was triggered every time the spindle motor was powered on. Upon examining the CNC Shield board, it was found to be lacking any form of filtering on the end stop inputs, so the effects of EMI were not really surprising.
CNC Shield EMI Modifications
The simple addition of a 0.1μF capacitor between each of the end stop signal inputs and ground is all that is required to form a basic filter to reduce the effects of EMI, but these capacitors were not present on the CNC Shield board and so need to be added. The main problem is deciding on a location on the board for these capacitors. The most obvious location would be to solder them on the bottom side of the board across the header pads for the end stop inputs, but these have been positioned so as to be directly above the ICSP header pins on the Arduino Uno, so the physical space here is very limited. For this reason, it was decided to add the capacitors to the top side of the board, using the pads for the header which connect to the Digital (PWM~) interface on the Arduino Uno.
Parts Required
The following parts will be required to modify the CNC Shield board. Please note that there are alternatives available for many of the parts on the list and so you may need to buy equivalent parts that may be more easily available in your locality. Also, the information links provided are intended to show examples of products that meet the requirements of the project and are not a recommendation of any particular supplier or product.
Part | Description | Manufacturer | Part Number | Quantity | Information Link |
---|---|---|---|---|---|
C1, C2, C3 | 0.1uF 50V Ceramic Capacitor1 | Kemet | C322C104K5R5TA | 3 | Kemet |
Solid Core Wire | Hook-up Wire 0.52mm2 | Various | - | 30mm | RS Components |
1 Any 0.1uF ceramic capacitor of suitable size will work in this application.
2 Any short length of solid core wire can be used as an alternative.
Step by Step Guide
Step 1 - X-Axis Limit Capacitor
The first capacitor to be assembled is for the X-axis end stops. Locate the header pin labelled 'X.LIM' on the Digital (PWM~) header of the CNC Shield board. The labels are on the bottom side of the board, but you will be soldering the capacitor to the top side of the board, so ensure that you have identified the correct pad. Trim the leads of the 0.1μF capacitor to a suitable length then solder the capacitor to the board between the X.LIM pad and the negative lead of the 100μF capacitor nearby, as shown in the photograph.
Step 2 - Ground Lead Bus Bar
The remaining two capacitors that need to be added do not have a convenient nearby ground point and so a short length of solid core wire is soldered on to the closest ground point provided by the negative lead of another of the 100μF capacitors.
Leave a short length of insulation on the solid core wire to ensure that the leads of the 100μF capacitor are not shorted accidentally, as shown in the photograph. Pre-form the wire using pliers and solder it in place leaving it little long at this point.
Step 3 - Y-Axis Limit Capacitor
The next capacitor to be assembled is the one for the Y-axis end stops. Identify the correct pad as before by looking at the bottom side of the board and locating the pin labelled Y.LIM. Trim the leads of the 0.1μF capacitor to a suitable length, then solder it in place between the Y.LIM pad and the ground lead bus bar added in step 2. Finally, trim the ground lead bus bar to it's final length, as shown in the photograph.
Step 4 - Z-Axis Limit Capacitor
The final capacitor to be assembled is the one for the Z-axis end stops. If you are not using a variable speed PWM controlled spindle motor, then this capacitor will be soldered on to the pad for the Z.LIM pin (identified as before). If you are using the variable speed PWM controlled spindle motor as described in the CNC Shield Machine Controller project, then you should solder this capacitor to the pad for the SPINDLE-ENABLE pin, as shown in the photograph. The other 0.1μF capacitor lead is soldered to the ground lead bus bar as before.
When used as part of the CNC Shield Machine Controller project, these simple modifications have been tested and are shown to reduce the EMI interference sufficiently to eliminate any unwanted triggering of the end stop inputs. There were therefore no resulting alarm locks on the CNC controller.