Idea - a more precise range finder (hacking the hc-sr04)

Thread Starter

fastlingo

Joined Apr 29, 2016
13
I have recently made an electronic ruler with a hc-sr04 ultrasonic module. The module has a transmitter and a receiver. It has two digital pins, TRIGGER and ECHO. You set TRIGGER high for over 10us, then the module sends 8 pulses of 40khz sound waves, then it puts ECHO high and keeps it high until an echo returns. If you measure the time ECHO is high, you can measure the distance.
I didn't like the performance at all, especially at longer distances, it is not very directional or precise.
My idea is like this: instead of trying to measure an echo, what if I measure direct sound from a second device, that you place exactly where you want to measure the distance from? I was thinking about removing the transmitter piezo and put an infrared led instead (it will be driven by the circuit that sends ultrasound pulses, at 40khz, which is the same frequency that remot controls use). The other device will detect the pulses of infrared by using one of these infrared detectors (in a negligeable amount of time compared to sound) and will start sending 8 pulses of ultrasound (which is what the original detector expects). Basically I am trying to fool the module into thinking it's detecting its own echo, but it's actually detecting the sound from another source.
I think replacing the ultrasound transmitter with an infrared transmitter will work, but I am not really sure how to drive the ultrasonic piezo from the second source. Is a single mosfet enough or will I need some sort of a bridge?
 

ericgibbs

Joined Jan 29, 2010
8,739
hi fast,
The technical name for what you are trying to do, is called a transponder.
You have not said what ranges you want to cover.?
I would suggest you set up a simple ultrasonic remote transmitter that sends either a burst or continous 40kHz signal and using regular ultrasonic RX modules, experiment what power levels you need from the remote TX,at the ranges you want, then you can design a suitable IR RX and Ultrasound TX.
E
 

Thread Starter

fastlingo

Joined Apr 29, 2016
13
hi fast,
The technical name for what you are trying to do, is called a transponder.
You have not said what ranges you want to cover.?
I would suggest you set up a simple ultrasonic remote transmitter that sends either a burst or continous 40kHz signal and using regular ultrasonic RX modules, experiment what power levels you need from the remote TX,at the ranges you want, then you can design a suitable IR RX and Ultrasound TX.
E
The ranges are not extreme (tens of meters). It just occured to me that I could use another hc-sr04 as a transmitter, since it can measure echos from 4 meters, it will probably have enough power to send a signal that will be detected directly from at least 20 meters. Just guessing.
 

ericgibbs

Joined Jan 29, 2010
8,739
hi,
Thats what I would do, experiment to find what range HC unit can cover.
If its got work outdoors the wind can cause loss of the ultrasound signal.
E
 

Alec_t

Joined Sep 17, 2013
10,372
Your unit will, of course, display half the distance it would have previously, if you modify it like that.
 

Thread Starter

fastlingo

Joined Apr 29, 2016
13
Your unit will, of course, display half the distance it would have previously, if you modify it like that.
I could of course use two hc sr04 to ping each other, maybe that's the easiest way, I don't know how well infrared signals will work in the open, especially with the sun providing interference.
 

Raymond Genovese

Joined Mar 5, 2016
1,661
I could of course use two hc sr04 to ping each other, maybe that's the easiest way, I don't know how well infrared signals will work in the open, especially with the sun providing interference.
If you were to use only two SR04s to ping each other, I don't know how either would be able to measure distance since neither knows when the other's pulse was initiated. It would be a case of detection only. Such pinging has been used in self-following robot projects.

In the case of normal use, SR04-A starts timing when its emitter is triggered and stops timing when its detector is activated, i.e., sees an ultrasonic pulse (or it bottoms out) as you said in your first post.

If I followed your first idea, SR04-A would be modified to substitute the trigger to begin timing by detecting an IR signal from "out there" that also emits the ultrasonic signal. The end of timing would be as usual, the reception of the ultrasonic signal on its detector. That could work, but with interference/false triggers as you have mentioned, I don't know how much you would gain.

To test out your idea, you could hard wire the trigger signal from SR04-A to SR04-B. SR04-A send the trigger to SR04-B and SR04-A also sends the ultrasonic pulse at the same time (as per usual). Upon receiving the trigger from SR04-A, SR04-B would do the timing as usual, but the detector on SR04-B would be receiving the ultrasonic signal from SR04-A, instead of the echo of a signal that it sent. The distance calculation would not have the /2 that an echo would. That experiment could be used to determine what kind of accuracy gain you might get. I don't exactly see why it would be a whole lot better except that it would not depend on an echo so that point measurements might work where they fail to produce echos (a situation that could be solved by simply placing an object to reflect the ultrasonic signal at the point of measurement).

But, I'm not seeing how you solve the remote trigger starting the receiver timer without the hard wire or the IR as you mentioned. Moreover, the better you make that triggering signal, IR or laser with a detector, the closer you get to IR or laser distance measuring systems (edited to add: that are also using reflection)- no?. If those trigger/detector parts are good enough, why bother with the ultrasonics at all?
 

Thread Starter

fastlingo

Joined Apr 29, 2016
13
If you were to use only two SR04s to ping each other, I don't know how either would be able to measure distance since neither knows when the other's pulse was initiated. It would be a case of detection only. Such pinging has been used in self-following robot projects.

In the case of normal use, SR04-A starts timing when its emitter is triggered and stops timing when its detector is activated, i.e., sees an ultrasonic pulse (or it bottoms out) as you said in your first post.

If I followed your first idea, SR04-A would be modified to substitute the trigger to begin timing by detecting an IR signal from "out there" that also emits the ultrasonic signal. The end of timing would be as usual, the reception of the ultrasonic signal on its detector. That could work, but with interference/false triggers as you have mentioned, I don't know how much you would gain.

To test out your idea, you could hard wire the trigger signal from SR04-A to SR04-B. SR04-A send the trigger to SR04-B and SR04-A also sends the ultrasonic pulse at the same time (as per usual). Upon receiving the trigger from SR04-A, SR04-B would do the timing as usual, but the detector on SR04-B would be receiving the ultrasonic signal from SR04-A, instead of the echo of a signal that it sent. The distance calculation would not have the /2 that an echo would. That experiment could be used to determine what kind of accuracy gain you might get. I don't exactly see why it would be a whole lot better except that it would not depend on an echo so that point measurements might work where they fail to produce echos (a situation that could be solved by simply placing an object to reflect the ultrasonic signal at the point of measurement).

But, I'm not seeing how you solve the remote trigger starting the receiver timer without the hard wire or the IR as you mentioned. Moreover, the better you make that triggering signal, IR or laser with a detector, the closer you get to IR or laser distance measuring systems- no?. If those trigger/detector parts are good enough, why bother with the ultrasonics at all?
You are right, I couldnt make the devices ping each other, since they have no listening mode.
As to the point of usefulness, I would disagree. It's not just about being able to pinpoint a specific place, but also to be able to measure great distances. yes you could use a reflector, but an echo will not be nearly as easy to detect from a greater distance as a direct wave, because of scatter, divergence of the beam etc. Compare with the difference between a direct ray of light from a flashlight and one that is reflected from the wall. Strength of signal also relates to accuracy.
 

Raymond Genovese

Joined Mar 5, 2016
1,661
You are right, I couldnt make the devices ping each other, since they have no listening mode.
As to the point of usefulness, I would disagree. It's not just about being able to pinpoint a specific place, but also to be able to measure great distances. yes you could use a reflector, but an echo will not be nearly as easy to detect from a greater distance as a direct wave, because of scatter, divergence of the beam etc. Compare with the difference between a direct ray of light from a flashlight and one that is reflected from the wall. Strength of signal also relates to accuracy.
Point taken. Do laser measurement devices work at much greater differences (too lazy to look it up and never used them)?
 
You are right, I couldnt make the devices ping each other, since they have no listening mode.
As to the point of usefulness, I would disagree. It's not just about being able to pinpoint a specific place, but also to be able to measure great distances. yes you could use a reflector, but an echo will not be nearly as easy to detect from a greater distance as a direct wave, because of scatter, divergence of the beam etc. Compare with the difference between a direct ray of light from a flashlight and one that is reflected from the wall. Strength of signal also relates to accuracy.
I was thinking about this some more. I thought I remembered from somewhere that the SR04 was run by one or two PIC chips. I just looked at my HC-SR04 and my HY-SRF05 and, apart from the 324, the two other chips are unlabeled. No matter.

What if you programmed the transmitter to issue two ultrasonic bursts, the first is meant to put the receiver into a listening/timing mode. The second burst from the transmitter occurs at a fixed period following the first. When the receiver detects that second burst, it subtracts the set period before making the distance calculation. This could [should] work, I think. Of course, it's not a trivial project, but it is feasible. Also, you could incorporate a more powerful transmitter than these dinky units which could result in a greater distance.

Hey, could you send me a couple after you finish designing and building them? :):):)
 

Thread Starter

fastlingo

Joined Apr 29, 2016
13
I was thinking about this some more. I thought I remembered from somewhere that the SR04 was run by one or two PIC chips. I just looked at my HC-SR04 and my HY-SRF05 and, apart from the 324, the two other chips are unlabeled. No matter.

What if you programmed the transmitter to issue two ultrasonic bursts, the first is meant to put the receiver into a listening/timing mode. The second burst from the transmitter occurs at a fixed period following the first. When the receiver detects that second burst, it subtracts the set period before making the distance calculation. This could [should] work, I think. Of course, it's not a trivial project, but it is feasible. Also, you could incorporate a more powerful transmitter than these dinky units which could result in a greater distance.

Hey, could you send me a couple after you finish designing and building them? :):):)
I think laser range finders use the same principle (measuring the time it takes a laser beam to reflect and come back). You need of course a timer that can measure nanoseconds. The second type has a camera parallel to the laser and measures the angle that the laser point deviates from the center (at infinity it should be in the center, as it gets closer it moves to one side)
 
Top