Blog · · 7 min read
Homing and limit switches: how your machine finds zero, and what keeps it from crashing
Mechanical, optical, Hall or sensorless homing? How a machine finds its zero point, why the switch is wired normally closed, and how hard and soft limits stop a crash.
Your machine has a lead screw, a belt or a rack, and a motor that can move it to the tenth of a millimetre. There is one problem: when the power comes on, the machine has no idea where it is. A stepper motor counts steps, not positions. A cheap DC motor with an incremental encoder counts pulses, not positions. Both only know how far they moved since they started counting.
So before a machine can do anything useful, it has to find a fixed point it can measure from. That is homing. The same sensors usually also stop the axis before it runs into the frame. This article covers the choices you have for both jobs, and the details that decide whether your machine finds zero the same way every time.
Why "the same way every time" matters more than "exactly"
A home position does not have to be at a special place. It can be 3 mm from the end of the rail or 40 mm, the machine does not care. What matters is repeatability: if you home the axis ten times, it has to stop at the same point each time.
If homing repeats within 0.02 mm, a part you drill today and a part you drill tomorrow line up. If it scatters by 0.5 mm, every restart shifts your work, and no amount of motor resolution fixes that. When you read a sensor datasheet for homing, look for repeatability first and accuracy second.
Four ways to find zero
1. Mechanical micro switch
The classic: a small lever switch at the end of the axis, pressed by the carriage. It is cheap, easy to wire, needs no power of its own, and every electronics supplier stocks it.
Good micro switches repeat well, often within a few hundredths of a millimetre, as long as the carriage always hits them from the same direction and at the same low speed. Their weak points are bounce (the contact chatters for a few milliseconds when it closes), wear after many cycles, and dirt. Chips and dust on a mill or a router can change the point where the lever trips.
Use it when: you build a first prototype, the axis moves at moderate speed, and the environment is reasonably clean.
2. Optical slot sensor
A small fork with an infrared light on one side and a receiver on the other. A thin vane on the carriage passes through the slot and breaks the beam. There is no contact, so nothing wears and nothing bounces, and the edge of the vane gives a sharp, repeatable switching point.
The catches: it needs supply voltage, ambient light or a dirty vane can confuse it, and the vane has to pass through a slot only a few millimetres wide, so your mechanical design must guide it well.
Use it when: you need better repeatability than a lever switch, or the axis homes many times a day.
3. Hall or inductive proximity sensor
A Hall sensor reacts to a small magnet on the carriage. An inductive sensor reacts to metal, such as a steel flag or the carriage itself. Both work without contact and shrug off dust, oil and coolant much better than an optical fork. Inductive sensors in threaded metal housings are the standard choice on industrial machines for that reason.
Their switching point drifts a little with temperature and with the gap between sensor and target. For homing that is usually fine if the gap is fixed by the mechanics. For the last hundredth of a millimetre, machines often combine a proximity sensor for coarse homing with an encoder index pulse for the final position (more on that below).
Use it when: the machine works in dust, chips or splash water, or has to run for years.
4. Sensorless homing
Some stepper and servo drives can tell when the motor stalls because the load suddenly rises. Drive the axis slowly against a hard stop, the drive notices the stall, and that point becomes zero. No switch, no cable, no bracket.
It is tempting for compact designs, but be careful. The stall point depends on speed, current setting, belt tension, friction and temperature, so repeatability is usually worse than with any real sensor. The axis also has to hit something solid every time it homes. On a light 3D printer axis that is acceptable. On a heavy axis, or one that carries a tool, it is not.
Use it when: space is tight, the axis is light, and a fraction of a millimetre does not matter.
A homing routine that repeats
The sensor is only half of the story. The routine that drives the axis onto it matters just as much. A robust routine has three moves:
- Fast approach. Move toward the sensor at moderate speed until it triggers. This saves time on long axes.
- Back off. Reverse a few millimetres until the sensor releases.
- Slow approach. Move toward the sensor again at low speed, and take the position where it triggers as zero.
The slow second touch is what gives you repeatability. At high speed the controller reacts a few milliseconds late, and the axis has already travelled further. At low speed that delay is a tiny distance. Always approach from the same side. Switches have hysteresis, so the point where they trigger is not the same as the point where they release.
If the drive has an incremental encoder with an index pulse (one pulse per revolution), you can add a fourth step: after the switch triggers, keep moving slowly to the next index pulse and use that as zero. The switch picks the right revolution, and the encoder picks the exact angle. That is how many industrial axes reach repeatability far below what any switch alone can deliver.
If you never want to home at all, an absolute encoder reports the real position at power-up. It costs more, but for a machine that must resume work after a power cut without moving, it can be worth it.
Limits: what stops the crash
Homing tells the machine where it is. Limits stop it from going where it must not go. There are two layers, and a serious machine uses both.
Soft limits live in the control logic. Once the axis is homed, the controller knows the travel range and refuses any move beyond it. They cost nothing and catch most mistakes, such as a typo in a coordinate or a wrong unit. But they only work after a successful homing, and they cannot catch a skipped step, a slipped belt or a bug in the control logic itself.
Hard limits are physical switches near both ends of travel. When one triggers, the controller stops the axis immediately, whatever it thinks the position is. On a small machine the home switch often doubles as the hard limit on one end. On a machine that can hurt someone or destroy itself, the hard limit switches should cut the motor power through the safety circuit, not only send a signal that software may or may not read.
Beyond the switches, leave a little mechanical overtravel: a few millimetres of space and a soft stop, so a fast axis that brakes late still does not slam into the frame.
Wiring details that decide reliability
- Use normally closed contacts. The circuit is closed in normal operation and opens when the switch is pressed. If a wire breaks or a connector falls off, the controller sees a triggered switch and stops. With normally open wiring, a broken wire looks like "all fine" until the axis crashes.
- Pull-ups and filtering. Long switch cables near motor cables pick up noise. Use a defined pull-up resistor, a small RC filter or software debounce, and twisted or shielded cable for runs longer than about half a metre.
- Keep sensor cables away from motor cables. Motor cables carry fast-switching currents. Route signal wires separately where you can, and cross at right angles where you cannot.
- Test the failure cases. Unplug each limit switch while the machine is idle and check that the controller refuses to move. It takes five minutes, and it is the cheapest safety test you will ever run.
How this fits into the rest of the design
Homing is not something you add at the end. The sensor needs a mounting point, a cable path and a target on the moving part, and those belong in the CAD model from the start. The choice also feeds back into the motion system: a belt axis that may skip teeth needs a reliable hard limit more than a lead screw that cannot back-drive. If you are still choosing the drive, start with lead screw, belt or rack and pinion and stepper, DC or servo motor, then pick the homing method that matches.
When makemachine designs a machine, the sensor choice, the mounting bracket, the wiring into the controller and the homing sequence come out of the same project as the mechanics and the circuit board. So the switch has a place to sit and a pin to connect to before the first part is printed. If you have a machine idea that needs to move, start a project on makemachine.ai and see how the pieces fit together.
Watch hardware get built by AI. Follow public projects on makemachine.ai, read every result in full and get an email when there is something new.
More from the blog
- Aluminium extrusion, welded steel or 3D printed? How to choose the frame for your prototype machine
- Can a satellite run a large AI model? The power and heat budget of a data center in orbit
- DC motor vs. stepper vs. servo: which one moves your prototype?
Open-hardware projects built with AI
- Data Center Satellite: I want to put a data center into orbit: a satellite that runs a large language model on board, with inference of a frontier-size model as…
- Automatic Archive Page Turner: Automatic Archive Page Turner: an open design study on makemachine. The idea came from a conversation on X, where someone wished this…
- Tile Steam-Cleaning Robot: Tile Steam-Cleaning Robot: an open design study on makemachine. The idea came from a conversation on X, where someone wished this device…
- Chute-Size Trash Compactor: Chute-Size Trash Compactor: an open design study on makemachine. The idea came from a conversation on X, where someone wished this device…
- DIY Automatic Plant Watering System: An open-hardware watering system for indoor plants: a small pump, a refillable tank and a soil moisture sensor in each pot keep up to six…
- DIY BBQ Temperature Controller: A temperature controller for charcoal grills and smokers that makers can build themselves. A pit probe, two meat probes and a small fan on…
- ZählerSchau: ZählerSchau is a small, battery-powered unit that clips onto an electricity meter in Germany (water meters via a clamp adapter), takes a…
- Roadstoy: Roadstoy is a remote-controlled toy version of the new Tesla Roadster that can briefly jump and flip using compressed air. It drives on an…
- The forever Washing machine: The forever washing machine is a washing machine offered as a service instead of a product. Customers do not buy the machine but pay for…
- Bike Light: I want to build a bike light that needs no battery. Magnets sit in the spokes close to the hub, and a coil on the fork picks up their…
- Rooficle: I want to develop a light, efficient and affordable e-bike that can be used legally on public roads in Singapore. Its core is an…
- BBQ Modular Grill: I want to design a modular grill. Instead of one sealed block, it is made of separate parts that can each be bought on their own online…