This year, we are using the Ultrasonic Sensor given to us from Maxbotix from the Kit of Parts. We copied the code on their website that they told us. However, we are running into some problems. When the sensor is between 0-24 inches and between 120-190 inches, the sensor works and gives us the correct value. However, when we are between 24-120 inches, the sensor is just returning the value of 28 even when we are driving it forward and back. If anyone else has used the sensor, have you had a similar problem? Is it a problem with the code, with the way we had it set up (it was relatively forward-looking on top of a stand and was attached to the stand with duct tape), our acoustics (our build site has a little bit of echo to it, but not a lot. There were no power tools being used at the time), or is it a problem with the sensor itself? We have never used the ultrasonic sensor before, so any type of help is greatly appreciated.
Without being able to see your code it’s hard to say for certain, but I doubt the code is at fault. If you are unsure, you should just be reading in the analog value using the
.getValue() method multiplied by some constant (defined as 0.125). I got this based on this web address.
After looking at the datasheet it appears unlikely that the beam width would be a problem unless you are at a large angle with the acoustically reflective surface you’re expecting to be detecting, but doesn’t rule out the possibility that it is detecting a closer object that’s within its field of view.
I find it unlikely that your mounting system is causing the problem because at some point your measurement returns to the expected value.
I know this doesn’t exactly answer your question, but I hope it puts you on the correct path