Rev 2m distance sensor randomly starts returning -1

Currently at competiton, all robot functionality except drivetrain is being destroyed by our distance sensor. We have an installed 2m distance sensor, which after a random amount of time starts to return -1. Seems to be fine after restarting robot code, but breaks again shortly after. Tried swapping the entire distance sensor, and moving from rio I2C to navX MXP i2c. Any help is appreciated.

-1 is usually a sign that no data is being transmitted, I would check the electrical along with re-reading the code to make sure your not breaking the sensor through robot code.

1 Like

What exactly do you mean by breaking? Here is the link to our distancesensor file in git: 5530-2024-Code/code/src/main/java/frc/robot/subsystems/ at working · Lawnmowers-5530/5530-2024-Code · GitHub

I²C on the roboRIO is known to be problematic – even when using the MXP pins. Pretty much, don’t do that… You can search here for threads on this topic.

So the issue persisted for a few matches, and then we brought an FTA over to look at the data on shuffleboard who magically fixed the issue by standing there and looking at it. Big shoutout to that FTA. Haven’t had the issue since those couple matches, but we plan to swap to a different distance sensor as soon as possible and stay away from the I2C. Thanks for your help.

1 Like

Something we’ve noticed, is that when using that same sensor, it will stop giving signal whenever the robot was forced to do something. This is because as the rio has a security mode, whenever the robot hits something, or motors are stalled or whatever, the rio protects itself from these voltage changes, and so the I2C port pretty much dies.

Team 7421 is currently testing changing the ground and voltage pins over to the vrm to see if it helps

You can read more about brownout protection here: roboRIO Brownout and Understanding Current Draw — FIRST Robotics Competition documentation

1 Like