Issues with Infrared Sensor Integration on Shuffleboard

Hello everyone, my team and I are working on programming an infrared sensor, like the one in the photo. However, we’re facing a difficulty: the sensor’s LED lights up when it detects something, but it doesn’t show up on the Shuffleboard. I’m using the code provided in the documentation, and the wiring is also correct.



IMG-20241122-WA0055

I haven’t really looked at your code, but if the wiring to the roborio is messed up it would cause what you’re seeing

concur with @cmdada it looks like the sensor is plugged into 0 and the code refers to 1.

The electrical schematic in the photo is the one that came when we bought it. It shows the connection on port 0, but in real life, it is on port 1, just like in the code.

Have you verified the electrical connection to the roborio is good? have you tried using a multimeter to verify its output to the output pin in reference to the ground

Can you provide a link to that documentation? Also, I cannot identify what the green chip is in the image you provided, for it is too blurry.

I can see the infrared sensor, the PDH, and switch

Here is the link to the Documentation. In the documentation, the wiring diagram is different from the photo I sent. The photo came with the sensor when we purchased it. I have already tested both wiring diagrams, but it still doesn’t appear on the Shuffleboard. We used a multimeter to test it, and the electrical part is working.

The green chip is a Optocoupler isolation module.

I’m not much of an electrical engineer but I don’t know why you’d include an optical isolator for this application and suggest removing it if you can. I suspect that it is shorting out your signal. From the documentation:

Note:
The input port is shared with GND;
The output ports are independent each other;
It is optocoupler output.V and G will be connected after input valid signa in input port.

This would be a better connection diagram:

The optional VRM probably gives you more stable detection distance as the battery voltage sags because of depletion and motor usage.

Indeed, the optical isolator was interfering with the current, so I made the connection with the VRM. After testing with the multimeter, the signal is passing through, but even so, the Shuffleboard still doesn’t work, staying on the red color even when the sensor detects something.

We could double check your wiring and code if you want but we’d need a picture of all of your actual wire (not the schematic) and your complete code.

Maybe the sensor is cnnected to the DIO? It should be cnnected to the PWM.

Careful! The documentation link that OP provided clearly shows the DIO. Don’t fry the sensor on the PWM port.

Oh you’re right!
Sorry, I seem to have gotten confused.

All this focus on wiring, but I’m not convinced that’s the problem.

OP, is that screenshot of code the exact code that you’re running? If there’s more code, please share it (ideally as a link to github or similar).

If so, DigitalInput::get() returns the value at that instant, so smartdashboard is receiving a basic boolean value, not a lambda that it uses to fetch the value in a loop. Since your code is in a static context, it’s run during class initialization.

In short, your code is functionally equivalent to SmartDashboard.putBoolean("widget", false)

1 Like

they have it in robotPeriodic() though, I don’t think this is the issue

1 Like

You’re right. Phone screen and uneven indentation got me. I swear I checked that 3 times

1 Like

Hey, today I did some more tests with the multimeter and noticed that the signal from this sensor outputs 3V when it’s not detecting anything, and 12V when it detects something (with slight variations). I’m not exactly sure why this happens, but I think that when the RoboRio receives the 3V signal, it interprets it as detecting something, even when there’s nothing.
I’m considering adding something to lower the voltage (a voltage regulator, resistor, or something else)

Sounds like you got a PNP type instead of NPN type. Or maybe the wiring isn’t right. Exactly what model sensor is printed on the sensor? Don’t necessarily trust the box.