Comparator (LM393) not saturating at low frequencies - Page 1
Forum section: electronics / beginners

author: Frongach
author_rank: Newbie
timestamp: January 16, 2020, 05:21:22 pm
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: January 16, 2020, 05:28:25 pm
content: 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.

author: Frongach
author_rank: Newbie
timestamp: January 16, 2020, 05:54:19 pm
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: January 16, 2020, 06:52:39 pm
content: 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 behighcompared 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 beat leastan 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.

author: floobydust
author_rank: Super Contributor
timestamp: January 16, 2020, 06:54:08 pm
content: 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.

author: Gyro
author_rank: Super Contributor
timestamp: January 16, 2020, 07:10:47 pm
content: Good point, I looked at the diagram and just saw TLV...

author: Frongach
author_rank: Newbie
timestamp: January 16, 2020, 10:32:05 pm
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: January 16, 2020, 10:54:09 pm
content: 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.

author: Frongach
author_rank: Newbie
timestamp: January 16, 2020, 11:01:55 pm
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: January 16, 2020, 11:09:34 pm
content: Brian,Quote from: Frongach on January 16, 2020, 05:54:19 pmSo 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.

author: jmelson
author_rank: Super Contributor
timestamp: January 16, 2020, 11:14:39 pm
content: 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-moderejection range of the comparator.Jon

author: Bud
author_rank: Super Contributor
timestamp: January 16, 2020, 11:27:49 pm
content: 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.

author: ogden
author_rank: Super Contributor
timestamp: January 16, 2020, 11:33:23 pm
content: Quote from: Frongach on January 16, 2020, 11:01:55 pmYet only proof we have is picture where scope is in AC couplingTo 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?

author: Frongach
author_rank: Newbie
timestamp: January 16, 2020, 11:46:19 pm
content: 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.

author: floobydust
author_rank: Super Contributor
timestamp: January 16, 2020, 11:56:46 pm
content: 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.

author: ogden
author_rank: Super Contributor
timestamp: January 17, 2020, 12:03:24 am
content: Quote from: Frongach on January 16, 2020, 11:46:19 pmRight. 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.  Look at 200Hz square wave coming out of signal generator. Also double-check compensation of your probe.Quote from: floobydust on January 16, 2020, 11:56:46 pmIncorrect. Input 1M/10k resistor divider together with input clamp (10mA) diodes provides enough protection.  Yet it appears that LM393 do not have input protection diodes

author: floobydust
author_rank: Super Contributor
timestamp: January 17, 2020, 12:36:10 am
content: Quote from: ogden on January 17, 2020, 12:03:24 amNa, 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.

author: ogden
author_rank: Super Contributor
timestamp: January 17, 2020, 12:45:50 am
content: Quote from: floobydust on January 17, 2020, 12:36:10 amYes 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.

author: floobydust
author_rank: Super Contributor
timestamp: January 17, 2020, 12:46:20 am
content: 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?LM393Datasheet: "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.

author: StillTrying
author_rank: Super Contributor
timestamp: January 17, 2020, 01:09:52 am
content: The 50k feedback resistance stopping it working makes me think the input resistors really are 1M/10k, even if the input voltage was the mainsthe 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.

author: eblc1388
author_rank: Frequent Contributor
timestamp: January 17, 2020, 01:34:08 am
content: Quote from: Frongach on January 16, 2020, 11:46:19 pmI 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.

author: Frongach
author_rank: Newbie
timestamp: January 17, 2020, 03:27:17 pm
content: 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

author: ogden
author_rank: Super Contributor
timestamp: January 17, 2020, 03:38:06 pm
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: January 17, 2020, 06:29:10 pm
content: 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.

author: StillTrying
author_rank: Super Contributor
timestamp: January 18, 2020, 03:05:50 pm
content: Quote from: Frongach on January 17, 2020, 03:27:17 pmIt'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.

author: floobydust
author_rank: Super Contributor
timestamp: January 19, 2020, 12:15:44 am
content: I've never seen a scope have an issue at low frequencies when DC coupled. It's a DC path from input to the deflection plates, really. So even that doesn't make sense here.

author: Gyro
author_rank: Super Contributor
timestamp: January 19, 2020, 10:53:33 am
content: Quote from: floobydust on January 19, 2020, 12:15:44 amRead again. His AC/DC coupling switch was broken - didn'twork inbypass the coupling cap in DC!I don't know about the one on the channel next door though. I don't think he tried Ch2.

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: January 19, 2020, 02:02:28 pm
content: No decoupling wont help.Yo u can use a speed up feedback capacitor from output to input (100pf )?I have used this comparator in a LC meter and it worked up to 100KHZ fine.Your waveform looks like the scope is on AC setting when it should be on DC.One thing that hit but might not be a problem is your lower comparator input goes to ground which means other input has to go below zero which might latch it up. Might work or as is.A slow moving input definitely needs hysteresis with a speed up capacitor.Also any comparators I have used need pull ups on the output.

author: Gyro
author_rank: Super Contributor
timestamp: January 19, 2020, 02:11:13 pm
content: Quote from: nigelwright7557 on January 19, 2020, 02:02:28 pmIsanyonereading the previous page?

author: StillTrying
author_rank: Super Contributor
timestamp: January 19, 2020, 02:20:27 pm
content: Quote from: floobydust on January 19, 2020, 12:15:44 amWe've seen a few. I don't know about the OP's scope, but a scope's Y amp often has an AC coupled high frequency path and a parallel DC path. A lowish frequency square wave can show any mismatch between the Y amp's AC and DC paths.Here's a bad one DC coupled @ 100 Hz, - now fixed.https://www.eevblog.com/forum/testgear/siglent-sds1000x-series-oscilloscopes/msg1210795/#msg1210795Nothing to do with the scope's AC/DC coupling switch, but switching to AC coupling can cause problems as well.https://www.eevblog.com/forum/chat/scope-acdc-coupling-at-60hz/

author: StillTrying
author_rank: Super Contributor
timestamp: January 19, 2020, 02:24:55 pm
content: Quote from: Gyro on January 19, 2020, 02:11:13 pmThe whole thread is surreal!

author: ogden
author_rank: Super Contributor
timestamp: January 19, 2020, 08:30:32 pm
content: Quote from: StillTrying on January 19, 2020, 02:24:55 pmNothing wrong with this thread. We can learn alot about: 1) comparators 2) specifics of old analog scopes 3) people