General Information About the Project

I am trying to design a zero-crossing detector circuit for convert the sinusoidal signal from an ultrasonic transducer to a square wave. Here is the image of ultrasonic transducer:

pair of transducer

To trigger the transmitter transducer I generate 40kHz square wave with SG3525. Square wave is 12Vpp and duty cycle is 49%. Oscilloscope output shown below:

PWM signal of transmitter

When I drive the transmitter with this pwm wave, I can read the signals from receiver sensor. Regardless of the location of the transmitter, the receiver always receives a signal at a frequency of 40kHz. What changes is the amplitude value and phase shift. Here is the receiver signal outputs below:

Receiver Signals

These measurements performed at different times, so frequency values of transmitter and receiver shown not equal. Even if their frequency values don't look compatible, they are compatible.

Zero-Crossing Detector

I want to convert the receiver's sinusoidal signal into a square wave to analyse the phase-shift between signals of transmitter and receiver. I used a Schmitt Trigger circuit, but it created a phase shift and could not successfully convert the sine wave into a square wave. Then, I decided to build the circuit with BJTs. The circuit that I built, and the output shown below:


simulate this circuit – Schematic created using CircuitLab

Zero-Crossing Detector Output


I tested the circuit shown above on a breadboard and analyse the circuit with an oscilloscope. My test steps are as follows:

  1. I test the circuit with function generator with different voltages and frequencies.
  2. I test the circuit with the receiver's output signal.

1st Experiment with Function Generator

When I analyse the circuit, I applied the voltage values from 1V to 10V and frequency value from 1kHz to 40kHz. When I apply a frequency value above around 5kHz, the square wave produced by the circuit begins to distort. Here are the images:

for 10Vpp and 1kHz:

1khz output

for 10Vpp and 7kHz:

7khz output

for 6Vpp and 40kHz:

40khz output

2nd Experiment with Receiver

I tested the signals of receiver to convert them into square waves. To trigger the receiver, I used the SG3525 PWM circuit and transmitter. Bu it does not work on the circuit. I read sinusoidal 40kHZ 3Vpp wave from receiver. Then I connect the signal into the circuit to examine the conversion, but it did not work.


When I feed the circuit with a sine wave using the Function Generator, I can receive a square wave at low frequencies. But when I increase the frequency (about 2-3 kHz and above) the square wave starts to distort. When I give the signals from the receiver to the relevant circuit, I cannot get any output. Not even a distorted signal occurs.


I want to convert the sinusoidal wave coming from the receiver into a square wave, compare it with the wave I created in the transmitter, and obtain the phase shift by looking at this. However, the circuit I built to convert the sinusoidal wave into a square wave is malfunctioning at high frequencies. At the same time, this circuit does not even process the signals coming from the Receiver.

If this method I have applied is a logical method to see the phase shift, why can't I process the receiver's signal? If you know a more logical way to see the phase shift, I would be happy if you share it with me.

Best regards

  • 1
    \$\begingroup\$ @kkrgzz Handling a full order of magnitude difference in swing at the input, without any change in the duty cycle at the output is going to be a challenge. But I gather that's what happens given the distance from the transmitter. I also don't think the ultrasonic receiver has an output impedance of 0 (your test supply in simulation.) You need to be very specific about the ultrasonic receiver's output details. Everything flows out of that. Start there -- what's the device, exactly, and it's datasheet? (Phase shift is a whole other topic.) \$\endgroup\$ Jan 3 at 9:59
  • 1
    \$\begingroup\$ @kkrgzz In simulation I generated this pair of timing pulses to illustrate what I mean. With a well-designed circuit (yours is not) the green phase pulses show things with \$1\:\text{V}\$ input and the dark blue phase pulses show the same circuit but with \$10\:\text{V}\$ input. Note that the higher voltage input will have a larger magnitude dV/dt and this will pull the phase up earlier relative to the transmitter event. Keeping that invariant over differing signal heights will be a challenge, as I said earlier. \$\endgroup\$ Jan 3 at 10:10
  • 1
    \$\begingroup\$ @kkrgzz But that's not all. From comparing the green and dark blue pulses you should also see that phase shift isn't the same for the rising and falling events -- that is also dependent upon the signal input magnitude. So. I must emphasize in every way possible that it is going to be a challenge to deal with an order of magnitude difference in source magnitude. This is part of the reason why the receiver details are vital. \$\endgroup\$ Jan 3 at 10:13
  • 1
    \$\begingroup\$ @kkrgzz One more thing I forgot to add. The receiver itself will have it's own phase shift. Your scope diagrams do not show the timing of the transmitter and also in parallel the sine wave at the receiver relative to it for the minimum fixed distance and then for one more different fixed distance away that is nearer the maximum. I suspect that the delays will not draw a line going back to (0,0) on a chart -- that there will be an "offset" to calibrate, different for each paring of Tx and Rx devices. You need a data logbook and to start taking lots of experimental notes. \$\endgroup\$ Jan 3 at 10:49
  • 2
    \$\begingroup\$ Are you taking output to oscilloscope from Q2's collector? Have you used a 1X oscilloscope probe? You might be adding approximately 100pf capacitance to R2 (100k) resistor, causing an RC rise time constant of 10 microseconds. As soon as you remove the probe, Q2 becomes much more square. Can you try a 10X attenuator probe? It should look more square because 'scope probe cable capacitance is now less-affecting your circuit. \$\endgroup\$
    – glen_geek
    Jan 3 at 13:27

2 Answers 2


Assuming a noiseless, perfectly sinusoidal, ideal voltage source, a \$12\:\text{V}\$ power supply rail, and that you only need one pulse or edge per full \$360^\circ\$ cycle consider the following experiment:


simulate this circuit – Schematic created using CircuitLab

(For the following tests please ignore the negative-going edge at OUT. You don't care about that. It's not important.)

Here, I've taken seriously your order-of-magnitude variation in the input voltage peak. And I'm trying to find a circuit that will allow you to handle it, while at the same time attempting to achieve other important goals. Hopefully, the above circuit provides some useful thoughts in that direction.

Set \$R_3\$ and \$R_{11}\$ to their midpoints and apply a \$50\:\Omega\$ signal generator output set to \$10\:\text{V}\$ peak sine source to IN. Adjust \$R_{11}\$ until you get a sharp positive-going edge at OUT that is exactly aligned with the zero-cross of your input source.

Now switch over to a \$1\:\text{V}\$ peak sine source in your signal generator (same output impedance) to IN. Adjust \$R_3\$ until you get a sharp positive-going edge at OUT that is exactly aligned with the zero-cross of your input source.

At this point you have calibrated the Schmitt trigger and I think it will work to provide a positive-going edge at the zero-crossing point, once per \$360^\circ\$ cycle regardless of the magnitude of your receiver signal.

Note: Don't use a solderless breadboard. (Or, use it, but worry.) There are random order-of-magnitude of \$10\:\text{pF}\$ capacitances floating about all over such breadboards. Large enough to be a pain. Small enough to possibly not matter... sometimes. Best to avoid them, if possible. Use construction techniques such as manhattan, rat’s nest, dead bug, live bug, etc. I prefer to avoid solderless breadboards when I'm uncertain about trace capacitances. As glen_geek also points out, scope probes also can matter. And when you are trying to evaluate Schmitt trigger circuits it is better to avoid confusion than to embrace it. So mitigate as much as you can.

(Finally, I've specifically avoided specifying the BJTs because the above design should accommodate a variety of small-signal devices.)

Here's a simulation using LTspice stepping the peak voltage from $1:\text{V}\$ to \$10:\text{V}$.

enter image description here

Pretty close fit.

Best wishes, kkrgzz...

  • \$\begingroup\$ Thank you for the circuit. I simulated the circuit, but I didn't get a successful result. I will make changes in line with the information you describe and simulate it again. At the same time trying with FET, the use of comparator is among my plans. I will try them and share the results. Thank you for all this effort! \$\endgroup\$
    – kkrgzz
    Jan 4 at 9:48
  • \$\begingroup\$ @kkrgzz I added the simulation output using some tweaked values for the pots. \$\endgroup\$ Jan 4 at 9:58

Instead of using a zero-crossing detector, you can convert a sine wave to a square wave directly using a comparator.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Thanks for your review! I tried the comparator circuit with LM741 in LTSpice but it did not work properly. At 40kHz it generates triangular wave output. I searched for comparator circuits but most of them built for 50/60Hz. \$\endgroup\$
    – kkrgzz
    Jan 4 at 10:01
  • 1
    \$\begingroup\$ @kkrgzz LM741 is not a comparator, it is an op-amp, and it's use is deprecated by virtually everyone on this site. If you are looking for an inexpensive comparator, in thru hole packaging, the LM311 is a reasonable choice, but beware of counterfeits. Buy from a reputable source like Mouser, Digikey or equivalent in your country. Parts from Amazon or AliExpress might be counterfeit and disappointing. I will update my answer with a LTSpice simulation using an LM311. \$\endgroup\$ Jan 4 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.