Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: NKS on May 23, 2018, 12:38:29 AM

Title: Homing & Limit Switches
Post by: NKS on May 23, 2018, 12:38:29 AM
I know this topic is common and I've tried to do my due diligence in reading related posts.  However, I have not been able to find a satisfactory answer, so here goes:

I have a single switch per axis that I'd like to use as ++, --, and home.  I have three total switches (3 axis) wired in series to a single input.

I can home the machine without it kicking up an e-stop (others have had problems with this).  However, when I hit a limit while jogging Mach throws up "XYZ home tripped, XYZ ++ tripped, XYZ -- tripped, and enters e-stop condition.  That is, I suppose, the correct response from Mach-- but it's not what I want.

I'd like Mach to ignore the sensor as a homing signal when jogging/running g code, and ignore the sensor as a limit signal when homing.

I haven't got there yet, but I also foresee another issue:  When I do trigger a limit switch (which mach sees as both ++ and --) and I going to be able to jog off the switch in the opposite direction?  Or am I going to be stuck in linear motion purgatory, not allowed to move either direction?

Thanks for taking the time to read and respond! 

Title: Re: Homing & Limit Switches
Post by: joeaverage on May 23, 2018, 12:58:56 AM
a limit switch is to indicate that the carriage is about to fall off the end....unless you want to be really
clever that means a switch at each end of an axis. You could use a switch as a home AND a limit although thats
poor practice. Lots of people do it, it always used to be done that way when Mach was 'small' but doesn't make
sense today.

If you only have three switches (one per axis) consider using them as home switches only. Then you can use 'soft limits'
which is a programmatic way of having limit switches and works pretty well.

Is there some reason you don't want to fit more switches?

All industrial machines will have nine switches, two for each axis as limit switches and another one per axis as a home switch,
three axes, ergo nine switches.

The best single addition to my three axis mill was three nice roller plunger microswitches for which I made little
adjustable ramps to activate them. I can reference the machine to within 0.02mm and thats without 'index homing'.
It means I can be doing a job, turn the machine off half way through, come out tomorrow, turn the machine on,
reference (also called homing), and start from where I left off without having to remeasure  or reset anything, brill!
They cost $60NZD for all three, about $45USD. Best and cheapest mod I ever did.

Title: Re: Homing & Limit Switches
Post by: joeaverage on May 23, 2018, 01:07:50 AM
you can have the Mach treat the switches as home switches when homing and ignore them as limits and vice versa.
Its just when you are homing you really want protection that limit switches provide, you are more likely to have a cock up
when homing and thats just when you told Mach to ignore limits...really bright!

You can have Mach ignore limits so you can jog back into bounds. If you have individual switches rather than all combined
then Mach will allow you to jog but disable the direction which takes you further into the crap.

What controller are you using?

If  other than a UC100 the you should have plenty of spare inputs, consider 'treating' yourself to one input to one switch.

Title: Re: Homing & Limit Switches
Post by: NKS on May 23, 2018, 01:12:12 AM
Hiya Craig, thanks for the quick reply.

The reason I don't want to fit more switches is for simplicity sake.  A switch as the end of each axis seems silly when one switch in the middle should be able to do the same job.  Less wires, less money, less things to go wrong...

I don't know why industrial machines use 9 (though I agree, that's also what I have seen), when the same can be accomplished with 3.

I may end up the soft limits route... though having the limit switches would be nice for peace of mind.  I'll surely forget to home the machine at some point...


Title: Re: Homing & Limit Switches
Post by: joeaverage on May 23, 2018, 03:02:09 AM

I don't know why industrial machines use 9 (though I agree, that's also what I have seen), when the same can be accomplished with 3.
Wrong, the same thing cannot be accomplished with three. If for instance you had one switch which activated as a limit, both ++ and --
on one axis when it triggers all Mach knows is to stop. If you try to jog in the + direction by mistake because its going to make it worse then it will let you,
it doesn't know which end the machine is at. Whereas if you had two limit switches (and two inputs) it would know that you had banged into the + limit so it would
let you jog in the - direction but stop you from jogging in the + direction.

Additionally industrial machines are powerful and fast, when you hit a limit the machine powers down, no ifs or buts. It does not rely on a computer to turn it
off, the limit switches trigger the electrical contactor to drop out. Have to for safety, in most countries its probably legally required.

The reason I don't want to fit more switches is for simplicity sake.
Its a poor excuse but I understand
Less wires, less money, less things to go wrong...
Less money, less wiring but because you are trying to combine things you have in fact ensured that there are MORE things to go wrong, not less!

Three good quality home switches and 'soft limits' are good. If you have modest steppers then 'soft limits' are probably enough. If your axis motors are powerful
and/or fast, especially servos then limits are mandatory for safety as well. If you chose to combine functions you will end up with less protection and robustness than you thought.

Title: Re: Homing & Limit Switches
Post by: NKS on May 23, 2018, 12:18:51 PM
it doesn't know which end the machine is at.
But it should!!  If I'm doing a X+ move when it trips the switch mach should know, "hey, I just tripped limit while moving in X+, I can't move anymore in X+, but I can move in X-".

The only thing limiting 3 switches being used instead of 9 is the control software.  Though I do understand the need for "kill" switches on bigger and more powerful machines.

Simplicity is not a poor excuse, it is good design philosophy. 

Title: Re: Homing & Limit Switches
Post by: Cbyrdtopper on May 23, 2018, 02:28:23 PM
If you have 1 switch that is used for X Home, X++, and X-- it will do 2 things.  1, It will home when it is in the homing routine, and 2, it will trigger an over travel.  

Although WE know the machine was moving in a positive direction when the over travel has been triggered, the CONTROLLER only knows that an over travel has been triggered.

If you have the one switch plugged into each over travel (X++ and X--) in the config the machine will think it is on both switches.  

Title: Re: Homing & Limit Switches
Post by: jwolfenstein on June 02, 2018, 11:10:59 PM
I have an ESS smooth stepper and C11G BOB.  How do I create more inputs to accommodate that many switches?
Title: Re: Homing & Limit Switches
Post by: NKS on June 02, 2018, 11:31:28 PM
You can wire multiple switches in series and use one input.  You don't need 9 discrete inputs.
Title: Re: Homing & Limit Switches
Post by: joeaverage on June 02, 2018, 11:46:17 PM
NKS is right, you can combine switches to reduce the number of inputs required, usually with a modest loss of functionality.

The ESS has three ports. With a second or even third BoB you can have multiple inputs. You may have noted in the ESS setup screens the option of declaring pins 2-9
in ports 2&3 as inputs rather than their default as outputs. This means that the two ports provide 26 inputs and 10 outputs.

I have two BoBs attached to my ESS to gain the extra inputs, its easy to do and such a luxury. Combining limit and home switches as NKS proposes is apt to confuse you
if not Mach and the first time you recognize a fault in your logic or perhaps a hardware fault like noise or a broken wire is when the carriage sails off the end breaking stuff as it goes.


Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 12:14:01 AM
I've found a wrinkle that offers some flexibility if you are using modern AC servos.

I have a second hand Allen Bradley servo and drive for a spindle motor and found amongst all the other features that you can hook the limit switches direct to the drive
not the controller/BoB at all. I have since noticed that this idea is common among other manufacturers also, certainly Granite Devices, Delta, Sneider, Panasonic and Yaskawa.

The idea is that with the limit switches each hooked to their own pin on their own drive that 1) it protects the axis against out-of-bounds excursions, 2) provides a logic lockout
to the axis jog direction that would make the excursion worse , 3) signal the controller that a fault has occurred and 4) whether that fault condition is combined with others
like 'following error' or not is subject to your control having programmable digital outputs on your drive.

I believe that this idea started with the concept of 'distributed motion control' where each axis driver controls its own motion only and therefore has need of direct access
to both its home and limit switches. The combined motion occurs when the controller synchronises the individual axis movements. Ether-Cat is a prominent example of this idea.

Title: Re: Homing & Limit Switches
Post by: jwolfenstein on June 03, 2018, 12:28:23 AM
I have a fourth motor that is slaved which I am trying to home.  I have already tried the in series connection and didn't care for the functionality.  With the fourth motor and separate switches, I found I was out of short inputs.  With an additional BOB, does the the ESS communicate with the original BOB to control the motor output?
Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 12:55:17 AM
yes. The ESS communicates with all three of its ports simultaneously.

Really the arrangement of the ESS's IO into three 'look-a-like parallel ports' is redundant. The core of the ESS, the FPGA chip controls ALL of the pins
and they could be arranged sequentially  1 through 50 say. This is how PoKeys name the IO pins of their 57CNC for example.

The ESS and the company that makes it, Warp9, started making control devices for the Mach3 market. As then users of Mach3 were intimately familiar with the
naming and numbering on the pins within the parallel port Warp9 decided to continue the naming/numbering scheme so that it  appeared seemless to their customers.

To take advantage of the extra IO would require you get a second BoB but they are usually pretty cheap and all the extra inputs and outputs is a luxury. You can plan,
design and build additional bits of gear without spilling over into the control space of existing gear.

You may have noticed that Mach4 provides four probe commands, G31.1 G31.2, G31.3 etc and they are supported by the ESS. You might have a probe mounted in your spindle
to measure the 'flatness' or otherwise of the material and another separate switch to set tool length offsets. Having multiple individual probe inputs allow you to do this
without an erroneous input on the unused probe interfering with the active probe. Very handy. We used to be able to do this only by combining the two probes to just
one input pin and getting wrong results  because of noise on the unused probe is not trivial. It does of course require that you have spare input pins available. The ESS
and others makes it easy.

Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 01:06:18 AM
amongst ESS owners this BoB from CNCRoom has become popular: (

All three ports are utilized. I don't have one but the reports of those that do are enthusiastic. Note how the ESS sits
atop the BoB, very convenient.

Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 02:35:05 AM
I've just been reading the C11 manual and it is not plain to me that it can be configured with pins 2-9 as inputs.

The original specification for the parallel port allowed pins 2-9 as outputs or alternately as inputs. You couldn't have some of each, they were either all inputs
or all outputs. Neither was it possible to re-define the data direction on the fly.

With Mach3s use of the parallel port it was the norm for pins 2-9 be outputs that could be used for step/direction outputs. If you used a second parallel port pins 2-9
are usually assigned as inputs as it was inputs that were seriously lacking when you only had one port. The second BoB then required circuitry that would treat pins 2-9 as
inputs. Not all BoBs did this or are capable of it.

I use Homan Designs BoBs from Austrailia, near enough to local for me. The BoB can be configured with pins 2-9 as either input or outputs for maximum flexibility.
This is made possible by the bi-directional tri-state buffer IC used by Homan designs.

A quick read of the C11 manual suggests this may not be possible with the C11. Before you rush off and buy another you may need to do some research, even confirming
with the supplier before parting with your money.

I have looked at the documentation of the MB2 from CNCRoom that I linked to previously. In table 1 page 4 of the manual shows the pin arrangements.
Pins 2-9 port1 are line driver outputs, ideal for driving higspeed step/direction pulses.
Pins 3-9 port2 are NPN inputs suitable for extra inputs such as limit and home switches.
Pin 2 port2 is a sink output rather quirkily
Pins 2-9 port3 are sink outputs.

Thus there are certainly sufficient inputs for your purposes but the manufacturer has made some design choices that might restrict your flexibility compared to having three separate
BoBs like the Homan Designs units.

Title: Re: Homing & Limit Switches
Post by: jwolfenstein on June 03, 2018, 10:24:42 AM
After reading your post, it appears that changing to the MB2 might be the way to go.  I am fairly new to CNC design and especially the electronics, but if I use ports 2-9 for a total of 8 additional inputs, there isn't room on the C11.  The C11 only has 5 inputs, so I don't know think that could work.
Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 04:35:31 PM
if you had a second BoB you'd have plenty of inputs.

You get the regular five inputs with the first BoB and another 13 with the second. As I say there is a question mark as to whether the C11 can re-purpose
its pins 2-9 as inputs, but if the C11 cant there are others that can. One additional BoB (that can re-purpose its inputs) is cheaper than the MB2 but the MB2
also represents a good solution.

Title: Re: Homing & Limit Switches
Post by: jwolfenstein on June 03, 2018, 07:24:15 PM
I looked at Warp's link to BoB's. (  There are a lot of less expensive solutions.  At least I have a direction now.  Thanks for your help.
Title: Re: Homing & Limit Switches
Post by: Roaster on June 03, 2018, 07:31:02 PM
I use a C10 bob on my port 3 with a short ribbon cable connector and it's fully configurable as to ins or outs and setting common as 5v or ground.
I use it mostly as an input bank for a joy-stick jogger.
Highly recommended at $23
Title: Re: Homing & Limit Switches
Post by: joeaverage on June 03, 2018, 07:43:23 PM
the C10: (
is cost effective.

The C13: (
is even cheaper again but it has no buffers. If you have a stuff up or moment when hooking stuff up then the fault will propagate back to the ESS
and blow the FPGA. I myself prefer buffers and won't use anything less.

The Homan Designs board: (
is what I use and have been very happy with, a bit more expensive than the C10. Note that it has LEDs on all the outputs
and makes diagnosing setup issues much easier, recommended.

Title: Re: Homing & Limit Switches
Post by: mark4 on June 04, 2018, 06:30:22 PM
Hello I use the MB2 and its 24volt IO. This has been the best design for me yet. I upgrade small mills usually they only have one limit switch on X and Y axis for + and - limit and home switch Z axis has two switches. I like the fact that i can set mach up to work with this. I also use Ac servo drives and thanks to this setup i don't need to add extra circuitry to get my homing to go to the index pulse. Which is the most accurate homing you can have. I have been homing to the index pulse for years on different machines sometimes i had to build circuitry to make this happen. Daisy chaining your limit/home inputs might be necessary depending upon config you can still run out of inputs. thats easy though add a plc howver that was tricky to configure as i couldn't get allot of information so i had to experiment. But with a little help from Machsupport and Ess support and Mb2 support they all helped me with different problems. Now i am thrilled with the final outcome and the mill works great.
good luck
Title: Re: Homing & Limit Switches
Post by: Roaster on June 04, 2018, 08:35:14 PM
I have an ESS smooth stepper and C11G BOB.  How do I create more inputs to accommodate that many switches?

If you want discrete inputs, you can use a C10 bob which comes with a db25 plug to parallel port cable and use port 3, and set up the pins as inputs.
The C10 requires 5v supply voltage from external source.
I use a C25 bob plugged into ports 1 and 2 directly, and a ribbon cable-connected C10 on port 3.
The C25 is quirky and I modified mine by removing the input led's.
Title: Homing & Limit Switches
Post by: jwolfenstein on October 07, 2018, 03:28:40 PM
I finally installed a new BOB to my ESS and increased the inputs.  I did this about three weeks ago and everything worked great.  My homing switches act as limit switches for X-, A- and Y- while the homing switch for Z was +.  Like I said, it was working great.  It would square my gantry and stopped if I hit a limit.  My sequence for Ref All Home is Z+, X- (A- Slave as well) and finished with Y-.  Today when I fired it up and hit Ref all home, it limits out on Z+ and shuts down.  When I do and axis override it homes to X- and limits out at X- and says referencing complete.  I am using Mach 4.  I am almost sure I didn't change a thing.

Any thoughts?
Title: Re: Homing & Limit Switches
Post by: mark4 on October 08, 2018, 11:41:09 AM
If everything was working great something changed either you changed a setting or you could have a wiring or switch problem. 1st thing is check the diagnostics screen and see if any of the limit or home switch leds are on. then if they are all off check the wires and switches and make sure one is not stuck.
Title: Re: Homing & Limit Switches
Post by: jwolfenstein on October 08, 2018, 01:30:35 PM
I had already done that.  I ended up changing my settings for my limit switches so they were just homing switches.  After that worked a couple of times I reset the homing switches back into homing and limits like I had originally and it worked.  Until this morning and I had to do the same thing again.  And to add further to my frustrations the Mach 4 wouldn't recognize the ESS for configuration.  I rebooted, reloaded and reset.  Finally I just set the switches to homing only.  After I had it homed I set the switches to limit.  Almost feels like there is a bug in the software.
Title: Re: Homing & Limit Switches
Post by: joeaverage on October 08, 2018, 02:12:01 PM
I have always advocated having separate home and limit switches.

I suspect that when you have them programmed as dual duty that intermittent noise is affecting them.
When programmed as home switches only the occasional spurious 'home event' doesn't matter, the machine carries on. When programmed
as limits however any spurious signal will be treated as a 'limit event' and Mach will stop.

May I suggest putting a 0.1uf capacitor across each input. Note that it may slow the response to the switches to the extent that it would
be unusable in practice but may help you resolve whether in fact the problem you describe is due to noise.

Title: Re: Homing & Limit Switches
Post by: mark4 on October 09, 2018, 12:38:50 AM
one thing I would add is the wire going to your home/limit switches shielded and is that shield grounded to one side only.
I have in the past successfully used .1 uf capacitors but haven't had to do that in years. and I 1/2 agree about the separate
switches. some machine like bridgeports only have one switch on X and Y, Z has two. It would take some doing to change and
aside from a Z switch playing up have never had trouble with the X and Y but I do replace the original wire with shielded wire.
Title: Re: Homing & Limit Switches
Post by: joeaverage on October 09, 2018, 02:54:46 AM
with powerful and fast industrial machines a 'limit event' shuts the machine down instantly and totally.....its a legal requirement.

Thus an opening switch contact will cause all the electrical contactors to drop out, the spindle stops, the axis and spindle brakes come on,
hydraulic pumps stop, coolant pumps ifs or computer required just a safety interlock circuit.

In normal circumstances you hope that a limit switch never activates, if it does, everything stops, often with tool breakage and the part being ruined.
For those situations you simply MUST have separate home switches, otherwise every time you tried homing your machine would shut down.
Remember to satisfy the law you cannot disable the limits under any circumstances.

Our hobby machines are not that powerful or fast and we can probably ignore the safety laws which apply if you are employing people to operate
machines. None the less I still advocate separate switches.

One distinct advantage is that limit switches are situated to activate at the very end of the allowed axis travel, usually that situates the switches at the ends
of the axis. Your home switch does not have to be at the end of travel and may therefore be mounted at a more convenient location with respect to
vulnerability to damage or contamination say. Also it allows you to choose switches which are optimized to the task. For instance I use roller plunger
switches for homing, they allow repeatability of better than 0.02mm but I use proximity switches for limits.

Irrespective of whether you combine limit and home switches or not there are some good precautions to take to avoid noise. Mark has already suggested
screened cable.

Another idea is to have some reasonable current flowing in the circuit at all times, say 20mA. This is another way of saying that a 'moderate impedance limit
circuit is less sensitive to noise than a very high impedance circuit or a very low impedance circuit'.

A high impedance circuit is likely to suffer from 'voltage' or 'displacement' noise whereas vey low impedance circuits are subject to 'induced current'
noise. For instance with respect to the pic attached. With the resistor of 250 Ohm as shown and a 5V supply with the switches closed about 20mA flows through
them. This circuit would still work with a resistance of 25kOhms but the current would now be only be 200uA and therefore much more prone to
capacitively induced noise spikes from an adjacent circuit. Likewise if the resistor is reduced to 20 Ohms the current is now 250mA but is now
subject to magnetically coupled noise spikes from adjacent circuits.

A little capacitance doesn't hurt either, I've shown a 1nF capacitor, you could buy ten of them for $1. You could use higher vales for more noise
suppression but eventually you will cause the speed of response to slow. If you need as much a 0.1uF you should look to find why that other
'bothersome' circuit is radiating that much noise.