Dropping this in here:
Automation direct has a good video on the different types of photoelectric sensors.
For line detection your generally looking for a diffuse reflection sensor. You adjust the pot on it till it “sees” the white tape and ignores the grey carpet. The same sensor can be used to detect objects like balls in your intake by adjusting it’s sensitivity or setting it closer to the object.
Because there are so many different types of photoelectric sensors and the same ones can be used in different ways is confusing for newbies.
As for wiring them, all I can do is talk generally. But generally you have a power in, ground and a signal line. The sensor at FirstChoice is a PNP sensor so if you have a choice you will want a PNP sensor. You can hook it to the signal in line on the DIO ports of the Roborio.
The power in can be 3.3, 5 , 12, 24 or more volts. As far as I know we can only use 3.3, 5 and 12 volts. We don’t have a 24v or higher supply on the robot. There is a 3.3 volt supply on the MXP port but I don’t know about using it for this. So that leaves 5v and 12v which ate the most common ones anyway. The 5v is right on the DIO pins that your already hooking to. So a 3 pin PWM style connector and your done. If you need 12 volts, use the 500ma output on the VRM Voltage Regulator Module. This is preferred over the battery lines because it is protected from sagging as your voltage goes down. The other regulated 12V sources are for other stuff and we are not allowed by rule to use them.
If your sensor has more than 3 wires the additional ones might be NPN or serial or something else that you can ignore, Just don’t let them short to anything.
The sensors can cost from $3 to $100. I can post more on what I know about the differences if there is interest.
I also remember using these sensors in 2011 but this year the models are
Allen Bradley 42EF-D2MPAK-F4 found in our KOP
The suppy is 10-30VDC and they are PNP which means if you power them with 12VDC when the output turns on it will deliver 12VDC to the DIO of the robo RIO.
Back in 2011 we were using cRIOs which may have been able to handle the 12VDC input through the side car but I also remember having to create a circuit to drop the voltage from 12 to 5VDc (Not sure I needed to)
I misread the roboRIO manual and NI has confirmed that the max voltage you can put on the DIO signal pin is 5.25VDC. So before you use these sensors with a digital input pin you will need to reduce the voltage output of the sensor from 12 to 5VDC.
@MarkBalla We did get it working without reducing the voltage. Not saying it should be done but in ignorance it was done and didn’t hurt anything
So I just purchased these in hoping they should take the 12v signal and take it down to 5v to use on the DIO rather then build my own circuit.
Should this work?
To verify - you are converting the output? If so, yes.
However, “making your own circuit” is literally as easy as three equal resistors in series.
Yes, these divide the signal voltage by 5 and will work. The DIO are 3.3V inputs. See page 15 of the Roborio manual. If there is a 5V or 5.25V spec, it is probably an Absolute Maximum meaning that exceeding that voltage will damage the circuit. Manufacturers do not guarantee proper operation between the nominal range (3.3V ±5%) and the Absolute Max.
It would be a good idea to wrap these with electrical tape or put a piece of large heatshrink tubing so it doesn’t short out your signal on some part of the robot frame.
Thanks for all of the information posters. I’m doing my best to put all of the information together…so if someone could verify the below for accuracy it would be very appreciated.
These sensors Allen Bradley 42EF-D2MPAK-F4 can be interfaced directly with the roborio with three wires in total:
- Power - 12V best supplied through the VRM using the 500ma ouput
- Ground - GND on one of the DIO ports
- Signal - S on the DIO port (but must first be taken down to 5V max)
Also suggested are the QTRXL-HD-01A Reflectance Sensor which can be interfaced directly with the roborio with three wires in total:
- Power - 5V best supplied through the 5V on one of the DIO ports
- Ground - GND on one of the DIO ports
- Signal - S on the DIO port
Do I have all of that right? Thanks in advance for your responses.
We bought 2 of the Pololu 16 x 8mm to test with. So far, we have not been able to detect the white gaffers tape with them from above about 5/8". Has anyone been able to get success anywhere near 2" high?
We’re using opto-isolators to take the 12V down to 5v for the KOP light sensor. These HAVE TWO LEDs and two NPN photo transistors so one board will do two sensors. I really wouldn’t advise feeding 12v straight into a DIO pin!
The voltage dividers might do it fine as well. We just wanted to be sure. https://www.sparkfun.com/products/9118
Here is NI’s official response. 5.25 is the maximum allowed into the DIO.
The pololu sensors have no optics. That is what makes them so short range. It also makes them more sensitive to stray light. Placing a lens in front of it would help if you can figure out the right strength.
My guess is this would help. https://www.amazon.com/Carson-MagniRead-1-5x-Magnifier-MR-25/dp/B0011X0PAU/ref=sr_1_4?rps=1&ie=UTF8&qid=1548257983&sr=8-4&keywords=bar+magnifier&refinements=p_85%3A2470955011
A bar magnifier will work with a line array of sensors. A 1/2 ball magnifier should work better than a bar if there is just one sensor. The reason I suggest these instead of a regular lens is that the focal distance for these types is the back side of them. So you can simply tape them to the front of the sensor. A regular lens would need to be held at around it’s focal distance from the sensor.
I have not done this as I would rather spend the money on the nicer ones with all the details worked out. But $40 vs $4 may be worth it.
Interesting. The way the Pololu sensors are laid out it would be hard separate the emitter from the receiver with regard to this lens…and how might that lens affect the emitter.
@blturner what “nicer ones” are there as alternatives that you would consider?
The nicer ones have separate small lenses on the emitter and sensor. As long as the focus of the two of them overlap it will work. It’s hard to get them not to overlap so I did not mention it.
The Allen Bradley one mentioned above and the Keyence ones that have been in the KOP in the past.
Here is one.
Here is a fixed link to the sensor.
I’m interested in using these too - I assume you have them hooked up and they work?
The low voltage side hook up looks really straight forward using 5V, Ground and signal with the DIO port.
I’m not sure about the 12V side - yes, the Allen-Bradley sensor signal output goes to the HV1 on the Level Converter, but I’m not 100% sure about the 12V and ground connection (HV and GND) connection source - VRM, or something else obvious that I’m not figuring out?
You want the 12v supply voltage to be coming from a boosted source, not the battery voltage that fluctuates as we drive.
The sensor works down to about 10.5v or so, but becomes undependable as the voltage dips below that, which is pretty common for FRC robot batteries.
So, either a VRM or similar custom circuit voltage booster is recommended to prevent the sensor from cutting in and out as you drive.
Yes thanks - I’m probably not being clear.
I will be connecting the Allen-Bradley sensor to a VRM, my question is the 12 volt input I saw in a picture for the step down to 5 volts when using the device from Sparkfun:
That 12v input can just be battery voltage, if it’s feeding a step down.