Low jitter trigger circuit for a frequency counter - Page 1
Forum section: electronics / projects

author: TmaxElectronics
author_rank: Regular Contributor
timestamp: March 24, 2019, 11:31:19 am
content: Hello,I have a project that will log the mains frequency deviation over time and i need a reliable trigger circuit.I have already tried to just use a comparator (general purpose and a fast prop. delay one) but i observed about 100us of jitter across one cycle time of the waveform(yes that is only a fraction of the actual waveform and easily enough for measuring 50Hz but since i want this to be really acurate i would need one that has at most 1us of jitter, with lower of course being better).What am i doing wrong/which part should i use?BTW i did google this and try out the first few results but they all had the same issue and i didn't quite know what exactly to google for after that.

author: Rerouter
author_rank: Super Contributor
timestamp: March 24, 2019, 11:40:20 am
content: If you ever look at mains with a scope, generally it is extremely noisy, your idea for a trigger would likely work if you had an aggressive low pass or band pass filter.as your only after drift in frequency, measure the zero crossing with some hysteresis, and have a dead time to ignore any secondary pulses.

author: TmaxElectronics
author_rank: Regular Contributor
timestamp: March 24, 2019, 12:03:06 pm
content: So far i was only running it from my signal generator so there probably wasn't too much noise on the input signal.And i also had some hysteresis (220k and 47k as the comparator wouldn't sink a lot of current).I also just tested the setup using other waveforms and it appears that the jitter was always at ~1/500 of the rise time so using a square wave completely eliminated any jitter, not sure if that is in any way important though.

author: RoGeorge
author_rank: Super Contributor
timestamp: March 24, 2019, 01:34:00 pm
content: Quote from: TmaxElectronics on March 24, 2019, 11:31:19 amYou are looking at each trigger point instead of averaging for a very long number of periods.

author: Benta
author_rank: Super Contributor
timestamp: March 24, 2019, 01:47:05 pm
content: Timebase is the word, not trigger.Measuring an AC sine wave precisely is close to impossible, the tiniest drift in DC levels will offset the measuring point significantly. This also goes for squaring up the sine wave with a Schmitt trigger, comparator or whatever.Your best bet is averaging as RoGeorge says.

author: Kleinstein
author_rank: Super Contributor
timestamp: March 24, 2019, 01:58:13 pm
content: Mains frequency is relatively low and the "sine" wave is full of distortion. So it is essentially impossible to get a simple accurate trigger on something like the zero crossing. Due to the low frequency the method of choice would be more like some filtering and than digitize the waveform and fit a sine wave to it. If done in a clever way the computational demand is not that large and even a simple µC could do that job quite well.If it really has to be trigger like, it would be more filtering (to get rid of most of the harmonics) and than triggering an every zero crossing and include them all in the calculation. The actual triggering (e.g. comparator with some hysteresis) would not be that critical, as the input signal is jittery anyway.

author: nctnico
author_rank: Super Contributor
timestamp: March 24, 2019, 02:07:25 pm
content: Quote from: Benta on March 24, 2019, 01:47:05 pmThere are ways to do this.This board uses a 10MHz sine wave which then gets shaped and filtered (schematics are also available from this page). This is more like metrology grade stuff but a similar approach is probably useful for the OP.https://www.ohwr.org/project/wrs-low-jitter/wikis/home

author: Benta
author_rank: Super Contributor
timestamp: March 24, 2019, 02:25:36 pm
content: Quote from: nctnico on March 24, 2019, 02:07:25 pmHell of a difference between an nice clean 10 MHz signal and dirty 50 Hz mains.

author: TmaxElectronics
author_rank: Regular Contributor
timestamp: March 24, 2019, 02:31:45 pm
content: thanks guys,i was able to get the jitter down to about +-5us with a diode clamped input and lots of filtering, i was just hoping to get away with as little averaging as possible.Quote from: Benta on March 24, 2019, 01:47:05 pmBut any offset would cancel itself out, as i am only interested in the period, so a short on-time would be offset by the larger off-time, right?

author: Kleinstein
author_rank: Super Contributor
timestamp: March 24, 2019, 03:11:03 pm
content: An DC offset, if not too large would mainly change the On/off ratio. So it would not be a big problem. The bigger problem is more like higher harmonics and their variations, as they can move the zero crossing. Something lime switched mode power supplies can be such nonlinear loads that can cause such waveform distortions.For a longer time to measure the frequency there are different ways of "averaging". Depending on the type of noise, different methods to calculate the frequency are best. With noise due to white phase noise, like jitter from a poor trigger, a good way would be a kind of linear interpolation of zero crossing time versus count number. If the trigger is perfect and noise is more like a poor oscillator the better method would be just looking at the 1 st and last time in the interval.With the mains frequency it's more like the trigger noise case, though there are true variations in the frequency too.

author: nctnico
author_rank: Super Contributor
timestamp: March 24, 2019, 03:25:23 pm
content: Quote from: Benta on March 24, 2019, 02:25:36 pmAt the ps level there is no such thing as a clean 10MHz signal. That is why I wrote: the problems are similar albeit at a different time scale.

author: TmaxElectronics
author_rank: Regular Contributor
timestamp: March 24, 2019, 07:02:14 pm
content: i now got it to work.I used a circuit similar to the one of the 100MHz thing, but with more filtering and some aggressive hysteresis on the comparator (using a capacitor across the resistor between the output and input) and applied a really long term average that takes into account each sample taken. In terms of stability i can get to x.0001Hz accuracy with just the least significant digit jumping about (obviously from my signal generator - when using the actual mains it moves up and down by ~0.03 Hz periodically). And the accuracy seems to be fine too (at 500kHz without the filter it measures 500950Hz - 501050Hz).Thanks again

author: David Hess
author_rank: Super Contributor
timestamp: March 24, 2019, 08:22:43 pm
content: The problem is basing the measurement off of a single point in the noisy input waveform. Instead, an integrated measurement over all or part of the waveform is necessary so noise has less of an effect.1. Filter the input to the desired measurement bandwidth including low and high pass. If preservation of phase is important, then take this into account. Notch out the lower harmonics.2. Phase lock a sine oscillator to the filtered power line signal using an integrating phase detector like an analog multiplier.3. Measure the now cleaned signal using the trigger circuit of your choice.It would be interesting to frequency multiply the cleaned signal to drive a switched capacitor filter for the noisy input signal so the filter tracks the input but I doubt this is necessary for most applications.Building a 50 or 60 Hz low noise voltage controlled oscillator is an interesting challenge in itself but there are a couple of ways to do it also using analog multipliers.

author: Kleinstein
author_rank: Super Contributor
timestamp: March 25, 2019, 05:11:19 pm
content: With only 50/60 Hz and the rather high amount of noise, there is no more need to do all the filtering analog. Digital filtering or a kind of digital PLL based on digitized data are probably easier.

author: David Hess
author_rank: Super Contributor
timestamp: March 26, 2019, 01:41:28 am
content: Quote from: Kleinstein on March 25, 2019, 05:11:19 pmI agree but the analog design gives a map of the minimum requirements in a digital implementation. I would still implement some low and high pass filtering before the ADC.