LM339 Comparator to measure Supply voltage AND temperature

Status
Not open for further replies.

Jules

New Member
I need a dual / quad voltage comparator circuit to control a transistor switch. One comparator used as a thermistor temp control, and the other to monitor low battery voltage. Do I need logic gates as well, or can these two outputs go into a third comparator? There are 4 on the 339 chip.
Here is the logic:

(Temp ABOVE a set value = 1, below = 0 )
Battery BELOW a set voltage = 0, above = 1 )

Final output Temp Battery voltage
1 1 1
0 1 0
0 0 0
0 0 1

Thanks,
Jules
 
You only need two comparators. Since they are open collector outputs, you can wire-AND them, as below.
 

Attachments

  • temp_and_voltage_alarm.png
    6.5 KB · Views: 2,198
The quad LM339 and its dual brother the LM393 have open collector outputs which require a pullup resistor to go to the high state. You can certainly connect a pulled up output to another comparator if you like but logic functions may be difficult. You do have the ability to wire-AND the outputs. What does that mean? It means that if you connect two or more comparator output together the output will be high if an only if each comparator outputs is high. In negative logic terms the out put will be low if either of the comparator outpus is low. You can also wire a comparator as an inverter and get a positive-logic NAND or a negative-logic NOR.

Doncha just love deMorgan's Theorems

And transistor inverters work also -- good point Ron.
 
I just put the transistor there because he said he needs to drive a transistor switch. I wanted to show that he can get maximum base drive, if needed, by omitting the usual series base resistor.
He could also drive a PNP or a MOSFET, with some restrictions.
 
LM339 as dual comparator

Thanks for the replies. I have a prototype up and running, but the open collector transistor at the LM339 outputs is causing some fun! The outputs work fine independently (One is on as temp rises, the second is on if battery voltage above 12V) and I have LEDs to indicate this. However, if the two outputs are connected together as AND logic, turning on the base of a transistor, the final logic state is REVERSED ! Why is this? I still have two unused op amps in the LM339. Can they be put to good use? I would ideally like to see all three outputs with LEDs. By joining two together, I only have one LED to show the logic state.
Also, I can't get any hysteresis on the voltage op amp, connecting a resistor from the + input to the output. I am using a 5.6V zener. The temp op amp works well with a hysteresis resistor added.
 
I'm assuming this entire circuit runs off 12V. If not, let us know. You can use a different resistor value to bias the zener, which I am assuming you used as the reference. If my assumptions are wrong, let us know.
OH- The LEDs are just some I used because I had symbols for them. Use what you have.
 

Attachments

  • temp_and_batt_alarm.png
    19.3 KB · Views: 2,593
LM339 comparator

That's a very useful circuit which I will try out. Thanks. One problem I'm running into is which input to use on the LM339 comparator's op amp. Should the ref. voltage (selected by trimmer pot) always be on the + input, and the varying input voltage on the - input. or does it make no difference? I have the 5.6V zener connected to pin 4 (-), the centre of the trimmer to pin 5(+), the thermistor to pin 11 (+), and the centre of the trimmer to pin 10 (-). I realise that the output transistor must reverse the logic, so I reversed it back by changing around the inverting and non-inverting inputs. Was this correct? I think your circuit is the way to go, but I have done some experimenting today.
 
Re: LM339 comparator

In a comparator, if the (+) input is higher than the (-) input, the output goes high. Actually, what really happens is the open-collector output transistor (inside the LM339) goes OFF. If the (-) input is higher than the (+) input, the internal output transistor turns ON. It is essential that you get this right. Note that, in my circuit, when an input (e.g., temp) goes higher than the reference voltage, the output transistor turns ON. This turns on the LED. If both outputs go LOW, both LEDs go on. This allows the (+) input of the 3rd comparator (these are NOT op amps) to go below the voltage divider that is connected to the (-) input, causing the 3rd output to go low and turning on the 3rd LED.
BTW, you can eliminate this voltage divider and just connect the (-) input to the zener.
 
Looking at the cct diag I have a few questions....
1. Where do I connect the thermistor and temp set control pot?
2. Where do I connect pot to set voltage?
3. What is the function of D3 and D4 ?
4. Why is a third comparator needed (U3) Can the two AND outputs go straight to the base of the transisitor switch (to turn on cooling fans) ?
 
1. Show me a schematic of what you have, and I'll tell you.
2. Ditto.
3. They form an OR gate (AND gate with negative logic). Only if both temperature and voltage are high will the junction of the diodes go low.
4. You said: "I still have two unused op amps in the LM339. Can they be put to good use? I would ideally like to see all three outputs with LEDs."
This comparator drives the LED which is only on when both temperature and voltage are high. You can drive your fan transistor from the output of this comparator, or, if you use a MOSFET, you can drive it directly from the junction of the diodes, and put the LED/resistor in parallel with the fan.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…