# Explain Limit Switches and Homing To Me



## speedre9

So, whats the skinny on this subject. I can put them on my machine but, how do I set them up?? I know they stop the travel in the x,y,z but how do they resume travel. Once travel is stopped does, Mach 3 then move them off the switch a little so the machine will resume movement or, does the operator need to intervene?
What about homing? Does that mean the machine will go back to that point when the machine is done whatever process it is doing? Like a "zero point" where everything starts and stops? So much brain fog about these things!!:bitingnails:


----------



## countryguy

My 3cents -There are several good youtube vids which helped me!   It was something that I did get running on my Mill but honestly do not use too much as yet.  The Mach3 pages had some really good vids and their online manual/docs do OK.      Gotta run.   CG.


----------



## Bill C.

My very limited experience with CNC are the following, Homing is any point within the machining area you send the table to where the table or vise is clear of the cutter so finished part(s) can be removed and new blanks can be loaded. I ran production for several months.  Limit switches are usually located near the end of travel and are considered emergency stops.  They are there in case of a programing error.  Without them one can cause serious damage to the drive screws. Even experienced programmers make mistakes. 

I hope this helps, I never programed but loaded enough stock to understand your concerns.


----------



## JimDawson

I am going to be doing exactly this in the next few days on a table top CNC router.  I'll post pictures and give an explanation of what I am doing and why.  I am not sure exactly how Mach3 will handle the travel limits, but I'm going to find out when I get it set up.  I think there is an override in the Mach3 software that allows you to jog the machine off of a travel limit.  I am going to use the travel limits for the Home limits also.  It's been a while since I worked with Mach3, so I expect my frustration level will be pretty high by the time I'm done setting up, at least based on my last experience with it.

As Bill C said, the home (or parking) position is normally where the tool or work parks at between loads, 0,0,0 could be anywhere you want it.  The home limit switches are needed in a system to be able to set the maximum travel limits in software, in other words, a known starting point.


----------



## rdean

You are right Jim Mach3 has a box to check for override jog off the limit switch. 
 As far as homing I hardly ever use it on my mill but my router table has 2 motors on the X axis.  I use homing to ensure the Y axis is not cocked and runs straight and square on the machine.  

Ray


----------



## f350ca

Im using Mach3 on my plasma table, it senses the direction you're traveling when it hits the home or limit switches and lets you back out of them.

Greg


----------



## j2mariashop

Speedre9

[SUB]_These are notes I made to digest my understanding of home and limit switches. I installed them on a Patriot CNC 3-in-1._[/SUB]

*Installing Home and Limit Switches in Mach 3*

There is no real need for physical home and limit switches as Mach3 can replicate these switches virtually in the software. You can set up virtual Limit switches or _Soft_ware _Limits_. In _Config/ Homing Limits/Motor Home Soft Limits_ tab, you can set actual dimensions that specify the maximum and minimum distance the machine can travel on each axis. Mach 3 scans the GCode to check if the max. and min. limits of axes travel is within the soft limits. If any movement is outside the soft limit, the code signals this and does not run. The only risk is you forget to turn on Soft Limits (see below) and then the axes drive motors could crash against the ends of an axis.  Physical switches can prevent operator error causing damage.


_Setting Soft Limits_

The Shopmaster does not have physical limit or home switches but here's how I set up soft limits on my 2012 machine:

1) jog each axis to the spot that you want to designate Home. In my case, Z Home was at the tailstock end (Z++), X Home was the furthest away from the spindle-tailstock center-line towards the operator (X++), and Y Home was at the top most position of the mill head. (Z,X and Y here are from Mach3 Turn's perspective). All movements are then in the -ve direction.

2) Select _Machine coordinates _in Mach3 Turn's _Manual_ screen and then click _Set Home Z_ and _Set Home X._ The axes DRO in the top left should now be 0.0.

3) From this position I also set _Soft Limits _in under _Config/Homing Limits_. My _Soft Max _for both the X and Z axes was 0.0. The _Soft Min _for the Z axis is -12.5" and for the X axis -6.7". I did not move the Z axis to the very end near the tailstock as I wanted some clearance in front of anything I mounted in the tailstock. At the other -ve end of the Z axis, my -12.5" _Soft Min_ was a function of allowing a safe clearance between my LH tool and the chuck jaws.​4) In the _Auto Cycle_ screen, click the _Set Soft Limits On/Off_ to set _Soft Limits On _so that the light is green. Otherwise, Mach3 will ignore any soft limits you entered. When a program is loaded in the _Auto Cycle_ screen, Mach3 scans ahead to see the max. and min. of axes travel and if any move is outside the soft limit, a warning pops up and it asks if the program should continue.

5) Click _Auto Override_ in the _Diagnostic Screen _so that you can jog off a limit though this is for physical switches.​You have to reset _Home_ each time you turn the machine on so that Z and X _Home Referenced _lights turn on in the _Manual _screen.​




*Terminology Basics for Physical Limit and Home Switches*

_Normally Closed (NC) and Normally Open (NO) Switches_

A normally closed (NC) switch is exactly what its name says: under normal operation of the  machine, when the switch is ON, the circuit is closed allowing voltage to flow through the circuit from the power source to the ground. When a normally open (NO) switch is ON, no voltage flows through the circuit as the open switch prevents the circuit from being completed.

_Active High and Active Low states_

NC and NO switch systems can be designated as Active High or Active Low. Usually in the transistor-transistor logic (TTL) circuits found in a PC, a _high_ voltage is between 2.8v to 4.8v and could be assigned a  binary value of 1, while a _low_ voltage is between 0v and 0.8v and could be assigned a binary value of 0. Input pin #s 10 through #13 and #15 take voltage inputs from the machine to send signals to the software.Pin #s 1 through #9 and #14 send signals out of the PC to the machine. In my wiring system, pin #2 is used to send PC power (4.8v) to the limit switch circuit and pin #11 is used to receive an input from a limit switch.


In an Active High system, under normal operating conditions, the voltage measured at an input pin (#10 through #13, #15) is Low since the high voltage is bled away to ground before reaching the input pin. When a limit switch in an NC system is activated - the switch is now Active - the circuit opens and the high voltage is redirected to the input pin changing it from its normal operating Low voltage state to an Active High state. This kind of a system is called a NC Active High system.


The advantage of using a NC system is that if a wire breaks, the circuit opens, lowering the voltage and triggering an alarm. In a NO system, a broken wire is viewed as just another normally open "switch" in the circuit. NC systems are also better at managing electrical "noise" that might confuse the switch because a closed circuit has low impedence. Another problem is that a NO Active High system (tells the machine to do something when the voltage is high) can be accidentally triggered by a voltage spike.

In an NC Active High system all the limit switches can be wired in a series (from one to the next to the next and so on) and connected to just one input pin. This kind of a system (a series of 6 switches on my machine) is called an "OR" system. If either switch 1 OR switch 2 OR ...switch 6 is triggered open, Mach 3 will recognize a Limit or Home switch has been activated. Under an OR system ,in the _Diagnostic Screen_, the LEDs for all 6 switches will light up when any one switch is tripped.

*Hardware setup:*

*Wiring the Switches* 

My switches were bought from Dan Mauch of Camtronics (www.camtronics-cnc.com). Each switch has a NC, NO and Com prong (see photos at the link below). On my 2012 Patriot, each axis has an NC limit switch on one end and a second NC switch that doubles as a Home and Limit switch at the other end. All 6 NC switches are wired in series as follows: the wire first goes from the NC prong in switch 1 (Y++ Limit and Y axis Home) to Common (COM) in switch 2 (Y- Limit), then from NC of switch 2 to COM of switch 3 (X- Limit),and so on to X++ (X++ Limit and X axis Home), and then to Z- Limit and Z++ (Z++ Limit and Z Home at the top of the mill. Finally, NC of switch 6 is connected to the V-ground on the CNC power supply panel which for my 2012 Patriot also has a black wire that connects to pin #12 (power supply ground) on the Gecko 540 board.The COM of switch 1 is connected  pin #2 on the Gecko 540 board. None of the NO prongs is connected. The circuit is as follows: 4.8v PC power from pin #2 flows through all 6 NC switches and goes to ground at pin #12 (power supply ground) on the Gecko 540 board through the V- ground onthe CNC power supply. When a switch is tripped, the circuit opens and 4.8v is diverted from ground to pin #11 (now Active High) and tells Mach 3 to stop the machine.


https://picasaweb.google.com/116982968384326297223/PatriotCNC?authkey=Gv1sRgCMfNg5G004XGIA#

I use 16 guage wire inside plastic protective sheaths, kept at least 1" away from any stepper motor and power cables to prevent "noise". The longest run for a wire is less than 4'. I did not use shielded cables. Finally, protective plates are mounted over the switches to keep swarf and any fluids off the rollers.I used a multimeter to check continuity each time I added a switch. After the system was wired, I measured approximately 4.5v across each switch (Active High). Since the voltage was more than 4v, I did not need the 470 ohms "pull-up" resistor shown in the Mach3 manual that should be added to the wire before it goes to the v- ground. After each switch was connected I checked for continuity.

*Software setup*:

_Getting Mach3 to recognize the switches:_

I used Mach3 to define the Limit and Home switches. Select _Config/Port & Pins/Input Signals_. Then click _Automated Setup of Inputs_. Select the appropriate switch - say, X limit++ at the tailstock end of my lathe - and click _Autoset_. Now manually trigger the X++ switch. Mach3 beeps, signalling that it has recognized the switch. Select the next switch, click _Autoset_ and trigger the switch. Repeat for all switches and then click OK.

Once all switches have been activated, the_ Input Signals_ tab should show a green check mark next to each switch, with the pin #. All my switches are assigned to Port #1, pin #11. There will be a red cross mark in the Active Low box for each switch. This indicates an Active High system - at input pin#11, the default operating voltage is Low, but when activated the voltage at the pin becomes high. Mach 3 now recognizes that there are Active High Home and Limit switches for each axis.


Trigger each switch to make sure the wiring works and that the Limit activated LEDs light up. If they don't, and the wiring has been checked for continuity, change the Active status and test. 

*Limit Switches in Normal Use*

When axis over-travel triggers a Limit switch, the Active High signal to Mach3 stops all movement and the red _Reset_ button will flash. In the _Diagnostic Screen_, since all switches have been wired in series and connected to one pin, all _Limit lights_ will be on. You cannot move the machine unless:

_Auto Limit Override_ is on in the _Diagnostic Screen_.This allows you to click the _Reset_ button and then use the arrow keys on the keyboard to jog off the Limit switch. The machine and part need to be re-referenced because stepper motors lose some steps due to inertia and do not know at which machine coordinate they stopped.

*Preventing noise from triggering the switches*

Unless you have shielded cables there is a fair amount of noise - electrical disturbance - in the switch wiring. Mach3 needs a way to distinguish "noise" from "signal". Debounce is the time a signal must be continually "on" before Mach3 realizes that it is a signal and not just noise. In the _General Config_ tab, in the _Input Signal Debouncing / Noise Rejection_ section in the top right corner, each value in the _Debounce Interval_ box corresponds to 1/kernel speed of time. Since I have my machine set to a kernel speed of 25,000Hz, a debounce interval of 500 is 500/25,000 or 0.02 or 2 milliseconds which is long enough for the computer to realize that it is a signal and not a random electrical disturbance. Since in _Config/Motor Tuning_ I have set my axis velocity to be 50 ipm, the actual distance the machine will move before it realizes that it is a "signal" is 50 ipm * 0.02 / 60 sec = 0.017" of travel beyond the Limit switch. Lowering the interval reduces the overtravel (and damage) but increases the probability of a false signal.

*Setting Home:*

_Home_ is the location that the machine recognizes as 0,0,0 on the X, Y and Z axes (Machine Coordinates 0,0 which should be displayed in the axes DROs). In Mach3 Turn's _Manual Screen_, for example, click _Machine Coordinates_ and then click _Set Home Z._ The machine moves slowly in the z+ direction towards the tailstock. (If the _Home Neg_ box is checked - see below - the machine moves in the z-ve direction towards the chuck looking for the Home switch). When Homing, Limits are not active. When the axis reaches Home, the machine reverses in the -ve direction to move off the switch.Clicking _Set Home X_ will repeat this for the X axis. The machine is now at 0.0 Z and 0.0 X. All movements will be in the -ve direction from Home. This procedure needs to be repeated each time the machine is turned on. The X and Z _Home Referenced_ lights in the top right corner of the _Manual_ S_creen_ will now be green.

If the machine has been referenced to Home on start up, clicking the _Home X_ or _Home Z_ or_ Home All_ in the _Manual or Auto screen_ will move the machine to the respective Home location. Clicking_ Home All_ first Homes X (moving it clear of the chuck or tail stock) and then Homes Z (in the positive direction towards the tail stock). 

If the machine is not referenced to Home on startup, none of the Home buttons will work.You need to reference Home each time you start up the machine.


_Diagnostic Screen_

All the Limit and Home switche lights in the _Input/Output Status Inputs_ grouping should be off when the switches are closed, and the X and Z DRO should read 0.0 or the value in the Home Off. cell when Homed. The Auto Limit Override switch should be turned on to allow movement off the Limit switches using the arrow keys on the keyboard.

_Setting the G28 Home Location_

The _G28_ command returns the machine to its Home position. However, if you share the Limit switch with a Home switch, this would trigger the Limit switch requiring a reset and a re-reference to be done. To avoid this, I set the _G28_ location to be -0.25" for both the X and Z axes. When the_ G28_ command is issued in a program, the machine moves to -0.25" off the Home switch for both axes.


If there is no _Home Off_. value entered (see below), the axis will move -0.25 off the location of the Home switches. However, if there is a _Home Off_. value entered (say, 4.349"), a _G28_ command of -0.25 would move the axis to -0.25" off the _spindle center line_ and not -0.25" off Home! It could crash into the stock!
_Auto Limit Override_

Turn _Auto Limit Override_ on in the Settings. In case you trip a Limit switch, this option lets you click_ Reset_ and use the keyboard arrow keys (manual motion control) to move off the Limit switche.The movement away from the Limit switch will be at a slow jog speed so that you can react if jogging in the wrong direction.If you release the jog arrow key and press it again, jogging will resume at normal speed.

_Override Limits_ lets you literally override the Limit switches. A red light flashes.

_Slow Zone and Speed %_

You can slow the machine down as it approaches the Soft Limits or Hard Limits/Home switches by specifying the distance before the Limit the machine should start reducing its approach speed. On my machine, I have set the  _Slow Zone_ to 0.20" for both axes which means that Mach3 will slow starting from 0.20" before the Limit. 

The speed the machine travels at while in the _Slow Zone_ can be specified in the _Speed %_ cell. In my case, I set it to 10% of the axis speed set in _Motor Inputs_.This only works when jogging the machine. Even though the shift key is held down to enable fast manual jogging, the machine will slow down when it enters the _Slow Zone_.It has no effect when a G-code program is running.

_Home Neg_

This box should be checked if the Home switch is in the -ve direction (at the chuck end for the Z axis or away from the operator on the X axis).

_Home Off._

_Home Off_set is the distance Home (usually Home X) is away from the spindle's center line. Say, using the method described below, _Home_ is offset from the spindle-tail stock center line by 4.349".  Moving towards the spindle center line will now progressively decrease the DRO reading from 4.349 until it reaches 0.0 at the center line.


_Setting Home Off._

Clear any values in this cell and click _Machine Coordinates / Zero World_ in the _Manual screen_. Click _Set Home X_ which will move the machine to its X axis Home location. Chuck some stock and using the MDI line take a light skim cut. Note the value in the top left X axis DRO in the _Manual screen_. It should be a -ve reading. Ignore the -ve sign and call the value X. Now measure the diameter D of the machined stock in the chuck.

Home Offset (HO) = X + D / 2
This is the distance Home X is from the spindle's center line.

Go to _Config/Homing Limits_ and in the _Home Off._ cell for the X axis input HO. Now, click _Set Home X_ and the machine will move to the Home X location. Once it reaches Home, the X axis DRO should read the value HO. Now, take another skim cut off the stock and note the X DRO reading. It should be the same as the stock's radius. If it does not match, either the measurement was not correct or the _Step/Unit_ is wrong.

_What is the advantage of using Home Off.?_


The main advantage is that once a _Home Off._ value has been input, there is no need to take a skim-cut or touch the part that is in the chuck to reference it.


Before you start any GCode program, you need to tell the machine where the_ Part _or_ Program_ _Coordinate_ is relative to the _Machine Coordinate_. This is usually done by touching or skimming the diameter of the stock to reference _Part Zero X_, and to the face for _Part Zero Z._ With _Home Off._, the machine always knows where it is relative to the spindle-tail stock center line. Since this obviously passes through the center line of the part in the chuck, the machine knows where it is relative to the part. This removes the need to take a skim cut saving time and effort. Both X and Z axes on the lathe can have _Home Off._ values. In the case of the Z axis, using the face of a chuck to measure Home Off. removes the need to reference Z when parts of varying lengths are mounted in the chuck. There is no need to take a facing cut to set the Z 0 coordinate.


_Referencing with Home Switches_


First Home the Z axis. The _Z Home Referenced_ LED turns green. Next move it to the face of the part in the chuck and touch or take a face cut. In the _Manual_ screen, in _Program Coordinate_ mode, set_ Part Zero Z_ = 0.0. Click _Part Zero Z_ which set the axis position DRO for Z in the top left of the _Manual_ screen to 0.0. Next Home X. The _X Home Referenced_ LED turns green. Click _Part Zero X_ in _Program Coordinate_ mode and the axis position DRO in the top left and the X axis DRO in the middle right of the _Manual_ screen take on the _Home Off_. value. Now, switching between _Machine, Part _and_ Program Coordinates_ will show that the top left axis position and middle right reference DROs all have the same Z and X coordinates. You can mount another part in the chuck and turn the diameter without referencing the diameter again. And, if your Z _Home Off_. is measured from the face of the chuck, you do not need to reference Z either. This saves time when many parts with varying dimensions need to be machined.


_Home Off._ however, works only if the Home switches are accurate and can maintain their accuracy repeatedly. Since I have no idea how accurate or repeatable my switches are, I chose the option of not having a _Home Off._ value and, instead just input 0.0 in the _Home Off_ cell. This means that I have to reference each part before I can start.


_Auto Zero

_If the _Auto Zero_ option is checked, then the axis DRO will take the value that is in the _Home Off._ cell.


_Tool Tables. _


If a_ Home Off._ value is set after the _Tool Table_ has been filled, all tools would need to be re-referenced.


----------



## Thomas Paine

^what he said.  Hard limits are actual switches that stop the travel to prevent damage.  Soft limits are points right before the machine would hit a hard limit, that are retained by the control software, to stop the control from moving before it actual hits the hard limit.

make sense?


----------



## awander

Homing is done to establish "where things are". Some say that it establishes your "zero" but Mach allows you to have the machine set each axis to any number you like(instead of zero) when homing.

When you home the machine(or an individual axis) the axes will move to the point where they activate the switches, then back off the switch and set the axis value.

The machine will not automatically go to home position when a program is over, unless you write that into the program.

Mach can use a different location as your "safe" or "toolchange" location-it does not have to be the same as your "home" location.

Mach does let you use the same physical switch for both home and limits-in the case where a switch is activated while you are not in a homing move, it will be interpreted as a limit switch, and activate the reset. In this case, you will need to turn off the reset, "override limits", and manually back the axis off the switch. There is also a setting called "auto limit override" which will let you turn off the reset and back off the axis without pressing the "override" button.


----------



## speedre9

I will add post #7 to my shop notes, it about covers all my questions but one I think. If I should hit any limit switch does Mach 3 allow the machine to move off the switch and stop the machine untill you can resume the program? If I get an answer to that I'll be golden on this issue.Thanks to  j2mariashop, post #7 very concise explanation.


----------



## awander

If a limit switch is hit during program execution, the program will stop, RESET(EmergencyStop) will be activated in Mach, and you will be able to jog off of the limit switch by Resetting Mach(take it out of E-Stop mode), "Limit Override" button(if Auto Limits Override is not selected), and using keyboard jog keys.

To resume the program, you will first need to make a note of where it was when it hit the E-Stop, edit the program so that it won;t hit the E-stop again, and then use "Run from Here".


----------



## j2mariashop

Glad you found the notes useful. Andy Wander has given the exact answer to your question!

Joe Joseph


----------



## speedre9

O.K. got it. It's still a, manual operation then, after it hits the limit. I will try to avoid hitting the "limits" when operating my machine as a safety practice. Thanks to all for the valuable information.


----------

