Square wave to sine wave
Cenlasoft
Posts: 265
Hello,
I am still working on an ultrasound non-destructive testing system using the prop and I experimented and can now measure small displacements(flaws) in materials. I used 2 (7476) flipflops and 1 (7486) XOR ic to measure phase shift from ultrasonic sensors. My problem is to convert a sinewave (echo) to a squarewave. Can anyone help? Thank you, Curtis
I am still working on an ultrasound non-destructive testing system using the prop and I experimented and can now measure small displacements(flaws) in materials. I used 2 (7476) flipflops and 1 (7486) XOR ic to measure phase shift from ultrasonic sensors. My problem is to convert a sinewave (echo) to a squarewave. Can anyone help? Thank you, Curtis
Comments
What can you tell us about the sinewave?
Do you have a capture?
Is the sinewave all one freq or is it mixed with others?
Does the sinewave vary in strength?
... Tim
The sine wave is produced by a receiver ultrasonic transducer (echo) whose transmitter (transducer) was excited by a continous wave at 40 khz. The amplitude does change and as the transducers get closer, the phase shift changes also between the two waves. The 40 khz transmitted wave is produced by one of the prop cog counters.
Thanks,
Curtis
Take a look at the microphone input circuit on the Propeller Demo Board. That's configured as a capacitively-coupled sigma-delta converter. The output pin keeps the input pin biased at the Propeller's logic threshold. What is read on the input pin port is whether the voltage is above or below the bias point. Now, the sigma-delta converter's RC time constant is fairly short, to enable analog-to-digital conversion. If you use larger caps to Vdd and Gnd at the summing junction, and a much larger feedback resistor, I believe you can coax the circuit to act as a comparator. If the RC time constant is too short, you will introduce a phase shift in the square wave, which is definitely not what you want in this app. Basically, what you want to do is compare the instantaneous voltage to the average voltage to get your square wave.
-Phil
Your knowledge of the Propeller far exceeds mine! To be honest, I just wanted to see what the signal looked like? Not that I had any relevant information on the topic!
... Tim
Oh, sorry. In my haste I addressed the post to you instead of to Curtis. It's now fixed.
-Phil
Also, the gain of the circuit is increased (toward comparator action) by using a lower imedance between the input source and the summing junction. I think Curtis might be better off using a capacitor at the input (as in the microphone circuit) and by driving that hard with a low-impedance op-amp output.
The voltage produced by a sigma-delta can be used to bias a 3rd pin near threshold thru a resistor, and a capacitor AC input to that third pin would produce a strong comparator action.
Curtis, what order of time delays are you seeing and expecting?
A comparator will do that. The exact choice of comparator would depend on the frequency and amplitude of the received signal.
I see what you mean. I probably didn't state that very well. Yes, you do want the input cap to be large w.r.t. the Vdd and Gnd caps, and you want the feedback resistor to be very large, so that the RC time constant is very long w.r.t. the input period. The effect will be to bias the input cap so that the average voltage on its input corresponds to Vth on its output. The voltage at the summing junction will oscillate about Vth resulting -- hopefully -- in a square wave on the feedback pin. The most likely scenario, however, will be some oscillation at the edges. This can be filtered out, but you don't want to introduce hysteresis, because that will entail a phase delay.
Your method will work, too, of course, so long as there is no discrepancy in the logic thresholds between two pins.
-Phil
I will try some of these suggestions today and will post my results,
Curtis
Since your signal is continuous, rather than being a chirp, there's another technique that might also work for you. It involves generating two square waves, the second 90 degrees out of phase with the one driving the output transducer. These are then used as local oscillator signals to drive an I/Q detector, whose other input is the feedback from a sigma-delta ADC, whose input, in turn, is your sine wave signal. The technique is described in detail in this thread:
The only difference is what you do with the I and Q outputs. In AM radio reception, they're squared, added, then square-rooted. For detecting phase differences, you'd use a different formula, but I'll have to do some searching to see what that formula is.
In any event, I think this method would yield more accuracy than converting the the return signal to square waves and trying to measure relative edge locations.
-Phil
As mentioned, comparator. Look on the net for a TI document Handbook for Op-Amp Applications.
I am curious as to how you are using phase shift to measure the displacements. I understand the use of echo times and amplitudes as used in many devices, just not sure how the phase shift comes into play.
Frank
I have been looking for a while for an easy way to measure phase shift. Everyone I talked to thought it was not possible. I found an article from India that listed ways to make a phase meter. It gave me some insights. I just finished testing it out and with the help of this forum members, I succeeded last night. I'll post the circuit soon, but basically I did this to test it out:
1. I constructed a circuit with a 7476 J-K Flip-Flop outputting to a XOR (7486).
2. The two outputs were connected to two prop pins.
3. I then used a cog and its two counters to give me two squarewaves which were out of phase.
4. I listened for each pulse to go high and started a counter then on the high to low, I stopped the counter
5. I repeated step 4 for the second XOR output.
I used a formula and sent the phase angle to the screen
My results were exact and matched the phase shift of the two squarewaves that I created.
For ultrasonic displacement measurment, I must take the transmitted squarewave of the transducer and send to one Flip-Flop pin input and then I now must find a way to make the echo pulse change from sinewave to squarewave
I think I have that almost complete.
Curtis
Sometimes when a a slow moving signal (like 40KHz) is an input to a comparator there can be a false and very fast pulse that's hard to see. The comparators hysteresis should take care of this but I've seen cases when they don't. A short prop delay in the order of 15-25ns should keep accuracy tight. You'll need a comparator with TTL outputs. You might also need an opamp to boost the signal amplitude because the fastest moving edge on a sine wave is near the zero crossing points. A resistor and diodes could be used to clamp the output of the opamp. And you might need to bias the compare input threshold about 50mv off zero to prevent oscillation when there is no signal.
Also, there are jelly bean digital devices (VHC, AHCT) with operating ranges from 0.5V to 7V and prop delays of 5ns, and a few microamps of operating current in simple logic like you describe.
Dom...
Some comparators have built-in hysteresis and some don't (LM339 for example) - you add it externally usually
since you know how much is appropriate. Its a compromise between switching speed/noise sensitivity and voltage
accuracy.
Also if I were trying to do this constant squaring simply I would just use a comparator or even just the sigma-delta method using a capacitively coupled input and picking off the "sign" as the input is always changing so it's always going to be positive or negative etc.