Question about IR sensor

Our team wants to use an IR sensor to detect the number of the ball we have intaked . However , we don’t know which IR sensor to buy , and which IR sensor can be used in a FRC competition. Besides, is there any programmimng instruction to it?

Any reply is appreciated~

Hello! Our team used these IR Beam Break Sensors and they’ve seemed to work pretty well for us. You can use them as a digital input and then have conditionals in your code that use the value outputted by the sensor.

We used the same sensors with pretty good results.

We have also used these sensors successfully. I do have one caution however. The receiver can give false positives negatives due to ambient IR (such as sunshine but also other sources). We put a “hood” of electrical tape across the top and down both sides that extended a bit out in front of the receiver (do not block the path from the emitter). We tested in sunshine with that without any issues.

1 Like

Thanks , is it available on Amazon?

It looks great, but is there any program instruction for it?

Go down ~18 posts

1 Like

Our ball sensors are these from Amazon that cost us a whole 88 cents each. They detect the red and blue cargo about equally from 3 inches away.

We’re using one of those same Amazon E18-D80NK sensors to control ball indexing. They can plug directly into the RoboRIO DIO ports (blue wire is negative/ground).

We made sure to shield the sensor from overhead lights and other ambient light as much as possible.

We used reflective (vision target) tape as the “target” so the ball blocks the beam so the sensor can no longer see the reflective tape. Then we adjusted the set screw to reduce the sensitivity as much as possible so that the ball itself doesn’t trigger the sensor.

To read the DIO port, you can use the DigitalInput class from WPILib. For example, assuming you have the sensor plugged into DIO zero, put this at the top of your Robot class in the member variable declarations:

private final DigitalInput ballsensor = new DigitalInput(0);

You can use ballsensor.get() to read the on/off status of the sensor, but it’ll return true when it doesn’t see a ball, and return false when it does see a ball. (Basically it’s returning whether or not it sees the reflective tape.)

Thanks , but how can you ensure that the ball limit has been reached. If l want to shoot while intaking, how can l confirm that?

l guess that two IR sensors are needed. One to detect whether a ball is intaked and the other to detect whether the ball is shooted. But l think a color sensor and a IR sensor can also do it.

There are two ways to handle counting: a beam break in each slot in the magazine so you can constantly know how many you have, or a check in check out system that counts them as they leave. The first works better if your sensors make mistakes, but both should work from a code side. It didn’t work for our robot as we had a third exit point, so we aren’t even counting them.
Color filtering is a much bigger deal than holding 3, and the IR sensors can help you with that too. (95’s blog has a good page on how they made their sorting).

1 Like

Does your E18-D80NK have three wires?

Besides , is your IR sensor this type
image

Or this type?
image

Which type can be wired directly to Roborio.

Yes, ours has 3 wires. It has the connector (first type).

1 Like

So l only need to plug this on the Roborio , write the relative code and then it can be used to detect the ball? Does it need anything else?

There should be a box of molex parts/wires in your kit of parts. If you still have any of the extension cables left, you can use these to extend the wire to get it where you’re going on the robot, if it’s too far from the RoboRIO. If you don’t have any left, you may want to buy more.

1 Like

Ok, thanks a lot!

4028 used the REV Color Sensor v3 to great success this year. This has the added benefit of knowing what color ball to use, although you will need to tune the “thresholds”.

Ensure to read the I2C thread first. We used a Pi Pico using ThadHouse’s code–you can see more details around here in the thread (the GitHub includes pinouts for the Pico).

For an example of how we wrapped around the PicoColorSensor class, see our code

2 Likes

What is Pi Pico , and where can l buy it? Can you provide a link? Thanks!

Essentially a Raspberry Pi, but without the OS. It’s literally a microcontroller and some pins, where you deploy some code to it and it runs that code forever.

You can usually buy it from any good hardware/electronics store, for $4. I believe this is where we got ours (we bought 6 in case we messed something up–spoiler alert, we did), but I didn’t buy it so I asked the controls mentor who did. I’ll let you know.

You can also buy it on adafruit for $5.