You are on page 1of 9

9/29/2018 Endstops | Marlin Firmware

Endstops
Endstops or limit switches are used on every moving axes of a 3D printer. The following chapter will provide
information on:

Purpose of the endstop


Types of endstops
Electromagnetic Interference / Electric Noise impact on endstops

Endstops purpose
Endstops ful ll two important functions in a 3D printer: Reference system for the axes system and safety.

Reference for the axes system


After powering up a 3D printer the printer’s controller board does not know at which position its axes are.
Marlin indicates this by blinking question-marks in place of X, Y and Z on the LCD screen (v1.1.8 and older) or
blinking ‘?’ in place of the coordinates besides X,Y and Z (Marlin v1.1.9 / v2.0.0 and newer).

This means the system needs rst to establish its starting point of the physical (machine) coordinate system,
a process called Homing. Homing can be initiated either via the G28 G-code
(http://marlinfw.org/docs/gcode/G028.html) or via the LCD controller.

Illustration 1: LCD indication not homed axes (Marlin <= v1.1.8)

Safety
The other important aspect of an endstop is protecting the hardware from damage. Should any movement
try to exceed the physical limits of the machine, the endstop will cut the movement.

Types of endstops
http://marlinfw.org/docs/hardware/endstops.html 1/9
9/29/2018 Endstops | Marlin Firmware

There are two main types of endstops. Hardware endstops and software endstops.

Hardware endstops
Hardware endstops are electrically connected to the endstop ports of the printer control board and will
provide a signal when the endstop condition is met.

Illustration 2: Most common endstops (left to right): Micro switch, optical endstop (light barrier), hall sensor (magnetic)

Regardless of the type the basic way of working is the same:

A typically 5 Volt signal (High) drops to 0 Volt (Low): Normally closed (NC) switch
A 0 Volt signal (Low) rises to 5 Volts (High): Normally open (NO) switch

 Note

Since endstops are a safety feature NC switches are recommended as they will halt the machine should
the switch be damaged, e.g. by a broken cable etc.

Probe as Z-Endstop
Probes can act like an endstop for the minimum Z-axis. While the typical endstop has a xed position, the
probe is mounted on the print-head and can freely move around the bed.

http://marlinfw.org/docs/hardware/endstops.html 2/9
9/29/2018 Endstops | Marlin Firmware

Illustration 3: Common probe types: Inductive (left), solenoid touch probe (right)

Probes and their con guration are beyond this endstop introduction. Further reading is provided in the
Chapter Probes Con guration (http://marlinfw.org/docs/con guration/probes.html), Auto Bed Leveling
(http://marlinfw.org/docs/features/auto_bed_leveling.html) and Uni ed Bed Leveling
(http://marlinfw.org/docs/features/uni ed_bed_leveling.html).

Software Endstops
Typically 3D printers are only equipped with hardware endstops on one side of each axis (Minimum or
Maximum of the respective axis). As discussed above this is used to determine the starting point (origin) of
the machine coordinate system.

In order to also protect the other side of the axes software endstops should be de ned in the rmware via
the #define MAX_SOFTWARE_ENDSTOPS / #define MIN_SOFTWARE_ENDSTOPS directive. This then uses the
value from #define [XYZ]_MAX_POS / #define [XYZ]_MIN_POS to determine the maximum distance
between the physical endstop and the software commanded stop of the axis. Software endstops can be
(de-)activated via the M211 G-code (http://marlinfw.org/docs/gcode/M211.html).

Endstops and Electromagnetic Interference (EMI)


Electromagnetic Interference (EMI) or electric noise, is an e ect which can ruin the clean signal needed to
properly and precisely measure electronically, be it temperature, endstop hits or any other value.

Sources and e ect of EMI


In today’s life an abundance of sources for Electric Noise exists: Mobile phones, microwaves, WIFI, power
supplies etc. In a 3D printer itself, there are also some prominent and strong sources of such noise:

Heated beds

http://marlinfw.org/docs/hardware/endstops.html 3/9
9/29/2018 Endstops | Marlin Firmware

Hot ends
Stepper motors
PWM modulation

The Electromagnetic Interference created by these sources are picked up by other components, either
because they are directly connected or via radiation. The useful signal needed by the other components will
be disturbed or even altered so much that it is no longer useful.

E ect on endstops / limit switches


In the following High = Logic 1 = 5 Volt will be used for a pressed switch and Low = Logic 0 = 0 Volt for a not
triggered switch.

Ideal endstop characteristic

Illustration 4: Ideal Endstop

The above Illustration 4 shows an ideal endstop characteristic: Once pressed it jumps from Low to High and
the printer control board realizes this in virtually no time.

Real endstop characteristic with low noise

http://marlinfw.org/docs/hardware/endstops.html 4/9
9/29/2018 Endstops | Marlin Firmware

Illustration 5: Real endstop characteristic

Illustration 5 shows:

There is no clean Low or High. Both states are somewhat unclean


Around the trigger point (marked in orange) an e ect known as bouncing is shown: Due to mechanical
in uences the switch bounces between Low and High a few times before settling to High
Bouncing is unwanted but in case of endstops not a show stopper

Real endstop characteristic with peak noise

Illustration 6: Real endstop with EMI

This Illustration 6 shows:

Same characteristic as above but with a peak caused by EMI (marked in red)
The peak is high enough to be falsely detected by the printer control board as pressed switch,
potentially ruining a running print

Countermeasures
http://marlinfw.org/docs/hardware/endstops.html 5/9
9/29/2018 Endstops | Marlin Firmware

There are numerous counter measures preventing noise:

1. Shielded cables / twisted cable pairs


2. Cable routing (route signal cables away from power cables)
3. Software ltering
4. Hardware ltering

In the following the options 3 and 4 will be discussed further.

Software ltering
Beginning with Marlin v1.1.9 and v2.0 the software measures against endstop noise are improved and
exposed as a setting. Prior versions already implemented ltering that is permanently active. For the sake of
precision, this now has been exposed as a user setting in Configuration.h and deactivated by default.

/**
* Endstop Noise Filter
*
* Enable this option if endstops falsely trigger due to noise.
* NOTE: Enabling this feature means adds an error of +/-0.2mm, so homing
* will end up at a slightly different position on each G28. This will also
* reduce accuracy of some bed probes.
* For mechanical switches, the better approach to reduce noise is to install
* a 100 nanofarads ceramic capacitor in parallel with the switch, making it
* essentially noise-proof without sacrificing accuracy.
* This option also increases MCU load when endstops or the probe are enabled.
* So this is not recommended. USE AT YOUR OWN RISK.
* (This feature is not required for common micro-switches mounted on PCBs
* based on the Makerbot design, since they already include the 100nF capacitor.)
*/
//#define ENDSTOP_NOISE_FILTER

Activating this option will lead to following endstop characteristics:

Illustration 7: Endstop with software ltering

http://marlinfw.org/docs/hardware/endstops.html 6/9
9/29/2018 Endstops | Marlin Firmware

The yellow marked area in Illustration 7 shows the area where the software compensation is active. The rst
yellow area is an e ect due to noise and the algorithm decides that no endstop is triggered since the signal
falls back to a Low state.

The second yellow area marks the spot where a real and wanted endstop triggering has happened. Now the
algorithm basically “watches” the situation for some milliseconds until deciding if the endstop really is
triggered or if an EMI / Noise e ect needs to be compensated. This will lead to delays and nally to a
precision loss in the detection of the endstop.

 Note

Depending on the printer’s geometry and a ected endstop, this precision loss may result in issues
especially concerning the bed leveling. Using this feature is not recommended. Implementing some
type of hardware ltering is strongly preferred.

Hardware Filtering
Hardware ltering can range from a simple capacitor in parallel to the switch over a resistor / capacitor
combination (RC-unit) up to opto-couplers and ip- ops.

Board
Some printer controller boards already contain such lters located at the endstop connectors. Unfortunately
the popular RAMPS v1.4 design does not. A de cit that has been corrected with the RAMPS v1.4.2 design:

Illustration 8: RAMPS v1.4 vs v1.4.2

Endstop PCB
For 3D printing ready made ltered endstops are available, e.g. according to the Makerbot design:

http://marlinfw.org/docs/hardware/endstops.html 7/9
9/29/2018 Endstops | Marlin Firmware

Illustration 9: Endstop PCB with RC unit

Endstop with capacitor


A more simple variant, that can easily be tted to existing endstops is a 100nF capacitor, soldered over the
two endstop connector pins (in parallel):

Illustration 10: Endstop with 100nF capacitor

E ect of the hardware ltering


Illustration 8 below shows the e ect of such hardware ltering: The noise level is smoothed and peaks will
be reduced so much that they no longer will cause false readings. Additionally the fast bouncing at the
beginning of the triggering will also be damped.

http://marlinfw.org/docs/hardware/endstops.html 8/9
9/29/2018 Endstops | Marlin Firmware

Illustration 11: Endstop characteristic with hardware lter

Conclusion
Electrical Noise should not be underestimated. It is invisible but it may lead to strange e ects that are very
hard to diagnose due to its spurious nature. Simple measures like adding a capacitor will already improve
the situation considerably, overall improving reliability of the machine.

Brought to you with  lack of  and lots of .


The contents of this website are © 2018 under the terms of the GPLv3 (http://www.gnu.org/licenses/gpl-
3.0.txt) License.

Back to top 

http://marlinfw.org/docs/hardware/endstops.html 9/9

You might also like