I made up this little input circuit out of parts on hand (less the PRX). It does work. My question is if it's a long term solution or if there are any potential pitfalls?
Source of proximity switch:
Assuming the sensor has an open collector output, the pullup to 12V and the diode are not needed. Your pullup to 3.3V supplies the "not triggered" HIGH, the open collector output supplies the LOW when the sensor triggers.
As mentioned in #2 above, most sensors like that have open collector or open drain outputs.
To test that, power the sensor up without the 12K resistor and use your multimeter to check for voltage on the output, for both activated and inactivated states. If the voltage is zero, it is open collector/drain.
It is not an open collector output, it has a 4K7 collector resistor.
So the 12K resistor wouldn't be necessary, nor would the one on the input if you enable its pull-up resistor.
Another option could be to use an optocoupler.
Poor reviews on the product webpage. Several claim that it fails or burns out in warm environments.
Two tests done. DMM on 20V scale for both.
Test #1 - bare PRX and power supply
Supply voltage: 11.8 (selectable wall wart)
target present - 0 volts
target not present - 11.73 volts
Test #2 - In-circuit PRX
3.3V source is Trinket_M0
Supply voltage: 12.1 (fixed output wall wart)
target present - 0 volts
target not present - 12.1 volts
Output circuit from link provided by @MaximoEsfuerzo
Nice find BTW! ![]()
So I can ditch the two discrete resistors and end up with:
No?
You may need INPUT_PULLUP on the Trinket input pin, otherwise, depending on the diode leakage it may be floating when sensor output is high. It certainly won't hurt.
I flagged @MaximoEsfuerzo's post as solution because of the datasheet link - which shows the actual wiring of the PRX output.
Thanks all for the assist.
Why the 12V?
I expect 3V3 will work...
Even though it is outside the range given in the datasheet...
No diode needed...