Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How would you fix this comparator circuit?

Status
Not open for further replies.

danjel

Member
I used to just use a standard OpAmp for basic comparator needs.

For a recent design I decided to use an LM393 since it was actually designed for this task and could provide faster switching.

I thought it was used just like an Op Amp except for the need for a pullup on the output.

Obviously I screwed up by not reading the datasheet and realising that a little hysterisis (via a large feedback resistor) was recommended but more importantly the Vin should never go below -0.3V.
This last part was the biggest screw up for me :S :S

The Vin on my circuit could have voltages as low as -12V fed to it. I obviously should have added protection via a clamping diode.

The biggest issue of all is that I already made a batch of PCBS using this circuit (see the diagram). Now I am trying to figure out the easiest way to fix this mess (they are all SMD parts).

Some ideas:

1. Replace R5 with a 100K resistor to minimise the max reverse current caused by a negative voltage

2. replace R4 with a diode (anode to ground) to act as a clamp. If this is done then there is no longer a pulldown resistor for the input.


I think it would be too difficult to cludge on a feedback resistor.

What do you guys think is the best solution????

**broken link removed**



Also another question:
What would happen to my circuit if someone put -12V at the input for a long period of time?
 
Last edited:
Hello,


From what i can gather on the data sheet, with your circuit if the input goes to -12v that will put about -0.6v at pin 3, so that's 11.4v across 15k which is 760ua which is not destructive to the IC chip itself, however, the output during this negative excursion may go to the highest voltage level possible which is equal to +Vcc. If your control logic can handle this condition you're ok without changing anything at all.

A possible solution to the lack of a feedback resistor (and hence any hysteresis) is to put the feedback resistor on another board and bring out connections from pin 3 and pin 1 to that other board. #22 gauge buss wire is good for fixes like this, but i've also used #24 with success for years. Anything of a lighter gauge may snap if the board is moved around.
Another possible solution is to use an 1/8 watt resistor with leads covered with teflon sleeving. for maximum physical stability you could drill holes near the nodes to be connected and put the leads through, then run the leads (very short) under the board to the nodes and solder. The teflon sleeving method is used in industry a lot and the hole drilling method is even more stable if of course you have the room on the board to drill holes right next to the pins to be connected to.
 
Last edited:
Hi Mr. Al thanks for the reply!

Do you mean -1.6V at pin 3? If it is -0.6V I am not clear how you calculated that.

One thing I have noticed so far (and one of the reasons I thought I needed a fix) is that when I feed Square signal to this that is 20Vpp I get a lot of oscillations in the adjacent comparator circuits (share on same chip or nearby). My circuit has 9 comparator circuits like this in a small area.
Do you think this is an issue with lack of hysteresis?

Since everything is SMD there is not much space for any kind of mod.


thanks!
 
Hi again,


Do you also have bypass caps near say every 2nd chip or so?

I meant -0.6v because that might be the saturation voltage of the internal circuit, but whatever it comes out to it should not damage the chip as long as the current into the chip stays low, and the spec is 50ma but that is much higher than what you should see with your 15k resistor.

Try the bypass caps first and see if that helps, and if possible maybe you can show some scope pics?

Normally when you have to build a large number of circuit boards you build one first (called the prototype) and test it thoroughly before building more. It's hard to mod later sometimes as i guess you are finding out now unfortunately. There's almost always a way though.
 
Hi MrAl,

I actually have 0.1u bypass caps on each chip (datasheet says it is not necessary though).

In this circuit I actually did build prototypes (breadboard, then short run pcb and then final run). It was not until later that I realised there was a problem under certain conditions... I guess I should have followed more proper engineering protocol and tested to failure by creating more extreme conditions.
 
The latter problem almost sounds like noise pickup in the adjacent IC's. Are you driving with a fast switching signal? If the diode clamp will fix it (probably will) you might be able to find a diode that will "piggyback" on top of your resistor. Another posibility would be to replace the comparator with a latch up free op amp if you can find one with the same pin out. It would probably have an active pull up but that might be okay??? Expensive but might fix both problems with no rework.
 
The signals are all audio rate or lower (5Hz to 20kHz) max 20Vpp

The boards are already populated so any solution involving different ICs would involve removing the IC and replacing it (which is not too big a deal).
The lm339 has an external pullup (is this what you mean by active pullup?).

I thought about that piggybacking a diode on R4 for clamping. This might be the fastest and simplest solution.
 
The noise issue (If there is one) with adjacent IC's may be caused by the fast rise time of the square wave coupling to the other circuits. If the actual appication is audio it may not be a problem. Try a diode to see if it solves it all.
Active pull up is when there is a transistor to pull the voltage up to Vcc. How many have you built?
 
Looks like I have discovered another issue.

On one PCB I have a single quad comparator circuit using a LM339. On this board things are working fine.

On the other boards I have two LM 339s and half a 393 to make 9 comparator circuits (all exactly the same as the diagram in my first post).

On the first pcb, any wave form works to trigger a pulse from a the comparator. However, on the second pcb with 9 comparators, they only work when feeding square waves. Every other type of waveform causes double triggers or oscillations.

For the 9 comparator circuit, they all have a single Voltage reference source that is shared in parallel for the three ICs. I checked the voltage at this pin on all of them and it is the correct 1.5V.

I can't figure out why they would freak out so much at anything that is not a square. Hysterisis or noise issues as well?
 
btw, I tried adding 1M feedback to (-) input and a clamping diode but neither of these things fixed the problem.

I do not understand why a triangle or sinewave etc. would not cause the Comparator to go high while their peaks are above the 1.5V threshold and then go low when it crosses the reference level. This should be such a basic function of this circuit but it simply does not work unless properly unless it is a pulse.
 
Hi again,


Sorry to hear about the problem persisting. Maybe it could be something else more basic is wrong, such as bad chip or even one board is not wired right.
If you can show some scope pictures i could help you scope it out. You'd have to post some more diagrams too and the board layout.

Try to keep in mind that these circuits are very simple, so something very simple must be wrong.
 
Last edited:
I think the comparator should have positive feedback not negative.

Hi,

Yes! The feedback resistor is not for linear feedback, it's for hysteresis, so it connects to the + input terminal (non inverting) not the inverting terminal. Connecting to the - terminal will make it even worse.
 
I just tried 1M of positive feedback and that made a huge difference!

However, sine wave inputs still gave erratic results. Triangle and saw were ok....
I am guessing I should play with the resistor value to adjust hysterisis?

Unfortunately the only problem with this solution is that there is no easy way to mod the pcb for easily mounting them.
 
You should be able to find a good value for the feedback resistor. For your problem with the erratic multiple comparator PCB, are you grounding the unused pins of the "extra" comparator. Also could be the trace layout.
 
Just thought of another solution: is there a pin compatible comparator to the lm393 and lm339 that has a larger internal hysteresis? This would negate the need for the external resistor.
 
You might try a 1458 op amp. It is latch up free but I'm not sure if you get an inversion if it is driven below ground. It would be slow but sure (maybe). I know there are inversion free op amps. You may have to look at a lot of data sheets. I know I have seen some from TI.
 
Hey Ron,

I am powering the circuit with a single supply so the output should not be able to go below ground.

However that means I need a latch-up free Opamps like the 741 or 1458.

Thanks for posting the ST op amp info. What is it about this op amp that makes it special?
 
If you look at the comparitor you are using now when the input goes below -.3v the output goes high when it should be low. Many op amps do the same thing. I'm not sure if the 741 and 1458 don't also have inversion they just don't latch up (stay high).
The TSH22 and others like it don't invert (like your comparitor) or latch up. If you look at the data sheet it has some pictures of the problem towards the end. It might help with your noise and hysterisis problem because the op amp is slower than the comparitor.
 
Status
Not open for further replies.

Latest threads

Back
Top