Given this PWM,
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.
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.
s3
side. On thes2
side there will be the first half of pulses and, when that stops, ats3
there will be the 2nd half, but not negative -- positive. It's the difference that makes them alternating signs. So, measure ats3
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\$