Comparator problem - Page 1
Forum section: electronics / beginners

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 08:00:55 am
content: I am a bit stuck with solving the following problem. I have an input pulse of about 500ns and the amplitude of 500mV biased by +5V. I would like to compare the amplitude of this pulse (without taking into account the bias voltage) to some threshold value of let's say 100mV. The problem is that I use AD8561 with +5V single supply. I am looking for any suggestion on how to optimize the input pulse circuitry to have the input pulse with +5V bias removed. I tried to do it with a cap but somehow the comparator starts to violently oscillate when I assemble the circuit. Thanks a lot in advance.

author: iMo
author_rank: Super Contributor
timestamp: April 23, 2024, 08:09:37 am
content: An input voltage divider, like two resistors such you get the input to say 2.5V with the 250mV pulse on top of it??

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 09:28:40 am
content: > I tried to do it with a cap but somehow the comparator starts to violently oscillate when I assemble the circuit.It should not. May be you place capacitor in wrong place? Please, provide us a schematic.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 09:38:30 am
content: I did it like this.Quote from: xvr on April 23, 2024, 09:28:40 am

author: magic
author_rank: Super Contributor
timestamp: April 23, 2024, 09:47:15 am
content: You need a resistor connected between the capacitor and the comparator input, weakly pulling this circuit node to some well defined voltage within the valid input range of the chip and draining bias current of the input pin away from there.Look up "highpass RC filter".

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 09:57:18 am
content: Thanks. I tried the RC option with connecting the resistor to the ground, but I guess the idea is to have a constant voltage instead.Quote from: magic on April 23, 2024, 09:47:15 am

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 11:29:27 am
content: Thanks to your suggestions. Modified the circuit. I managed to make it work nearly fine if I add a 1k resistor on the supply of the comparator, which looks odd to me. Without this resistor, the circuit behaves oddly.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 11:31:01 am
content: Attaching the pictures now ..Yellow is input of the comparator, blue is output.

author: shapirus
author_rank: Super Contributor
timestamp: April 23, 2024, 11:35:14 am
content: Noise on the input? Try adding some hysteresis.

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 11:35:28 am
content: Bias should be at least 0.5V (or more). Now your input pulse generates negative voltage on comparator pin.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 11:38:08 am
content: Thank you. Could you please elaborate a bit more - where does this 0.5V come from - can it be inferred from the data sheet or it is specific to my case?Quote from: xvr on April 23, 2024, 11:35:28 am

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 11:47:26 am
content: > where does this 0.5V come fromIt's your input pulse amplitude (from OP)

author: shapirus
author_rank: Super Contributor
timestamp: April 23, 2024, 11:49:45 am
content: Quote from: xvr on April 23, 2024, 11:35:28 amAnd then the 0.1V threshold voltage will always stay below the voltage on the non-inverting input.later edit: maybe it'll actually be all right. Needs simulation, I'm failing to put it together in my head at the moment :)One way to avoid applying too low a negative voltage to the non-inverting input pin is to connect a Schottky diode from ground to the non-inverting input.At this point it becomes cumbersome enough so that the solution suggested earlier to use a resistor divider to bring the input signal level in the suitable range (around 2.5 V) starts to look more attractive. Of course, the threshold voltage source will then have to be adjusted accordingly.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 11:50:22 am
content: What if the input pulse amplitude is expected to span from 0 to 5V? What would be the strategy for the bias in this case?Quote from: xvr on April 23, 2024, 11:47:26 am

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 11:54:19 am
content: > What if the input pulse amplitude is expected to span from 0 to 5V? What would be the strategy for the bias in this case?Set small bias (about the same 0.5V) and add protection schottky diode from comparator input to ground (anode to ground, cathode to input)

author: shapirus
author_rank: Super Contributor
timestamp: April 23, 2024, 12:01:32 pm
content: It's worth mentioning, though, that the protection diode will have a capacitance that may be non-negligible, when fast signals are considered, which actually appears to be the case here. That's where things start to become tricky.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 12:10:48 pm
content: Thanks again for all the ideas. Saga continues. Added a Schottky diode, raised the bias. Things work somewhat better but I don't get it why the input signal gets distorted - the input signal is simply raising and then falling. The comparator makes it zigzag like.

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 12:19:34 pm
content: Your pulse is quite big (2V). This comparator has +3.0V input common range - your definitely hit it.From DS:QuoteSeems that input capacitor discharged by current surge.You can add series resistor (for C1) to form voltage divider with R1 to reduce pulse level to acceptable. But in this case pulses of low level can be affectedAnd speed also will be affected.

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 12:25:29 pm
content: Tried with input voltage divider as suggested in the first post. This approach also works, and is maybe more straightforward, however, the same effect of the input signal getting distorted as in the 'biased' version.

author: xvr
author_rank: Frequent Contributor
timestamp: April 23, 2024, 12:27:05 pm
content: > however, the same effect of the input signal getting distorted as in the 'biased' version.Check the voltage on comparator input pin. It should not exceed 3.0V

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 12:37:24 pm
content: The maximum voltage on the input pin does not exceed 1.5V. The issue might be elsewhere. Any other suggestions on how to protect the input signal are welcome.Quote from: xvr on April 23, 2024, 12:27:05 pm

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 12:51:45 pm
content: Further investigations revealed that indeed the voltage goes above 3V on the input pin of the comparator, however, the initial pulse is below 1.5V. Looks like comparator drives it to the rail. Adding a 1k resistor to the supply rail fixes the problem at the cost of reducing the comparator output to about 1V. Not ideal.

author: magic
author_rank: Super Contributor
timestamp: April 23, 2024, 02:32:06 pm
content: Stupid question: do you have 100nF between the comparator's VCC and GND pins?

author: elki
author_rank: Regular Contributor
timestamp: April 23, 2024, 03:17:42 pm
content: YesQuote from: magic on April 23, 2024, 02:32:06 pm