It is possible that the mechanical switch is sliding off the contacts and the change in contact resistance is being picked up as debounce and it's tripping the limit switch status and not the "home" switch status?
Have you tried to add a little debounce to see what happens?
I know that this is self defeating in that the debounce will slow down the reaction time, but it may be that the mechanical switch just is the way it is?
50mm/min = 0.833 mm/sec, there is probably a switch pivot point (the click in the mechanical switch) that is creating the issue.
I'm not sure it would help, but you can try things like using a comparator (LM339) to square up the wave again.
http://www.ti.com/lit/an/snoa654a/snoa654a.pdfMechanical switches are never clean in "break", "make" is normally more rapidly achieved as the switch clicks its contracts in position.
Is there any merit in changing to linear encoders {the machine always knows where it is then..... no need to home?} ..... I noticed reinshaw do some 0.1uM ( 0.1 micro meter) accuracy encoders. Others are available with less accuracy and lower cost
https://www.ebay.co.uk/sch/i.html?_from ... r&_sacat=0