Author Topic: Comparator (LM393) not saturating at low frequencies  (Read 4291 times)

0 Members and 1 Guest are viewing this topic.

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Comparator (LM393) not saturating at low frequencies
« on: January 16, 2020, 05:21:22 pm »
Hello,
I've made a circuit to detect the zero crossing point of a low voltage sine wave from a signal generator (for testing) using an LM393 and based on the design from (http://www.ti.com/lit/an/snoa999/snoa999.pdf) "Zero crossing detection using comparator circuit" application note, the circuit is shown below. The output of the comparator is a square wave.

The circuit works great at frequencies above about 200 Hz. Below this, the square wave high and low levels begin to have a slope where the low level increases and the high decreases from their initial levels at the beginning of each cycle. I've attached a photo of the scope waveform. The lines are faint, but if the faint lines were darker, this is exactly what I see.

I've tried many of the usual advised things to improve comparator performance. Hysteresis (from output to + terminal) kills the signal below 50k Ohms, and a 100k resistor has no effect. I've attached (and removed!) a 2k2 pullup resistor from output to Vcc, which is required anyway for a decent output, but other values higher and lower give no further improvement. I've also tried capacitors (1pf +) to bypass the input voltage.

I've tried 5v up to 15v input voltage on the LM393, and have also put the output through a schmitt trigger, neither of which solved this.

Would anyone have any advice on this? Maybe I just need a different comparator, as I'm assuming what is happening is that the output transistors are not saturating.. I've looked for low frequency comparators but they don't seem to exist.

Thanks in advance, please let me know if any other details would help,
Brian

« Last Edit: January 16, 2020, 11:56:57 pm by Frongach »
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #1 on: January 16, 2020, 05:28:25 pm »
From your picture, you have your scope input coupling set to AC. The trace corresponds to what you would see at low frequencies with AC coupling. The faint lines are probably due to your scope not triggering properly on the degrading signal [EDIT: Or you have your dual timebase set to 'Mixed']


P.S. You may also start getting multiple transitions due to noise at low frequencies. You can add a high value feedback resistor from output to + input to provide some hysteresis too.
« Last Edit: January 16, 2020, 05:35:56 pm by Gyro »
Best Regards, Chris
 

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Re: Comparator (LM393) not saturating at low frequencies
« Reply #2 on: January 16, 2020, 05:54:19 pm »
Gyro,
Thanks for your reply. I've tried many values for the hysteresis resistor, from 10k to 1M and like I said, below 50k the output disappears and above this there is no effect of the output. You're quite right about the AC coupling!
All the best,
Brian
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #3 on: January 16, 2020, 06:52:39 pm »
Glad you've now got a sensible waveform. The first thing to do in such situations is look at your scope setting to see if it is lying to you - the AC coupling is a common one and you will learn to spot it immediately.

The value of the hysteresis resistor needs to be high compared to the source impedance - the idea is to feed back just a tiny amount of current from the output (which is swinging a long way compared to the input). You want just enough to ensure clean transition of the output as the input goes through zero (and is susceptible to noise) and no more.

As you have found, anything down at the 50k level will be enough to completely mess up the operation of your comparator circuit (~10k input impedance), causing it to latch in one state or the other. You need to be at least an order of magnitude higher.

Now that you are not trying to correct a non-existent output waveform problem, you can look at cleaning up any multiple transitions (you may not see any) as your input waveform goes through zero at low frequency.
Best Regards, Chris
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7681
  • Country: ca
Re: Comparator (LM393) not saturating at low frequencies
« Reply #4 on: January 16, 2020, 06:54:08 pm »
LM393 output is open-collector, so you must have a pullup resistor to VCC, and low enough value the hysteresis resistor does not load it .
Compare to TLV7011 which has a push-pull output.
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #5 on: January 16, 2020, 07:10:47 pm »
Good point, I looked at the diagram and just saw TLV...
Best Regards, Chris
 

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Re: Comparator (LM393) not saturating at low frequencies
« Reply #6 on: January 16, 2020, 10:32:05 pm »
Hi there,
Thanks for taking the time to reply, however I am aware that the LM393 output is open collector, I wrote that I had a pullup resistor on the output. In addition, having the oscilloscope AC coupled, while it does display interference, will also show the square waveform perfectly well, I'm not sure if you have much experience with scopes Gyro. It seems a bit counterproductive to submit several replies without reading the original post.

The issue persists anyway, might anyone else have suggestions as to why the LM393 performs poorly at low frequencies?
Thanks,
Brian
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #7 on: January 16, 2020, 10:54:09 pm »
The issue persists?  I thought the issue was what you were seeing on the scope, due the the scope input coupling being set to AC.  :-//


P.S. In your OP you said that you had tried a 2k2 pullup resistor from the Output to Vin...  Not V+, just to show that I've read it.  ;)
« Last Edit: January 16, 2020, 10:58:50 pm by Gyro »
Best Regards, Chris
 

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Re: Comparator (LM393) not saturating at low frequencies
« Reply #8 on: January 16, 2020, 11:01:55 pm »
Gyro,
The issue is in no way about AC coupling of the scope!! The waveform outline is identical with DC or AC coupling. The issue is I think fairly clearly explained in my original post, that the square wave deforms at low frequencies, <200Hz or so, which seems to me to be related to incomplete turning on of the output transistors. Please read the original post man!!
Brian
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #9 on: January 16, 2020, 11:09:34 pm »
Brian,

Gyro,
Thanks for your reply. I've tried many values for the hysteresis resistor, from 10k to 1M and like I said, below 50k the output disappears and above this there is no effect of the output. You're quite right about the AC coupling!
All the best,
Brian

So changing the scope input coupling didn't fix the distorted waveform... Thanks for making that so clear in your reply above!

The LM393 will work perfectly happily down to DC.

Good luck with your problem.
Best Regards, Chris
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2852
  • Country: us
Re: Comparator (LM393) not saturating at low frequencies
« Reply #10 on: January 16, 2020, 11:14:39 pm »
You only have positive voltages supplied to the LM393, so it can only operate with positive signal voltages.  Since the other input is grounded, it will just about always say the + input is greater than the minus.  If you want to detect the zero-crossing of the input, you need either a comparator with + and minus power supplies, or to shift BOTH inputs positive to be within the common-mode
rejection range of the comparator.

Jon
 

Offline Bud

  • Super Contributor
  • ***
  • Posts: 7276
  • Country: ca
Re: Comparator (LM393) not saturating at low frequencies
« Reply #11 on: January 16, 2020, 11:27:49 pm »
I always ask the posters a same question: where did you get  the part from, if from China, throw it away right now and buy from a reputable supplier before even thinking about doing anything else.
Facebook-free life and Rigol-free shack.
 
The following users thanked this post: ogden

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Comparator (LM393) not saturating at low frequencies
« Reply #12 on: January 16, 2020, 11:33:23 pm »
The issue is in no way about AC coupling of the scope!! The waveform outline is identical with DC or AC coupling.
Yet only proof we have is picture where scope is in AC coupling ;) To show that we all are on the same page, could you possibly show waveform & switch "AC/GND/DC" (below volts/div dial) in DC position?
 

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Re: Comparator (LM393) not saturating at low frequencies
« Reply #13 on: January 16, 2020, 11:46:19 pm »
I'm away from the shop now, but I will post pictures of DC coupled waveform tomorrow and scope screen at higher frequencies.

Jon, I had thought that the problem might be with the single supply, but firstly the circuit is from a pretty good source so I had confidence in it. Secondly, the output is really clean, and conforms to calculated values (I measured frequency of the square wave output with microcontroller), at higher frequencies. Finally, I was avoiding a split supply as the output is used for a microcontroller (arduino) which cannot take negative voltages, or at least not below -0.3v I believe. I will try a split supply tomorrw for sure, thanks.

Bud, the part is from Farnell, TI I think, or at least a reputable manufacturer, and I've switched it out several times for new ICs, plus it only suffers at low frequencies so fairly sure this is not the problem.

 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7681
  • Country: ca
Re: Comparator (LM393) not saturating at low frequencies
« Reply #14 on: January 16, 2020, 11:56:46 pm »
Give us the schematic you have, it's not making sense.

I say the TI circuit is crap (as a starting point even) because it has no hysteresis, no low-pass filter to stop noise from false triggering, and no proper clamp diodes/resistors to limit the comparator's input overload.
If you tell us what you are trying to do, probably have better circuits in mind.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Comparator (LM393) not saturating at low frequencies
« Reply #15 on: January 17, 2020, 12:03:24 am »
Jon, I had thought that the problem might be with the single supply, but firstly the circuit is from a pretty good source so I had confidence in it.
Right. This is textbook "above zero" detector circuit, single supply definitely is not an issue. My consideration is that particular circuit do not have *any* frequency-sensitive components that can distort waveform the way you show. Especially at low 200Hz(!), yet your scope has. Maybe AC/DC coupling of your scope is faulty? Try 2nd channel and 2nd probe, if any. [edit] Look at 200Hz square wave coming out of signal generator. Also double-check compensation of your probe.

no proper clamp diodes/resistors to limit the comparator's input
Incorrect. Input 1M/10k resistor divider together with input clamp (10mA) diodes provides enough protection. [edit] Yet it appears that LM393 do not have input protection diodes
« Last Edit: January 17, 2020, 05:09:22 am by ogden »
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7681
  • Country: ca
Re: Comparator (LM393) not saturating at low frequencies
« Reply #16 on: January 17, 2020, 12:36:10 am »
no proper clamp diodes/resistors to limit the comparator's input
Incorrect. Input 1M/10k resistor divider together with input clamp (10mA) diodes provides enough protection.
Na, the Schottky diode before the input, clamps -ve excursions but there is nothing to deal with +ve overload.  See the input diodes in the LM393's internal schematic, it will not tolerate much maybe VCC-1.5V maximum before overriding the current source. That could explain very slow recovery times.
We don't know OP's input voltages or divider resistors.
« Last Edit: January 17, 2020, 12:39:43 am by floobydust »
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Comparator (LM393) not saturating at low frequencies
« Reply #17 on: January 17, 2020, 12:45:50 am »
Na, the Schottky diode before the input, clamps -ve excursions but there is nothing to deal with +ve overload.  See the input diodes in the LM393's internal schematic, it will not tolerate much maybe VCC-1.5V maximum before overriding the current source. That could explain very slow recovery times.
We don't know OP's input voltages or divider resistors.
Yes you are right. I did not bother to check LM393 assuming that it is equivalent to TLV7011 (that has proper input protection). This is the case when simple copy-pasting of the circuits between parts that are not equivalent may go wrong.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7681
  • Country: ca
Re: Comparator (LM393) not saturating at low frequencies
« Reply #18 on: January 17, 2020, 12:46:20 am »
TLV7011 "Input terminals are diode-clamped to VEE. Input signals that can swing 0.3V below VEE must be current-limited to 10mA or less." So why bother adding the Schottky?  :palm:

LM393 Datasheet: "Input current flows thorough parasitic diode to ground and turns on parasitic transistors that increases ICC and may cause output to be incorrect. Normal operation resumes when input current is removed."

Both parts don't like +ve overload.
 
The following users thanked this post: ogden

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator (LM393) not saturating at low frequencies
« Reply #19 on: January 17, 2020, 01:09:52 am »
The 50k feedback resistance stopping it working makes me think the input resistors really are 1M/10k, even if the input voltage was the mains :o the max input voltage would be +3.3V and the highest input current -0.33mA.

"and have also put the output through a schmitt trigger, neither of which solved this."

It's bound to be the scope, definitely try channel 2. :)
« Last Edit: January 17, 2020, 01:36:31 am by StillTrying »
.  That took much longer than I thought it would.
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #20 on: January 17, 2020, 01:34:08 am »
I was avoiding a split supply as the output is used for a microcontroller (arduino) which cannot take negative voltages, or at least not below -0.3v I believe.

I had no trouble detecting the zero crossing of an AC waveform of low frequency(<5Hz), using LM393 on a single supply. Perhaps the following simulation can give you some ideas of how to approach your problem.

 

Offline FrongachTopic starter

  • Newbie
  • Posts: 9
  • Country: ie
Re: Comparator (LM393) not saturating at low frequencies
« Reply #21 on: January 17, 2020, 03:27:17 pm »
Thanks to everyone who helped out here, it turns out my oscilloscope DC channel is shot, I took it to a friend's place and the DC waveform displayed correctly I'm really sorry for wasting everyone's time  :palm:
« Last Edit: January 17, 2020, 03:46:57 pm by Frongach »
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Comparator (LM393) not saturating at low frequencies
« Reply #22 on: January 17, 2020, 03:38:06 pm »
It's ok. This is exactly why you seek for 2nd opinion when stuck. - Others may look at your problem from another angle and ask right questions you did not know exist ;)
 
The following users thanked this post: Frongach

Online Gyro

  • Super Contributor
  • ***
  • Posts: 10174
  • Country: gb
Re: Comparator (LM393) not saturating at low frequencies
« Reply #23 on: January 17, 2020, 06:29:10 pm »
Treat it as a learning opportunity. When your test gear looks as if it's lying to you (in this case, an apparent C-R time constant where none should exist), check its settings and basic functionality. It will stand you in good stead when you get onto more complex situations than this one.
Best Regards, Chris
 
The following users thanked this post: Prehistoricman, Frongach

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Comparator (LM393) not saturating at low frequencies
« Reply #24 on: January 18, 2020, 03:05:50 pm »
turns out my oscilloscope DC channel is shot,

It's very likely to just be dirty contacts on the AC-GND-DC switches, so fixable. Searching google images with the scope's model number might show some images of its insides and the switch.
.  That took much longer than I thought it would.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf