-1

I have a LED in a car and I want to hook up onto it to detect when its on. But voltage for that LED can depend on the intensity of the LED (depends if its night or day). I've measured voltages from 1.8V to 5V. Could I get some ideas how to design a circuit that would detect if there is any voltage on a pin (or detect anything above 1V), then turn it to 5V to be used as logic level high?

First idea was to use some comparator and based on resistor values, trigger it if above 1V is reached on the input. But maybe same can be achieved with simple BJTs? Or use optocoupler? Ideas?

Best regards


I appreciate your answers, but I bought the LM311 comparator and will go with this design:

enter image description here

Any comments if this is ok or something I should consider with this?

SamGibson
  • 17,870
  • 5
  • 40
  • 59
  • It can be achieved with just two BJTs (both NPN, if I understand you) and it includes appropriate hysteresis, too, for good proper behavior during transitions. I've used such a circuit many times. In fact, I have a little routine that develops the necessary resistor values given specifications. – jonk Aug 11 '21 at 20:00
  • Great, can you share circuit design? – Twoface Aug 11 '21 at 20:52
  • Before I do that, look here and see if this is a topology you could consider using. There is another similar one, as well, but slightly different topology. If something like this is okay with you, I'll write something up. – jonk Aug 11 '21 at 20:56
  • It seems ok, but now on second though, comparator seems even simpler. So if its too much effort to write, dont bother :) – Twoface Aug 11 '21 at 21:01
  • I'll pass, then. If you like the comparator idea (and that's fine) then I'd say go that direction, instead. I'll save the effort. – jonk Aug 11 '21 at 21:02
  • @Twoface - Hi, Your "answer" was still asking for advice, so here on SE that is an update not an answer, as you were not finally answering the question. As the OP, the only time you would write in the "Your Answer" box below, is if you have solved the problem yourself, and don't need further help. To add updates where you still want help, you must [Edit] your question and add updates (or edit existing text). I have moved your "answer" into the question as an update and Spehro has moved his comment. Please see the [tour] and [help] to see more site rules and etiquette. Thanks. [Edited] – SamGibson Aug 13 '21 at 18:39
  • @spehro-pefhany hmm, good that you noticed this. I guess I can lower the reference voltage as I initially wanted to detect any voltage, but went with 1.8V to be sure. But what kind of resistor for protection I would need? – Twoface Aug 13 '21 at 20:01
  • 1
    [comment moved] You are comparing the input to about 1.8V which does not agree with your original question title. The LM311 input common mode voltage limit can be as high as 500mV above the negative rail (0V in your case). I think it will work as long as one input is within range but it's not ideal. The LM393 does not have that issue. If you reduce the reference voltage, use something like 650mV nominal. The inputs are prone to damage (and possibly momentary incorrect operation) from transients below ground, a series resistor or other protection might be prudent. – Spehro Pefhany Aug 13 '21 at 20:07
  • 1
    As to what resistor would be protective, it depends on the transients, but a few K ohms would help a lot. – Spehro Pefhany Aug 13 '21 at 20:08
  • I'm curious what do you mean by transients in this case? Also, since this LED is controlled by PWM voltage, I've added low pass RC filter to get stable voltage. Not sure if this would help or hurt the input protection – Twoface Aug 13 '21 at 21:23

3 Answers3

4

This circuit will translate to 5V with at threshold of about 1.0V.

enter image description here

Below is a plot of the input/output response simulated in LT-SPICE.

enter image description here

If you need more drive strength on the output you can buffer it with another NPN transistor with the base connected to VOUT and the collector connected to 5V, and the emitter connected to the load.

user4574
  • 12,214
  • 18
  • 33
  • Maybe I like this the most now, but I've already bought a comparator. First I've tried your design with variable voltage from Arduino PWM pin, but it didnt work. I got on the output same voltage I provide from Arduino. Later I tried with non-PWM signal and then it worked as expected. But I'm not sure why it behaves like that with PWM signal – Twoface Aug 13 '21 at 17:34
  • @Twoface A PWM signal isn't a single analog voltage, it's a square wave between 0 V (for which that circuit also outputs 0 V) and 5 V (for which that circuit also outputs 5 V). If you low-pass-filtered and buffered it before putting it into the circuit, you would see a similar behavior. – nanofarad Aug 13 '21 at 18:05
1

It depends on where the signal is going but a comparator with a rail-to-rail push-pull output is probably the easiest way to get the desired behavior.

vir
  • 18,294
  • 1
  • 16
  • 36
  • Signal will just go to the relay that is triggered on high level. Therefore it doesn't trigger below 2.5V (maybe even lower). But do you have any recommendation on comparator or maybe circuit design? I first wanted to do it with some "off the shelf" components, but comparator is also simple enough to go with. – Twoface Aug 11 '21 at 20:58
  • 1
    Unless you have a very small relay like a reed relay you'll need some sort of driver for it, be it a transistor or a purpose built chip. I'd also recommend putting hysteresis in since it sounds like this might be a slowly changing input signal. – vir Aug 11 '21 at 22:11
0

Depends if the Led is connected as high or low side. Here the Led is driven low-side what can be detected with two NPN BJTs. For Led connected at high side you must convert the detection circuit using PNPs.

Voltage on Led above approximately 1V will force the output to 5V:

enter image description here