This winter, I decided to make ultrasonic rangefinder (later UR). Conventional rangefinders, like MAXsonar and not bad and even not very overpriced, but they are sold online (I have no credit card), and delivery would have doubled the price. The idea was making cheap and “smart” UR using ADC, not just comparator. I bought Murata MA40B8R and MA40B8S receiver transmitter pair http://pdf1.alldatasheet.com/datasheet-pdf/view/116599/MURATA/MA40E8-2.html
(~4$ each). In Mouse the junkbot project I found LM386 sound amplifier. It was cheap, had good gain (200) and suitable bandwidth. For transmitter, conventional MAX232 level converter was used to get higher voltage from common 5 Volts.
But performance was poor, especially measurable distance.
Here is the image of wall 2 meters away (up), and sent pulse (down). As you can see, it is weak, too weak to be a wall J. I got stuck for some time, and replaced LM386 with two opamps (TLV272) in conventional single-supply position. The answer was Lm requires higher supply voltage, and saturates with 3 Volts on output.
After that, voltage limiter on Schottkey diodes was added to enlarge dynamic range. High voltages would be dropped on resistor, while small on diodes only. This will allow using higher gain in next stage. However, in reality, this not works – gain in the first stage is too low. Then, conventional rectifier was added. After that, I tried ADC sampling. 12 MHz crystal allowed me 25 and 70 KHz sample rate. Both are too low to sense 40 KHz, so I added analog filter from two RC stages. It is possible to use active filters, but I don’t like them, and passive woks great. Analog path ends with buffer (AD820) and go to ADC.
/ There is divider after rectifier – it is used not to saturate poor LM358. It was the only thing I had that time. In etched board I will use quad rail-to-rail opamp/
The next step was receiving of sampled signal. To do that, RS232 was used with 57,6 Kbps speed. As ADC sample rate was 25 KHz, it was impossible to send sampled byte each time between measurements (it requires nearly 250 Kbps, but my PC failed to support it). So I just made buffer for 900 bytes in RAM and sent it whole after it is full. This allowed scanning nearly 6 meters - more than enough.
Now, I am working on signal processing. 25 KHz sample rate means 480 crystal clocks between samples. This allow to process echo(es) in real time, but suitable algorithm required. I try to use simple IF (previous lesser then current) AND (next lesser then current) statements, this helps, but not very much. Depending of distance and target reflectivity and size, echo signal from one object can be very sharp, but smooth from another. I tried to use differences, but it doesn’t work at all. So, if anybody knows better way of maximum detection, help is very appreciated.
Here is the signal of the second amplifier stage recorded with soundcard. Sample rate is 96 KHz sow and this allow CoolEdit to reconstruct 40KHz. First left maximum is direct coupled signal. Receiver is tight together with transmitter, and receiver catch signal during and after transmitter oscillation. Next peak is a side of the bed, 1.5 meters away from UR, and much lower. Next is a pillow (not of winds
, but main echoes are close
), standing straight on bed, 1.9 meters away from sonar. The last peak is a Wall 2.7 meters away. I fail to explain received signal after that point, and interpret it as noise.
Here is sampled signal. Same thee echoes. Looks good, and SNR is higher than I expected. Pink graph relates to my peak detection algorithm processing. As you can see, small oscillations are also told to be maximums. Now I am working on next stage of processing.
Other problem is small distance detection. In that situation, direct coupled signal mixes with reflected signal. Minimum range with detectors tight together is more than 15 cm. Perhaps, with transmitter and receiver taken further (4-5 cm like on conventional URs ), this problem could be minimized. I will do so on etched board.
In this measurement, objet is moving towards the UR. As you can see, peaks are getting closer.
Object is 10 cm. away from UR. No detecion. One intensive peak is just second reflection, not primary echo.
In attachment you can see sample signal from bed, pillow and wall with higher resolution.
Second is high resolution version of obstacle moving towards UR. Sharp single peaks before signals mean new measurement cycle started, they are not related with signal itself.