When plugging in the photo sensor (light sensor, photo eye, etc), where do you plug it into the RoboRIO? Thanks!
I don’t know of a “standard” photo sensor, so the answer is, it depends on what you have. An analog photo sensor will plug into the analog I/O, and a binary (on/off only) sensor will plug into the DIO. What make/model sensor do you have?
Our sensor is the Allen Gradley Right-Sight sensor, PN 42EF-DIMNAK-A2. We aren’t sure if it is digital or analog, and we can’t find the information online.
I found it first try, but it appears that the part number is actually 42EF-D1MNAK-A2. You can find info on this page. In the product selection table, this is designed for a “diffuse” sensing mode, meaning to detect a wall or boulder. (The table shows suffix -F4, but the notes at the bottom indicate that -A2 is the same device with diferent connector.) This is an NPN sensor (works with a pull-up resistor), so you don’t need to add an inverter. Unfortunately, this looks like it’s designed to be powered by 10.8 to 30VDC, and the DIO only provides 5V.
My recollection is that the 0V of the DIO may not match the 0V of the electrical system, so in order to use this, you will need to power the sensor from a 12V branch circuit and do some sort of isolation to switch the DIO. The simple mechanical solution would be a 12V relay, and the electronic solution would be an optoisolator. Because the isolator breakout I linked to is designed for 5V input, you will need to add another resistor in between the output of your sensor and the input of the isolator. If I’ve done my math correctly, a 680 ohm or 1k resistor should do it.
Edit: both my look at the data sheet and a PM from Ether reminded me that if you have a 3.3V or 5V PNP logic sensor, you will need to use an inverter between the sensor and the DIO port. More info in this thread.