I bought an ultrasonic sensor about a year ago and have used it ever since. I think it is a great sensor and I have had no complaints. However, about a week ago, my sensor started to act strange. When I plug it in, and yes I am plugging it in correctly, it gives me a reading of 1-250, I am pretty sure it is only supposed to reply 1-99. Also the code is not wrong because this “strange behavior” happens in on-line mode and when I use the ultrasonic test code. Besides giving me a strange reading, I think it is returning the data way to quickly. When I use the terminal window, the sensor returns 411 “readings” in 1 second! I am not sure but this seems **a lot **more than what it used to return. I was wondering if this has happend to anyone before and how to fix it?
Thanks,
-Ben
The ultrasonic should only send back signals between 1-99 and definitely should not send anywhere near 411 readings in a second (realistically 2-5 readings per second tops). Could you possibly show me the code you are currently working with? I will try it here, see the readings and try to help you out further. I recently had a ultra sonic sensor go bad that had some uncharacteristic things happening to it. At first glance, I would say your sensor is simply going bad.
I am using the Ultrasonic test code that comes with EasyC V2. I attached a screen shot of the code. The data is also messed when I use the on-line mode. I am not sure what the problem is. Do you think this could do something with the battery? When I turn my microcontroller on the battery light is red for about 5 seconds and then turns green. I am using rechargable “AA” batteries. I have read some where that rechargeable batteries can loose their charge overtime. So maybe they have just worn out because of all the use. I think I am going to get the battery pack and see what happends.
Thanks
![rsz_code[1].jpg](https://www.vexforum.com/uploads/default/original/2X/c/c52d96d9cebc18b7aac57df1c7c2a18503b79c0f.jpeg)
That’s very odd. I typically use rechargeable 7.2 or 9.6 batteries on the controller. Both read the same range of readings (1-99). So, I doubt it’s the batteries that are doing it.
About the code, that is the test code. So, it should just print to screen (terminal window) the readings. If it’s giving you insanely high readings that really odd. I would first change the ports that you have it plugged in to. Try plugging the OUTPUT into INTERRUPT 2 and the INPUT into ANALOG input 12. Go ahead and if this doesn’t work, bump them up to the next slot, if this doesn’t work, I would say that your sensor is bad.
Short story about ultrasonics. We use programming robots with the bumper, encoder, ultrasonic, line follower and light sensor on a weekly basis over the summer. The robots that we use currently have a year and a half on them. The only sensor (literally only one sensor out of the fleet of programming robots) to go bad is a ultrasonic sensor. So, I would not totally rule out that the sensor just went bad.