Through studying other posts on this forum (and elsewhere), I've built a circuit like the attached diagram. I ping for about 80usec, then listen for the response -- pretty simple stuff. On the o-scope, the readings are easy to pick out (see CurrentOutput for what the trace looks like). But variations in real-world situations make for a lot of variety in the kind of returns. If I'm watching the scope, I can absolutely pick out returns at close ranges (where there's a lot of reverb) and long ranges (where the signal response is very weak). But teaching a computer to spot the returns is harder.
- The first iteration just used, basically, threshold detection. I just used the 4th OPAMP in the chain (IC1D) as a comparator. If the output of IC1C was less than a threshold voltage, I'd trigger the output. The microcontroller (an Arduino Mega) just watched for the comparator output to toggle. The trick is that ... well, it works poorly. At close ranges, the reverb response overwhelms the return signal, so the whole response is below the threshold voltage. So if the threshold is set low enough to trigger only on the actual response at short ranges, it's not sensitive enough to trigger on a return at longer ranges.
- The second iteration is what is shown in the attached circuit. The output of IC1C goes to an A/D. Instead of doing a digital threshold comparison, I'm sampling the actual amplifier output signal. In a perfect world, I should be able to watch the low points and see that the slope is going up during the reverb portion, then down when the ping response arrives. This is, after all, what I'm doing when I watch the signal myself on the scope. The problem is that my microcontroller is slow -- I can only get a sample every (on average) 22usec, while the signal needs better than double that to actually see the fluctuations smoothly. So what I'm actually reading is almost arbitrary -- taking random samples down the length of the wave form, sometimes getting high points, sometimes low, so it's pretty tough to really make sense of a response. (I think Nyquist would have something to say about this, but I don't have a faster A/D handy, so ...)
- Not directly circuit related, but potentially good background: I tried a sneaky trick on the software side to fix that problem. Basically, I pinged 10 times, stored all of those returns, and picked out the minimum reading from each time slice. That way, theoretically, if each sample time is a little random, I'd be able to pick out the bottom of the curve. Sweet idea, almost worked.
- Now what I'm trying for is a smooth signal, which should make for a really easy thing to read on a relatively slow A/D converter. The first attached o-scope picture is what I'm getting -- the 40khz reverb and return (CurrentOutput). The second has a neat red line on it which is what I'd really like to get out of this circuit (DesiredOutput). The neat red line would give me an easy-to-sample A/D point that I could process in code almost trivially -- if the slope is going up, it's still reverb. If the slope is going down, it's a return. Yay! It doesn't need to be that perfectly smooth, but I need to smooth out a lot of the 40khz waveform to get the major shape of the curve.
I am not a EE, so I'm kind of messing around blind here. I tried a full wave rectifier, but that only takes the absolute value of the stuff that's negative. I've biased my amps at 12V, so I don't really get any negative voltages. I tried shifting the amp bias to 0 (grounding the + inputs on IC1), and the amp stopped providing useful output; no more signal. (Not at all sure why.) I've tried various combinations of low pass filters, but I think I'm just not experienced enough to arrange the bits correctly. Maybe a low-pass filter is the right answer, but maybe all I'm doing with a filter is filtering all of the signal, so I get nothing out the far side at all.
Thoughts? How can I get the 40khz line to give me a neat red smooth line?
Thanks in advance. Hope I've provided enough information to make this useful for everyone.
Dan
- The first iteration just used, basically, threshold detection. I just used the 4th OPAMP in the chain (IC1D) as a comparator. If the output of IC1C was less than a threshold voltage, I'd trigger the output. The microcontroller (an Arduino Mega) just watched for the comparator output to toggle. The trick is that ... well, it works poorly. At close ranges, the reverb response overwhelms the return signal, so the whole response is below the threshold voltage. So if the threshold is set low enough to trigger only on the actual response at short ranges, it's not sensitive enough to trigger on a return at longer ranges.
- The second iteration is what is shown in the attached circuit. The output of IC1C goes to an A/D. Instead of doing a digital threshold comparison, I'm sampling the actual amplifier output signal. In a perfect world, I should be able to watch the low points and see that the slope is going up during the reverb portion, then down when the ping response arrives. This is, after all, what I'm doing when I watch the signal myself on the scope. The problem is that my microcontroller is slow -- I can only get a sample every (on average) 22usec, while the signal needs better than double that to actually see the fluctuations smoothly. So what I'm actually reading is almost arbitrary -- taking random samples down the length of the wave form, sometimes getting high points, sometimes low, so it's pretty tough to really make sense of a response. (I think Nyquist would have something to say about this, but I don't have a faster A/D handy, so ...)
- Not directly circuit related, but potentially good background: I tried a sneaky trick on the software side to fix that problem. Basically, I pinged 10 times, stored all of those returns, and picked out the minimum reading from each time slice. That way, theoretically, if each sample time is a little random, I'd be able to pick out the bottom of the curve. Sweet idea, almost worked.
- Now what I'm trying for is a smooth signal, which should make for a really easy thing to read on a relatively slow A/D converter. The first attached o-scope picture is what I'm getting -- the 40khz reverb and return (CurrentOutput). The second has a neat red line on it which is what I'd really like to get out of this circuit (DesiredOutput). The neat red line would give me an easy-to-sample A/D point that I could process in code almost trivially -- if the slope is going up, it's still reverb. If the slope is going down, it's a return. Yay! It doesn't need to be that perfectly smooth, but I need to smooth out a lot of the 40khz waveform to get the major shape of the curve.
I am not a EE, so I'm kind of messing around blind here. I tried a full wave rectifier, but that only takes the absolute value of the stuff that's negative. I've biased my amps at 12V, so I don't really get any negative voltages. I tried shifting the amp bias to 0 (grounding the + inputs on IC1), and the amp stopped providing useful output; no more signal. (Not at all sure why.) I've tried various combinations of low pass filters, but I think I'm just not experienced enough to arrange the bits correctly. Maybe a low-pass filter is the right answer, but maybe all I'm doing with a filter is filtering all of the signal, so I get nothing out the far side at all.
Thoughts? How can I get the 40khz line to give me a neat red smooth line?
Thanks in advance. Hope I've provided enough information to make this useful for everyone.
Dan
Attachments
-
149.1 KB Views: 14
-
70.7 KB Views: 13
-
73 KB Views: 12