"Limit" Switches Finally!

I am trying to implement magnetic switches based on normally-open reed sensors.
So far, the achievements have been as following:

  • I built three little boards, installed the sensors on the axes and placed the magnets (see photo)
  • If checked with a multimeter, the limit switches are reliably triggered at the end points, with accuracy < 1 mm.
  • grbl v 0.9j recognizes the switches and reports correct closure (e.g. ? Lim=101 if Z and X are at the end-point, and Y is not.)
  • However, if I try to run the homing cycle ($H), grbl stops randomly. Sometimes a homing error is reported, sometimes is not, but reliable homing is not achieved.

By digging into the issue, I realized that 20K internal pull-up resistor in the Uno board is adequate to handle simple breadboard projects with several cm of wiring, but can’t handle sensor wires several meters long. As the wires move, the capacitance between them changes, creating transients, and the digital pin reacts to the change. To add to the problem, different makes/batches of Uno boards are slightly different, and my have different resistors and such. The result: everybody plays with wire gauges, shielding, resistors and capacitors until some result is achieved (sometimes it’s never achieved). But: creating a dynamic system with stable capacitance parameters is tricky!

The obvious solution would be to condition the input signals. The proposed (simple) diagram is as below:

Attaching the reed sensor between the test point and the ground should do the trick. As a side benefit, the LED is lit if the reed is triggered.

The more complex option is to condition each sensor with a Schmitt trigger and an invertor, to achieve a reliable logical ones and zeroes on the line.

Does anybody have experience powering the limit switches from the external power?

You’re over thinking it, use the circuit i posted above (one for each axis) and you will be fine with your magnetic switches

Thanks. Are you using Arduino’s 5 V pin to power up your boards?

Yes

One more question: are you disabling the pull-up resistors in GRBL?

define DISABLE_LIMIT_PIN_PULL_UP

No just enabling hard limits

Well, all works! The final wiring diagram was like this:

The resistors are packaged within the control box:

Fundamentally, the “classic” approach with large-gauge shielded wires can be simply addressed by an extra 5V connection. As suspected, the internal 20K pull up resistor cannot supply current for the long wires fast enough, creating transients. It does not matter what exact value resistors are used to power up the sensors as soon as they are less than 3-5K. The inputs are limited by 10K resistors. Perhaps, the Inventables should include this into the standard limit switch kit? The cost of 6 resistors and 3 capacitors in next to none.

The debouncing in my machine is set to 32, pull-off 6 mm, hardware limits control:

$20=0 (soft limits, bool)
$21=1 (hard limits, bool)
$22=1 (homing cycle, bool)
$23=3 (homing dir invert mask:00000011)
$24=25.000 (homing feed, mm/min)
$25=750.000 (homing seek, mm/min)
$26=32 (homing debounce, msec)
$27=6.000 (homing pull-off, mm)

The code is compiled with:

define HOMING_CYCLE_0 (_Z_AXIS) // First move Z to clear workspace.
define HOMING_CYCLE_1 (_X_AXIS) // Then move X (to left).
define HOMING_CYCLE_2 (_Y_AXIS) // Then move Y (to front).
// (homing by each axis separately)

define HOMING_FORCE_SET_ORIGIN // Uncomment to enable positive machine coord.
define LIMITS_TWO_SWITCHES_ON_AXES // magnets on both sides
define DISABLE_LIMIT_PIN_PULL_UP // hence we are pulling pins with external resistors

Thanks BrainSaban for timely advice!

3 Likes

Where do I send money? I could build them but the closest Radio Shack is far away.
I am very tiered of crashing it and Inventables does not understand what a limit switch is.
I even have a large diagram to show what direction is what.

Sent you a message with the info

This is much like moving the Z axis down before moving the X and Y to start position. Auto crash.
I have been a CNC machinist for about 40 some years, The Z is moved last so to clear all obstacles.

This brings us to the limit switch. The limit switch is a hard stop limit which keeps the machine from hitting the end of travel and attempting to continue.
They are present on all commercial CNC machines for that reason.
A homing switch can double as one end but a second is required at the other end so over travel does not happen.
Has nothing to do with device or function, it has to do with hardware and machine safety.
Just as moving the X and Y before the Z.
I quit using Easel because of that. I now do some designing and then export to CNC editor to remove bad moves and useless lines.
Just to clarify.

Isn’t there a way to put the limits within the machine? (I don’t have my Xcarve yet)

Is there an ideal configuration in terms of doing everything you’d want to do? I would think that wiring the machine for limit switches (i.e. switches at each end of each axis) would be the ideal given that it should be possible to use them as homing switches in addition to getting hardwired stops, but given that so many implementations use the single switch (homing) that I’m wondering if there’s a reason beyond cost/complexity.

If hardwired as limit switches they work as homing switches as well, one doesn’t cancel out the other.

You can use them as homing switches only.
You can use them as homing switches with soft limits.
You can use them as limit switches only.
You can use them as homing switches and limit switches.
You can use them as homing switches, soft limits, and hard limits, all at the same time.

The best compromise is to use them as homing switches with soft limits.

6 Likes

You forgot to add, “Do I make myself clear Soldiers.”
That’s awesome explanation Larry, as always.

This is my limit switch, there are many like it, but this one is mine …

So is there a downside (other than the cost of the switches) to setting the machine up with limit switches (2 switches per axis) and using them for homing and limits? (assuming here that the extra cost and hassle of wiring them is negligible)

I think the issue is that you don’t get a fast enough response from the switches in order to have them prevent crashes. The downside is that they give a false sense of security.

Soft limits are better.

Completely disagree with that statement. First and foremost soft limits is software reliant meaning if you neglect to home your machine by chance, your limits will not work and you will be susceptible to a crash. Hard limits on the other hand work no matter if your machine knows it’s location, making soft limits a false sense of security. While many use soft limits and i’m not knocking them (to each there own), but making a statement like yours is at best an uneducated response. As for response it stops the machine on a dime when a switch is triggered. I posted a video somewhere years ago showing how fast it stops the machine, not sure which thread it’s in. As for which is better, it all comes down to personal preference (then again I think I just pointed out soft limits major flaw :joy:)

I tried limit switches on my homegrown machine but eventually pulled them. they just kept going off in error. I had shielded them with a metal mesh sleeve, but I had them sharing a D connector with the steppers, so there could have been some field leakage there. I’m rebuilding my controller with fully separate stepper connectors and may try the limits on my X-Carve, but to be honest, the pieces that I cut are mostly 3"x3", with a few that are 6.5"x3.5", so I’m miles from the limit on my 500mm

1 Like