This conversation has stimulated my hacking instinct. So I went to the closet, fetched and dusted off my official hacker benie (top propeller included).
Here are my preliminary findings:
The PIC firmware does 3 things.
(1) generate 40KHz ping - no change needed
(2) setup return detection - no change needed
(3) report leading edge of 1st return ONLY - we would like to see other returns
My conclusion is not to change the PIC but rather to breakout the raw return echo. This turns out to be quite simple. Please examine the file ‘HY-SRF05-Sonar-Annotated.jpg’. Note that the raw echo return is taken off the Collector of Q2. In ‘HC-SR04-PingAtNPN-xtraWire.JPG’ I have soldered to Q2. The SR04 and SRF05 have nearly identical circuits.
Next we examine the oscilloscope traces of the Q2 signal ‘HC-SR04-PingAtNPN-1target.JPG’ and
‘HC-SR04-PingAtNPN-2targets.JPG’ When 2 objects are present we can easily see both echos. The PIC firmware simply ignores everything after the 1st echo.
By feeding the raw output to my Arduino, I should be able to see both objects. Note that existing code & libraries will not work. They use either pulseIn() or Timer2. Both are bad ideas. I connect the return to pin 2 (Uno) and use attachInterrupt(). The micros() value converts to the distance. I should be able to extend this to 2 or more targets.
I tried to attach the code but the forum only allows uploading 4 files. I invite additional comments and criticism.