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: