Basic LM393 circuit help

Thread Starter

AlcoHelix

Joined May 15, 2017
20
Hello,

Please forgive my lack of knowledge in analog circuits, I only have experience with digital circuits and am a computer systems engineer. But I'm slowly delving into analog circuits and need some help properly understanding a basic circuit to compare voltages. Attached is my shamefully rough sketch of the circuit (any suggestions for a good and free circuit diagram program for Linux?).

The LM393 is the heart of the project, 5v power source, and:

S1 = a pressure sensor, powered by 5v and ground, with third contact that is between 0v and 5v depending on the pressure, 1.5v seems to be the ambient pressure reading.

R1 = resistance value needed to be compared to the voltage value coming off the sensor, I had thought of using a potentiometer here so I can adjust the point at which the LM393 will allow power flow to the LED.

R2 = currently a 47Ohm resistor, to limit power to the LED.

The idea for this circuit is to eventually allow a series of LEDs to light up depending on how much pressure the pressure sensor sees. Right now, just getting a single LED to light only when a certain pressure threshold is achieved would be a start. I want to make sure I've even got the basic understanding of how to wire the LM393 first. Again, I'm pretty new to analog circuits. Thanks for any help.
 

Attachments

dl324

Joined Mar 30, 2015
16,943
Welcome to AAC!

The output will be LOW when the difference between the noninverting and inverting inputs is negative. The way you have it wired, output will always be HIGH.
 

Thread Starter

AlcoHelix

Joined May 15, 2017
20
Welcome to AAC!

The output will be LOW when the difference between the noninverting and inverting inputs is negative. The way you have it wired, output will always be HIGH.
Would you mind changing up my sketch so I know exactly what you mean, sounds like you mean that the LED connected to the output of the LM393 should be HIGH by default, except when the IN- is higher voltage than the IN+ on the LM393, is that correct?
 

Thread Starter

AlcoHelix

Joined May 15, 2017
20
Dodgydave, I've been staring at that same schematic for a while now, and that's what I was working off of for my circuit. But I'm definitely missing something, and I'm not clear on what you mean by no "reference" on pin 3. Isn't my line to R1 and then Vcc the same thing? Must not be. What if, for a simplified example, I simply attached pin 2 to Vcc and pin 3 to ground, that should make the activate the output on pin 1, correct? And then swapping pin 2 and 3 should deactivate, right? Just trying to make sure I understand it all.
 

MrChips

Joined Oct 2, 2009
30,824
Dodgydave, I've been staring at that same schematic for a while now, and that's what I was working off of for my circuit. But I'm definitely missing something, and I'm not clear on what you mean by no "reference" on pin 3. Isn't my line to R1 and then Vcc the same thing? Must not be. What if, for a simplified example, I simply attached pin 2 to Vcc and pin 3 to ground, that should make the activate the output on pin 1, correct? And then swapping pin 2 and 3 should deactivate, right? Just trying to make sure I understand it all.
The voltage from the light sensor going into pin-2 will be a voltage somewhere between 0 and 5V.
The reference voltage going into pin-3 also has to be between 0 and 5V. What you have shown sets the voltage at pin-3 to 5V.
You need another resistor from pin-3 to GND to partially pull the voltage down, i.e. a voltage divider.

What Dodgydave has shown is an adjustable voltage divider using a 10k pot so that you can set the threshold voltage.
 

EM Fields

Joined Jun 8, 2016
583
Hello,

Please forgive my lack of knowledge in analog circuits, I only have experience with digital circuits and am a computer systems engineer. But I'm slowly delving into analog circuits and need some help properly understanding a basic circuit to compare voltages.
SNIP

I want to make sure I've even got the basic understanding of how to wire the LM393 first. Again, I'm pretty new to analog circuits. Thanks for any help.
Basically, a voltage comparator functions by having its output go high (or its output transistor turn OFF) when its non-inverting (+) input is more positive than its inverting input, and having its output go low by turning its output transistor ON when its - input is more positive than than its + input.

The LM393 sports open-collector outputs, so when the + input is more positive than the - input the output transistor will be turned OFF and, conversely, when the - input is more positive than the + input, the output transistor will be turned ON and driven into saturation.

In your case, the wiring would look like this,:
Comparator wiring.png
Where R1 is the pressure pot, Vin is the pressure pot's output, and Vref is the reference voltage generated by R2.
Now, assume that the reference voltage, Vref, has been set to represent a pressure somewhat greater than ambient and that Vin, R1's output, has risen to a voltage more positive than Vref.
When that happens, the comparator's output will go low, the LED will light, and will stay lit as long as Vin is more positive than Vref. Then, as the pressure into R1 drops to the point where Vin falls below Vref, U1's output will go high and the LED will turn OFF, like this:
Comparato trip points.png

Just as an aside, the LM393's output can't sink an awful lot of current without going out of saturation, so I've chosen a high-efficiency red LED with a forward voltage of 2.2 volts when there's 2 milliamperes through the LED, which the LM393 can easily handle.

The formula for calculating the value of the ballast resistor (R3) is:
R3 = (Vcc - VLED) / ILED = (5V - 2.2V) / 0.002A = 1400 ohms. 1500 ohms is a standard E24 value and won't cause an appreciable loss of output from the LED, and 1300 ohms will get a little extra out of the LED without hurting it.
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,523
Voltage Comparator Information And Circuits is a pretty good read on the subject and should afford you a good basioc understanding of the subject. Another good read and useful information can be found here and is quite good forum material. Both links should get you started understanding comparator circuits and how they work. That done you can begin to apply comparator circuits into actual useful circuits.
S1 = a pressure sensor, powered by 5v and ground, with third contact that is between 0v and 5v depending on the pressure, 1.5v seems to be the ambient pressure reading.
If with no pressure applied this unit has an output then it is likely an absolute pressure gauge and reading atmospheric pressure. Got a part number for the sensor?

Ron
 

dl324

Joined Mar 30, 2015
16,943
Would you mind changing up my sketch so I know exactly what you mean
upload_2017-5-15_5-46-25.png
When the voltage at the non-inverting input is greater than the voltage at the inverting input, the LED will be on.

As mentioned earlier, output sink current is only guaranteed to be 6mA; with 16mA typical. It can't source any current because the output is open collector.
 

Thread Starter

AlcoHelix

Joined May 15, 2017
20
Thank you all for so much help. This is the first time I've posted a question on an electronics forum, so I didn't know how that would go, especially asking such noob questions, and I must say I'm happily surprised (asking noob questions on software development forums can DEFINITELY go different!).

I think the main part I was missing was the reference voltage. The only non-digital/analog voltage I've worked with in the past was "line voltage", like when you wire a house, and it just seemed non-intuitive to do something like run a connection from power to ground with just a resistor in place (like R2 in "EM Fields" post). I had looked at voltage divider circuits before this as well, and they just didn't make sense. But it's starting to become more clear now.

For everybody that suggested the LM3914, I wish I would have seen that IC before, that would have been the PERFECT solution for what I was trying to do. It hadn't even occurred to me that the LEDs I'm using might overload the rated current sink of the LM393 either.

I did get the circuit working just fine with a single LED after the help provided, and will probably switch everything out to the LM3914 now.

Thanks again for all the help!
 

MrChips

Joined Oct 2, 2009
30,824
Thank you all for so much help. This is the first time I've posted a question on an electronics forum, so I didn't know how that would go, especially asking such noob questions, and I must say I'm happily surprised (asking noob questions on software development forums can DEFINITELY go different!).

I think the main part I was missing was the reference voltage. The only non-digital/analog voltage I've worked with in the past was "line voltage", like when you wire a house, and it just seemed non-intuitive to do something like run a connection from power to ground with just a resistor in place (like R2 in "EM Fields" post). I had looked at voltage divider circuits before this as well, and they just didn't make sense. But it's starting to become more clear now.

For everybody that suggested the LM3914, I wish I would have seen that IC before, that would have been the PERFECT solution for what I was trying to do. It hadn't even occurred to me that the LEDs I'm using might overload the rated current sink of the LM393 either.

I did get the circuit working just fine with a single LED after the help provided, and will probably switch everything out to the LM3914 now.

Thanks again for all the help!
You are welcome.
Computer geeks have their heads stuck to a computer screen. They live in a virtual world.
Hardware hackers do real stuff in a real world with their hands and they remember to stop and smell the roses.
 

Thread Starter

AlcoHelix

Joined May 15, 2017
20
Well said, and that's exactly what's drawn me to electronics after 16 years as a systems engineer, was ready to do something NOT virtual!
 
Top