I found a line of best fit for its output to make sure my reading are the best possible.
These are my points and their ADC reading:
Average ADC reading: Distance:
76.3929 40
126.9655172 65
176.0333333 90
226.3103448 115
256.8125 130
296.0714286 150
The best line fit:
y = 0.501x + 1.67
distance = 0.501 * ADC_reading + 1.67
The equation works quite well. The ultrasonic has 3 different types of output:
1) Analog: which I like it, since it is fast, easy but less accurate compare to others but fine for me
2) Pulse width: a bit more complicated since you have to use a timer. I am using Arduino which does not have a lot of timer and for my robot, I will be using most of timers. If you want very accurate result then go for next option.
3) Serial output: This is the most accurate output. But wasting a UART may not be a good idea. The other issue is that if you use interrupt to read your UART input, you have to turn other interrupts off which may not be suitable for some situation. If you read UART without interrupt it will take some time since the baud rate is 9600. (I may try this in future just for sake of accuracy)
they are two modes of reading the output from sensor:
1) free run:
It has a filter included and I prefer to use this since it has a filter.
2) Real time:
It has no filter and it will do its reading when you send a signal.
Now I start with tests.
Testing different material:
The sensor has the same output for different type of materials. I tried with metal sheet, carton and polystyrene.
Testing different shapes:
It could detect the cylinder without any issue from sides and it showed an accurate output. Flat surfaces are definitely detected and there is no issue with them.
Object with different size:
the size of object is not going to change the output.
Detecting the closest object:
Even if there is a big object at the back and small object in front, sensor output will be the distance to closest one.
Detecting 15 degrees ramp:
It could detect the ramp with acceptable accuracy from 30 cm to 15o cm. The length of the ramp is 60cm.
I used this ultrasonic on my robot and I think you have to consider the following if you are going to use one:
1) In the real time mode you do not get a very reliable reading (I tried it in a parking lot and I was not happy with it)
2) If you are using the free run mode, your readings are impressive, however you cannot move very fast because it takes some time for changes to appear on you reading. (This is what you should expect when you are using ultrasonic, I did some research and I found out that laser range finder can do a better job at much higher. Hopefully I will be making one laser range finder with my friend.)
3) If you are using the sensor very close (5 cm) to a surface which is not supposed to be detected, you have to make sure that the surface is flat. To give you an idea we had to wooden sheet next to each other with a gap around 1mm. The sensor was detecting the edge from 190 cm. It was detecting the edge of the gap (located at 190cm) instead of the wall which was located ~240 cm away.
Conclusion:
A good sensor for application where respond time can have a delay of 1s. Accuracy is good. Sensor has 3 different outputs which make them easier to use. If you want to have a fast robot forget about ultrasonic and go for laser range finder.