Limit Switches


Limit switch schematic
Schematic for a simple limit switch.

The parallel port pin is connected to the computer's +5vdc power supply through a 4.7k to 10kΩ resistor. The ones here are a half watt off-the-shelf from RadioShack. :-/ This pulls the pin high.
The resistor protects the pin from the excess current it would receive were the pin wired directly to the power supply. Also wired to the same parallel port pin are the normally closed  limit switches linked in series.

One switch wire is connected to the pin and the other wire from the switches is grounded to the computer's power supply low voltage ground.

When the switches are all closed, the parallel pin is grounded and low. When one of the switches is open the pin is pulled high.

The software is configured to stop the machine when the signal is high.
 
Sometimes the parallel port's limit switch terminal will be signaled by the noise in the steppers’ wires.
This can be addressed by running the wires separately, using shielded cables, or using an opto-coupler as shown below.

Limit switch opto-coupler schematic

One side of the 4N25 opto-coupler is wired to the limit switches, and the other is wired to the parallel port terminal.

The optional LEDs in the circuit indicate the state of the connections.

The green LED shows that the limit switches are ready (on) or hit (off), and the other LED indicates that the limits are disabled.
The LED's resistors depend on the LED. 300Ω is a ballpark value.
The limit switches are disabled by connecting the circuit to ground via the double pole switch.

The software sees this as a closed circuit and assumes the limit switches are ready, though they are now out of the circuit.

This is done this way so the software settings do not have to be altered to temporarily disable the limit switches.
 
Xylotex limit switch attachment
Xylotex limit switch wiring.
This image is of the end of the Xylotex board with a pair of limit switches and a pull-up resistor.

One end of the 10kΩ resistor is connected to the +5vdc terminal on the Xylotex board, and the other is connected to the same terminal as one wire from the limit switches; in this image it is terminal 10 (the red wire).

The other wire (black) from the switches is connected to the ground terminal on the Xylotex board.
 
The limit switches can be micro switches with an attached lever.

The ones shown on this page are from Mouser.com part number 101·1203.

They are single pole, double throw, and are wired to be normally closed, rather than normally open.
(An open switch is not conducting; a closed switch is conducting.)
In this configuration any open connection problems in the circuit will trigger a stop.

If wired normally open, an open circuit due to a faulty connection would not be noticed by the software, and no signal would be received when the switch was hit.

All switches are wired in series with each other; therefore, only one pin of the parallel port is used for all switches. All motion ceases when any switch is struck.
 
A variety of switches can be used for the limits.

This photo is of a normally closed push button switch, which is cobbled to be hit by the gantry ends on the old trial table.

Push Button Limit Switch
Push button switch.

A switch at each end of the table is activated by a bearing support.
A switch at each end of the gantry is activated by the sides of the carriage.
25x25 X Axis Limit Switch
Switch on table end triggered
by bearing support.

Y Axis Limit on 25x25 CNC Machine
Switch on gantry endplate
triggered by carriage.
 
In this shop, only one switch is used with the Z axis since the bottom travel will vary depending on the bit in the router.

Here is a switch in a CNC cut housing that is used on the 18 x 24 machine. There is more information with links to the g-codes for the housing components on the 18 x 24 Limits Page.
Z Axis Limit
Limit switch in CNC cut housing.
 
Limit switches are not as critical with smaller motors as they are on more powerful machines.
The smaller steppers will stall before inflicting extreme damage to the table. However, they may pull the machine out of tune.
Larger motors can strip threads, blow the drives, or otherwise pull the machine apart.
With small machines that are not damaged by over-travel, it may be convenient to disable the limit switches during setups.
Triggering the limits while jogging is a nuisance since it requires resetting the software just to continue.
Once setup is complete, the limits can be enabled.
 
Disclaimer
These circuits have worked well for me, but you assume all risk when using them on your machines.