This LM339 model does not work quite as I expect.

Thread Starter

Boundary_A_La_Mode

Joined Jul 4, 2024
64
My question relates to LTSpice:

I got an LM339 Spice model from https://github.com/evenator/LTSpice-Libraries/blob/master/sub/LM339.sub. Thanks to another post on this forum.

My question is that LM339_Test_01.asc in the attached has the LM339 connected as sort of a follower (if it were an op amp but it is a comparator.)1721189377139.png

FWIW: I get the same result with C1 disconnected.

A real LM339 output should display some oscillation when connected as I have in this. (That circuit is NOT a good oscillator but it should be unstable.) The zip includes another circuit which is a relaxation oscillator. I can relax because that one does oscillate. ;)
But I question the operation of the model in LM339_Test_01.asc. Am I missing something, or is the model missing something? Is there a more accurate model around? This is just sort of an academic question; I have no pressing need...

Thanks for any thoughts on this.
 

Attachments

Last edited:

dl324

Joined Mar 30, 2015
18,268
Please post a schematic for those of us not using a computer with LTspice installed. Preferably monochrome with no grid.
 

Thread Starter

Boundary_A_La_Mode

Joined Jul 4, 2024
64
Please post a schematic for those of us not using a computer with LTspice installed. Preferably monochrome with no grid.
Thanks, Dennis. I thought of attaching an image at the same time that you offered your quick reply. It is not monochrome but I can probably figure out how to do that if there is some issue with the image that I posted.LM339_Test_01.png
 

Attachments

Last edited:

Ian0

Joined Aug 7, 2020
13,112
I would have expected it to be unstable, but as it isn't a useful circuit, I wouldn't be trying to simulate it!
 

Thread Starter

Boundary_A_La_Mode

Joined Jul 4, 2024
64
The thing of it is...an op amp is designed for stability (among other things) while comparators are designed for speed (not that an LM339 is particularly fast. I have run them at 100 KHz in a production design.) But this is a test that tells me that the model is not so accurate. If you were to go back to some original National Semiconductor datasheets (maybe it was LM311 or LM339) they show how to use it as an op amp. But I cannot imagine anyone really doing that; not a very good performing circuit.
 

hrs

Joined Jun 13, 2014
524
I found something similar too once. You can make an LM339 act like an opamp in a simulation. On the breadboard I got some ugly oscillations at ~400kHz or so for the attached circuit. I do not have a better model to offer.
 

Attachments

Ian0

Joined Aug 7, 2020
13,112
An LM339 is an LM324 without half its output stage and without its compensation capacitor.
So, it will become a decompensared op-amp, so is more likely to be stable at higher gains, and unlikely to be stable at unity gain.
 
The circuit is not very stable, but can't sustain oscillations. Here are some simulation results:
1721216494346.png
It creates a burst on power up, but oscillations die out.

To make it oscillate, you need to add hysteresis:
1721216672363.png1721216681867.png
It oscillates in simulation and I'm sure it will oscillate in real circuit.
 

Thread Starter

Boundary_A_La_Mode

Joined Jul 4, 2024
64
Yes; I have made similar oscillators using both LM339 and LM324. But the LM339 will oscillate (not in a useful way) when connected as a follower on the bench while the LM324 will be stable. The model is not faithful in that way so far as I can tell.
 

crutschow

Joined Mar 14, 2008
38,408
In general, the only reason to try to use a comparator as an op amp, is if you need an op amp, and have an unused comparator and no op amps available in your circuit,
 

Alec_t

Joined Sep 17, 2013
15,112
You may be unlucky with your sim model. Mine oscillates even with a tiny amount of positive feedback via a 5 gigohm resistor.
 

Thread Starter

Boundary_A_La_Mode

Joined Jul 4, 2024
64
You may be unlucky with your sim model. Mine oscillates even with a tiny amount of positive feedback via a 5 gigohm resistor.
I am not sure if unlucky is the right word. Another way to look at it is that a circuit works better in simulation than it does on the bench. That could lead to design errors. Don't you think?

For many high speed comparators, proper layout is important to prevent oscillation even with a good circuit design. But I don't think that is what is going on here. I have never heard anyone accuse the LM339 of being "high speed."
 
Top