Wiring 12v PNP photo switch to RoboRIO


We got some photoelectric switches made for industrial applications but they operate between 10-30v. I need to know how to connect then to a RoboRIO. They are three wire PNP type.

Sensor: HER-AP-3A
Datasheet: https://cdn.automationdirect.com/static/specs/pe8mmheeher.pdf

Wiring RightSight Photoswitch

PNP just needs a voltage divider to bring the 12V signal down to 5V for the roboRio digital input to read.

Do you know how to solder and calculate voltage dividers?


Any chance you can get an NPN sensor instead? With an NPN sensor, you can connect the sensor’s output to the signal pin on the roboRIO and everything just works.

For a PNP sensor, you’ll need to either create a voltage divider with the roboRIO signal pin connected to the middle, or get or make an opto-isolator. Voltage divider is the simplest option here, but runs the risk of damaging your robotRIO input if the voltage divider is disconnected from 0V while the sensor is outputting 12V.


Was afraid of that. Will work on the voltage divider then, thank you.


The RoboRIO was designed and tested to survive battery voltage on every pin, so this won’t cause damage, but the input might not be functional while the excess voltage is present.


Would the attached schematic be valid?




that gives you a high voltage of 4.2 volts, which should be sufficient. The total load on the sensor output is under 5mA, so that should be fine too.


*Another option?](https://www.chiefdelphi.com/forums/showpost.php?p=1536272&postcount=12)