I'm currently having trouble with detecting the RPM frequency from a tacho generator signal. I have tried everything I know.
My tacho generator is attached to a universal washing machine motor, and it provides an AC signal of 0..3300 Hz at 0..170 Vpp.
The 230 Vac 50 Hz motor is driven from a TRIAC using phase control on a separate board isolated with EMI filters. I'm running a speed ramp up to span all available frequencies, 0..1 kHz from the raw tachometer. This is 0..2 kHz after rectification, as you'll see in the circuit below.
Here is the circuit I'm using for zero-crossing detection of the tacho signal. Right now, everything is dispatched around 4 separate breadboards as it is still a prototype.
Please note that, in the first versions, C1 and R5/C2 are not present. Adding them cleans the signals somewhat, but reduces the bandwidth and thus the detection capability of the tacho sensing circuit.
Here is the raw signal from the tacho generator (blue, using a differential probe) and the rectified/scaled/clamped signal (cyan, comparator input, standard probe). I do not understand why the signal at Vclamp point is so dirty.
As you can see, it is quite noisy. I was thinking it is EMI/RFI from the motor itself, even though the tacho is isolated and not connected to the motor circuit in any way, as the real tacho signal is cleaner.
As the signal has 20 ms periodic spikes, it lead me to think it has something to do with the motor control. But that is a completely separate board in a separate enclosure, with a dedicated EMI filter on its input.
Update : as advised by @Andyaka i probed the tacho signal before and after the rectifier, disconnecting everything else and probing between v+ and V-. Here is the waveform, and i would say the noise comes from the rectifier and/or the breadboard and/or the breadboard wires ... because it is clean before, and after the rectifier (even at <50hz) it is already noisy :
Then here is the action of the comparator on that signal (purple is comparator output) without any filter:
I added a low-pass filter before the comparator: C1 (330 pF) and R2 (100 kohm), giving a 4.8 kHz cut-off frequency. This enhanced the signal before the comparator. But, due the signal average voltage rising with the frequency, I cannot lower my reference voltage to detect the lower frequency oscillations.
I also tried lowering and raising the Vref of the comparator: lower to detect the low RPM, higher to keep triggering even with the low-pass filter on the input.
Then I tried filtering the output of the comparator by adding R5 and C2 and reading the output, first alone then combined with the input filter. With both filters, I still have these kind of spikes on the signal, which falsely trigger the interrupts and corrupt the frequency calculations:
Because the signal is not a fixed frequency from 0 Hz to >2 kHz, I cannot seem to find a standard way to reject the spikes/changes (like a debounce) or to reject the invalid values in software, when triggered by spurious interrupts.
On the software side, the only thing i have not tried yet is a Sigma-Kappa clipping. This would track a sliding window, sort the window, reject the outliers and keep the middle value. But I fear it is too time-intensive for an interrupt routine on the microcontroller, which will be an Atmel168 as far as I know.
On the electronics side, I would love to get some ideas:
- What did I do wrong on the first rectified stage to get so much noise?
- Is there anything I could improve in my circuit?
- Should I try any other kind of circuit for this frequency detection?