I am simulating a leak sensor I have designed using a comparator and an NPN transistor. Basically, when V- < Vref - the BJT will become saturated and conduct current - causing the LED to turn on (this is represented by the short to GND). When water doesn't short the connection to GND - V- = 5V and V- > Vref meaning the NPN should be cut-off. However, my LTspice simulation shows 80 mA of base current into the NPN transistor. Can anyone explain why I am seeing this and what I might be missing. Shouldn't there be no base current?
-
\$\begingroup\$ There is somthing wrong with your LM2901 model. Where did you obtain this LM2901 model? \$\endgroup\$G36– G362025-10-27 05:24:08 +00:00Commented Oct 27 at 5:24
-
\$\begingroup\$ Comparator models with driven-high output are shockingly common (or were?). Can you show what model file is being used by the component? \$\endgroup\$Tim Williams– Tim Williams2025-10-27 06:11:56 +00:00Commented Oct 27 at 6:11
-
\$\begingroup\$ I downloaded the model file from this link: ti.com/product/LM339#design-tools-simulation and I used the Rev. C version. I am not sure how this could have been incorrect \$\endgroup\$Dinkle Bob– Dinkle Bob2025-10-27 07:01:57 +00:00Commented Oct 27 at 7:01
-
\$\begingroup\$ Did you use LTSpice or Something else. I did the simulation (x64, version 24.1.9) and the output is "correct". Did not need downloading file LM2901. \$\endgroup\$Antonio51– Antonio512025-10-27 08:56:27 +00:00Commented Oct 27 at 8:56
-
\$\begingroup\$ @DinkleBob I'm not going to the site to download the model. But assuming it is a .SUBCKT model, have you verified that the part drawing you have has the correct pin assigments to the body that correspond to the pins listed in the .SUBCKT model? Any difference there would mess things up terribly and you wouldn't see why just looking at the schematic images. \$\endgroup\$periblepsis– periblepsis2025-10-27 16:10:34 +00:00Commented Oct 27 at 16:10
1 Answer
The problem lies in your application and the simulation mode you are using.
The first problem is that you have connected the inverting input to Vcc. By doing this, you are violating the input common-mode range, so the behavior is not necessarily going to be what you might expect. And this is what the simulation is training to tell you.
In the LM2901.lib file from Ti, we can read:
Error Conditions:
- If the input goes beyond the recommended input voltage range, the output will float to mid supply
- If the supplies goes beyond the recommended supply voltage ranges, the output will float to mid supply
- The real device will NOT do this. (In a real device, the output will be at a low state (around 100mV)).
And this answers your question.
The allowed input common-mode range is from GND to Vcc-1.5V = (5V - 1.5V = 3.5V), as we read in the datasheet.