MB1013 HRLV-MaxSonar-EZ1 Problem

Our sonar sensor (mb1013 HRLV-MaxSonar-EZ1) is not stabilizing the distance as it is measuring. We tried to find better volts_per_inch value but the volts themselves aren’t stabilizing. How do we fix this?

Your description of the problem is vague compare to the many possibilities of how the sensor is used. I can make a bunch of assumptions that lead to a conclusion but assumptions are risky to make and I’m probably wrong.

A graph of sensed object distance vs time would be helpful. That shows us how much variation there is. And what is the actual distance that you want?

Is the object moving?

What voltages are you talking about? The Vcc voltage isn’t stable? (What is powering your sensor?) Rapidly changing Vcc causes bad readings.

A picture of the environment you are trying to sense would be helpful. Although the beam is somewhat narrow (about 2 feet at distance) that model of sensor has a very large range (about 15 feet). It may be sensing objects you didn’t want it to sense. How wide is the object and how close is it to the sensor?

What output are you using from the sensor? Analog? Pulse Width? RS-232? TTL?

What are you plugging the sensor into to take a reading? Hardware?

What are you using to interpret the sensor values? Software?

Have you tried using a different identical sensor to verify the sensor isn’t broken?

Assuming the sensor is perfect (they are hard to break) and you are powering the sensor from a good source like the roboRIO 5V (which if you check carefully over time varies slightly and could be more like 4.9V) and the object isn’t moving and is fairly large then I’ll guess you haven’t filtered the unstable values as, IIRC, the WPILib documentation recommends. The sensor manual tells us that almost everything that could go wrong is compensated for but in the end they admit “Most range readings are accurately reported.” Filters are appropriate even if the sensor manual says maybe not.

We are running the sensor through wpilib and the roborio. The code works by reading the voltage returned by the sensor and then using a conversion of 0.0098 volts per centimeter for our sensor to return the distance of the object, the conversion rate is from the mb1013 HRLV-MaxSonar-EZ1 datasheet. We tried testing it with a wood plank propped up 30 cm away. The values that we are getting from running it are nowhere near its actual distance at all.

We’ll try using a identical sensor in our next meeting to see if this one is just broken or not

In my experience (it’s been 10 years since we used one) the reading you get will not be linear. I believe they provide a formula to use. Adjust your constant until you get the right distance measurement. I’m not sure what work wpilib does for you, but we also needed to filter the response because it was very noisy.