The end stops I am using on my homebuilt 3D printer, the Configurable Fab Machine, are not accurate enough to home the printer vertically - there's up to 0.5mm slop, enough to mess up the first layer adhesion. This Instructable shows how to use a force sensitive resistor (I used https://www.sparkfun.com/products/9375) to get precise positioning.
Step 1: Mount and Connect the Resistor
I mounted the resistor outside of the print area of my printer (negative Y position and negative Z position). Since the resistor will trigger only at a particular XY location, the Z end stop is still useful and should trigger below the resistor Z position.
The Sparkfun resistor is self adhesive and easy to attach. It's a good idea to cover the resistor with a small patch of PEI to protect it from the hot extruder nozzle, in case you home the printer while the extruder is hot.
Wire the resistor in parallel with the printer Z-stop.
Step 2: Set Up the Homing Procedure G-code
Since the printhead has to be in a particular XY position to use the resistor, it is useful to have a G-code sequence that does all of the steps automatically. The G-code below will first home the X axis, then position the printhead to the X position of the resistor. Y axis is homed and the printhead moved above the resistor. Z axis is homed next. Finally, the printhead is moved to printable area and Y and Z are set to 0.
G28 X ; home X
G1 X15 F4800 ; move X to edge of printable area G92 X0 ; set X to 0 G1 X405 F4800 ; go to the X position of the resistor G28 Y ; home Y G1 Y17 ; go to the Y position of the resistor G28 Z ; home Z using the resistor G1 Z2.2 ; move Z up to the Z=0 printable height G1 Y35 F4800 ; move Y to the edge of the printable are G92 Y0 Z0 ; set Y and Z to 0
This is the homing sequence for my Configurable Fab Machine. X end stop triggers 15mm left of the printable area. Resistor is at X=405mm. Y end stop is 35mm beyond the printable area and 17mm beyond the resistor. Resistor triggers 2.2mm below the Z=0 plane. You will need to substitute your own values for 15, 405, 17, 35 and 2.2.
Since my printer is reasonably large, I use F4800 to move the head reasonably quickly (80mm/sec). Increase this number to speed the move, decrease it to slow the move, or erase the term to use whatever default your controller uses.
To home Z accurately, which is the object of the whole exercise, the homing should always be run with the same temperature - either everything off, or bed heated, or the hot end heated, or both. This is because the bed and the hot end expand when heated, so the Z increment (2.2mm above) designed to position the printer properly when homed cold will likely result in the nozzle being too high above the printing surface if the homing is executed with the bed and the hot end heated up. It does not matter what is heated up or cold when the homing is done, as long as it is the same every time.
Step 3: Enable the G-Code
Finally, you need a way to send the homing G-code to the printer. This depends on the software you use to control your printer. In Repetier Host, you might put the G-Code sequence from Step 2 into a script.
I use Octoprint and the Custom Control Editor plugin (http://plugins.octoprint.org/plugins/customControl/). This lets me put a button on the Octoprint control tab page that will send the G-code to the printer.