0
\$\begingroup\$

Given this PWM,

PWM-sine

How to detect a zero crossing without a dual-voltage supply? There is only VCC and GND.


I've tried using a low-pass filter approach, but the PWM frequency is not guaranteed to be constant: it may be anywhere from 1 kHz to 60 kHz.

I am trying not to sink too much current or use an LRC filter which may affect the original waveform.

Here is what I've tried, but some crossings are missed, and spikes occur. LM358 is what I happen to have on hand.

What I've tried

S2 and S3 are from the PWM source without a common GND. Note, the source of the PWM signal is from a stepper motor driver: I'm trying to test various stepper motor drivers that do full steps, half steps, and microsteps.

\$\endgroup\$
6
  • \$\begingroup\$ Maybe the analog domain isn’t the correct place to find the zero crossing, perhaps a digital circuit to check for times when the signal has been low “long enough” to be considered zero? \$\endgroup\$
    – Bryan
    Commented Nov 20, 2022 at 3:37
  • \$\begingroup\$ You could avoid using RC filters (inherent lag) and simply rely on measuring on the s3 side. On the s2 side there will be the first half of pulses and, when that stops, at s3 there will be the 2nd half, but not negative -- positive. It's the difference that makes them alternating signs. So, measure at s3 and detect the first pulse that comes. There may be noise which may make the true zero-crossing have mixed pulses, and the first pulse, even with a clean waveform, will not come at a perfect zero-crossing but, you won't need bipolar supply; only a comp and a divider. One idea. \$\endgroup\$ Commented Nov 20, 2022 at 8:22
  • \$\begingroup\$ Or, if you have access to, you could measure directly before the PWM comparator in the control loop. That will give you the precise modulating waveform. This assumes an analog approach. \$\endgroup\$ Commented Nov 20, 2022 at 8:24
  • \$\begingroup\$ "the PWM frequency is not guaranteed to be constant...may be...1 to 60 kHz" Is the source using PDM then, not PWM? If the frequency can constantly vary during the waveform then it is. \$\endgroup\$
    – TonyM
    Commented Nov 20, 2022 at 8:45
  • \$\begingroup\$ @TonyM No. PWM. "I'm trying to test various stepper motor drivers that do full steps, half steps, and microsteps." --> The circuit is constant, the stepper drivers (and their PWM frequency) change. \$\endgroup\$
    – Drakes
    Commented Nov 21, 2022 at 4:40

0

Your Answer

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