Frequency counter

I would like to count the frequency of a sine wave using an esp32 for the display side of things. I am unsure about the hardware circuit to use. I am thinking a high value resistor divider to get the signal well into safe levels and then an opamp to normalise it to a digital input compatable 2.5v, is this a good way to do it?

The signal is generated by a royer oscillator, which is running an induction heater coil - the purpose of measuring is so the coil can be tuned to a useable frequency. The tank circuit will have a voltage from 20-200v ac, and a frequency I would expect between 10khz to 250khz.

I am thinking a high value resistor divider to get the signal well into safe levels

Since you have such a wide voltage range I'd recommend a [u]protection circuit[/u]. You'll probably want to increase the value of the current-limiting resistor, and you need to make sure you have a pull-down resistor (or a bias circuit etc., as a DC reference and current path to ground).

and then an opamp

You don't need amplification but if the oscillator/resonant circuit is high impedance you might need a buffer amplifier.

to normalise it to a digital input compatable 2.5v, is this a good way to do it?

The "standard solution" is a voltage divider to bias the analog input, with a series capacitor to "isolate" the DC bias from the source. But, if you have a sine wave you can just use the protection circuit to kill the negative-half of the wave and measure the time for the positive-half.

A comparator, not an opamp, is the way to convert analog zero-crossings to digital signals. Logic signals
need to switch rapidly and the hysteresis in a comparator circuit will protect from multiple transitions due to
noise.

A way to remove the DC bias, then detect zero-crossing and provide hysteresis is provided thus:

Its a bit complicated, since the circuit has to provide ac coupling and dc-bias to the input, and have
hysteresis feedback (which requires the strong pull-up resistor). But it should be pretty robust to
signal level and frequency.

Thanks! I have a lot of reading to do but I think I understand the basics. Would a LM393 be any good for this as I think Ive got one I can take from something else.

Yes, LM393 or LM339 type comparators are "industry standard" and frequently (no pun intended)
used in interfacing analog to digital. For higher frequencies there are faster comparators available
too.

It might, with some care, be possible to employ the built-in comparator in the ATmega chip if using
an Uno or other ATmega based Arduino - not sure how convenient it would be to bias.

If you want hardware frequency division the comparator comes first as you need a logic signal
for a divider chip.

That is quite large voltage and frequency range. If galvanic isolation is not needed I would use just a current limiting resistor (100k) and protection Schottky diodes to GND and Vcc. Read HIGH and LOW and calculate frequency (possibly with some digital low pass filtering).

Thanks I will try each and see how it works and what I can learn from it.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.