1
\$\begingroup\$

I would like to make a simple circuit to detect when an analog signal goes either above +10V or below -10V, and switch on a single LED if either of these cases occur. I have available only +12V and -12V power supply rails. The figure below shows what I want to achieve:

enter image description here

So far, I have discovered the so-called windowed comparator, and tried to implement it for the circuit. To do this, I used the LM393 dual comparator chip, powered by +12V and -12V, and then used two pairs of resistors to get the required +10V and -10V references derived from the existing PSU rails. I have also pulled the open-collector output up to the positive rail. So far so good. The schematic so far is shown below:

enter image description here

Now, this circuit does not quite do what I want - namely the voltage V_comp is -12V when I want an LED to be ON, and +12V when I would like it to be OFF, as shown below: enter image description here

So, my question is: What is a simple way to take this and finish the last part of my goal? Would I need to use some inverter chip now? Or can it be done using some simple logic inversion / level shifting using MOSFETs? Also, if there is a nicer way to do it without the comparators, I would be interested to learn.

Thanks

| improve this question | | | | |
\$\endgroup\$
2
\$\begingroup\$

The LM393 comparator used is not really designed to drive LEDs. The current limiting circuit causes a voltage drop at the output so you should NOT try to pass any more than the minimum spec of 6mA.

The output current limiting is severe and may result in destruction of the device.

enter image description here

Read Note 7 in the datasheet and understand that at just 20mA the device dissipation could rise to beyond 2W ....clearly far beyond its rating. You can understand the rather primitive current limiting by examining the schematic diagram:

enter image description here

The output transistor is driven by a constant current source, so depending on hfe the device rapidly pulls out of saturation at some given point not related to the supply voltage. While the datasheet specifies the output can be shorted to ground continuously ....you'd expect that for an open collector output!!! What they say about a short to a positive supply is that you MAY DESTROY THE DEVICE. For this configuration with +/-12V supplies YOU CANNOT short the output to either ground or +12V.
So @Dave Tweeds comment about short circuit capability of the device is completely wrong.
In this particular application with +/-12V supplies I would suggest that a short to ground or a short to +12V would instantly destroy the device.

There are several ways you might alter your circuit to provide more LED current in a reliable fashion. Given that you have already chosen to use +/-12V, I'll suggest only modifications to that schema (it would not be my first choice):

schematic

simulate this circuit – Schematic created using CircuitLab

The LED is driven by a constant current source (Q1, 2N3906), so the output is short circuit to ground friendly. This is important if your LED is panel mounted and you have to run wires to it (You should never run your supply voltages in external wiring without current limits in place). In fact the collector output of Q1 could be shorted to +/-12V or ground without damage to the device.

How does this work?

  1. Q1 works as a constant current source limiting the current through the LED.
    The advantage to setting the LED current with a constant current source is that you now don't have to consider the LED Vf. You could use any LED.

  2. R4,5 limit the current sunk by the window comparator to approximately 4mA. My original calculation set the divider current to 10x the base current required, but that was just to be ultra conservative. R4,5 provide a fixed base voltage to Q1 of about 8 V.

You could reduce the current through R4,6 further if you want to. For example you could raise R4 to 2k and R5 to 10k. This would drop the comparator current to about 2 mA which is still enough to define the base voltage for Q1. The base current for Q1 is likely around 400 uA so any resistor selection has to take this into account.

You are of course limited in how high you can set the LED current. You are limited by the power dissipation in Q1. In the circuit shown with just a single LED load (Vf=2.2 V) you may see Q1 dissipating a maximum of about 130 mW. Well within rating, but it will get warm to the touch. With a Vf=3.2 V this power dissipation is about 110 mW. You could easily double the LED current to 40 mA and still be well within the rating of the 2N3906.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ Thank you, I have simulated the circuit you proposed using LTSpice, and it works nicely (20mA through LED), but I don't understand why! Could you explain a little how it works? I see from my sim that when the LED is ON then there is 4mA sunk by the CMP - I assume you chose the resistor values somehow to ensure this was below the 6mA limit of the CMP? Also, usually the resistor R4 is to ensure the PNP BJT is off properly by pulling the base high, but I see in this case it seems to serve a different purpose, because it carries the 4mA. R6 is also lower than I expected for 20mA@12V? \$\endgroup\$ – teeeeee Jul 14 '19 at 18:07
  • \$\begingroup\$ It seems to me like you are using some trick to explicitly set the base voltage of the transistor by using R4 and R5 as a potential divider? So am I right in thinking that R4 is not a pull-up in this case (as is sometimes seen to ensure the transistor switches off)? Is the general idea to try to explicitly set the base to around ~8V, which puts the emitter at ~9V (in the ON state), and so the LED current is then I = (12V-9V)/165 = ~20mA ? Please forgive my naivety - I am not trained in electronics, and have not seen this type of arrangement before. Thanks for your patience! \$\endgroup\$ – teeeeee Jul 14 '19 at 18:47
  • \$\begingroup\$ @teeeeee Yes you have it right, the voltage from +12 V to the base of Q1 is the voltage that defines the CC through R6. R4 also ensures that Q1 is off when the comparator output is high. \$\endgroup\$ – Jack Creasey Jul 14 '19 at 18:53
8
\$\begingroup\$

You can simply connect your LED in series with R5. That puts a little over 2 mA through it. If you want more light, reduce the value of R5 — 2200 Ω would give you about 10 mA.

| improve this answer | | | | |
\$\endgroup\$
  • 2
    \$\begingroup\$ It will work (+1), but the LM393 is only guaranteed to sink 6mA @ Vo = 1.5V and 25°C. \$\endgroup\$ – Spehro Pefhany Jul 9 '19 at 11:48
  • 1
    \$\begingroup\$ @SpehroPefhany: Well, technically you're right. But the typical value is 16 mA, and the chip can tolerate a continuous short circuit. The LED doesn't really care about the exact value of the output voltage anyway. -1 for excessive pedantry. :-) \$\endgroup\$ – Dave Tweed Jul 9 '19 at 11:58
  • \$\begingroup\$ The LED current is likely to be only 9mA max with a 2.2k pullup to +12V, and you should not use more than 6mA if you are following reasonable design rules. \$\endgroup\$ – Jack Creasey Jul 9 '19 at 13:44
  • \$\begingroup\$ @DaveTweed thanks - I (stupidly!) didn't consider that option because for some reason I was thinking the pull-up wouldn't work if there was a diode blocking off the +12V. I will go with this solution. \$\endgroup\$ – teeeeee Jul 10 '19 at 11:13
  • 1
    \$\begingroup\$ All they're saying is that 2200 ohms is too low a value. If you keep it above 3900 ohms, then the comparator won't be overloaded. \$\endgroup\$ – Dave Tweed Jul 10 '19 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.