Author Topic: Voltage comparator  (Read 6028 times)

0 Members and 2 Guests are viewing this topic.

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Voltage comparator
« on: April 29, 2019, 12:33:34 pm »
I'm becoming interested in making a frequency counter and the software part is all done.
I just needed a way to convert any incoming signal to a clean square wave so my first idea was to use an op amp / voltage comparator in schmitt trigger mode to do that. my main questions is: what do I need to look out in the op amp spec for high frequency applications? let's say I want about 20MHz bandwidth. should I care about slew rate as it's purely just switching between two states? is gain bandwidth product important in this configuration? would a dedicated voltage comparator be more suitable in this application?
And finally if op amps / comparators can't provide that much bandwidth, what's the simplest way I can make a voltage comparator using BJTs?
 

Offline ArthurDent

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: us
Re: Voltage comparator
« Reply #1 on: April 29, 2019, 01:05:26 pm »
The way it was explained to me was that you can view the rise time of a square wave as a clipped sine wave of infinite frequency. The faster rise time will give a more precise trigger point so slew rate is important. Have you considered a high speed amp followed by a fast logic gate.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #2 on: April 29, 2019, 01:27:07 pm »
I won't need a logic gate as I'm currently running on an LPC1768 uC which runs at about 100 or 140MHz (can't remember but it's plenty fast enough) with interrupts on rising edge and a 5 second rolling average for that extra bit of accuracy! that being said, yes I had a look at op amps and fast ones seem to be application specific, for example driving a video signal. This one from TI seems overkill and costs about 5$ which is acceptable.
http://www.ti.com/lit/ds/symlink/opa855.pdf
but again I'm not sure what spec to look for? Recovery time? slew rate? bandwidth?

here are a few cheaper alternatives that I can use for testing but I'm not sure which one to order due to not knowing which spec I should optimize for.
http://www.ti.com/lit/ds/symlink/opa355.pdf
https://www.mouser.co.uk/datasheet/2/609/ADA4851-1_4851-2_4851-4-878231.pdf
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17143
  • Country: us
  • DavidH
Re: Voltage comparator
« Reply #3 on: April 29, 2019, 02:22:49 pm »
Do not use an operational amplifier; they are only suitable for low speed comparator applications.

20 MHz will require higher speed than common comparators like the 150 nanosecond LM311 or 300 nanosecond LM339/LM393 will support.  The 10 nanosecond LT1016 would be a good choice or the 12 nanosecond LT1116 if single supply operation is required.

Faster designs would likely use discrete differential amplifier stages followed by just a suitably fast logic gate.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #4 on: April 29, 2019, 02:51:42 pm »
did you even look at the data sheets of the op amps I posted? the first one has 8GHz bandwidth and 2.7KV/uS slew rate, not to mention 3nS recovery time   :wtf::palm: what part of that is "low speed"?  :-//

also the parts you mentioned seem fine but this TI one seems to have just 4.5nS rise and fall time?
http://www.ti.com/lit/ds/symlink/tlv7031.pdf?HQS=TI-null-null-mousermode-df-pf-null-wwe&DCM=yes&ref_url=https%3A%2F%2Fwww.mouser.co.uk%2F
I don't strictly care about propagation delay as the period is the most important thing here, I don't even require the output to have a balanced duty cycle (i.e: close to 50%). I'm not sure if I'm missing something here (for example if I should care about propagation delay as it affects frequency response somehow? )
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6237
  • Country: de
Re: Voltage comparator
« Reply #5 on: April 29, 2019, 03:27:27 pm »
The classic way as done by HP and others is a JFET input stage followed by an MC10H115 or MC10H116 line receiver with the stages in series.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #6 on: April 29, 2019, 03:44:28 pm »
The classic way as done by HP and others is a JFET input stage followed by an MC10H115 or MC10H116 line receiver with the stages in series.

can you please post a schematic of that? It would be very helpful thanks!
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1941
  • Country: us
Re: Voltage comparator
« Reply #7 on: April 29, 2019, 05:01:56 pm »
I just needed a way to convert any incoming signal to a clean square wave....
Maybe you're overthinking this. I don't see any mention of the signal levels you're trying to measure. Schmitt Triggers are literally designed to do exactly what you're describing, and you're going into digital logic anyway. Are you sure you need an analog front end on this?

Many MCU's have ST's on their digital inputs. Microchip's PIC series comes to mind. However, I looked at the spec sheet for your MCU and it only appears to use an ST input on its reset pin, so you'll need something external. Still not a problem, as there's no shortage of discrete logic parts with ST's.

If the signals are within the range of any off-the-shelf ST's you may be able to just go straight into an ST input presuming that loading of your source isn't the limiting factor. If the signal levels are too high, perhaps a simple voltage divider is all you'll need. You could put it on the input to the ST, in which case run a low-voltage ST part and make the divider switchable to accommodate different ranges of signal levels. Or you could run the ST on higher voltage rails (which you'd need for an analog approach anyway) and then voltage divide its output down to what the MCU expects. This latter approach would lock you to the ST's fixed hysteresis thresholds so it's less flexible.

If the signal levels are too low, then yes - you'll need some sort of amplification. And if you need 50/600 ohm termination you'll need to do some extra work. But otherwise you have a lot of potentially simpler options.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17143
  • Country: us
  • DavidH
Re: Voltage comparator
« Reply #8 on: April 29, 2019, 05:24:13 pm »
did you even look at the data sheets of the op amps I posted? the first one has 8GHz bandwidth and 2.7KV/uS slew rate, not to mention 3nS recovery time   :wtf::palm: what part of that is "low speed"?  :-//

I did not because an operational amplifier is just not suitable.

For instance the OPA855 has a maximum differential input voltage of 1 volt; this could usually be designed around (like in figure 63 discussed below) but it complicates things.  Operational amplifiers can do all kinds of weird things when driven into saturation.

The OPA855 has a gain-bandwidth product of 8 GHz, not bandwidth.  That is impressive for an operational amplifier but peanuts compared to the 50 GHz gain-bandwidth product of an old LT1016.

For what it is worth, the reason I suggested the LT1016 is that for a fast comparator, it is easier to use than most because it maintains stability in its active region.  Faster devices and older but slower devices tend to be more temperamental.

Check out Linear Technology application note 13 for an in depth discussion about the LT1016 and fast comparators in general.  Then check out Linear Technology application note 72 which discusses the even faster LT1394 and especially figure 63 on page 29 which shows an adaptive trigger circuit which may be exactly the sort of thing you are looking for although this particular example is AC coupled but that can be changed.  The transistor array shown in the schematic can be replaced with individual transistors.

Quote
Also the parts you mentioned seem fine but this TI one seems to have just 4.5nS rise and fall time?
http://www.ti.com/lit/ds/symlink/tlv7031.pdf?HQS=TI-null-null-mousermode-df-pf-null-wwe&DCM=yes&ref_url=https%3A%2F%2Fwww.mouser.co.uk%2F

Rise and fall time have very little to do with propagation time.  If a faster transition time is needed, then a single transistor (or gate) on the output can provide it.

Quote
I don't strictly care about propagation delay as the period is the most important thing here, I don't even require the output to have a balanced duty cycle (i.e: close to 50%). I'm not sure if I'm missing something here (for example if I should care about propagation delay as it affects frequency response somehow? )

At 3 microseconds for a TLV7031, a 20 MHz input pulse could and would likely be completely missed.

TI does make suitably fast parts; perhaps the LMV7219 would be suitable.

The classic way as done by HP and others is a JFET input stage followed by an MC10H115 or MC10H116 line receiver with the stages in series.

Line receivers work well but require higher drive levels; voltage comparators have more gain.  Line receivers would be good for use in something like a logic analyser input circuit where the input levels are more predictable.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #9 on: April 29, 2019, 05:27:00 pm »
If you read the first post carefully, I have mentioned that I will be building a schmitt trigger using op amps / voltage comparators  ;) :-DD
the voltage levels are unknown as it will be used as a general purpose frequency counter, so input resistor + schottky diodes are used for high voltage protection, as well as the amplifier stage to clean up the input signal (reference of the schmitt trigger can be adjusted using mosfets and some resistor which are switched in / out of the circuit for the different ranges.

I would really like to know how name brand manufacturers like HP did it as Benta mentioned. I really wish he had provided some sort of schematic , more details or where to find those details ...
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6237
  • Country: de
Re: Voltage comparator
« Reply #10 on: April 29, 2019, 05:27:23 pm »
The classic way as done by HP and others is a JFET input stage followed by an MC10H115 or MC10H116 line receiver with the stages in series.

can you please post a schematic of that? It would be very helpful thanks!

Unfortunately I only have these crappy screenshots. The schematic is equivalent to the input stage of an HP 20 MHz counter.
A1 and A2 are 1/2 MC10H115, A3 is a fast comparator.
It's a nice design, input sensitivity is 50 mV up to 5 V, with attenuator up to 100 V and not really sensitive to overload.

 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1941
  • Country: us
Re: Voltage comparator
« Reply #11 on: April 29, 2019, 05:30:32 pm »
Operational amplifiers can do all kinds of weird things when driven into saturation.
x2 on that statement, which I didn't say myself because I thought it was common knowledge. Can you use an opamp as a linear comparator? Of course. Should you? No. There's a reason they make dedicated linear comparators, and it's not just speed.

Again, if you can keep this in the digital domain with a Schmitt Trigger that would be an excellent solution.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #12 on: April 29, 2019, 05:36:12 pm »
At 3 microseconds for a TLV7031, a 20 MHz input pulse could and would likely be completely missed.
TI does make suitably fast parts; perhaps the LMV7219 would be suitable.

As far as I can tell from reading data sheets and a quick google search:
propagation delay is just what the name implies: a delay between the output and input where output is supposed to follow the input. by that logic no matter how fast the input is, the output will be the same, but with x amount of delay  :-// rise and fall times are what limit the output speed as far as I can tell. please correct me if I'm wrong.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #13 on: April 29, 2019, 05:39:20 pm »
Operational amplifiers can do all kinds of weird things when driven into saturation.
x2 on that statement, which I didn't say myself because I thought it was common knowledge. Can you use an opamp as a linear comparator? Of course. Should you? No. There's a reason they make dedicated linear comparators, and it's not just speed.

Again, if you can keep this in the digital domain with a Schmitt Trigger that would be an excellent solution.

as I mentioned that's simply not possible given the application. what's the best way of implementing a comparator as an schmitt trigger with variable voltage reference (again, switched by fets)
The entire reason I'm bringing this up is I actually saw the chinese clones of the frequency counter, which as you said use the PIC uCs to create a very simple frequency counter, however the input is directly connected to the pin of the MCU which is not very good. the original designer has suggested using a pre amplifier to boost the input using a BJT. I just wanted to do it with a digital circuit rather than a common emitter amplifier because as you said, my particular one does not include schmitt triggers built on the IO pins. I'm not sure if the ICs like those slow rising edges of sine waves for example (at low frequencies that is). so I'm open to suggestions as to how I can solve this issue.

Edit:
here is the original article: https://www.qsl.net/dl4yhf/freq_counter/freq_counter.html
many people have tested it and it works surprisingly well (the 5 digit version is the one that chinese have cloned).
« Last Edit: April 29, 2019, 05:46:06 pm by OM222O »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17143
  • Country: us
  • DavidH
Re: Voltage comparator
« Reply #14 on: April 29, 2019, 06:04:16 pm »
I would really like to know how name brand manufacturers like HP did it as Benta mentioned. I really wish he had provided some sort of schematic , more details or where to find those details ...

I can tell you how they did it and it was not by using operational amplifiers as comparators.

If the input impedance was high, then first an impedance buffer was used like you would find in an oscilloscope.  Then a cascade of limiting amplifiers was used followed by a line receiver, logic gate, or sometimes a two transistor comparator with hysteresis.  A modern integrated comparator can replace the cascade of limiting amplifiers to drive logic directly in lower frequency (below 100 MHz) applications.

Check out the various old Tektronix and HP frequency and universal counter designs which are fully documented.

The example below is from the 125 MHz Tektronix DC503A which does the high impedance conversion using a dual FET to drive a chain of 10216 ECL line receivers used as differential limiting amplifiers.  The output from the amplifier chain just goes into a normal ECL gate.  A discrete implementation would add hysteresis to the last amplifier stage.  Everything shown except the input FET can be replaced by an LT1016 or similar. (1)

I have a modern (20 year old) counter which uses an LT1016 for its 10 and perhaps 50 MHz inputs.

(1) Do not bother looking for a fast comparator with high impedance inputs to avoid having to use a separate FET input buffer.  Such a device is a contradiction in terms.

Update: I am not sure what happened to the example so I added it back.
« Last Edit: April 30, 2019, 03:56:04 am by David Hess »
 

Offline duak

  • Super Contributor
  • ***
  • Posts: 1048
  • Country: ca
Re: Voltage comparator
« Reply #15 on: April 29, 2019, 11:25:47 pm »
At one time National made a FET input comparator, the LF311.  It looks like it was phased out in the 90's.  I built a frequency counter in the 70's using one of these things.  Even back then it wasn't particularly fast with a response time of 200 ns.  This implies a 5 - 10 MHz frequency limit which was just good enough for the rest of the counter.

I think David Hess knows of what he speaks.  A frequency counter with a good input circuit is a pleasure to use because it isn't fooled by abberations in the input signat.  I preferred Tek scopes over hp's because, to me anyway, they had better and more consistant triggering.  Since you can't see the trigger points with a frequency counter, how do you know it's the right frequency?
 

Offline rcbuck

  • Frequent Contributor
  • **
  • Posts: 352
  • Country: us
Re: Voltage comparator
« Reply #16 on: April 30, 2019, 12:37:20 am »
I used this circuit for the front end of a counter I built last year. It is a slightly modified version of my 1970s Simpson 710 counter that still works fine today. The pot is supposed to be an input sensitivity adjustment. However, I found it has very little effect on the sensitivity. Input sensitivity is about 50 mV from 20 Hz to 60 MHz. It is more sensitive above 1 kHz.

You may be better off to just copy the Simpson version. I built an exact copy and it operates the same as my circuit. The Simpson operating manual can be found online and the schematic, although not very clear is at the back of the manual. The sensitivity control in the Simpson also had very little effect on sensitivity so you could just replace it with a fixed 100 ohm resistor. The MC10H116P is available from Mouser.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17143
  • Country: us
  • DavidH
Re: Voltage comparator
« Reply #17 on: April 30, 2019, 04:26:12 am »
At one time National made a FET input comparator, the LF311.  It looks like it was phased out in the 90's.  I built a frequency counter in the 70's using one of these things.  Even back then it wasn't particularly fast with a response time of 200 ns.  This implies a 5 - 10 MHz frequency limit which was just good enough for the rest of the counter.

The LF311 is about the only one I know of and I suspect it was discontinued because it was just a dumb idea.  Tektronix used custom hybrids for their logic analyzers which included a JFET buffer followed by an ECL line receiver.

The major problem is capacitive coupling between the output and inputs and between the inputs.  In an operational amplifier, a small amount of feedback capacitance can be added to neutralized the pole formed by the input resistance and capacitance at the inverting input but comparators are not compensated so that will not work for them.  It also will not work for a current feedback amplifier without some additional cleverness.

Coupling from the output to the inputs and between the inputs when the source impedances are high can cause all kinds of weirdness.  And if you use low source impedances to prevent this, then a high impedance input is no longer required.  The corner cases left over where a low input bias current is desirable were just not enough.

Of course CMOS input comparators have all of the same problems and the same solutions; drive them with low source impedances.

Quote
I think David Hess knows of what he speaks.  A frequency counter with a good input circuit is a pleasure to use because it isn't fooled by abberations in the input signat.  I preferred Tek scopes over hp's because, to me anyway, they had better and more consistant triggering.  Since you can't see the trigger points with a frequency counter, how do you know it's the right frequency?

Tektronix's earliest counters used oscilloscope input circuits and they worked great, better than most later counters.  The 7D15 shown below is a completely discrete design and includes compensated input attenuators and an HF gain trim.  Notice how the trigger level is added to the input signal and only the last stage (1) adds hysteresis and operates with a fixed trigger level; this is effectively a schmitt trigger with one input and one output so no comparator is used even to support a variable trigger level.  A tunnel diode based circuit would work this way and support incredibly high speeds.

If I was going to duplicate a good but simple design, I would consider the HP 5314/15/16 which uses a JFET buffer to directly drive an AMD (!) AM687 comparator.  The comparator then drives a differential pair to create an ECL logic output.  (2) These counters support a mode where the level control becomes a sensitivity control and the designer abused the latch enable input of the AM687 to provide this so finding a suitable modern comparator to act this way might be a problem.  Replace the JFET with your favorite high bandwidth JFET or CMOS operational amplifier operating as a voltage follower unless you need higher performance.

(1) There are two last stages in parallel.  One of the two is enabled so triggering on the rising or falling edge is selected instead of trying to invert the analog signal at an earlier point.  A modern design could just stick an exclusive-or gate after the comparator to select which edge to use.

(2) See the application note I mentioned which discusses comparator level shifters to drive different types of logic.
« Last Edit: April 30, 2019, 04:29:25 am by David Hess »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19937
  • Country: gb
  • 0999
Re: Voltage comparator
« Reply #18 on: April 30, 2019, 08:10:40 am »
I'm becoming interested in making a frequency counter and the software part is all done.
I just needed a way to convert any incoming signal to a clean square wave so my first idea was to use an op amp / voltage comparator in schmitt trigger mode to do that. my main questions is: what do I need to look out in the op amp spec for high frequency applications? let's say I want about 20MHz bandwidth. should I care about slew rate as it's purely just switching between two states? is gain bandwidth product important in this configuration? would a dedicated voltage comparator be more suitable in this application?
And finally if op amps / comparators can't provide that much bandwidth, what's the simplest way I can make a voltage comparator using BJTs?
Yes, use a dedicated comparator IC.

Here's some information regarding the pitfalls of interchanging op-amps and comparators.
http://encon.fke.utm.my/nikd/latest/sloa067.pdf
https://www.analog.com/media/en/training-seminars/tutorials/MT-084.pdf
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #19 on: April 30, 2019, 11:03:18 am »
Thanks for the replies, I will buy both the TI and the AD part to see if there are any major differences up to the bandwidth I want (there shouldn't be, but you never know  ;))

pretty much every circuit that has been referred to seems to use a JFET input buffer. is this just to create a high impedance input or are there any other reasons? I'm not sure about the input impedance of comparators but op amps have better than good enough input impedance on their own so I'm not sure why the JFET buffer is used.

Also I wonder if there is a better way of creating the hysteresis where it doesn't need adjusting the gain based on the input ???
the schematics that have been provided so far don't seem to have that but they're a bit too complex for me to see how they have gotten around the trigger point problem. maybe the hysteresis points are chosen close together at something like 50mv and 100mv? rcbuck mentioned that even the professional ones that include sensitivity adjustment don't seem to do much anyways ...
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19937
  • Country: gb
  • 0999
Re: Voltage comparator
« Reply #20 on: April 30, 2019, 12:25:16 pm »
Why are you against varying the gain of the pre-amplifier?

To vary the hysteresis, simply adjust the feedback resistor value. A digital potentiometer, with sufficient bandwidth and low parasitic capacitance could theoretically be used, but I admit, I haven't investigated whether it's practical or not.
http://www.ti.com/lit/ug/tidu020a/tidu020a.pdf

Another method of adjusting the hysteresis, is to use two comparators, each with their own reference, connected to an RS flip-flop.
https://www.edn.com/design/analog/4312255/Add-hysteresis-to-a-voltage-comparator
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #21 on: April 30, 2019, 12:38:53 pm »
as I mentioned, in the schematics that have been posted non of them seem to have adjustable hysteresis or even if they do, it doesn't seem to do much  :-//
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19937
  • Country: gb
  • 0999
Re: Voltage comparator
« Reply #22 on: April 30, 2019, 01:43:40 pm »
as I mentioned, in the schematics that have been posted non of them seem to have adjustable hysteresis or even if they do, it doesn't seem to do much  :-//
I've just told you how to implement adjustable hysteresis and what do you mean by "it doesn't do much"?
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Voltage comparator
« Reply #23 on: April 30, 2019, 03:15:31 pm »
I used this circuit for the front end of a counter I built last year. It is a slightly modified version of my 1970s Simpson 710 counter that still works fine today. The pot is supposed to be an input sensitivity adjustment. However, I found it has very little effect on the sensitivity. Input sensitivity is about 50 mV from 20 Hz to 60 MHz. It is more sensitive above 1 kHz.

You may be better off to just copy the Simpson version. I built an exact copy and it operates the same as my circuit. The Simpson operating manual can be found online and the schematic, although not very clear is at the back of the manual. The sensitivity control in the Simpson also had very little effect on sensitivity so you could just replace it with a fixed 100 ohm resistor. The MC10H116P is available from Mouser.

as he pointed out, the adjustment seems to be pointless for the overall function of the end product  :scared: |O so if possible, I would also like to not include it and change my input circuit to take care of that (presumably with some sort of amplification?)
 

Offline duak

  • Super Contributor
  • ***
  • Posts: 1048
  • Country: ca
Re: Voltage comparator
« Reply #24 on: April 30, 2019, 04:36:09 pm »
David noted something about the AM687 comparator.  I remember a story about one of AMD's fast comparators, maybe the AM686 - the one with TTL outputs.  In the mid 80's I had just been hired at a startup and a contractor was battling with one of these comparators for a different project.  AMD was not kidding when they talked about sensitivity to layout and choice of bypass caps.  My contribution was to suggest adding a shield over the pin side of the PCB which helped.  I believe the ultimate solution was to go surface mount when the part became available in that form.   The DIP package leadframe just had too much mutual inductance.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf