I am a DIY CNC guy. I love building these machines and making things using machines that I made. I have built a CNC laser and a CNC router from scratch and have been forced to innovate some solutions along the way due to cost limitations. I wanted to share one of my recent innovations that will allow you to build very accurate/precise limit switches for less than $25 total (could be even less depending on how you make the brackets).
The heart of the system is what is called a Pogo Pin. They are used in the electrical industry to test circuit boards. They are very inexpensive and perfect for the application. Here is a short discussion of the pogo pin and how I was intending to use them:
As I stated, I bored a hole in the nylon machine screw and mounted the pogo pin inside of the nylon screw. The purpose using the machine screw is to isolate the Pogo Pin from ground. Essentially, you want to create a direct contact electrical switch by using a pull up resistor on an input pin to ensure that the input pin sees 5 volts (or whatever voltage your system works on) when the pin is isolated from ground and then will see 0 volts when it touches any grounded component. This will tell your machine controller that the machine is at the position you call home or at the machine limit. It is actually more accurate to walk your machine onto the pin and then step back more slowly to a position off of the pin.
So, you have all the parts... now you have to make the nylon pogo pin holder. Since I have a CNC router, I used that, but you could easily set this up with a drill press too. I wouldn't recommend doing this by hand as they need to be drilled pretty straight.
Here is how I set it up:
After you bore out the nylon machine screws, you will want to build some brackets that will hold the screw in place so that it will contact your machine in a location at the end of it's travel. I built mine out of 1.5"x1.5" aluminum angle that is 1/8" thick. You can find that kind of stuff just about any big box home improvement store or hardware store. The great thing about aluminum is that it is fairly strong and is also easy to cut and machine. It is also reasonably inexpensive (though much more expensive than steel).
The next thing to do is solder a wire to the end of the Pogo Pin. I found it was easiest to solder using a light gauge wire stripped so that there was just about 1/32 of an inch of wire showing. I then used one of those soldering assistants with the alligator clip hands to hold the wire and the pogo pin together. I aligned the pogo pin and wire so that the two butt jointed directly at the ends. That is to day that they were aligned axially and toughing at their extremes. It only takes a small drop of solder to attach them They stay together very well. The brass end of the pogo pin wets well with solder.
The next thing to do is roughen the end of the pin where the solder was applied. I used a flat file. This helps the glue adhere. I then inserted the pogo pin into the nylon screw about half way and put a drop of CA glue (super glue) onto the shaft of the pogo pin and slid it into the desired position and let it set up. It is really quite strong when set up. You will break the pogo pin before the glue lets go.
Next you want to assemble one of them and give it a test on your machine. Here's my first test:
Next you will want to make all the brackets for your rig and get all the switches installed and connected back to your machine controller. After that, you will want to test the repeatability of your system. It is very important that your homing system be as repeatable as possible. This is the only way your machine will know it's absolute position. If you do any kind of fixturing, this is absolutely critical. It is best to set this up with a dial indicator of some kind. Here is my test:
Finally, if you have a gantry type system like I do with a slave axis, you will want to square up your gantry as best you can. I find that the most accurate way to do this it to indicate off of a machinist square. I put some reference pins in the table along my long axis and got my square set up so it is touching the pins. I then set up a feeler gauge in my spindle and set it up to indicate off of the other edge of the square. You can then adjust the pogo pins forward and backward on either side until the feeler gauge reads zero across the length of the square. Here is a demo:
Now you are done and set up. Hopefully you do not have any more than $25 into the system.
A couple further notes:
1) if you don't have a solidly grounded machine like mine, you can set up your brackets with an extra ground wire run to them so that the direct contact electrical switch will still function correctly.
2) use the soft limit feature in your machine controller. This will help prevent a crash and will check your code to be sure you aren't going to crash during a cut. It isn't fool proof, but it helps a lot. I think the only time you should have a problem is if your steppers or gears slip so the machine thinks it's somewhere where it isn't. It is also possible for the machine controller to straight up fail, though this is fairly rare.