Today I installed an inductive sensor (4 mm sensing distance, NPN) on my printer to perform auto-bed leveling. The sensor works at 12 V and the board at 5 V, so I used a voltage divider (as suggested in many places online) using a 10kOhm and a 15kOhm resistor.
In testing the sensor, I noticed that the sensor's LED turns on, but the printer (Anet A8) doesn't recognize the fact that the sensor is triggering. I'm running the Skynet3D firmware, though I still have not switched to the version with auto bed-leveling. Regardless, the inductive sensor should still act as a limit switch, yet the Z-Axis motor does not stop when the sensor triggers. Am I doing something wrong, or missing a step?
I have also measured the voltage across the leads that connect to the board and the voltage is slightly over 5 V when the sensor is not triggered, and lowers to around 2.5 V when the sensor triggers. I get the feeling it should be closer to 0 V.
Thank you very much for any help.
Perhaps the culprit is a pull-up resistor on the board. Normally, endstops on 3D printers use the microcontroller's internal pullups. These have a resistance of around 50kΩ, which is far too high to be a problem. However, if lower value pull up resistors are used on your main board, this could cause a problem.
The resistor of your voltage divider form, when the output of the sensor is low, a parallel pair of resistors to ground, with an effective resistance equal to
1/(1/10+1/15) = 6kΩ. If there was (let's say) a 4.7k pull-up resistor on the board, you'd expect to see around 2.8V on the output (because the pull-up resistor, together with the two resistors of your voltage divider, forms another voltage divider).
I don't have the Anet A8 main board myself, but on pictures I do see a set of 6 resistors suspiciously close to the thermistor and endstop connectors.
You could verify my suspicions by unplugging the endstop, powering down the electronics and then measuring the resistance between the endstop signal and 5V pins.
Desolder the offending resistor. This is pretty easy with SMD parts: you just alternate between heating up both sides until it slides off.
Use a diode in place of a voltage divider. Anode goes to the endstop connector, cathode to the signal of the probe. This prevents the high voltage of the probe from being seen by the electronics, while allowing the probe to drain the current from the pull-up resistor.
With this last solution, make sure the reverse leakage current of the diode is not too high. If it has a reverse current of (let's say) 50uA, then 50uA flowing through the (supposed 4.7k) pull-up to ground would raise the voltage at the signal pin to 5.002V. This is unlikely to be a problem, but with higher value resistors or higher leakage you'd see the voltage raise higher above 5V (which the microcontroller won't like).