EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: hp3310a on November 30, 2024, 04:00:04 pm

Title: Comparator causes ripples what can I do
Post by: hp3310a on November 30, 2024, 04:00:04 pm
Hi everyone,

   I'm working on a frequency counter and am fighting with the input stage up until the digital counter. For the longest time I couldn't figure out why the counter keeps counting way too many pulses in some situations. Using my new SDS804X I finally was able to figure it out (I think).

First the simplified schematic, on the breadboard all ICs have decoupling capacitors on supply and ground pins. Supply is +5V (also -5V for the opamp), coming from lab power supply.
[attach=1]

Here's the big picture.
Red=Signal in
Yellow=Opamp out
Green=comparator out
Note the vertical lines right when the comparator switches.
[attachimg=2]

Closeup at 11kHz. The ripples move along with the event when the comparator is switching (when I change the threshold, the ripples move along), so I believe it's the comparator output that causes this.
[attachimg=3]

I believe what happens is this: When the comparator switches from one level to the other, the opamp output starts swinging (the span is 700mV with a 2V output signal), which in turn switches the comparator, then immediately back and so on, until the switching action no longer goes past the comparator's mid point. The LT1720 has a 3.5mV hysteresis which doesn't help enough.

Closeup at 100kHz and 1MHz, since the time spent in the "switching zone" is shorter, there is less time for back and forth switching, so there are less ripples at 100kHz and almost nothing a 1MHz.
[attachimg=4]
[attachimg=5]

Input comes from the frequency generator (HP3310a). The ripples are also visible on the input (red) which makes me think that ground is somehow offset by the switch.

Probably this is all wrong, in which case it would be great to know what it is. And of course, how to fix it at the source.

Thanks for any pointers! Just a quick reminder, I'm a rookie so please be gentle.
Title: Re: Comparator causes ripples what can I do
Post by: temperance on November 30, 2024, 04:07:17 pm
What you need is this:

https://www.ti.com/lit/ug/tidu020a/tidu020a.pdf?ts=1732982379194&ref_url=https%253A%252F%252Fwww.google.com%252F (https://www.ti.com/lit/ug/tidu020a/tidu020a.pdf?ts=1732982379194&ref_url=https%253A%252F%252Fwww.google.com%252F)
Title: Re: Comparator causes ripples what can I do
Post by: palpurul on November 30, 2024, 05:09:11 pm
Looks like you need some hysteresis.

I think as you increase the frequency of the input signal (while keeping the amplitude the same) you'll get less pulses and eventually pulses disappear.
Title: Re: Comparator causes ripples what can I do
Post by: PGPG on November 30, 2024, 05:48:54 pm
If you increase hysteresis it will certainly help, but ruin your input sensitivity.
Comparator output propagates to analog stage. It can be through 'air', or through supply or gnd. Do you have analog circuitry supply filtered from digital supply (comparator consumes supply current like digital IC).
Title: Re: Comparator causes ripples what can I do
Post by: BennoG on December 01, 2024, 10:36:57 am
you forgot the PCB layout, this can be the big part of the problem.
and decoupling capacitors as close as possible to the op amps.

Benno
Title: Re: Comparator causes ripples what can I do
Post by: hp3310a on December 01, 2024, 11:56:11 am
What you need is this:
Looks like you need some hysteresis.
If you increase hysteresis it will certainly help, but ruin your input sensitivity.
Comparator output propagates to analog stage. It can be through 'air', or through supply or gnd. Do you have analog circuitry supply filtered from digital supply (comparator consumes supply current like digital IC).

Indeed! Thanks a lot! Adding additional hysteresis is even explained in the LT1720 data sheet but I failed to realize this applied here.
[attach=1]

It also solves the no-signal noise switching.
[attach=2]

I tried to calculate the resistor values according to the data sheet but ended up experimenting to get to a good result. For the record, I ended up with this configuration:
[attachimg=3]

Thanks again!